Merge "Fix sandman crash" into sc-dev
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user