diff options
| author | 2023-01-20 11:02:21 +0000 | |
|---|---|---|
| committer | 2023-03-01 17:52:39 +0000 | |
| commit | 3f6a4e9d5cfcce33eb5db800f04452a3ab1a7643 (patch) | |
| tree | e40431f8872e0c74ba6979d8305d34c9cb38a14e | |
| parent | b436b2f18361d7bea11de107a0e2d7b26cc8afcb (diff) | |
Make DreamService detach on DreamActivity onDestroy
Currently DreamService.onDestroy is called whenever the DreamActivity is being destroyed. This causes issues with the lifecycle of the dream
window, because the DreamService is destroyed before
onDetachedFromWindow is called.
In this CL, we change the implementation of onActivityDestroyed to
detach the DreamService instead of destroy it immediately. This is a
more gentle way to achieve the same result.
Bug: 243385408
Bug: 266668856
Bug: 270913936
Test: atest DreamServiceManagerTests
Test: atest DreamServiceTests
Test: atest DreamOverlayTest
Change-Id: Iadb7880faabf54f70a64c76c6e3e267fde9c42dd
| -rw-r--r-- | core/java/android/service/dreams/DreamActivity.java | 2 | ||||
| -rw-r--r-- | core/java/android/service/dreams/DreamService.java | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/core/java/android/service/dreams/DreamActivity.java b/core/java/android/service/dreams/DreamActivity.java index ff14404f787e..a3892238f1e6 100644 --- a/core/java/android/service/dreams/DreamActivity.java +++ b/core/java/android/service/dreams/DreamActivity.java @@ -70,7 +70,7 @@ public class DreamActivity extends Activity { @Override public void onDestroy() { - if (mCallback != null && !isFinishing()) { + if (mCallback != null) { mCallback.onActivityDestroyed(); } diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java index d79ea8929047..c7099fdd202a 100644 --- a/core/java/android/service/dreams/DreamService.java +++ b/core/java/android/service/dreams/DreamService.java @@ -1588,7 +1588,8 @@ public class DreamService extends Service implements Window.Callback { // If DreamActivity is destroyed, wake up from Dream. void onActivityDestroyed() { mActivity = null; - onDestroy(); + mWindow = null; + detach(); } } |