Fingerprint 亮灭屏监听

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界面。



  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值