Fix regression of pressing power key cancel sfps enrollment

Previous ag/19699461 used to fix UdfpsControllerOverlay bug.
However, we didn't consider a feature click power button to
notify user with a Toast on sfps project.

Bug: 245383975
Bug: 228261883
Bug: 242478941
Bug: 227905887
Test: make RunSettingsRoboTests ROBOTEST_FILTER=FingerprintEnrollEnrollingTest
Test: manual verify sfps enrollment, press/long press power key would
not cancel enrollment.
Test: manual verify udfps enrollment, UdfpsControllerOverlay lose focus
cancel enrollment.

Change-Id: I44394bdb91660b27a704064a7f7cdc5d0ad95d30
This commit is contained in:
lbill
2022-09-07 03:14:14 +00:00
parent 06cc4ed4ab
commit 82a42834b1
2 changed files with 13 additions and 1 deletions

View File

@@ -203,7 +203,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
// Do NOT cancel enrollment progress after rotating, adding mIsOrientationChanged // Do NOT cancel enrollment progress after rotating, adding mIsOrientationChanged
// to judge if the focus changed was triggered by rotation, current WMS has triple callbacks // to judge if the focus changed was triggered by rotation, current WMS has triple callbacks
// (true > false > true), we need to reset mIsOrientationChanged when !hasFocus callback. // (true > false > true), we need to reset mIsOrientationChanged when !hasFocus callback.
if (!mIsOrientationChanged) { // Side fps do not have to synchronize udfpsController overlay state, we should bypass sfps
// from onWindowFocusChanged() as long press sfps power key will prompt dialog to users.
if (!mIsOrientationChanged && !mCanAssumeSfps) {
onCancelEnrollment(FINGERPRINT_ERROR_USER_CANCELED); onCancelEnrollment(FINGERPRINT_ERROR_USER_CANCELED);
} else { } else {
mIsOrientationChanged = false; mIsOrientationChanged = false;

View File

@@ -222,6 +222,16 @@ public class FingerprintEnrollEnrollingTest {
); );
} }
@Test
public void fingerprintSfpsEnrollment_loseFocus_shouldNotCancel() {
initializeActivityFor(FingerprintSensorProperties.TYPE_POWER_BUTTON);
mActivity.onEnrollmentProgressChange(1, 1);
mActivity.onWindowFocusChanged(true);
verify(mActivity, never()).onCancelEnrollment(anyInt());
}
private void initializeActivityFor(int sensorType) { private void initializeActivityFor(int sensorType) {
final List<ComponentInfoInternal> componentInfo = new ArrayList<>(); final List<ComponentInfoInternal> componentInfo = new ArrayList<>();
final FingerprintSensorPropertiesInternal prop = final FingerprintSensorPropertiesInternal prop =