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

Commit d601b5a4 authored by Bill Lin's avatar Bill Lin Committed by Android (Google) Code Review
Browse files

Merge "4/ Add config_face_auth_supported_posture to listen for Face by posture" into tm-qpr-dev

parents 89387bcc 799c71b6
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -668,6 +668,16 @@
        <item>17</item> <!-- WAKE_REASON_BIOMETRIC -->
    </integer-array>

    <!-- Whether to support posture listening for face auth, default is 0(DEVICE_POSTURE_UNKNOWN)
         means systemui will try listening on all postures.
         0 : DEVICE_POSTURE_UNKNOWN
         1 : DEVICE_POSTURE_CLOSED
         2 : DEVICE_POSTURE_HALF_OPENED
         3 : DEVICE_POSTURE_OPENED
         4 : DEVICE_POSTURE_FLIPPED
    -->
    <integer name="config_face_auth_supported_posture">0</integer>

    <!-- Whether the communal service should be enabled -->
    <bool name="config_communalServiceEnabled">false</bool>

+3 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.keyguard.InternalFaceAuthReasons.KEYGUARD_RESET
import com.android.keyguard.InternalFaceAuthReasons.KEYGUARD_VISIBILITY_CHANGED
import com.android.keyguard.InternalFaceAuthReasons.NON_STRONG_BIOMETRIC_ALLOWED_CHANGED
import com.android.keyguard.InternalFaceAuthReasons.OCCLUDING_APP_REQUESTED
import com.android.keyguard.InternalFaceAuthReasons.POSTURE_CHANGED
import com.android.keyguard.InternalFaceAuthReasons.PRIMARY_BOUNCER_SHOWN
import com.android.keyguard.InternalFaceAuthReasons.PRIMARY_BOUNCER_SHOWN_OR_WILL_BE_SHOWN
import com.android.keyguard.InternalFaceAuthReasons.RETRY_AFTER_HW_UNAVAILABLE
@@ -126,6 +127,7 @@ private object InternalFaceAuthReasons {
    const val STRONG_AUTH_ALLOWED_CHANGED = "Face auth stopped because strong auth allowed changed"
    const val NON_STRONG_BIOMETRIC_ALLOWED_CHANGED =
        "Face auth stopped because non strong biometric allowed changed"
    const val POSTURE_CHANGED = "Face auth started/stopped due to device posture changed."
}

/**
@@ -173,6 +175,7 @@ constructor(private val id: Int, val reason: String, var extraInfo: Int = 0) :
            return PowerManager.wakeReasonToString(extraInfo)
        }
    },
    @UiEvent(doc = POSTURE_CHANGED) FACE_AUTH_UPDATED_POSTURE_CHANGED(1265, POSTURE_CHANGED),
    @Deprecated(
        "Not a face auth trigger.",
        ReplaceWith(
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ data class KeyguardFaceListenModel(
    var keyguardGoingAway: Boolean = false,
    var listeningForFaceAssistant: Boolean = false,
    var occludingAppRequestingFaceAuth: Boolean = false,
    val postureAllowsListening: Boolean = false,
    var primaryUser: Boolean = false,
    var secureCameraLaunched: Boolean = false,
    var supportsDetect: Boolean = false,
+34 −3
Original line number Diff line number Diff line
@@ -63,11 +63,13 @@ import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_KEYGUARD_RE
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_KEYGUARD_VISIBILITY_CHANGED;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_ON_FACE_AUTHENTICATED;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_ON_KEYGUARD_INIT;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_POSTURE_CHANGED;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_PRIMARY_BOUNCER_SHOWN;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STARTED_WAKING_UP;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STRONG_AUTH_CHANGED;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_USER_SWITCHING;
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_UNKNOWN;

import android.annotation.AnyThread;
import android.annotation.MainThread;
@@ -155,6 +157,7 @@ import com.android.systemui.shared.system.TaskStackChangeListener;
import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.telephony.TelephonyListenerManager;
import com.android.systemui.util.Assert;
import com.android.systemui.util.settings.SecureSettings;
@@ -357,6 +360,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private final TrustManager mTrustManager;
    private final UserManager mUserManager;
    private final DevicePolicyManager mDevicePolicyManager;
    private final DevicePostureController mPostureController;
    private final BroadcastDispatcher mBroadcastDispatcher;
    private final SecureSettings mSecureSettings;
    private final InteractionJankMonitor mInteractionJankMonitor;
@@ -374,6 +378,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private final FaceManager mFaceManager;
    private final LockPatternUtils mLockPatternUtils;
    private final boolean mWakeOnFingerprintAcquiredStart;
    @VisibleForTesting
    @DevicePostureController.DevicePostureInt
    protected int mConfigFaceAuthSupportedPosture;

    private KeyguardBypassController mKeyguardBypassController;
    private List<SubscriptionInfo> mSubscriptionInfo;
@@ -384,6 +391,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private boolean mLogoutEnabled;
    private boolean mIsFaceEnrolled;
    private int mActiveMobileDataSubscription = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    private int mPostureState = DEVICE_POSTURE_UNKNOWN;
    private FingerprintInteractiveToAuthProvider mFingerprintInteractiveToAuthProvider;

    /**
@@ -1794,6 +1802,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                }
    };

    @VisibleForTesting
    final DevicePostureController.Callback mPostureCallback =
            new DevicePostureController.Callback() {
                @Override
                public void onPostureChanged(int posture) {
                    mPostureState = posture;
                    updateFaceListeningState(BIOMETRIC_ACTION_UPDATE,
                            FACE_AUTH_UPDATED_POSTURE_CHANGED);
                }
            };

    @VisibleForTesting
    CancellationSignal mFingerprintCancelSignal;
    @VisibleForTesting
@@ -2060,6 +2079,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            @Nullable FingerprintManager fingerprintManager,
            @Nullable BiometricManager biometricManager,
            FaceWakeUpTriggersConfig faceWakeUpTriggersConfig,
            DevicePostureController devicePostureController,
            Optional<FingerprintInteractiveToAuthProvider> interactiveToAuthProvider) {
        mContext = context;
        mSubscriptionManager = subscriptionManager;
@@ -2089,6 +2109,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mDreamManager = dreamManager;
        mTelephonyManager = telephonyManager;
        mDevicePolicyManager = devicePolicyManager;
        mPostureController = devicePostureController;
        mPackageManager = packageManager;
        mFpm = fingerprintManager;
        mFaceManager = faceManager;
@@ -2100,6 +2121,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                        R.array.config_face_acquire_device_entry_ignorelist))
                .boxed()
                .collect(Collectors.toSet());
        mConfigFaceAuthSupportedPosture = mContext.getResources().getInteger(
                R.integer.config_face_auth_supported_posture);
        mFaceWakeUpTriggersConfig = faceWakeUpTriggersConfig;

        mHandler = new Handler(mainLooper) {
@@ -2290,6 +2313,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                        FACE_AUTH_TRIGGERED_ENROLLMENTS_CHANGED));
            }
        });
        if (mConfigFaceAuthSupportedPosture != DEVICE_POSTURE_UNKNOWN) {
            mPostureController.addCallback(mPostureCallback);
        }
        updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE, FACE_AUTH_UPDATED_ON_KEYGUARD_INIT);

        TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackListener);
@@ -2794,6 +2820,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        final boolean biometricEnabledForUser = mBiometricEnabledForUser.get(user);
        final boolean shouldListenForFaceAssistant = shouldListenForFaceAssistant();
        final boolean isUdfpsFingerDown = mAuthController.isUdfpsFingerDown();
        final boolean isPostureAllowedForFaceAuth =
                mConfigFaceAuthSupportedPosture == 0 /* DEVICE_POSTURE_UNKNOWN */ ? true
                        : (mPostureState == mConfigFaceAuthSupportedPosture);

        // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
        // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
@@ -2810,7 +2839,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                && faceAuthAllowedOrDetectionIsNeeded && mIsPrimaryUser
                && (!mSecureCameraLaunched || mOccludingAppRequestingFace)
                && faceAndFpNotAuthenticated
                && !mGoingToSleep;
                && !mGoingToSleep
                && isPostureAllowedForFaceAuth;

        // Aggregate relevant fields for debug logging.
        logListenerModelData(
@@ -2830,6 +2860,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    mKeyguardGoingAway,
                    shouldListenForFaceAssistant,
                    mOccludingAppRequestingFace,
                    isPostureAllowedForFaceAuth,
                    mIsPrimaryUser,
                    mSecureCameraLaunched,
                    supportsDetect,
@@ -2915,7 +2946,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                getKeyguardSessionId(),
                faceAuthUiEvent.getExtraInfo()
        );

        mLogger.logFaceUnlockPossible(unlockPossible);
        if (unlockPossible) {
            mFaceCancelSignal = new CancellationSignal();

+6 −0
Original line number Diff line number Diff line
@@ -132,6 +132,12 @@ class KeyguardUpdateMonitorLogger @Inject constructor(
        logBuffer.log(TAG, DEBUG, { int1 = faceRunningState }, { "faceRunningState: $int1" })
    }

    fun logFaceUnlockPossible(isFaceUnlockPossible: Boolean) {
        logBuffer.log(TAG, DEBUG,
                { bool1 = isFaceUnlockPossible },
                {"isUnlockWithFacePossible: $bool1"})
    }

    fun logFingerprintAuthForWrongUser(authUserId: Int) {
        logBuffer.log(TAG, DEBUG,
                { int1 = authUserId },
Loading