Remove double-locking from PowerManagerService.onBootPhase

The PowerManagerService.systemReady have some code that needs to be
executed with the mLock held, and some that requirest it not to be held.
One this is the BatterySaverPolicy.systemReady, that uses the same lock
object as the PowerManagerService and explicitly required it not to be
locked at that point.

Moving the synchronized block inside the PHASE_BOOT_COMPLETED phase,
since the incrementBootCount also don't require the lock as it acquires
one as well.

Fix: 222098360
Test: manual
Change-Id: I1a25de3c7ba4be6d88d2654d42cdd496387391c2
This commit is contained in:
Lais Andrade
2022-03-01 17:02:05 +00:00
parent 5960382afe
commit 8c6a02a4e0

View File

@@ -1176,14 +1176,14 @@ public final class PowerManagerService extends SystemService
@Override
public void onBootPhase(int phase) {
synchronized (mLock) {
if (phase == PHASE_SYSTEM_SERVICES_READY) {
systemReady();
if (phase == PHASE_SYSTEM_SERVICES_READY) {
systemReady();
} else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
incrementBootCount();
} else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) {
incrementBootCount();
} else if (phase == PHASE_BOOT_COMPLETED) {
} else if (phase == PHASE_BOOT_COMPLETED) {
synchronized (mLock) {
final long now = mClock.uptimeMillis();
mBootCompleted = true;
mDirty |= DIRTY_BOOT_COMPLETED;