Fix inaccuracy in biometric timeout

Bug: 212210817

AlarmManager.set() does not trigger on the exact timeout,
AlarmManager.setExact() should be used instead.

Change-Id: I7a59cfebd714ccd0192aeb01571a5ac531abe342
This commit is contained in:
jiangkun5
2022-02-21 15:26:26 +08:00
parent 2a491d487f
commit d99e713e59
2 changed files with 5 additions and 5 deletions

View File

@@ -262,7 +262,7 @@ public class LockSettingsStrongAuth {
long nextAlarmTime = strongAuthTime + dpm.getRequiredStrongAuthTimeout(null, userId);
// schedule a new alarm listener for the user
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, nextAlarmTime,
mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextAlarmTime,
STRONG_AUTH_TIMEOUT_ALARM_TAG, alarm, mHandler);
}
@@ -303,7 +303,7 @@ public class LockSettingsStrongAuth {
alarm = new NonStrongBiometricTimeoutAlarmListener(userId);
mNonStrongBiometricTimeoutAlarmListener.put(userId, alarm);
// schedule a new alarm listener for the user
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, nextAlarmTime,
mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextAlarmTime,
NON_STRONG_BIOMETRIC_TIMEOUT_ALARM_TAG, alarm, mHandler);
}
@@ -394,7 +394,7 @@ public class LockSettingsStrongAuth {
}
// schedule a new alarm listener for the user
if (DEBUG) Slog.d(TAG, "Schedule a new alarm for non-strong biometric idle timeout");
mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, nextAlarmTime,
mAlarmManager.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextAlarmTime,
NON_STRONG_BIOMETRIC_IDLE_TIMEOUT_ALARM_TAG, alarm, mHandler);
}

View File

@@ -229,8 +229,8 @@ public class LockSettingsStrongAuthTest {
}
private void verifyAlarm(long when, String tag, AlarmManager.OnAlarmListener alarm) {
verify(mAlarmManager).set(
eq(AlarmManager.ELAPSED_REALTIME),
verify(mAlarmManager).setExact(
eq(AlarmManager.ELAPSED_REALTIME_WAKEUP),
eq(when),
eq(tag),
eq(alarm),