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

Commit 8c1a8684 authored by tysonwei's avatar tysonwei
Browse files

Fix potential race condition problem

If we call forceSuspend to enter STR and then resume from it,
we should make sure that mForceSuspendActive is set to false
to wake up device correctly.

Bug: 205257123
Test: 1. forceSuspend
      2. wait until kernel enter suspend mode
      3. press power button to wakeUp
Change-Id: I3c57ff7c7352fe078f2139d9679dc3d860482f05
parent 4ee969e8
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -4211,8 +4211,8 @@ public final class PowerManagerService extends SystemService
    }

    private boolean forceSuspendInternal(int uid) {
        try {
        synchronized (mLock) {
            try {
                mForceSuspendActive = true;
                // Place the system in an non-interactive state
                for (int idx = 0; idx < mPowerGroups.size(); idx++) {
@@ -4222,7 +4222,6 @@ public final class PowerManagerService extends SystemService

                // Disable all the partial wake locks as well
                updateWakeLockDisabledStatesLocked();
            }

                Slog.i(TAG, "Force-Suspending (uid " + uid + ")...");
                boolean success = mNativeWrapper.nativeForceSuspend();
@@ -4231,7 +4230,6 @@ public final class PowerManagerService extends SystemService
                }
                return success;
            } finally {
            synchronized (mLock) {
                mForceSuspendActive = false;
                // Re-enable wake locks once again.
                updateWakeLockDisabledStatesLocked();