diff options
| author | 2023-02-15 11:03:24 +0000 | |
|---|---|---|
| committer | 2023-02-15 11:03:24 +0000 | |
| commit | 9d37599d16a4a2f534afd4ff39ca5414359340fb (patch) | |
| tree | 8c0fec36d86a8940c679441873f71c9ba3066795 | |
| parent | 2ba1d91c5e141726cfd668dc414dcd22aa297c53 (diff) | |
| parent | e454a698d9f1fcc37c110e3d08b21f31b0be2b7e (diff) | |
Merge "Handle dream restart" into tm-qpr-dev
| -rw-r--r-- | services/core/java/com/android/server/dreams/DreamController.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/dreams/DreamController.java b/services/core/java/com/android/server/dreams/DreamController.java index f74356debd0f..97ab58764e1e 100644 --- a/services/core/java/com/android/server/dreams/DreamController.java +++ b/services/core/java/com/android/server/dreams/DreamController.java @@ -42,6 +42,7 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Iterator; import java.util.NoSuchElementException; +import java.util.Objects; /** * Internal controller for starting and stopping the current dream and managing related state. @@ -119,10 +120,20 @@ final class DreamController { + ", isPreviewMode=" + isPreviewMode + ", canDoze=" + canDoze + ", userId=" + userId + ", reason='" + reason + "'"); - if (mCurrentDream != null) { - mPreviousDreams.add(mCurrentDream); - } + 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)) { + // 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); + } + } mCurrentDream.mDreamStartTime = SystemClock.elapsedRealtime(); MetricsLogger.visible(mContext, |