diff --git a/packages/SystemUI/src/com/android/systemui/controls/ControlsServiceInfo.kt b/packages/SystemUI/src/com/android/systemui/controls/ControlsServiceInfo.kt index 66e5d7c4a3bcd..dbe301df8e780 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/ControlsServiceInfo.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/ControlsServiceInfo.kt @@ -69,12 +69,14 @@ class ControlsServiceInfo( private var resolved: Boolean = false @WorkerThread - fun resolvePanelActivity() { + fun resolvePanelActivity( + allowAllApps: Boolean = false + ) { if (resolved) return resolved = true val validPackages = context.resources .getStringArray(R.array.config_controlsPreferredPackages) - if (componentName.packageName !in validPackages) return + if (componentName.packageName !in validPackages && !allowAllApps) return panelActivity = _panelActivity?.let { val resolveInfos = mPm.queryIntentActivitiesAsUser( Intent().setComponent(it), diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt index c6428ef6eb8e3..c81a2c7e2ac68 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsListingControllerImpl.kt @@ -98,7 +98,9 @@ class ControlsListingControllerImpl @VisibleForTesting constructor( backgroundExecutor.execute { if (userChangeInProgress.get() > 0) return@execute if (featureFlags.isEnabled(Flags.USE_APP_PANELS)) { - newServices.forEach(ControlsServiceInfo::resolvePanelActivity) + val allowAllApps = featureFlags.isEnabled(Flags.APP_PANELS_ALL_APPS_ALLOWED) + newServices.forEach { + it.resolvePanelActivity(allowAllApps) } } if (newServices != availableServices) { diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt index 4d0edc522107e..c712a94df6061 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt @@ -94,8 +94,7 @@ object Flags { unreleasedFlag(259217907, "notification_group_dismissal_animation", teamfood = true) // TODO(b/257506350): Tracking Bug - @JvmField - val FSI_CHROME = unreleasedFlag(117, "fsi_chrome") + @JvmField val FSI_CHROME = unreleasedFlag(117, "fsi_chrome") @JvmField val SIMPLIFIED_APPEAR_FRACTION = @@ -419,6 +418,10 @@ object Flags { // 2000 - device controls @Keep @JvmField val USE_APP_PANELS = unreleasedFlag(2000, "use_app_panels", teamfood = true) + @JvmField + val APP_PANELS_ALL_APPS_ALLOWED = + unreleasedFlag(2001, "app_panels_all_apps_allowed", teamfood = true) + // 2100 - Falsing Manager @JvmField val FALSING_FOR_LONG_TAPS = releasedFlag(2100, "falsing_for_long_taps") diff --git a/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt index c677f19f93e50..35cd3d2615621 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/controls/management/ControlsListingControllerImplTest.kt @@ -36,6 +36,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.controls.ControlsServiceInfo import com.android.systemui.dump.DumpManager 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.concurrency.FakeExecutor @@ -119,6 +120,8 @@ class ControlsListingControllerImplTest : SysuiTestCase() { // Return true by default, we'll test the false path `when`(featureFlags.isEnabled(USE_APP_PANELS)).thenReturn(true) + // Return false by default, we'll test the true path + `when`(featureFlags.isEnabled(APP_PANELS_ALL_APPS_ALLOWED)).thenReturn(false) val wrapper = object : ContextWrapper(mContext) { override fun createContextAsUser(user: UserHandle, flags: Int): Context { @@ -517,6 +520,37 @@ class ControlsListingControllerImplTest : SysuiTestCase() { assertNull(controller.getCurrentServices()[0].panelActivity) } + @Test + fun testPackageNotPreferred_allowAllApps_correctPanel() { + `when`(featureFlags.isEnabled(APP_PANELS_ALL_APPS_ALLOWED)).thenReturn(true) + + mContext.orCreateTestableResources + .addOverride(R.array.config_controlsPreferredPackages, arrayOf()) + + val serviceInfo = ServiceInfo( + componentName, + activityName + ) + + `when`(packageManager.getComponentEnabledSetting(eq(activityName))) + .thenReturn(PackageManager.COMPONENT_ENABLED_STATE_ENABLED) + + setUpQueryResult(listOf( + ActivityInfo( + activityName, + exported = true, + permission = Manifest.permission.BIND_CONTROLS + ) + )) + + val list = listOf(serviceInfo) + serviceListingCallbackCaptor.value.onServicesReloaded(list) + + executor.runAllReady() + + assertEquals(activityName, controller.getCurrentServices()[0].panelActivity) + } + @Test fun testListingsNotModifiedByCallback() { // This test checks that if the list passed to the callback is modified, it has no effect