Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
SystemUI: Allow listening for face only on pin/pass view
Browse files Browse the repository at this point in the history
Useful for devices with popup camera

Change-Id: Ifba770dd1681858844d5d0290cbf385bfa47f841
  • Loading branch information
jhenrique09 committed Mar 20, 2022
1 parent 0b5c323 commit 16b8104
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/res/res/values/custom_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,7 @@
(without "Focus" state) instead of Dual-stage. -->
<bool name="config_singleStageCameraKey">false</bool>

<!-- Enable face auth only when swiping security view -->
<bool name="config_faceAuthOnlyOnSecurityView">false</bool>

</resources>
3 changes: 3 additions & 0 deletions core/res/res/values/custom_symbols.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,7 @@
<!-- Camera key type -->
<java-symbol type="bool" name="config_singleStageCameraKey" />

<!-- Enable face auth only when swiping security view -->
<java-symbol type="bool" name="config_faceAuthOnlyOnSecurityView" />

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@

import com.google.android.collect.Lists;

import com.android.internal.util.custom.faceunlock.FaceUnlockUtils;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
Expand Down Expand Up @@ -432,6 +434,12 @@ static class BiometricAuthenticated {

private static int sCurrentUser;

private final boolean mFaceAuthOnlyOnSecurityView;
private boolean mBouncerFullyShown;

// Face unlock
private static final boolean mCustomFaceUnlockSupported = FaceUnlockUtils.isFaceUnlockSupported();

public synchronized static void setCurrentUser(int currentUser) {
sCurrentUser = currentUser;
}
Expand Down Expand Up @@ -1809,6 +1817,8 @@ protected KeyguardUpdateMonitor(
mTelephonyListenerManager = telephonyListenerManager;
mDeviceProvisioned = isDeviceProvisionedInSettingsDb();
mStrongAuthTracker = new StrongAuthTracker(context, this::notifyStrongAuthStateChanged);
mFaceAuthOnlyOnSecurityView = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_faceAuthOnlyOnSecurityView);
mBackgroundExecutor = backgroundExecutor;
mBroadcastDispatcher = broadcastDispatcher;
mInteractionJankMonitor = interactionJankMonitor;
Expand Down Expand Up @@ -2392,7 +2402,7 @@ public boolean shouldListenForFace() {

// Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
// instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
final boolean shouldListen =
boolean shouldListen =
(mBouncer || mAuthInterruptActive || mOccludingAppRequestingFace || awakeKeyguard
|| shouldListenForFaceAssistant)
&& !mSwitchingUser && !faceDisabledForUser && becauseCannotSkipBouncer
Expand All @@ -2402,6 +2412,10 @@ public boolean shouldListenForFace() {
&& !faceAuthenticated
&& !fpLockedout;

if (shouldListen && mFaceAuthOnlyOnSecurityView && !mBouncerFullyShown){
shouldListen = false;
}

// Aggregate relevant fields for debug logging.
if (DEBUG_FACE || DEBUG_SPEW) {
maybeLogListenerModelData(
Expand Down Expand Up @@ -2429,6 +2443,15 @@ public boolean shouldListenForFace() {
return shouldListen;
}

public void onKeyguardBouncerFullyShown(boolean fullyShow) {
if (mBouncerFullyShown != fullyShow){
mBouncerFullyShown = fullyShow;
if (mFaceAuthOnlyOnSecurityView){
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE);
}
}
}

private void maybeLogListenerModelData(KeyguardListenModel model) {
// Too chatty, but very useful when debugging issues.
if (DEBUG_SPEW) {
Expand Down Expand Up @@ -2915,6 +2938,7 @@ public void onKeyguardVisibilityChanged(boolean showing) {
Assert.isMainThread();
Log.d(TAG, "onKeyguardVisibilityChanged(" + showing + ")");
mKeyguardIsVisible = showing;
mBouncerFullyShown = false;

if (showing) {
mSecureCameraLaunched = false;
Expand Down Expand Up @@ -2954,6 +2978,7 @@ public void onKeyguardOccludedChanged(boolean occluded) {
private void handleKeyguardReset() {
if (DEBUG) Log.d(TAG, "handleKeyguardReset");
updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE);
mBouncerFullyShown = false;
mNeedsSlowUnlockTransition = resolveNeedsSlowUnlockTransition();
}

Expand Down Expand Up @@ -3019,6 +3044,7 @@ private void handleRequireUnlockForNfc() {
* Handle {@link #MSG_REPORT_EMERGENCY_CALL_ACTION}
*/
private void handleReportEmergencyCallAction() {
mBouncerFullyShown = false;
Assert.isMainThread();
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public void onFullyShown() {
updateStates();
mStatusBar.wakeUpIfDozing(SystemClock.uptimeMillis(),
mStatusBar.getBouncerContainer(), "BOUNCER_VISIBLE");
onKeyguardBouncerFullyShownChanged(true);
}

@Override
Expand All @@ -136,6 +137,7 @@ public void onStartingToShow() {

@Override
public void onFullyHidden() {
onKeyguardBouncerFullyShownChanged(false);
}

@Override
Expand Down Expand Up @@ -974,6 +976,10 @@ public void run() {
}
};

private void onKeyguardBouncerFullyShownChanged(boolean fullyShown){
mKeyguardUpdateManager.onKeyguardBouncerFullyShown(fullyShown);
}

protected void updateStates() {
boolean showing = mShowing;
boolean occluded = mOccluded;
Expand Down

0 comments on commit 16b8104

Please sign in to comment.