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

Commit 2fefd466 authored by Kevin Chyn's avatar Kevin Chyn
Browse files

enable FP auth when assistant is showing and device is locked

Bug: 37875884
Test: manual
Change-Id: I4f310f71a50187735c1430b462291b2f57f54324
parent a9c798eb
Loading
Loading
Loading
Loading
+47 −5
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ import android.os.Handler;
import android.os.IRemoteCallback;
import android.os.Message;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
@@ -62,7 +61,6 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.util.ArraySet;
import android.util.Log;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
@@ -74,6 +72,8 @@ import com.android.internal.telephony.IccCardConstants.State;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyIntents;
import com.android.internal.widget.LockPatternUtils;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -131,6 +131,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private static final int MSG_SCREEN_TURNED_OFF = 332;
    private static final int MSG_DREAMING_STATE_CHANGED = 333;
    private static final int MSG_USER_UNLOCKED = 334;
    private static final int MSG_ASSISTANT_STACK_CHANGED = 335;

    /** Fingerprint state: Not listening to fingerprint. */
    private static final int FINGERPRINT_STATE_STOPPED = 0;
@@ -170,6 +171,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private boolean mBootCompleted;
    private boolean mNeedsSlowUnlockTransition;
    private boolean mHasLockscreenWallpaper;
    private boolean mAssistantVisible;
    private boolean mKeyguardOccluded;

    // Device provisioning state
    private boolean mDeviceProvisioned;
@@ -287,6 +290,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                case MSG_USER_UNLOCKED:
                    handleUserUnlocked();
                    break;
                case MSG_ASSISTANT_STACK_CHANGED:
                    mAssistantVisible = (boolean)msg.obj;
                    updateFingerprintListeningState();
                    break;
            }
        }
    };
@@ -414,6 +421,15 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        mKeyguardGoingAway = goingAway;
    }

    /**
     * Updates KeyguardUpdateMonitor's internal state to know if keyguard is occluded
     * @param occluded
     */
    public void setKeyguardOccluded(boolean occluded) {
        mKeyguardOccluded = occluded;
        updateFingerprintListeningState();
    }

    private void onFingerprintAuthenticated(int userId) {
        Trace.beginSection("KeyGuardUpdateMonitor#onFingerPrintAuthenticated");
        mUserFingerprintAuthenticated.put(userId, true);
@@ -429,6 +445,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                cb.onFingerprintAuthenticated(userId);
            }
        }

        // Only authenticate fingerprint once when assistant is visible
        mAssistantVisible = false;
        updateFingerprintListeningState();

        Trace.endSection();
    }

@@ -1110,6 +1131,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            mFpm.addLockoutResetCallback(mLockoutResetCallback);
        }

        SystemServicesProxy.getInstance(mContext).registerTaskStackListener(mTaskStackListener);
        mUserManager = context.getSystemService(UserManager.class);
    }

@@ -1126,7 +1148,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {

    private boolean shouldListenForFingerprint() {
        return (mKeyguardIsVisible || !mDeviceInteractive ||
                    (mBouncer && !mKeyguardGoingAway) || mGoingToSleep)
                    (mBouncer && !mKeyguardGoingAway) || mGoingToSleep ||
                    (mAssistantVisible && mKeyguardOccluded))
                && !mSwitchingUser && !isFingerprintDisabled(getCurrentUser());
    }

@@ -1155,8 +1178,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    private void stopListeningForFingerprint() {
        if (DEBUG) Log.v(TAG, "stopListeningForFingerprint()");
        if (mFingerprintRunningState == FINGERPRINT_STATE_RUNNING) {
            if (mFingerprintCancelSignal != null) {
                mFingerprintCancelSignal.cancel();
                mFingerprintCancelSignal = null;
            }
            setFingerprintRunningState(FINGERPRINT_STATE_CANCELLING);
        }
        if (mFingerprintRunningState == FINGERPRINT_STATE_CANCELLING_RESTARTING) {
@@ -1679,6 +1704,23 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        }
    }

    private final TaskStackListener mTaskStackListener = new TaskStackListener() {
        @Override
        public void onTaskStackChangedBackground() {
            try {
                ActivityManager.StackInfo info = ActivityManager.getService().getStackInfo(
                        ActivityManager.StackId.ASSISTANT_STACK_ID);
                if (info == null) {
                    return;
                }
                mHandler.sendMessage(mHandler.obtainMessage(MSG_ASSISTANT_STACK_CHANGED,
                        info.visible));
            } catch (RemoteException e) {
                Log.e(TAG, "unable to check task stack", e);
            }
        }
    };

    /**
     * @return true if and only if the state has changed for the specified {@code slotId}
     */
+1 −0
Original line number Diff line number Diff line
@@ -1173,6 +1173,7 @@ public class KeyguardViewMediator extends SystemUI {

            if (mOccluded != isOccluded) {
                mOccluded = isOccluded;
                mUpdateMonitor.setKeyguardOccluded(isOccluded);
                mStatusBarKeyguardViewManager.setOccluded(isOccluded, animate
                        && mDeviceInteractive);
                adjustStatusBarLocked();