Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6f0286f authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Resume stopped preserved window when relaunching visible activity

The ViewRoot will be stopped with activity onStop. And unstop when
resuming activity, but it is only called when resuming an existing
activity (from performRestart).

So if a ViewRoot is preserved during relaunching while the activity
was stopped, the ViewRoot is also stopped. And because the activity
is a new instance, performRestart won't be called, then the RootView
keeps the stopped state.

The case happens more frequently since wm shell is introduced, which
by default use "preserveWindow=true" for
ActivityRecord#ensureActivityConfiguration via
WindowOrganizer#applyTransaction.

Bug: 269179932
Test: WMShellFlickerTests:CopyContentInSplit
Test: Simple simulation:
      Modify code to force "preserveWindow" to always be enabled.
      Launch an activity without handling config change in landscape.
      Return to home and launch the activity again in portrait.
      The activity should be able to response for input event.
Change-Id: Iee780c12535217a5a9726f9f4d6b21952ce56d70
parent 7137d916
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1135,6 +1135,10 @@ public final class ViewRootImpl implements ViewParent,
        updateLastConfigurationFromResources(getConfiguration());
        // Make sure to report the completion of draw for relaunch with preserved window.
        reportNextDraw("rebuilt");
        // Make sure to resume this root view when relaunching its host activity which was stopped.
        if (mStopped && getHostVisibility() != View.GONE) {
            setWindowStopped(false);
        }
    }

    private Configuration getConfiguration() {