Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit c558857f authored by Lais Andrade's avatar Lais Andrade
Browse files

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
parent c9daa032
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment