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

Commit 59fe0c6f authored by Matt Pietal's avatar Matt Pietal
Browse files

Send "Unlock to continue" bouncer message

On the user switcher bouncer, when "Manage Users" is
tapped, ensure a secondary message is displayed to
prompt the user to unlock.

Fixes: 365574398
Test: manual, use bouncer user switcher and tap manager users
Flag: EXEMPT bugfix
Change-Id: I4d9c0072576dce80dc23a18140ba41c5350ab6d4
parent a8ef53cc
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1102,8 +1102,11 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
        }

        mView.initMode(mode, mGlobalSettings, mFalsingManager, mUserSwitcherController,
                () -> showMessage(getContext().getString(R.string.keyguard_unlock_to_continue),
                        /* colorState= */ null, /* animated= */ true), mFalsingA11yDelegate);
                () -> {
                        String msg = getContext().getString(R.string.keyguard_unlock_to_continue);
                        showMessage(msg, /* colorState= */ null, /* animated= */ true);
                        mBouncerMessageInteractor.setUnlockToContinueMessage(msg);
                }, mFalsingA11yDelegate);
    }

    public void reportFailedUnlockAttempt(int userId, int timeoutMs) {
+32 −21
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ constructor(
        deviceEntryBiometricsAllowedInteractor.isFingerprintCurrentlyAllowedOnBouncer.stateIn(
            applicationScope,
            SharingStarted.Eagerly,
            false
            false,
        )

    private val currentSecurityMode
@@ -114,13 +114,13 @@ constructor(
                        BiometricSourceType.FACE ->
                            BouncerMessageStrings.incorrectFaceInput(
                                    currentSecurityMode.toAuthModel(),
                                    isFingerprintAuthCurrentlyAllowedOnBouncer.value
                                    isFingerprintAuthCurrentlyAllowedOnBouncer.value,
                                )
                                .toMessage()
                        else ->
                            BouncerMessageStrings.defaultMessage(
                                    currentSecurityMode.toAuthModel(),
                                    isFingerprintAuthCurrentlyAllowedOnBouncer.value
                                    isFingerprintAuthCurrentlyAllowedOnBouncer.value,
                                )
                                .toMessage()
                    },
@@ -130,7 +130,7 @@ constructor(

            override fun onBiometricAcquired(
                biometricSourceType: BiometricSourceType?,
                acquireInfo: Int
                acquireInfo: Int,
            ) {
                if (
                    repository.getMessageSource() == BiometricSourceType.FACE &&
@@ -143,7 +143,7 @@ constructor(
            override fun onBiometricAuthenticated(
                userId: Int,
                biometricSourceType: BiometricSourceType?,
                isStrongBiometric: Boolean
                isStrongBiometric: Boolean,
            ) {
                repository.setMessage(defaultMessage, biometricSourceType)
            }
@@ -169,7 +169,7 @@ constructor(
                deviceEntryBiometricsAllowedInteractor.isFingerprintLockedOut,
                deviceEntryBiometricsAllowedInteractor.isFaceLockedOut,
                isFingerprintAuthCurrentlyAllowedOnBouncer,
                ::Septuple
                ::Septuple,
            )
            .map { (_, flags, _, biometricsEnrolledAndEnabled, fpLockedOut, faceLockedOut, _) ->
                val isTrustUsuallyManaged = trustRepository.isCurrentUserTrustUsuallyManaged.value
@@ -220,14 +220,14 @@ constructor(
                    } else {
                        BouncerMessageStrings.faceLockedOut(
                                currentSecurityMode.toAuthModel(),
                                isFingerprintAuthCurrentlyAllowedOnBouncer.value
                                isFingerprintAuthCurrentlyAllowedOnBouncer.value,
                            )
                            .toMessage()
                    }
                } else if (flags.isSomeAuthRequiredAfterAdaptiveAuthRequest) {
                    BouncerMessageStrings.authRequiredAfterAdaptiveAuthRequest(
                            currentSecurityMode.toAuthModel(),
                            isFingerprintAuthCurrentlyAllowedOnBouncer.value
                            isFingerprintAuthCurrentlyAllowedOnBouncer.value,
                        )
                        .toMessage()
                } else if (
@@ -236,19 +236,19 @@ constructor(
                ) {
                    BouncerMessageStrings.nonStrongAuthTimeout(
                            currentSecurityMode.toAuthModel(),
                            isFingerprintAuthCurrentlyAllowedOnBouncer.value
                            isFingerprintAuthCurrentlyAllowedOnBouncer.value,
                        )
                        .toMessage()
                } else if (isTrustUsuallyManaged && flags.someAuthRequiredAfterUserRequest) {
                    BouncerMessageStrings.trustAgentDisabled(
                            currentSecurityMode.toAuthModel(),
                            isFingerprintAuthCurrentlyAllowedOnBouncer.value
                            isFingerprintAuthCurrentlyAllowedOnBouncer.value,
                        )
                        .toMessage()
                } else if (isTrustUsuallyManaged && flags.someAuthRequiredAfterTrustAgentExpired) {
                    BouncerMessageStrings.trustAgentDisabled(
                            currentSecurityMode.toAuthModel(),
                            isFingerprintAuthCurrentlyAllowedOnBouncer.value
                            isFingerprintAuthCurrentlyAllowedOnBouncer.value,
                        )
                        .toMessage()
                } else if (trustOrBiometricsAvailable && flags.isInUserLockdown) {
@@ -292,7 +292,7 @@ constructor(
        repository.setMessage(
            BouncerMessageStrings.incorrectSecurityInput(
                    currentSecurityMode.toAuthModel(),
                    isFingerprintAuthCurrentlyAllowedOnBouncer.value
                    isFingerprintAuthCurrentlyAllowedOnBouncer.value,
                )
                .toMessage()
        )
@@ -304,19 +304,30 @@ constructor(
            defaultMessage(
                currentSecurityMode,
                value,
                isFingerprintAuthCurrentlyAllowedOnBouncer.value
                isFingerprintAuthCurrentlyAllowedOnBouncer.value,
            ),
            BiometricSourceType.FINGERPRINT,
        )
    }

    fun setUnlockToContinueMessage(value: String) {
        if (!Flags.revampedBouncerMessages()) return
        repository.setMessage(
            defaultMessage(
                currentSecurityMode,
                value,
                isFingerprintAuthCurrentlyAllowedOnBouncer.value,
            )
        )
    }

    fun setFaceAcquisitionMessage(value: String?) {
        if (!Flags.revampedBouncerMessages()) return
        repository.setMessage(
            defaultMessage(
                currentSecurityMode,
                value,
                isFingerprintAuthCurrentlyAllowedOnBouncer.value
                isFingerprintAuthCurrentlyAllowedOnBouncer.value,
            ),
            BiometricSourceType.FACE,
        )
@@ -329,7 +340,7 @@ constructor(
            defaultMessage(
                currentSecurityMode,
                value,
                isFingerprintAuthCurrentlyAllowedOnBouncer.value
                isFingerprintAuthCurrentlyAllowedOnBouncer.value,
            )
        )
    }
@@ -338,7 +349,7 @@ constructor(
        get() =
            BouncerMessageStrings.defaultMessage(
                    currentSecurityMode.toAuthModel(),
                    isFingerprintAuthCurrentlyAllowedOnBouncer.value
                    isFingerprintAuthCurrentlyAllowedOnBouncer.value,
                )
                .toMessage()

@@ -400,7 +411,7 @@ private fun Flow<Boolean>.or(anotherFlow: Flow<Boolean>) =
private fun defaultMessage(
    securityMode: SecurityMode,
    secondaryMessage: String?,
    fpAuthIsAllowed: Boolean
    fpAuthIsAllowed: Boolean,
): BouncerMessageModel {
    return BouncerMessageModel(
        message =
@@ -408,21 +419,21 @@ private fun defaultMessage(
                messageResId =
                    BouncerMessageStrings.defaultMessage(
                            securityMode.toAuthModel(),
                            fpAuthIsAllowed
                            fpAuthIsAllowed,
                        )
                        .toMessage()
                        .message
                        ?.messageResId,
                animate = false
                animate = false,
            ),
        secondaryMessage = Message(message = secondaryMessage, animate = false)
        secondaryMessage = Message(message = secondaryMessage, animate = false),
    )
}

private fun Pair<Int, Int>.toMessage(): BouncerMessageModel {
    return BouncerMessageModel(
        message = Message(messageResId = this.first, animate = false),
        secondaryMessage = Message(messageResId = this.second, animate = false)
        secondaryMessage = Message(messageResId = this.second, animate = false),
    )
}