Fix NullPointerException in DreamManagerService

mCurrentDreamName has one access from an unlocked context, which causes
a race condition between the dream being stopped and started. This
causes a NullPointerExcpetion.

This CL fixes this by moving the mCurrentDreamName read operation back
into a locked block.

Bug: 209911670
Test: m
Change-Id: Icb8e904f067199fbfa62ff90aecd57bf38015546
This commit is contained in:
Galia Peycheva
2021-12-10 11:37:32 +01:00
parent 0f8f6a0d89
commit 34320067d5

View File

@@ -416,13 +416,14 @@ public final class DreamManagerService extends SystemService {
mCurrentDreamCanDoze = canDoze;
mCurrentDreamUserId = userId;
if (!mCurrentDreamName.equals(mAmbientDisplayComponent)) {
mUiEventLogger.log(DreamManagerEvent.DREAM_START);
}
PowerManager.WakeLock wakeLock = mPowerManager
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "startDream");
mHandler.post(wakeLock.wrap(() -> {
mAtmInternal.notifyDreamStateChanged(true);
if (!mCurrentDreamName.equals(mAmbientDisplayComponent)) {
mUiEventLogger.log(DreamManagerEvent.DREAM_START);
}
mController.startDream(newToken, name, isTest, canDoze, userId, wakeLock,
mDreamOverlayServiceName);
}));