diff options
author | 2025-03-06 01:17:48 -0800 | |
---|---|---|
committer | 2025-03-06 15:51:07 -0800 | |
commit | dcd69b994e269331d06287cd97ef81f81e42a02c (patch) | |
tree | 5a5afd6d1fd14fd2d80832d34b5998066968b3b7 /apex | |
parent | 4d872d48a61406c9137650581e2c20c61e2366bf (diff) |
Release wakelock only when no alarms are in-flight
Fix the bug where the alarm wakelock could be released before all alarms
completed.
Test: atest FrameworksMockingServicesTests:com.android.server.alarm
Flag: com.android.server.alarm.acquire_wakelock_before_send
Fixes: 400058421
Change-Id: I86210548b9a8fc6050577ca1f7e973b127c47862
Diffstat (limited to 'apex')
-rw-r--r-- | apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java index 251776e907d8..44e4999ccf44 100644 --- a/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java +++ b/apex/jobscheduler/service/java/com/android/server/alarm/AlarmManagerService.java @@ -5369,7 +5369,9 @@ public class AlarmManagerService extends SystemService { // to do any wakelock or stats tracking, so we have nothing // left to do here but go on to the next thing. mSendFinishCount++; - if (Flags.acquireWakelockBeforeSend()) { + if (Flags.acquireWakelockBeforeSend() && mBroadcastRefCount == 0) { + // No other alarms are in-flight and this dispatch failed. We will + // acquire the wakelock again before the next dispatch. mWakeLock.release(); } return; @@ -5409,7 +5411,9 @@ public class AlarmManagerService extends SystemService { // stats management to do. It threw before we posted the delayed // timeout message, so we're done here. mListenerFinishCount++; - if (Flags.acquireWakelockBeforeSend()) { + if (Flags.acquireWakelockBeforeSend() && mBroadcastRefCount == 0) { + // No other alarms are in-flight and this dispatch failed. We will + // acquire the wakelock again before the next dispatch. mWakeLock.release(); } return; |