diff options
| author | 2021-04-29 22:04:20 +0000 | |
|---|---|---|
| committer | 2021-04-29 22:04:20 +0000 | |
| commit | 8b9809f10d566e7410fe709d386b5ed6d753231c (patch) | |
| tree | 86aa930665a51332790ceec23970eee3bea61e27 | |
| parent | 54255f7ab4308e128c8960eed2a24afb217addbf (diff) | |
| parent | 93992527af701c99ca3fb4abe265d1cc7c0995d8 (diff) | |
Merge "Fix sandman crash" into sc-dev
| -rw-r--r-- | services/core/java/com/android/server/power/PowerManagerService.java | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 805252260209..c4aca6c18453 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -102,6 +102,7 @@ import com.android.internal.app.IAppOpsService; import com.android.internal.app.IBatteryStats; import com.android.internal.display.BrightnessSynchronizer; import com.android.internal.os.BackgroundThread; +import com.android.internal.util.ArrayUtils; import com.android.internal.util.DumpUtils; import com.android.internal.util.Preconditions; import com.android.server.EventLogTags; @@ -2926,16 +2927,13 @@ public final class PowerManagerService extends SystemService private void scheduleSandmanLocked() { if (!mSandmanScheduled) { mSandmanScheduled = true; - Message msg = mHandler.obtainMessage(MSG_SANDMAN); - msg.setAsynchronous(true); - mHandler.sendMessage(msg); - } - } - - private void handleSandman() { - for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { - if (mDisplayGroupPowerStateMapper.isSandmanSupported(id)) { - handleSandman(id); + for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) { + if (mDisplayGroupPowerStateMapper.isSandmanSupported(id)) { + Message msg = mHandler.obtainMessage(MSG_SANDMAN); + msg.arg1 = id; + msg.setAsynchronous(true); + mHandler.sendMessage(msg); + } } } } @@ -2953,6 +2951,11 @@ public final class PowerManagerService extends SystemService final int wakefulness; synchronized (mLock) { mSandmanScheduled = false; + final int[] ids = mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked(); + if (!ArrayUtils.contains(ids, groupId)) { + // Group has been removed. + return; + } // TODO (b/175764708): Support per-display doze. wakefulness = getWakefulnessLocked(); if ((wakefulness == WAKEFULNESS_DREAMING || wakefulness == WAKEFULNESS_DOZING) && @@ -2986,6 +2989,12 @@ public final class PowerManagerService extends SystemService // Update dream state. synchronized (mLock) { + final int[] ids = mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked(); + if (!ArrayUtils.contains(ids, groupId)) { + // Group has been removed. + return; + } + // Remember the initial battery level when the dream started. if (startDreaming && isDreaming) { mBatteryLevelWhenDreamStarted = mBatteryLevel; @@ -4770,7 +4779,7 @@ public final class PowerManagerService extends SystemService handleUserActivityTimeout(); break; case MSG_SANDMAN: - handleSandman(); + handleSandman(msg.arg1); break; case MSG_SCREEN_BRIGHTNESS_BOOST_TIMEOUT: handleScreenBrightnessBoostTimeout(); |