Merge changes from topic "261990919" into tm-qpr-dev
* changes: Allow any app to show panel, based on flag Add flag to allow panels for all apps
This commit is contained in:
committed by
Android (Google) Code Review
commit
938aed255a
@@ -69,12 +69,14 @@ class ControlsServiceInfo(
|
|||||||
private var resolved: Boolean = false
|
private var resolved: Boolean = false
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
fun resolvePanelActivity() {
|
fun resolvePanelActivity(
|
||||||
|
allowAllApps: Boolean = false
|
||||||
|
) {
|
||||||
if (resolved) return
|
if (resolved) return
|
||||||
resolved = true
|
resolved = true
|
||||||
val validPackages = context.resources
|
val validPackages = context.resources
|
||||||
.getStringArray(R.array.config_controlsPreferredPackages)
|
.getStringArray(R.array.config_controlsPreferredPackages)
|
||||||
if (componentName.packageName !in validPackages) return
|
if (componentName.packageName !in validPackages && !allowAllApps) return
|
||||||
panelActivity = _panelActivity?.let {
|
panelActivity = _panelActivity?.let {
|
||||||
val resolveInfos = mPm.queryIntentActivitiesAsUser(
|
val resolveInfos = mPm.queryIntentActivitiesAsUser(
|
||||||
Intent().setComponent(it),
|
Intent().setComponent(it),
|
||||||
|
|||||||
@@ -98,7 +98,9 @@ class ControlsListingControllerImpl @VisibleForTesting constructor(
|
|||||||
backgroundExecutor.execute {
|
backgroundExecutor.execute {
|
||||||
if (userChangeInProgress.get() > 0) return@execute
|
if (userChangeInProgress.get() > 0) return@execute
|
||||||
if (featureFlags.isEnabled(Flags.USE_APP_PANELS)) {
|
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) {
|
if (newServices != availableServices) {
|
||||||
|
|||||||
@@ -94,8 +94,7 @@ object Flags {
|
|||||||
unreleasedFlag(259217907, "notification_group_dismissal_animation", teamfood = true)
|
unreleasedFlag(259217907, "notification_group_dismissal_animation", teamfood = true)
|
||||||
|
|
||||||
// TODO(b/257506350): Tracking Bug
|
// TODO(b/257506350): Tracking Bug
|
||||||
@JvmField
|
@JvmField val FSI_CHROME = unreleasedFlag(117, "fsi_chrome")
|
||||||
val FSI_CHROME = unreleasedFlag(117, "fsi_chrome")
|
|
||||||
|
|
||||||
@JvmField
|
@JvmField
|
||||||
val SIMPLIFIED_APPEAR_FRACTION =
|
val SIMPLIFIED_APPEAR_FRACTION =
|
||||||
@@ -421,6 +420,10 @@ object Flags {
|
|||||||
// 2000 - device controls
|
// 2000 - device controls
|
||||||
@Keep @JvmField val USE_APP_PANELS = unreleasedFlag(2000, "use_app_panels", teamfood = true)
|
@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
|
// 2100 - Falsing Manager
|
||||||
@JvmField val FALSING_FOR_LONG_TAPS = releasedFlag(2100, "falsing_for_long_taps")
|
@JvmField val FALSING_FOR_LONG_TAPS = releasedFlag(2100, "falsing_for_long_taps")
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import com.android.systemui.SysuiTestCase
|
|||||||
import com.android.systemui.controls.ControlsServiceInfo
|
import com.android.systemui.controls.ControlsServiceInfo
|
||||||
import com.android.systemui.dump.DumpManager
|
import com.android.systemui.dump.DumpManager
|
||||||
import com.android.systemui.flags.FeatureFlags
|
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.flags.Flags.USE_APP_PANELS
|
||||||
import com.android.systemui.settings.UserTracker
|
import com.android.systemui.settings.UserTracker
|
||||||
import com.android.systemui.util.concurrency.FakeExecutor
|
import com.android.systemui.util.concurrency.FakeExecutor
|
||||||
@@ -119,6 +120,8 @@ class ControlsListingControllerImplTest : SysuiTestCase() {
|
|||||||
|
|
||||||
// Return true by default, we'll test the false path
|
// Return true by default, we'll test the false path
|
||||||
`when`(featureFlags.isEnabled(USE_APP_PANELS)).thenReturn(true)
|
`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) {
|
val wrapper = object : ContextWrapper(mContext) {
|
||||||
override fun createContextAsUser(user: UserHandle, flags: Int): Context {
|
override fun createContextAsUser(user: UserHandle, flags: Int): Context {
|
||||||
@@ -517,6 +520,37 @@ class ControlsListingControllerImplTest : SysuiTestCase() {
|
|||||||
assertNull(controller.getCurrentServices()[0].panelActivity)
|
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<String>())
|
||||||
|
|
||||||
|
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
|
@Test
|
||||||
fun testListingsNotModifiedByCallback() {
|
fun testListingsNotModifiedByCallback() {
|
||||||
// This test checks that if the list passed to the callback is modified, it has no effect
|
// This test checks that if the list passed to the callback is modified, it has no effect
|
||||||
|
|||||||
Reference in New Issue
Block a user