不积跬步无以至千里

之前也是比较发闷儿,密码解锁后清楚指纹识别的次数是在哪里处理的,今天正好查找一个问题正好发现,记录下来

1.调用密码验证流程

代码路径:frameworks/base/services/core/java/com/android/server/locksettings/LockSettingsService.java

/**     * Verify user credential and unlock the user. Fix pattern bug by deprecating the old base zero     * format.     */    private VerifyCredentialResponse doVerifyCredential(String credential, int credentialType,            boolean hasChallenge, long challenge, int userId,            ICheckCredentialProgressCallback progressCallback) throws RemoteException {        if (TextUtils.isEmpty(credential)) {            throw new IllegalArgumentException("Credential can't be null or empty");        }        ...        response = verifyCredential(userId, storedHash, credentialToVerify,                hasChallenge, challenge, progressCallback);        if (response.getResponseCode() == VerifyCredentialResponse.RESPONSE_OK) {            mStrongAuth.reportSuccessfulStrongAuthUnlock(userId);            if (shouldReEnrollBaseZero) {                setLockCredentialInternal(credential, storedHash.type, credentialToVerify,                        DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, userId);            }        }        return response;    }

这里是通过密码验证的流程中,当验证成功了VerifyCredentialResponse.RESPONSE_OK,调用了reportSuccessfulStrongAuthUnlock.

2.上报强解锁成功

代码路径:frameworks/base/services/core/java/com/android/server/locksettings/LockSettingsStrongAuth.java

public void reportSuccessfulStrongAuthUnlock(int userId) {        if (mFingerprintManager != null) {            byte[] token = null; /* TODO: pass real auth token once fp HAL supports it */            mFingerprintManager.resetTimeout(token);        }        final int argNotUsed = 0;        mHandler.obtainMessage(MSG_SCHEDULE_STRONG_AUTH_TIMEOUT, userId, argNotUsed).sendToTarget();    }

这里调用了mFingerprintManager.resetTimeout(token);

3.指纹识别外部接口

代码路径:frameworks/base/core/java/android/hardware/fingerprint/FingerprintManager.java

/**     * Reset the lockout timer when asked to do so by keyguard.     *     * @param token an opaque token returned by password confirmation.     *     * @hide     */    public void resetTimeout(byte[] token) {        if (mService != null) {            try {                mService.resetTimeout(token);            } catch (RemoteException e) {                throw e.rethrowFromSystemServer();            }        } else {            Log.w(TAG, "resetTimeout(): Service not connected!");        }    }

4.去重置指纹解锁次数

代码路径:frameworks/base/services/core/java/com/android/server/fingerprint/FingerprintService.java

这里调用了mService.resetTimeout(token);

@Override // Binder call        public void resetTimeout(byte [] token) {            checkPermission(RESET_FINGERPRINT_LOCKOUT);            // TODO: confirm security token when we move timeout management into the HAL layer.            mHandler.post(mResetFailedAttemptsRunnable);        }

所对应的Runnable

private final Runnable mResetFailedAttemptsRunnable = new Runnable() {        @Override        public void run() {            resetFailedAttempts(true /* clearAttemptCounter */);        }    };

清除指纹失败的尝试次数

// attempt counter should only be cleared when Keyguard goes away or when    // a fingerprint is successfully authenticated    protected void resetFailedAttempts(boolean clearAttemptCounter) {        if (DEBUG && getLockoutMode() != AuthenticationClient.LOCKOUT_NONE) {            Slog.v(TAG, "Reset fingerprint lockout, clearAttemptCounter=" + clearAttemptCounter);        }        if (clearAttemptCounter) {            mFailedAttempts = 0;        }        mTimedLockoutCleared = true;        // If we're asked to reset failed attempts externally (i.e. from Keyguard),        // the alarm might still be pending; remove it.        cancelLockoutReset();        notifyLockoutResetMonitors();    }

这次就知道了.

话外篇:(封装指纹清楚次数方法)

所以咱们也可以在KeyguardUpdateMonitor中封装一个清楚指纹次数的方法,因为指纹的更新认证状态都是在这个类里实现的,因此封装成此方法,如下(自测有效):

public void reportSuccessfulFingerprintAttempt() {        if (mFpm != null) {            byte[] token = null; /* TODO: pass real auth token once fp HAL supports it */            mFpm.resetTimeout(token);        }    }

 

 

更多相关文章

  1. FragmentPagerAdapter notifyDataSetChanged不起作用
  2. Android—WebView介绍
  3. 多次调用 android onmesure onlayout
  4. SensorManager与Sensor交互
  5. Android短信插入器源码
  6. 自定义Android(安卓)ORM 框架greenDAO数据库文件的路径
  7. Service START_NOT_STICKY、START_STICKY
  8. 关于Listview的一个没有notifyDataSetChanged导致的错误
  9. 一个android 异步多线程类介绍

随机推荐

  1. [android]MonkeyRunner-andrec实现思路
  2. 巧用android setTag()
  3. 获得android手机的联网状态
  4. [android] Activity 的生命周期 以及横屏
  5. Android(安卓)demo倒计时原理(CountDownT
  6. Android下图像文件获取方式小结
  7. Android切换前后置摄像头并录制视频
  8. Android(安卓)build.prop修改详细说明
  9. arcgis for android 学习 - (8) 空间查询
  10. android小游戏 飞机躲子弹