Check sleep reason and time before cancelling vibrations
Add a method PowerManagerInternal.getLastGoToSleep(), similar to existing method getLastWakeup(), to retrieve global values for last go to sleep events, including system uptime and reason. Retrieve this data in VibratorManagerService before cancelling ongoing vibrations by the broadcast of ACTION_SCREEN_OFF intents to indicate that the screen was turned of when the vibration was still playing. This new logic allows vibrations to continue in the following cases: - the broadcasted event was triggered before the vibration started; - there is already a wakeup event triggered by the time the screen off broadcast is being processed by the vibrator service; - the screen off reason is in allowlist, indicating it's an automatically triggered event (screen timeout or user inattentive); This should handle the following scenarios: - delayed broadcasts of screen off events, that should not cancel vibrations that started when the screen was already off (e.g. notification or ringtone that are allowed to vibrate in that state); - race conditions when the screen automatically turns off right after a ringtone/notification vibration starts, before the notification acquires a screen lock; Fix: 219849350 Test: VibrationSettingsTest Change-Id: I358327192196989a7d4fc49a96b2ab92ec677302
Loading
Please register or sign in to comment