Merge "Restrict panel to supportMultiWindow" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
02f10a32d1
@@ -35,6 +35,7 @@ import com.android.systemui.dump.DumpManager
|
||||
import com.android.systemui.flags.FeatureFlags
|
||||
import com.android.systemui.flags.Flags
|
||||
import com.android.systemui.settings.UserTracker
|
||||
import com.android.systemui.util.ActivityTaskManagerProxy
|
||||
import com.android.systemui.util.asIndenting
|
||||
import com.android.systemui.util.indentIfPossible
|
||||
import java.io.PrintWriter
|
||||
@@ -67,6 +68,7 @@ class ControlsListingControllerImpl @VisibleForTesting constructor(
|
||||
@Background private val backgroundExecutor: Executor,
|
||||
private val serviceListingBuilder: (Context) -> ServiceListing,
|
||||
private val userTracker: UserTracker,
|
||||
private val activityTaskManagerProxy: ActivityTaskManagerProxy,
|
||||
dumpManager: DumpManager,
|
||||
private val featureFlags: FeatureFlags
|
||||
) : ControlsListingController, Dumpable {
|
||||
@@ -76,9 +78,18 @@ class ControlsListingControllerImpl @VisibleForTesting constructor(
|
||||
context: Context,
|
||||
@Background executor: Executor,
|
||||
userTracker: UserTracker,
|
||||
activityTaskManagerProxy: ActivityTaskManagerProxy,
|
||||
dumpManager: DumpManager,
|
||||
featureFlags: FeatureFlags
|
||||
) : this(context, executor, ::createServiceListing, userTracker, dumpManager, featureFlags)
|
||||
) : this(
|
||||
context,
|
||||
executor,
|
||||
::createServiceListing,
|
||||
userTracker,
|
||||
activityTaskManagerProxy,
|
||||
dumpManager,
|
||||
featureFlags
|
||||
)
|
||||
|
||||
private var serviceListing = serviceListingBuilder(context)
|
||||
// All operations in background thread
|
||||
@@ -113,7 +124,8 @@ class ControlsListingControllerImpl @VisibleForTesting constructor(
|
||||
}
|
||||
|
||||
private fun updateServices(newServices: List<ControlsServiceInfo>) {
|
||||
if (featureFlags.isEnabled(Flags.USE_APP_PANELS)) {
|
||||
if (featureFlags.isEnabled(Flags.USE_APP_PANELS) &&
|
||||
activityTaskManagerProxy.supportsMultiWindow(context)) {
|
||||
val allowAllApps = featureFlags.isEnabled(Flags.APP_PANELS_ALL_APPS_ALLOWED)
|
||||
newServices.forEach {
|
||||
it.resolvePanelActivity(allowAllApps) }
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.util
|
||||
|
||||
import android.app.ActivityTaskManager
|
||||
import android.content.Context
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
import javax.inject.Inject
|
||||
|
||||
/** Proxy for static calls to [ActivityTaskManager]. */
|
||||
@SysUISingleton
|
||||
class ActivityTaskManagerProxy @Inject constructor() {
|
||||
|
||||
/** Calls [ActivityTaskManager.supportsMultiWindow] */
|
||||
fun supportsMultiWindow(context: Context) = ActivityTaskManager.supportsMultiWindow(context)
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import com.android.systemui.flags.FeatureFlags
|
||||
import com.android.systemui.flags.Flags.APP_PANELS_ALL_APPS_ALLOWED
|
||||
import com.android.systemui.flags.Flags.USE_APP_PANELS
|
||||
import com.android.systemui.settings.UserTracker
|
||||
import com.android.systemui.util.ActivityTaskManagerProxy
|
||||
import com.android.systemui.util.concurrency.FakeExecutor
|
||||
import com.android.systemui.util.mockito.any
|
||||
import com.android.systemui.util.mockito.argThat
|
||||
@@ -88,6 +89,8 @@ class ControlsListingControllerImplTest : SysuiTestCase() {
|
||||
private lateinit var packageManager: PackageManager
|
||||
@Mock
|
||||
private lateinit var featureFlags: FeatureFlags
|
||||
@Mock
|
||||
private lateinit var activityTaskManagerProxy: ActivityTaskManagerProxy
|
||||
|
||||
private var componentName = ComponentName("pkg", "class1")
|
||||
private var activityName = ComponentName("pkg", "activity")
|
||||
@@ -112,6 +115,7 @@ class ControlsListingControllerImplTest : SysuiTestCase() {
|
||||
// Return disabled by default
|
||||
`when`(packageManager.getComponentEnabledSetting(any()))
|
||||
.thenReturn(PackageManager.COMPONENT_ENABLED_STATE_DISABLED)
|
||||
`when`(activityTaskManagerProxy.supportsMultiWindow(any())).thenReturn(true)
|
||||
mContext.setMockPackageManager(packageManager)
|
||||
|
||||
mContext.orCreateTestableResources
|
||||
@@ -136,6 +140,7 @@ class ControlsListingControllerImplTest : SysuiTestCase() {
|
||||
executor,
|
||||
{ mockSL },
|
||||
userTracker,
|
||||
activityTaskManagerProxy,
|
||||
dumpManager,
|
||||
featureFlags
|
||||
)
|
||||
@@ -171,6 +176,7 @@ class ControlsListingControllerImplTest : SysuiTestCase() {
|
||||
exec,
|
||||
{ mockServiceListing },
|
||||
userTracker,
|
||||
activityTaskManagerProxy,
|
||||
dumpManager,
|
||||
featureFlags
|
||||
)
|
||||
@@ -637,7 +643,34 @@ class ControlsListingControllerImplTest : SysuiTestCase() {
|
||||
assertThat(services[0].serviceInfo.componentName).isEqualTo(componentName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoPanelIfMultiWindowNotSupported() {
|
||||
`when`(activityTaskManagerProxy.supportsMultiWindow(any())).thenReturn(false)
|
||||
|
||||
val serviceInfo = ServiceInfo(
|
||||
componentName,
|
||||
activityName
|
||||
)
|
||||
|
||||
`when`(packageManager.getComponentEnabledSetting(eq(activityName)))
|
||||
.thenReturn(PackageManager.COMPONENT_ENABLED_STATE_DEFAULT)
|
||||
|
||||
setUpQueryResult(listOf(
|
||||
ActivityInfo(
|
||||
activityName,
|
||||
enabled = true,
|
||||
exported = true,
|
||||
permission = Manifest.permission.BIND_CONTROLS
|
||||
)
|
||||
))
|
||||
|
||||
val list = listOf(serviceInfo)
|
||||
serviceListingCallbackCaptor.value.onServicesReloaded(list)
|
||||
|
||||
executor.runAllReady()
|
||||
|
||||
assertNull(controller.getCurrentServices()[0].panelActivity)
|
||||
}
|
||||
|
||||
private fun ServiceInfo(
|
||||
componentName: ComponentName,
|
||||
|
||||
Reference in New Issue
Block a user