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

Commit c728c37f authored by Haining Chen's avatar Haining Chen
Browse files

Add Keyguard bottom area string for adaptive auth

Flag: ACONFIG android.adaptiveauth.enable_adaptive_auth DEVELOPMENT
Bug: 285053096
Test: 1. Trigger 5 failed biometric attempts and/or primary auth
         attempts from BiometricPrompt or Settings (not on Keyguard),
         which will lock the device out
      2. See message in the Keyguard bottom area
Change-Id: Iec5752e38661eb0a51b30151d36fe8a357207eae
parent 9a4877d3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import static android.hardware.biometrics.BiometricSourceType.FINGERPRINT;
import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN;
import static android.os.BatteryManager.CHARGING_POLICY_DEFAULT;

import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_BOOT;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
@@ -1570,6 +1571,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        return isEncrypted || isLockDown;
    }

    /**
     * Whether the device is locked by adaptive auth
     */
    public boolean isDeviceLockedByAdaptiveAuth(int userId) {
        return containsFlag(mStrongAuthTracker.getStrongAuthForUser(userId),
                SOME_AUTH_REQUIRED_AFTER_ADAPTIVE_AUTH_REQUEST);
    }

    private boolean containsFlag(int haystack, int needle) {
        return (haystack & needle) != 0;
    }
+5 −1
Original line number Diff line number Diff line
@@ -404,6 +404,7 @@ public class KeyguardIndicationRotateTextViewController extends
    public static final int INDICATION_TYPE_BIOMETRIC_MESSAGE = 11;
    public static final int INDICATION_TYPE_BIOMETRIC_MESSAGE_FOLLOW_UP = 12;
    public static final int INDICATION_IS_DISMISSIBLE = 13;
    public static final int INDICATION_TYPE_ADAPTIVE_AUTH = 14;

    @IntDef({
            INDICATION_TYPE_NONE,
@@ -419,7 +420,8 @@ public class KeyguardIndicationRotateTextViewController extends
            INDICATION_TYPE_REVERSE_CHARGING,
            INDICATION_TYPE_BIOMETRIC_MESSAGE,
            INDICATION_TYPE_BIOMETRIC_MESSAGE_FOLLOW_UP,
            INDICATION_IS_DISMISSIBLE
            INDICATION_IS_DISMISSIBLE,
            INDICATION_TYPE_ADAPTIVE_AUTH
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface IndicationType{}
@@ -455,6 +457,8 @@ public class KeyguardIndicationRotateTextViewController extends
                return "biometric_message";
            case INDICATION_TYPE_BIOMETRIC_MESSAGE_FOLLOW_UP:
                return "biometric_message_followup";
            case INDICATION_TYPE_ADAPTIVE_AUTH:
                return "adaptive_auth";
            default:
                return "unknown[" + type + "]";
        }
+21 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar;

import static android.adaptiveauth.Flags.enableAdaptiveAuth;
import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.KEYGUARD_MANAGEMENT_DISCLOSURE;
import static android.app.admin.DevicePolicyResources.Strings.SystemUi.KEYGUARD_NAMED_MANAGEMENT_DISCLOSURE;
@@ -32,6 +33,7 @@ import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.flags.Flags.LOCKSCREEN_WALLPAPER_DREAM_ENABLED;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.IMPORTANT_MSG_MIN_DURATION;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_IS_DISMISSIBLE;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_ADAPTIVE_AUTH;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_ALIGNMENT;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_BATTERY;
import static com.android.systemui.keyguard.KeyguardIndicationRotateTextViewController.INDICATION_TYPE_BIOMETRIC_MESSAGE;
@@ -454,6 +456,9 @@ public class KeyguardIndicationController {
        updateLockScreenAlignmentMsg();
        updateLockScreenLogoutView();
        updateLockScreenPersistentUnlockMsg();
        if (enableAdaptiveAuth()) {
            updateLockScreenAdaptiveAuthMsg(userId);
        }
    }

    private void updateOrganizedOwnedDevice() {
@@ -740,6 +745,22 @@ public class KeyguardIndicationController {
        }
    }

    private void updateLockScreenAdaptiveAuthMsg(int userId) {
        final boolean deviceLocked = mKeyguardUpdateMonitor.isDeviceLockedByAdaptiveAuth(userId);
        if (deviceLocked) {
            mRotateTextViewController.updateIndication(
                    INDICATION_TYPE_ADAPTIVE_AUTH,
                    new KeyguardIndication.Builder()
                            .setMessage(mContext
                                    .getString(R.string.kg_prompt_after_adaptive_auth_lock))
                            .setTextColor(mInitialTextColorState)
                            .build(),
                    true);
        } else {
            mRotateTextViewController.hideIndication(INDICATION_TYPE_ADAPTIVE_AUTH);
        }
    }

    private boolean isOrganizationOwnedDevice() {
        return mDevicePolicyManager.isDeviceManaged()
                || mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile();