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

Commit 82792153 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Fixing issue with wrong initial multi-window mode." into oc-dev

parents d193972a 609e1e9f
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -249,6 +249,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
    // Last configuration reported to the activity in the client process.
    private MergedConfiguration mLastReportedConfiguration;
    private int mLastReportedDisplayId;
    private boolean mLastReportedMultiWindowMode;
    private boolean mLastReportedPictureInPictureMode;
    CompatibilityInfo compat;// last used compatibility mode
    ActivityRecord resultTo; // who started this entry, so will get our reply
    final String resultWho; // additional identifier for use by resultTo.
@@ -289,10 +291,6 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
    boolean frozenBeforeDestroy;// has been frozen but not yet destroyed.
    boolean immersive;      // immersive mode (don't interrupt if possible)
    boolean forceNewConfig; // force re-create with new config next time
    private boolean mInMultiWindowMode; // whether or not this activity is currently in multi-window
                                        // mode (default false)
    private boolean mInPictureInPictureMode; // whether or not this activity is currently in
                                             // picture-in-picture mode (default false)
    boolean supportsPictureInPictureWhilePausing;  // This flag is set by the system to indicate
        // that the activity can enter picture in picture while pausing (ie. only when another
        // task is brought to front or started)
@@ -535,6 +533,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
        }
        if (info != null) {
            pw.println(prefix + "resizeMode=" + ActivityInfo.resizeModeToString(info.resizeMode));
            pw.println(prefix + "mLastReportedMultiWindowMode=" + mLastReportedMultiWindowMode
                    + " mLastReportedPictureInPictureMode=" + mLastReportedPictureInPictureMode);
            if (info.supportsPictureInPicture()) {
                pw.println(prefix + "supportsPictureInPicture=" + info.supportsPictureInPicture());
                pw.println(prefix + "supportsPictureInPictureWhilePausing: "
@@ -637,15 +637,15 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo

        // An activity is considered to be in multi-window mode if its task isn't fullscreen.
        final boolean inMultiWindowMode = !task.mFullscreen;
        if (inMultiWindowMode != mInMultiWindowMode) {
            mInMultiWindowMode = inMultiWindowMode;
        if (inMultiWindowMode != mLastReportedMultiWindowMode) {
            mLastReportedMultiWindowMode = inMultiWindowMode;
            scheduleMultiWindowModeChanged(getConfiguration());
        }
    }

    private void scheduleMultiWindowModeChanged(Configuration overrideConfig) {
        try {
            app.thread.scheduleMultiWindowModeChanged(appToken, mInMultiWindowMode,
            app.thread.scheduleMultiWindowModeChanged(appToken, mLastReportedMultiWindowMode,
                    overrideConfig);
        } catch (Exception e) {
            // If process died, I don't care.
@@ -659,11 +659,11 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo

        final boolean inPictureInPictureMode = (task.getStackId() == PINNED_STACK_ID) &&
                (targetStackBounds != null);
        if (inPictureInPictureMode != mInPictureInPictureMode) {
        if (inPictureInPictureMode != mLastReportedPictureInPictureMode) {
            // Picture-in-picture mode changes also trigger a multi-window mode change as well, so
            // update that here in order
            mInPictureInPictureMode = inPictureInPictureMode;
            mInMultiWindowMode = inPictureInPictureMode;
            mLastReportedPictureInPictureMode = inPictureInPictureMode;
            mLastReportedMultiWindowMode = inPictureInPictureMode;
            final Configuration newConfig = task.computeNewOverrideConfigurationForBounds(
                    targetStackBounds, null);
            schedulePictureInPictureModeChanged(newConfig);
@@ -673,7 +673,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo

    private void schedulePictureInPictureModeChanged(Configuration overrideConfig) {
        try {
            app.thread.schedulePictureInPictureModeChanged(appToken, mInPictureInPictureMode,
            app.thread.schedulePictureInPictureModeChanged(appToken,
                    mLastReportedPictureInPictureMode,
                    overrideConfig);
        } catch (Exception e) {
            // If process died, no one cares.
@@ -940,6 +941,12 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo

        task.addActivityToTop(this);

        // When an activity is started directly into a split-screen fullscreen stack, we need to
        // update the initial multi-window modes so that the callbacks are scheduled correctly when
        // the user leaves that mode.
        mLastReportedMultiWindowMode = !task.mFullscreen;
        mLastReportedPictureInPictureMode = (task.getStackId() == PINNED_STACK_ID);

        onOverrideConfigurationSent();
    }