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
This commit is contained in:
Louis Chang
2023-05-17 03:31:08 +00:00
parent 31b84806a8
commit f7256f5dd5

View File

@@ -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;