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

Commit 98057c66 authored by Faye Yan's avatar Faye Yan Committed by Cherrypicker Worker
Browse files

Security fix for VPN app killable via lockscreen.

Do not show the active apps dialog when the screen is locked.
Instead prompt the user to unlock directly if clicked and only open the dialog on
successsful unlock.

Flag: NONE
Fix: 304772709
Test: manually, locked and unlocked
Test: atest com.android.systemui.qs.footer.ui.viewmodel.FooterActionsViewModelTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d7628d5621c912399cefcddd9977199d62df320c)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:65422919f84c2742ff00554a66c23dc7b3213435)
Merged-In: I384699d478e5abcee3a165afc45211b9ed96334a
Change-Id: I384699d478e5abcee3a165afc45211b9ed96334a
24D1-dev is based on 24Q2-release. Therefore, we merged this CL to 24D1-dev.
parent 58f14f7e
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.common.shared.model.Icon
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.globalactions.GlobalActionsDialogLite
import com.android.systemui.globalactions.GlobalActionsDialogLite
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.qs.dagger.QSFlagsModule.PM_LITE_ENABLED
import com.android.systemui.qs.dagger.QSFlagsModule.PM_LITE_ENABLED
import com.android.systemui.qs.footer.data.model.UserSwitcherStatusModel
import com.android.systemui.qs.footer.data.model.UserSwitcherStatusModel
@@ -109,6 +110,7 @@ class FooterActionsViewModel(
        private val falsingManager: FalsingManager,
        private val falsingManager: FalsingManager,
        private val footerActionsInteractor: FooterActionsInteractor,
        private val footerActionsInteractor: FooterActionsInteractor,
        private val globalActionsDialogLiteProvider: Provider<GlobalActionsDialogLite>,
        private val globalActionsDialogLiteProvider: Provider<GlobalActionsDialogLite>,
        private val activityStarter: ActivityStarter,
        @Named(PM_LITE_ENABLED) private val showPowerButton: Boolean,
        @Named(PM_LITE_ENABLED) private val showPowerButton: Boolean,
    ) {
    ) {
        /** Create a [FooterActionsViewModel] bound to the lifecycle of [lifecycleOwner]. */
        /** Create a [FooterActionsViewModel] bound to the lifecycle of [lifecycleOwner]. */
@@ -134,6 +136,7 @@ class FooterActionsViewModel(
                footerActionsInteractor,
                footerActionsInteractor,
                falsingManager,
                falsingManager,
                globalActionsDialogLite,
                globalActionsDialogLite,
                activityStarter,
                showPowerButton,
                showPowerButton,
            )
            )
        }
        }
@@ -145,6 +148,7 @@ fun FooterActionsViewModel(
    footerActionsInteractor: FooterActionsInteractor,
    footerActionsInteractor: FooterActionsInteractor,
    falsingManager: FalsingManager,
    falsingManager: FalsingManager,
    globalActionsDialogLite: GlobalActionsDialogLite,
    globalActionsDialogLite: GlobalActionsDialogLite,
    activityStarter: ActivityStarter,
    showPowerButton: Boolean,
    showPowerButton: Boolean,
): FooterActionsViewModel {
): FooterActionsViewModel {
    suspend fun observeDeviceMonitoringDialogRequests(quickSettingsContext: Context) {
    suspend fun observeDeviceMonitoringDialogRequests(quickSettingsContext: Context) {
@@ -169,7 +173,14 @@ fun FooterActionsViewModel(
            return
            return
        }
        }


        activityStarter.dismissKeyguardThenExecute(
            {
                footerActionsInteractor.showForegroundServicesDialog(expandable)
                footerActionsInteractor.showForegroundServicesDialog(expandable)
                false /* if the dismiss should be deferred */
            },
            null /* cancelAction */,
            true /* afterKeyguardGone */
        )
    }
    }


    fun onUserSwitcherClicked(expandable: Expandable) {
    fun onUserSwitcherClicked(expandable: Expandable) {
+3 −1
Original line number Original line Diff line number Diff line
@@ -68,6 +68,7 @@ class FooterActionsTestUtils(
    private val testableLooper: TestableLooper,
    private val testableLooper: TestableLooper,
    private val scheduler: TestCoroutineScheduler,
    private val scheduler: TestCoroutineScheduler,
) {
) {
    private val mockActivityStarter: ActivityStarter = mock<ActivityStarter>()
    /** Enable or disable the user switcher in the settings. */
    /** Enable or disable the user switcher in the settings. */
    fun setUserSwitcherEnabled(settings: GlobalSettings, enabled: Boolean) {
    fun setUserSwitcherEnabled(settings: GlobalSettings, enabled: Boolean) {
        settings.putBool(Settings.Global.USER_SWITCHER_ENABLED, enabled)
        settings.putBool(Settings.Global.USER_SWITCHER_ENABLED, enabled)
@@ -90,13 +91,14 @@ class FooterActionsTestUtils(
            footerActionsInteractor,
            footerActionsInteractor,
            falsingManager,
            falsingManager,
            globalActionsDialogLite,
            globalActionsDialogLite,
            mockActivityStarter,
            showPowerButton,
            showPowerButton,
        )
        )
    }
    }


    /** Create a [FooterActionsInteractor] to be used in tests. */
    /** Create a [FooterActionsInteractor] to be used in tests. */
    fun footerActionsInteractor(
    fun footerActionsInteractor(
        activityStarter: ActivityStarter = mock(),
        activityStarter: ActivityStarter = mockActivityStarter,
        metricsLogger: MetricsLogger = FakeMetricsLogger(),
        metricsLogger: MetricsLogger = FakeMetricsLogger(),
        uiEventLogger: UiEventLogger = UiEventLoggerFake(),
        uiEventLogger: UiEventLogger = UiEventLoggerFake(),
        deviceProvisionedController: DeviceProvisionedController = mock(),
        deviceProvisionedController: DeviceProvisionedController = mock(),