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

Commit ffc1789c authored by Sean Stout's avatar Sean Stout Committed by Automerger Merge Worker
Browse files

Merge "Fix sandman crash" into sc-dev am: 8b9809f1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14255737

Change-Id: I7b1677dbd9fcb2d49c2bfa20e8a813ce1aee1457
parents b1083fe8 8b9809f1
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -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,17 +2927,14 @@ public final class PowerManagerService extends SystemService
    private void scheduleSandmanLocked() {
        if (!mSandmanScheduled) {
            mSandmanScheduled = true;
            for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) {
                if (mDisplayGroupPowerStateMapper.isSandmanSupported(id)) {
                    Message msg = mHandler.obtainMessage(MSG_SANDMAN);
                    msg.arg1 = id;
                    msg.setAsynchronous(true);
                    mHandler.sendMessage(msg);
                }
            }

    private void handleSandman() {
        for (int id : mDisplayGroupPowerStateMapper.getDisplayGroupIdsLocked()) {
            if (mDisplayGroupPowerStateMapper.isSandmanSupported(id)) {
                handleSandman(id);
            }
        }
    }

@@ -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();