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

Commit 5dfbd15f authored by Jorge Gil's avatar Jorge Gil
Browse files

Restore systemBarsAppearance from preserved window

When an activity is relaunching, the systemBarsAppearance set by the
application is automatically restored on the client views by function
of the same DecorView instance being transfered to the new Window
instance. However, the server (who is also aware of appearance changes
via TaskDescription updates), was having its appearance reset during
the activity recreation process.
To fix this, this change transfers the existing systemBarsAppearance
state held in Window.java from the preserved window to the new window
instance. Then, when ActivityThread#performLaunchActivity sets the
new activity instance's theme for the first time, we make sure that the
preserved appearance is also transfered to the new TaskDescription that
will soon be sent to the server.

Fix: 325125042
Test: manual - set custom system bars appearance in an activity, then
force activity recreation (e.g. with a resize). Ensure TaskDescription
in WM/Shell remains unchanged.

Change-Id: I0fee6244e5c1551b9cfe1c4c0a75c9476da385ac
parent 619b5a81
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -5535,6 +5535,15 @@ public class Activity extends ContextThemeWrapper
        }

        a.recycle();
        if (first && mTaskDescription.getSystemBarsAppearance() == 0
                && mWindow != null && mWindow.getSystemBarAppearance() != 0) {
            // When the theme is applied for the first time during the activity re-creation process,
            // the attached window restores the system bars appearance from the old window/activity.
            // Make sure to restore this appearance in TaskDescription too, to prevent the
            // #setTaskDescription() call below from incorrectly sending an empty value to the
            // server.
            mTaskDescription.setSystemBarsAppearance(mWindow.getSystemBarAppearance());
        }
        setTaskDescription(mTaskDescription);
    }

+6 −1
Original line number Diff line number Diff line
@@ -1037,6 +1037,11 @@ public abstract class Window {
        mDecorCallback = decorCallback;
    }

    /** @hide */
    public final void setSystemBarAppearance(@WindowInsetsController.Appearance int appearance) {
        mSystemBarAppearance = appearance;
    }

    /** @hide */
    @WindowInsetsController.Appearance
    public final int getSystemBarAppearance() {
@@ -1046,7 +1051,7 @@ public abstract class Window {
    /** @hide */
    public final void dispatchOnSystemBarAppearanceChanged(
            @WindowInsetsController.Appearance int appearance) {
        mSystemBarAppearance = appearance;
        setSystemBarAppearance(appearance);
        if (mDecorCallback != null) {
            mDecorCallback.onSystemBarAppearanceChanged(appearance);
        }
+1 −0
Original line number Diff line number Diff line
@@ -406,6 +406,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
            mElevation = preservedWindow.getElevation();
            mLoadElevation = false;
            mForceDecorInstall = true;
            setSystemBarAppearance(preservedWindow.getSystemBarAppearance());
            // If we're preserving window, carry over the app token from the preserved
            // window, as we'll be skipping the addView in handleResumeActivity(), and
            // the token will not be updated as for a new window.