diff options
| author | 2022-12-19 12:06:48 +0100 | |
|---|---|---|
| committer | 2023-02-21 15:07:38 +0000 | |
| commit | f8ebb8da43b7c04a69ec0f7e15f3f99ff9721531 (patch) | |
| tree | 7a2421412bee841ae7c78ef16e321fe99e3883e3 | |
| parent | 16ac8f216ed11b3dd73d5388e82256fe612ff7fd (diff) | |
Make DreamActivity no history
The DreamActivity is tied to a DreamService. When the DreamActivity is
destroyed, so is the DreamService. If the DreamActivity is
consequently recreated by the WM, this leads to a ClassCastException
in the DreamActivity.onCreate method.
This CL makes the DreamActivity a noHistory activity, which prevents
it from being recreated after having been destroyed once. We also handle
the case where the callback in onCreate is null or of the wrong type and
finish the dream immediately if so.
Bug: 231602954
Test: atest DreamManagerServiceTests
Change-Id: I93637368374d9de90c588e2b0355ae7b66fb4167
(cherry picked from commit becfbaf25f5aab659e92e08cc3e0fe6b903044d4)
| -rw-r--r-- | core/java/android/service/dreams/DreamActivity.java | 10 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityTaskManagerService.java | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/core/java/android/service/dreams/DreamActivity.java b/core/java/android/service/dreams/DreamActivity.java index a2fa1392b079..a3892238f1e6 100644 --- a/core/java/android/service/dreams/DreamActivity.java +++ b/core/java/android/service/dreams/DreamActivity.java @@ -58,11 +58,13 @@ public class DreamActivity extends Activity { setTitle(title); } - final Bundle extras = getIntent().getExtras(); - mCallback = (DreamService.DreamActivityCallbacks) extras.getBinder(EXTRA_CALLBACK); - - if (mCallback != null) { + final Object callback = getIntent().getExtras().getBinder(EXTRA_CALLBACK); + if (callback instanceof DreamService.DreamActivityCallbacks) { + mCallback = (DreamService.DreamActivityCallbacks) callback; mCallback.onActivityCreated(this); + } else { + mCallback = null; + finishAndRemoveTask(); } } diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 861961599ada..2c69c9a2ae9c 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -1486,7 +1486,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { a.persistableMode = ActivityInfo.PERSIST_NEVER; a.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; a.colorMode = ActivityInfo.COLOR_MODE_DEFAULT; - a.flags |= ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS; + a.flags |= ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS | ActivityInfo.FLAG_NO_HISTORY; a.resizeMode = RESIZE_MODE_UNRESIZEABLE; a.configChanges = 0xffffffff; |