SystemUI 指纹解锁或者人脸解锁效果优化

针对手机指纹或人脸解锁时出现的黑屏闪动及上移动画问题进行分析,发现解锁过程中涉及KeyguardUpdateMonitor、FingerprintUnlockController和KeyguardSecurityContainer的交互。通过修改FingerprintUnlockController.java,避免了PanelView动画和Bouncer界面的不必要显示,从而优化了解锁体验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

不积跬步无以至千里

一.现象

在平常的项目中有测试提出了对比华为手机等竞品手机,发现有如下两点

对比竞品手机中,手机亮屏在锁屏第一屏指纹解锁(或者支持人脸解锁)

1.发现解锁会闪一下黑屏

2.发现解锁会有一个过渡动画(即一个上移动的动画)

二.分析

其实这里是因为指纹解锁是在锁屏的第一界面的时候解锁会执行第一界面的上移的动画,并且显示出Bouncer界面即解锁界面。

看一下指纹成功解锁的逻辑:

1.指纹注册监听验证结果的回调在此类中,其与Frameworks通信

/app/src/com/android/keyguard/KeyguardUpdateMonitor.java

private FingerprintManager.AuthenticationCallback mAuthenticationCallback
            = new AuthenticationCallback() {
            ...
            //指纹验证成功的方法回调
            @Override
  
public void onBiometricError(int msgId, String errString, BiometricSourceType biometricSourceType) { mMetricsLogger.write(new LogMaker(MetricsEvent.BIOMETRIC_AUTH) .setType(MetricsEvent.TYPE_ERROR).setSubtype(toSubtype(biometricSourceType)) .addTaggedData(MetricsEvent.FIELD_BIOMETRIC_AUTH_ERROR, msgId)); Optional.ofNullable(BiometricUiEvent.ERROR_EVENT_BY_SOURCE_TYPE.get(biometricSourceType)) .ifPresent(event -> UI_EVENT_LOGGER.log(event, getSessionId())); final boolean fingerprintLockout = biometricSourceType == BiometricSourceType.FINGERPRINT && (msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT || msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT); if (fingerprintLockout) { mLogger.d("fingerprint locked out"); startWakeAndUnlock( MODE_SHOW_BOUNCER, BiometricUnlockSource.Companion.fromBiometricSourceType(biometricSourceType) ); UI_EVENT_LOGGER.log(BiometricUiEvent.BIOMETRIC_BOUNCER_SHOWN, getSessionId()); } // #ifdef OPLUS_EDIT // liaozucheng@ANDROID.SYSTEMUI, 2024/2/19 : Add for V upgrade // lijiahui@ANDROID.SYSTEMUI, 2023/2/9 : Add for U upgrade boolean isFaceLockout = biometricSourceType == BiometricSourceType.FACE && (msgId == FACE_ERROR_LOCKOUT || msgId == FACE_ERROR_LOCKOUT_PERMANENT); if (mUpdateMonitor.useOplusBiometricUnlock()) { if (fingerprintLockout || isFaceLockout) { mOplusBiometricUnlockController.vibrateError(isFaceLockout, false); } if (biometricSourceType == BiometricSourceType.FINGERPRINT || isFaceLockout) { mOplusBiometricUnlockController.handleOnBiometricError(biometricSourceType, this, msgId); } } // #endif /* OPLUS_EDIT */ cleanup(); }分析这段代码并给出注释
最新发布
07-12
BiometricUnlockController.java public void onBiometricError(int msgId, String errString, BiometricSourceType biometricSourceType) { mMetricsLogger.write(new LogMaker(MetricsEvent.BIOMETRIC_AUTH) .setType(MetricsEvent.TYPE_ERROR).setSubtype(toSubtype(biometricSourceType)) .addTaggedData(MetricsEvent.FIELD_BIOMETRIC_AUTH_ERROR, msgId)); Optional.ofNullable(BiometricUiEvent.ERROR_EVENT_BY_SOURCE_TYPE.get(biometricSourceType)) .ifPresent(event -> UI_EVENT_LOGGER.log(event, getSessionId())); final boolean fingerprintLockout = biometricSourceType == BiometricSourceType.FINGERPRINT && (msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT || msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT); if (fingerprintLockout) { mLogger.d("fingerprint locked out"); startWakeAndUnlock( MODE_SHOW_BOUNCER, BiometricUnlockSource.Companion.fromBiometricSourceType(biometricSourceType) ); UI_EVENT_LOGGER.log(BiometricUiEvent.BIOMETRIC_BOUNCER_SHOWN, getSessionId()); } // #ifdef OPLUS_EDIT // liaozucheng@ANDROID.SYSTEMUI, 2024/2/19 : Add for V upgrade // lijiahui@ANDROID.SYSTEMUI, 2023/2/9 : Add for U upgrade boolean isFaceLockout = biometricSourceType == BiometricSourceType.FACE && (msgId == FACE_ERROR_LOCKOUT || msgId == FACE_ERROR_LOCKOUT_PERMANENT); if (mUpdateMonitor.useOplusBiometricUnlock()) { if (fingerprintLockout || isFaceLockout) { mOplusBiometricUnlockController.vibrateError(isFaceLockout, false); } if (biometricSourceType == BiometricSourceType.FINGERPRINT || isFaceLockout) { mOplusBiometricUnlockController.handleOnBiometricError(biometricSourceType, this, msgId); } } // #endif /* OPLUS_EDIT */ cleanup();分析这段代码并给出注释
07-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Rom_Fisher

赠人玫瑰,手留余香。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值