Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b761b04e authored by Anton Potapov's avatar Anton Potapov
Browse files

Rollout APP_PANELS_ALL_APPS_ALLOWED flag

Test: manual check that it's possible to add a panel to Device Controls
Test: atest ControlsListingControllerImplTest
Fixes: 261990919
Change-Id: I44dd3151bfeedfd3e3aa4fc459841391765a916c
parent 539232a1
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -71,14 +71,9 @@ open class ControlsServiceInfo(
    private var resolved: Boolean = false

    @WorkerThread
    fun resolvePanelActivity(
        allowAllApps: Boolean = false
    ) {
    fun resolvePanelActivity() {
        if (resolved) return
        resolved = true
        val validPackages = context.resources
            .getStringArray(R.array.config_controlsPreferredPackages)
        if (componentName.packageName !in validPackages && !allowAllApps) return
        panelActivity = _panelActivity?.let {
            val resolveInfos = mPm.queryIntentActivitiesAsUser(
                Intent().setComponent(it),
+1 −3
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
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
@@ -125,9 +124,8 @@ class ControlsListingControllerImpl @VisibleForTesting constructor(

    private fun updateServices(newServices: List<ControlsServiceInfo>) {
        if (activityTaskManagerProxy.supportsMultiWindow(context)) {
            val allowAllApps = featureFlags.isEnabled(Flags.APP_PANELS_ALL_APPS_ALLOWED)
            newServices.forEach {
                it.resolvePanelActivity(allowAllApps) }
                it.resolvePanelActivity() }
        }

        if (newServices != availableServices) {
+0 −3
Original line number Diff line number Diff line
@@ -634,9 +634,6 @@ object Flags {
    // 1900
    @JvmField val NOTE_TASKS = releasedFlag("keycode_flag")

    // 2000 - device controls
    @JvmField val APP_PANELS_ALL_APPS_ALLOWED = releasedFlag("app_panels_all_apps_allowed")

    // 2200 - biometrics (udfps, sfps, BiometricPrompt, etc.)
    // TODO(b/259264861): Tracking Bug
    @JvmField val UDFPS_NEW_TOUCH_DETECTION = releasedFlag("udfps_new_touch_detection")
+1 −36
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ 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.settings.UserTracker
import com.android.systemui.util.ActivityTaskManagerProxy
import com.android.systemui.util.concurrency.FakeExecutor
@@ -123,9 +122,6 @@ class ControlsListingControllerImplTest : SysuiTestCase() {
                        arrayOf(componentName.packageName)
                )

        // 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 {
                return baseContext
@@ -469,38 +465,7 @@ class ControlsListingControllerImplTest : SysuiTestCase() {
    }

    @Test
    fun testPackageNotPreferred_nullPanel() {
        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()

        assertNull(controller.getCurrentServices()[0].panelActivity)
    }

    @Test
    fun testPackageNotPreferred_allowAllApps_correctPanel() {
        `when`(featureFlags.isEnabled(APP_PANELS_ALL_APPS_ALLOWED)).thenReturn(true)

    fun testPackageNotPreferred_correctPanel() {
        mContext.orCreateTestableResources
                .addOverride(R.array.config_controlsPreferredPackages, arrayOf<String>())