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

Commit 113c404e authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Allow FSI when device provisioned but user setup incomplete

We don't allow notifications to peek during user setup, so we need to
let FSIs through for things like incoming calls.

Implement this in both the old and new visual interruption decision code
since the flag for the new code isn't completely rolled out yet.

Bug: 326356165
Test: atest VisualInterruptionDecisionProviderImplTest
Test: atest NotificationInterruptStateProviderWrapperTest
Flag: NA
Change-Id: I50399bea3bafb6bc65e58006a44cb092bc6a86ee
parent f87fab8a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.systemui.statusbar.notification.interruption.FullScreenIntent
import com.android.systemui.statusbar.notification.interruption.FullScreenIntentDecisionProvider.DecisionImpl.FSI_KEYGUARD_OCCLUDED
import com.android.systemui.statusbar.notification.interruption.FullScreenIntentDecisionProvider.DecisionImpl.FSI_KEYGUARD_SHOWING
import com.android.systemui.statusbar.notification.interruption.FullScreenIntentDecisionProvider.DecisionImpl.FSI_LOCKED_SHADE
import com.android.systemui.statusbar.notification.interruption.FullScreenIntentDecisionProvider.DecisionImpl.FSI_USER_SETUP_INCOMPLETE
import com.android.systemui.statusbar.notification.interruption.FullScreenIntentDecisionProvider.DecisionImpl.NO_FSI_EXPECTED_TO_HUN
import com.android.systemui.statusbar.notification.interruption.FullScreenIntentDecisionProvider.DecisionImpl.NO_FSI_NOT_IMPORTANT_ENOUGH
import com.android.systemui.statusbar.notification.interruption.FullScreenIntentDecisionProvider.DecisionImpl.NO_FSI_NO_FULL_SCREEN_INTENT
@@ -101,6 +102,7 @@ class FullScreenIntentDecisionProvider(
        FSI_KEYGUARD_OCCLUDED(true, "keyguard is occluded"),
        FSI_LOCKED_SHADE(true, "locked shade"),
        FSI_DEVICE_NOT_PROVISIONED(true, "device not provisioned"),
        FSI_USER_SETUP_INCOMPLETE(true, "user setup incomplete"),
        NO_FSI_NO_HUN_OR_KEYGUARD(
            false,
            "no HUN or keyguard",
@@ -189,6 +191,10 @@ class FullScreenIntentDecisionProvider(
            return FSI_DEVICE_NOT_PROVISIONED
        }

        if (!deviceProvisionedController.isCurrentUserSetup) {
            return FSI_USER_SETUP_INCOMPLETE
        }

        return NO_FSI_NO_HUN_OR_KEYGUARD
    }
}
+5 −1
Original line number Diff line number Diff line
@@ -104,7 +104,11 @@ public interface NotificationInterruptStateProvider {
        /**
         * The device is not provisioned, launch FSI.
         */
        FSI_NOT_PROVISIONED(true);
        FSI_NOT_PROVISIONED(true),
        /**
         * The current user has not completed setup, launch FSI.
         */
        FSI_USER_SETUP_INCOMPLETE(true);

        public final boolean shouldLaunch;

+6 −0
Original line number Diff line number Diff line
@@ -362,6 +362,12 @@ public class NotificationInterruptStateProviderImpl implements NotificationInter
                    suppressedByDND);
        }

        // The current user hasn't completed setup, launch FSI.
        if (!mDeviceProvisionedController.isCurrentUserSetup()) {
            return getDecisionGivenSuppression(FullScreenIntentDecision.FSI_USER_SETUP_INCOMPLETE,
                    suppressedByDND);
        }

        // Detect the case determined by b/231322873 to launch FSI while device is in use,
        // as blocked by the correct implementation, and report the event.
        return getDecisionGivenSuppression(FullScreenIntentDecision.NO_FSI_NO_HUN_OR_KEYGUARD,
+27 −2
Original line number Diff line number Diff line
@@ -148,7 +148,10 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() {

    @Before
    fun setUp() {
        val user = UserInfo(ActivityManager.getCurrentUser(), "Current user", /* flags = */ 0)
        val userId = ActivityManager.getCurrentUser()
        val user = UserInfo(userId, "Current user", /* flags = */ 0)

        deviceProvisionedController.currentUser = userId
        userTracker.set(listOf(user), /* currentUserIndex = */ 0)

        provider.start()
@@ -820,6 +823,13 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() {
        assertNoEventsLogged()
    }

    @Test
    fun testShouldFsi_userSetupIncomplete() {
        ensureUserSetupIncompleteFsiState()
        assertShouldFsi(buildFsiEntry())
        assertNoEventsLogged()
    }

    @Test
    fun testShouldNotFsi_noHunOrKeyguard() {
        ensureNoHunOrKeyguardFsiState()
@@ -886,7 +896,8 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() {
        var statusBarState: Int? = null,
        var keyguardIsShowing: Boolean = false,
        var keyguardIsOccluded: Boolean = false,
        var deviceProvisioned: Boolean = true
        var deviceProvisioned: Boolean = true,
        var currentUserSetup: Boolean = true
    )

    protected fun setState(state: State): Unit =
@@ -923,6 +934,7 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() {
            keyguardStateController.isShowing = keyguardIsShowing

            deviceProvisionedController.deviceProvisioned = deviceProvisioned
            deviceProvisionedController.isCurrentUserSetup = currentUserSetup
        }

    protected fun ensureState(block: State.() -> Unit) =
@@ -997,6 +1009,18 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() {
        hunSettingEnabled = false
        keyguardIsShowing = false
        deviceProvisioned = false
        currentUserSetup = true
        run(block)
    }

    protected fun ensureUserSetupIncompleteFsiState(block: State.() -> Unit = {}) = ensureState {
        isInteractive = true
        isDreaming = false
        statusBarState = SHADE
        hunSettingEnabled = false
        keyguardIsShowing = false
        deviceProvisioned = true
        currentUserSetup = false
        run(block)
    }

@@ -1007,6 +1031,7 @@ abstract class VisualInterruptionDecisionProviderTestBase : SysuiTestCase() {
        hunSettingEnabled = false
        keyguardIsShowing = false
        deviceProvisioned = true
        currentUserSetup = true
        run(block)
    }