Add oldDream to mPreviousDreams always when dreams overlap

Bug: 270178573
Test: start dream; press power button; wake up device; start dream;
      ensure dream starts
Change-Id: Ie601d2b4303340f89001265ba685ae97ee7fd6d8
This commit is contained in:
Galia Peycheva
2023-02-22 15:00:07 +00:00
committed by Darrell Shi
parent 316e02f3a8
commit 01c6a7af31

View File

@@ -123,15 +123,14 @@ final class DreamController {
final DreamRecord oldDream = mCurrentDream;
mCurrentDream = new DreamRecord(token, name, isPreviewMode, canDoze, userId, wakeLock);
if (oldDream != null) {
if (!oldDream.mWakingGently) {
// We will stop these previous dreams once the new dream is started.
mPreviousDreams.add(oldDream);
} else if (Objects.equals(oldDream.mName, mCurrentDream.mName)) {
if (Objects.equals(oldDream.mName, mCurrentDream.mName)) {
// We are attempting to start a dream that is currently waking up gently.
// Let's silently stop the old instance here to clear the dream state.
// This should happen after the new mCurrentDream is set to avoid announcing
// a "dream stopped" state.
stopDreamInstance(/* immediately */ true, "restarting same dream", oldDream);
} else {
mPreviousDreams.add(oldDream);
}
}