From f7256f5dd56369b182c084f52f7aa45cfd6a05ca Mon Sep 17 00:00:00 2001 From: Louis Chang Date: Wed, 17 May 2023 03:31:08 +0000 Subject: [PATCH] Relaunching activity to PAUSE state Relaunching activity locally from ON_START state used to go to ON_STOP and skipped ON_RESUME. However, the Activity#mDecor (and the other preserve window handling) is set in ActivityThread#handleResumeActivity. So, the decor window may be dropped when relaunching twice. Relaunch the activity to PAUSE state if it is currently in START state. This is also the expected state while relaunching the activity from server side. Bug: 249451905 Test: verified locally with sample app Change-Id: Ia24ecc764ff783a1298a706457ab907bf9c52c98 --- .../app/servertransaction/TransactionExecutorHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/java/android/app/servertransaction/TransactionExecutorHelper.java b/core/java/android/app/servertransaction/TransactionExecutorHelper.java index 5311b09e609db..baf2a4722dffa 100644 --- a/core/java/android/app/servertransaction/TransactionExecutorHelper.java +++ b/core/java/android/app/servertransaction/TransactionExecutorHelper.java @@ -193,8 +193,8 @@ public class TransactionExecutorHelper { switch (prevState) { // TODO(lifecycler): Extend to support all possible states. case ON_START: - lifecycleItem = StartActivityItem.obtain(null /* activityOptions */); - break; + // Fall through to return the PAUSE item to ensure the activity is properly + // resumed while relaunching. case ON_PAUSE: lifecycleItem = PauseActivityItem.obtain(); break;