Use AlarmManager to schedule private space lock requests
We currently use Handler.postDelayed() to schedule the private space auto-lock message if the auto-lock setting to lock after 5 mins of screen timeout have been turned on. However, this timer does not take into the account the time spent by the device in "sleep" state. To fix this, we are moving to use AlarmManager timers with this change. Here we use AlarmManager.setWindow with ELAPSED_REALTIME_WAKEUP to ensure the alarm gets reeven when the device is asleep. We will be using setWindow with a windowLength of 1 min, ensuring the alarm gets delivered between 5 mins and 6 minutes of scheduling time to offset the system health cost of the alarm, while honoring the auto-lock promise. Test: atest UserManagerServiceTest#testAutoLockAfterInactityForPrivateProfile. Test: Also tested manually by flashing changes on a test device, keeping the device with PS installed idle for 6 mins and checking the logs. Bug: 342660878 Flag: android.multiuser.support_autolock_for_private_space Change-Id: I6d7feb23076b0b8dcd0aceffa6a8fdd2ffa2be26
Loading
Please register or sign in to comment