frameworks\base\packages\Keyguard\src\com\android\keyguard\KeyguardUpdateMonitor.java
protected void handleStartedGoingToSleep(int arg1) { clearFingerprintRecognized(); final int count = mCallbacks.size(); for (int i = 0; i < count; i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { cb.onStartedGoingToSleep(arg1); } } mGoingToSleep = true; mFingerprintAlreadyAuthenticated = false; updateFingerprintListeningState(); }
private void updateFingerprintListeningState() { boolean shouldListenForFingerprint = shouldListenForFingerprint(); if (mFingerprintRunningState == FINGERPRINT_STATE_RUNNING && !shouldListenForFingerprint) { stopListeningForFingerprint(); } else if (mFingerprintRunningState != FINGERPRINT_STATE_RUNNING && shouldListenForFingerprint) { startListeningForFingerprint(); // 指纹监听 } }
private boolean shouldListenForFingerprint() { return (mKeyguardIsVisible || !mDeviceInteractive || mBouncer || mGoingToSleep || (mOccluded && !mUserFingerprintAuthenticated.get(getCurrentUser()))) && !mSwitchingUser && !mFingerprintAlreadyAuthenticated && !isFingerprintDisabled(getCurrentUser()); }
// mGoingToSleep 为true 且 mFingerprintAlreadyAuthenticated 为false ,灭屏进入睡眠进入监听指纹触摸事件
frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\StatusBarKeyguardViewManager.java
public void updateStates() {
if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { //PIN码或手势解锁界面显示与消失 Log.d(TAG, "updateStates() - setBouncerShowing(" + bouncerShowing + ")") ; mStatusBarWindowManager.setBouncerShowing(bouncerShowing); mPhoneStatusBar.setBouncerShowing(bouncerShowing); mScrimController.setBouncerShowing(bouncerShowing); } KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) { //keyguard 显示与消失 updateMonitor.onKeyguardVisibilityChanged(showing && !occluded); } if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { updateMonitor.sendKeyguardBouncerChanged(bouncerShowing); }
}
/** * Notifies that the visibility state of Keyguard has changed. * * <p>Needs to be called from the main thread. */ public void onKeyguardVisibilityChanged(boolean showing) { if (DEBUG) Log.d(TAG, "onKeyguardVisibilityChanged(" + showing + ")"); mKeyguardIsVisible = showing; for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { cb.onKeyguardVisibilityChangedRaw(showing); } } if (!showing) { mFingerprintAlreadyAuthenticated = false; //亮屏keyguard 消失,设置为false,当灭屏时就可以监听指纹,并再次被设置为true. } updateFingerprintListeningState(); }
/** * Dismisses the keyguard by going to the next screen or making it gone. */ public void dismiss() { dismiss(false); }
亮屏,从keyguard 切换到输入pin/手势码界面调用, keyguard 界面-》bouncer 界面
或者亮屏在指纹解锁会调用。 keyguard 界面-》laucher界面。