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

Commit 066a2419 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Dismiss bouncer when clicking on action button

This returns to the lockscreen scene when the "emergency button" is
clicked by the user.

The change helps avoid occlusion problems as described in the attached
bug and also mimics the solution done in pre-flexiglass.

Fix: 355496091
Test: unit test updated
Test: manually verified that the emergency services activity appears and
is not occluded by the bouncer - checked on first unlock after reboot
and on subsequent unlocked
Test: manually verified that the camera app, when shown after a
double-press of the power button properly brings up the bouncer and that
unlocking it returns to the camera app as it should
Flag: com.android.systemui.scene_container

Change-Id: I6284a70992fe3ab32069d1405713477fa17d1887
parent 47802d24
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import com.android.systemui.common.ui.data.repository.fakeConfigurationRepositor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeMobileConnectionsRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.fakeMobileConnectionsRepository
import com.android.systemui.telephony.data.repository.fakeTelephonyRepository
@@ -91,6 +93,8 @@ class BouncerActionButtonInteractorTest : SysuiTestCase() {
        kosmos.fakeTelephonyRepository.setHasTelephonyRadio(true)

        kosmos.telecomManager = telecomManager

        kosmos.sceneInteractor.changeScene(Scenes.Bouncer, "")
    }

    @Test
@@ -130,6 +134,7 @@ class BouncerActionButtonInteractorTest : SysuiTestCase() {
            assertThat(metricsLogger.logs.element().category)
                .isEqualTo(MetricsProto.MetricsEvent.ACTION_EMERGENCY_CALL)
            verify(activityTaskManager).stopSystemLockTaskMode()
            assertThat(kosmos.sceneInteractor.currentScene.value).isEqualTo(Scenes.Lockscreen)
            verify(telecomManager).showInCallScreen(eq(false))
        }

@@ -156,6 +161,7 @@ class BouncerActionButtonInteractorTest : SysuiTestCase() {
            assertThat(metricsLogger.logs.element().category)
                .isEqualTo(MetricsProto.MetricsEvent.ACTION_EMERGENCY_CALL)
            verify(activityTaskManager).stopSystemLockTaskMode()
            assertThat(kosmos.sceneInteractor.currentScene.value).isEqualTo(Scenes.Lockscreen)

            // TODO(b/25189994): Test the activity has been started once we switch to the
            //  ActivityStarter interface here.
+10 −2
Original line number Diff line number Diff line
@@ -34,10 +34,14 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.doze.DozeLogger
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionsRepository
import com.android.systemui.telephony.domain.interactor.TelephonyInteractor
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.util.EmergencyDialerConstants
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
@@ -69,6 +73,7 @@ constructor(
    private val emergencyDialerIntentFactory: EmergencyDialerIntentFactory,
    private val metricsLogger: MetricsLogger,
    private val dozeLogger: DozeLogger,
    private val sceneInteractor: Lazy<SceneInteractor>,
) {
    /** The bouncer action button. If `null`, the button should not be shown. */
    val actionButton: Flow<BouncerActionButtonModel?> =
@@ -158,7 +163,10 @@ constructor(
    }

    private fun prepareToPerformAction() {
        // TODO(b/308001302): Trigger occlusion and resetting bouncer state.
        if (SceneContainerFlag.isEnabled) {
            sceneInteractor.get().changeScene(Scenes.Lockscreen, "Bouncer action button clicked")
        }

        metricsLogger.action(MetricsEvent.ACTION_EMERGENCY_CALL)
        activityTaskManager.stopSystemLockTaskMode()
    }
+3 −2
Original line number Diff line number Diff line
@@ -29,11 +29,12 @@ import kotlinx.coroutines.flow.StateFlow
class TelephonyInteractor
@Inject
constructor(
    repository: TelephonyRepository,
    private val repository: TelephonyRepository,
) {
    @Annotation.CallState val callState: Flow<Int> = repository.callState

    val isInCall: StateFlow<Boolean> = repository.isInCall

    val hasTelephonyRadio: Boolean = repository.hasTelephonyRadio
    val hasTelephonyRadio: Boolean
        get() = repository.hasTelephonyRadio
}
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.systemui.bouncer.data.repository.emergencyServicesRepository
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.statusbar.pipeline.mobile.data.repository.mobileConnectionsRepository
import com.android.systemui.telephony.domain.interactor.telephonyInteractor
import com.android.systemui.user.domain.interactor.selectedUserInteractor
@@ -50,5 +51,6 @@ val Kosmos.bouncerActionButtonInteractor by Fixture {
            },
        metricsLogger = metricsLogger,
        dozeLogger = mock(),
        sceneInteractor = { sceneInteractor },
    )
}