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

Commit f2fa8f8b authored by Chandru S's avatar Chandru S Committed by Automerger Merge Worker
Browse files

Merge changes Ibca81eed,I5539cdaf,I3f7029f5,I9ce0fe29,I59e48540, ... into...

Merge changes Ibca81eed,I5539cdaf,I3f7029f5,I9ce0fe29,I59e48540, ... into udc-qpr-dev am: 36d7fcd6 am: e0324c47

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24289207



Change-Id: Iddcae46ecbf91c0fbfc3a202cc7c0662b79fefbc
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7838fee3 e0324c47
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@
    <string name="kg_prompt_after_user_lockdown_pattern">Pattern is required after lockdown</string>

    <!-- Message shown to prepare for an unattended update (OTA). Also known as an over-the-air (OTA) update.  [CHAR LIMIT=70] -->
    <string name="kg_prompt_unattended_update">Update will install during inactive hours</string>
    <string name="kg_prompt_unattended_update">Update will install when device not in use</string>

    <!-- Message shown when primary authentication hasn't been used for some time.  [CHAR LIMIT=70] -->
    <string name="kg_prompt_pin_auth_timeout">Added security required. PIN not used for a while.</string>
+1 −1
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
                getKeyguardSecurityCallback().dismiss(true, userId, getSecurityMode());
            }
        } else {
            mView.resetPasswordText(true /* animate */, false /* announce deletion if no match */);
            if (isValidPassword) {
                getKeyguardSecurityCallback().reportUnlockAttempt(userId, false, timeoutMs);
                if (timeoutMs > 0) {
@@ -186,7 +187,6 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
                    handleAttemptLockout(deadline);
                }
            }
            mView.resetPasswordText(true /* animate */, false /* announce deletion if no match */);
            if (timeoutMs == 0) {
                mMessageAreaController.setMessage(mView.getWrongPasswordStringId());
            }
+5 −2
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_PRIMARY;
import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_SECONDARY_USER;
import static com.android.keyguard.KeyguardSecurityContainer.USER_TYPE_WORK_PROFILE;
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.flags.Flags.REVAMPED_BOUNCER_MESSAGES;

import android.app.ActivityManager;
import android.app.admin.DevicePolicyManager;
@@ -1081,10 +1082,12 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
        mLockPatternUtils.reportFailedPasswordAttempt(userId);
        if (timeoutMs > 0) {
            mLockPatternUtils.reportPasswordLockout(timeoutMs, userId);
            if (!mFeatureFlags.isEnabled(REVAMPED_BOUNCER_MESSAGES)) {
                mView.showTimeoutDialog(userId, timeoutMs, mLockPatternUtils,
                        mSecurityModel.getSecurityMode(userId));
            }
        }
    }

    private void getCurrentSecurityController(
            KeyguardSecurityViewFlipperController.OnViewInflatedCallback onViewInflatedCallback) {
+0 −8
Original line number Diff line number Diff line
@@ -2695,14 +2695,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        return mAuthController.isUdfpsSupported();
    }

    /**
     * @return true if the FP sensor is non-UDFPS and the device can be unlocked using fingerprint
     * at this moment.
     */
    public boolean isFingerprintAllowedInBouncer() {
        return !isUdfpsSupported() && isUnlockingWithFingerprintAllowed();
    }

    /**
     * @return true if there's at least one sfps enrollment for the current user.
     */
+55 −25
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_NON_STRONG_BIOMET
import com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_PREPARE_FOR_UPDATE
import com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_PRIMARY_AUTH_LOCKED_OUT
import com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_RESTART
import com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_RESTART_FOR_MAINLINE_UPDATE
import com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT
import com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TRUSTAGENT_EXPIRED
import com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST
@@ -53,6 +54,9 @@ import com.android.systemui.R.string.kg_primary_auth_locked_out_password
import com.android.systemui.R.string.kg_primary_auth_locked_out_pattern
import com.android.systemui.R.string.kg_primary_auth_locked_out_pin
import com.android.systemui.R.string.kg_prompt_after_dpm_lock
import com.android.systemui.R.string.kg_prompt_after_update_password
import com.android.systemui.R.string.kg_prompt_after_update_pattern
import com.android.systemui.R.string.kg_prompt_after_update_pin
import com.android.systemui.R.string.kg_prompt_after_user_lockdown_password
import com.android.systemui.R.string.kg_prompt_after_user_lockdown_pattern
import com.android.systemui.R.string.kg_prompt_after_user_lockdown_pin
@@ -89,69 +93,76 @@ constructor(
    fun createFromPromptReason(
        @BouncerPromptReason reason: Int,
        userId: Int,
        secondaryMsgOverride: String? = null
    ): BouncerMessageModel? {
        val pair =
            getBouncerMessage(
                reason,
                securityModel.getSecurityMode(userId),
                updateMonitor.isFingerprintAllowedInBouncer
                updateMonitor.isUnlockingWithFingerprintAllowed
            )
        return pair?.let {
            BouncerMessageModel(
                message = Message(messageResId = pair.first),
                secondaryMessage = Message(messageResId = pair.second)
                message = Message(messageResId = pair.first, animate = false),
                secondaryMessage =
                    secondaryMsgOverride?.let {
                        Message(message = secondaryMsgOverride, animate = false)
                    }
                        ?: Message(messageResId = pair.second, animate = false)
            )
        }
    }

    fun createFromString(
        primaryMsg: String? = null,
        secondaryMsg: String? = null
    ): BouncerMessageModel =
        BouncerMessageModel(
            message = primaryMsg?.let { Message(message = it) },
            secondaryMessage = secondaryMsg?.let { Message(message = it) },
        )

    /**
     * Helper method that provides the relevant bouncer message that should be shown for different
     * scenarios indicated by [reason]. [securityMode] & [fpAllowedInBouncer] parameters are used to
     * scenarios indicated by [reason]. [securityMode] & [fpAuthIsAllowed] parameters are used to
     * provide a more specific message.
     */
    private fun getBouncerMessage(
        @BouncerPromptReason reason: Int,
        securityMode: SecurityMode,
        fpAllowedInBouncer: Boolean = false
        fpAuthIsAllowed: Boolean = false
    ): Pair<Int, Int>? {
        return when (reason) {
            // Primary auth locked out
            PROMPT_REASON_PRIMARY_AUTH_LOCKED_OUT -> primaryAuthLockedOut(securityMode)
            // Primary auth required reasons
            PROMPT_REASON_RESTART -> authRequiredAfterReboot(securityMode)
            PROMPT_REASON_TIMEOUT -> authRequiredAfterPrimaryAuthTimeout(securityMode)
            PROMPT_REASON_DEVICE_ADMIN -> authRequiredAfterAdminLockdown(securityMode)
            PROMPT_REASON_USER_REQUEST -> authRequiredAfterUserLockdown(securityMode)
            PROMPT_REASON_AFTER_LOCKOUT -> biometricLockout(securityMode)
            PROMPT_REASON_PREPARE_FOR_UPDATE -> authRequiredForUnattendedUpdate(securityMode)
            PROMPT_REASON_RESTART_FOR_MAINLINE_UPDATE -> authRequiredForMainlineUpdate(securityMode)
            PROMPT_REASON_FINGERPRINT_LOCKED_OUT -> fingerprintUnlockUnavailable(securityMode)
            PROMPT_REASON_FACE_LOCKED_OUT -> faceUnlockUnavailable(securityMode)
            PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT ->
                if (fpAllowedInBouncer) incorrectSecurityInputWithFingerprint(securityMode)
                else incorrectSecurityInput(securityMode)
            PROMPT_REASON_AFTER_LOCKOUT -> biometricLockout(securityMode)
            // Non strong auth not available reasons
            PROMPT_REASON_FACE_LOCKED_OUT ->
                if (fpAuthIsAllowed) faceLockedOutButFingerprintAvailable(securityMode)
                else faceLockedOut(securityMode)
            PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT ->
                if (fpAllowedInBouncer) nonStrongAuthTimeoutWithFingerprintAllowed(securityMode)
                if (fpAuthIsAllowed) nonStrongAuthTimeoutWithFingerprintAllowed(securityMode)
                else nonStrongAuthTimeout(securityMode)
            PROMPT_REASON_TRUSTAGENT_EXPIRED ->
                if (fpAllowedInBouncer) trustAgentDisabledWithFingerprintAllowed(securityMode)
                if (fpAuthIsAllowed) trustAgentDisabledWithFingerprintAllowed(securityMode)
                else trustAgentDisabled(securityMode)
            // Auth incorrect input reasons.
            PROMPT_REASON_INCORRECT_PRIMARY_AUTH_INPUT ->
                if (fpAuthIsAllowed) incorrectSecurityInputWithFingerprint(securityMode)
                else incorrectSecurityInput(securityMode)
            PROMPT_REASON_INCORRECT_FACE_INPUT ->
                if (fpAllowedInBouncer) incorrectFaceInputWithFingerprintAllowed(securityMode)
                if (fpAuthIsAllowed) incorrectFaceInputWithFingerprintAllowed(securityMode)
                else incorrectFaceInput(securityMode)
            PROMPT_REASON_INCORRECT_FINGERPRINT_INPUT -> incorrectFingerprintInput(securityMode)
            // Default message
            PROMPT_REASON_DEFAULT ->
                if (fpAllowedInBouncer) defaultMessageWithFingerprint(securityMode)
                if (fpAuthIsAllowed) defaultMessageWithFingerprint(securityMode)
                else defaultMessage(securityMode)
            PROMPT_REASON_PRIMARY_AUTH_LOCKED_OUT -> primaryAuthLockedOut(securityMode)
            else -> null
        }
    }

    fun emptyMessage(): BouncerMessageModel =
        BouncerMessageModel(Message(message = ""), Message(message = ""))
}

@Retention(AnnotationRetention.SOURCE)
@@ -172,6 +183,7 @@ constructor(
    PROMPT_REASON_NONE,
    PROMPT_REASON_RESTART,
    PROMPT_REASON_PRIMARY_AUTH_LOCKED_OUT,
    PROMPT_REASON_RESTART_FOR_MAINLINE_UPDATE,
)
annotation class BouncerPromptReason

@@ -284,6 +296,15 @@ private fun authRequiredForUnattendedUpdate(securityMode: SecurityMode): Pair<In
    }
}

private fun authRequiredForMainlineUpdate(securityMode: SecurityMode): Pair<Int, Int> {
    return when (securityMode) {
        SecurityMode.Pattern -> Pair(keyguard_enter_pattern, kg_prompt_after_update_pattern)
        SecurityMode.Password -> Pair(keyguard_enter_password, kg_prompt_after_update_password)
        SecurityMode.PIN -> Pair(keyguard_enter_pin, kg_prompt_after_update_pin)
        else -> Pair(0, 0)
    }
}

private fun authRequiredAfterPrimaryAuthTimeout(securityMode: SecurityMode): Pair<Int, Int> {
    return when (securityMode) {
        SecurityMode.Pattern -> Pair(keyguard_enter_pattern, kg_prompt_pattern_auth_timeout)
@@ -311,7 +332,7 @@ private fun nonStrongAuthTimeoutWithFingerprintAllowed(securityMode: SecurityMod
    }
}

private fun faceUnlockUnavailable(securityMode: SecurityMode): Pair<Int, Int> {
private fun faceLockedOut(securityMode: SecurityMode): Pair<Int, Int> {
    return when (securityMode) {
        SecurityMode.Pattern -> Pair(keyguard_enter_pattern, kg_face_locked_out)
        SecurityMode.Password -> Pair(keyguard_enter_password, kg_face_locked_out)
@@ -320,6 +341,15 @@ private fun faceUnlockUnavailable(securityMode: SecurityMode): Pair<Int, Int> {
    }
}

private fun faceLockedOutButFingerprintAvailable(securityMode: SecurityMode): Pair<Int, Int> {
    return when (securityMode) {
        SecurityMode.Pattern -> Pair(kg_unlock_with_pattern_or_fp, kg_face_locked_out)
        SecurityMode.Password -> Pair(kg_unlock_with_password_or_fp, kg_face_locked_out)
        SecurityMode.PIN -> Pair(kg_unlock_with_pin_or_fp, kg_face_locked_out)
        else -> Pair(0, 0)
    }
}

private fun fingerprintUnlockUnavailable(securityMode: SecurityMode): Pair<Int, Int> {
    return when (securityMode) {
        SecurityMode.Pattern -> Pair(keyguard_enter_pattern, kg_fp_locked_out)
Loading