Merge "Fix potential race condition problem"

This commit is contained in:
Treehugger Robot
2022-12-19 07:10:16 +00:00
committed by Gerrit Code Review

View File

@@ -4212,8 +4212,8 @@ public final class PowerManagerService extends SystemService
} }
private boolean forceSuspendInternal(int uid) { private boolean forceSuspendInternal(int uid) {
try { synchronized (mLock) {
synchronized (mLock) { try {
mForceSuspendActive = true; mForceSuspendActive = true;
// Place the system in an non-interactive state // Place the system in an non-interactive state
for (int idx = 0; idx < mPowerGroups.size(); idx++) { for (int idx = 0; idx < mPowerGroups.size(); idx++) {
@@ -4223,16 +4223,14 @@ public final class PowerManagerService extends SystemService
// Disable all the partial wake locks as well // Disable all the partial wake locks as well
updateWakeLockDisabledStatesLocked(); updateWakeLockDisabledStatesLocked();
}
Slog.i(TAG, "Force-Suspending (uid " + uid + ")..."); Slog.i(TAG, "Force-Suspending (uid " + uid + ")...");
boolean success = mNativeWrapper.nativeForceSuspend(); boolean success = mNativeWrapper.nativeForceSuspend();
if (!success) { if (!success) {
Slog.i(TAG, "Force-Suspending failed in native."); Slog.i(TAG, "Force-Suspending failed in native.");
} }
return success; return success;
} finally { } finally {
synchronized (mLock) {
mForceSuspendActive = false; mForceSuspendActive = false;
// Re-enable wake locks once again. // Re-enable wake locks once again.
updateWakeLockDisabledStatesLocked(); updateWakeLockDisabledStatesLocked();