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

Commit 15344024 authored by Jeremy Sim's avatar Jeremy Sim Committed by Android (Google) Code Review
Browse files

Merge "Fix bug where splitscreen causes unlaunchable camera" into main

parents b8ea4dca bd34b1b5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -110,12 +110,12 @@ public interface SplitScreen {
    void registerSplitAnimationListener(@NonNull SplitInvocationListener listener,
            @NonNull Executor executor);

    /** Called when device waking up finished. */
    void onFinishedWakingUp();

    /** Called when device starts going to sleep (screen off). */
    void onStartedGoingToSleep();

    /** Called when device wakes up. */
    void onStartedWakingUp();

    /** Called when requested to go to fullscreen from the current active split app. */
    void goToFullscreenFromSplit();

+8 −8
Original line number Diff line number Diff line
@@ -471,14 +471,14 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
        mStageCoordinator.onKeyguardStateChanged(visible, occluded);
    }

    public void onFinishedWakingUp() {
        mStageCoordinator.onFinishedWakingUp();
    }

    public void onStartedGoingToSleep() {
        mStageCoordinator.onStartedGoingToSleep();
    }

    public void onStartedWakingUp() {
        mStageCoordinator.onStartedWakingUp();
    }

    public void exitSplitScreenOnHide(boolean exitSplitScreenOnHide) {
        mStageCoordinator.exitSplitScreenOnHide(exitSplitScreenOnHide);
    }
@@ -1084,13 +1084,13 @@ public class SplitScreenController implements SplitDragPolicy.Starter,
        }

        @Override
        public void onFinishedWakingUp() {
            mMainExecutor.execute(SplitScreenController.this::onFinishedWakingUp);
        public void onStartedGoingToSleep() {
            mMainExecutor.execute(SplitScreenController.this::onStartedGoingToSleep);
        }

        @Override
        public void onStartedGoingToSleep() {
            mMainExecutor.execute(SplitScreenController.this::onStartedGoingToSleep);
        public void onStartedWakingUp() {
            mMainExecutor.execute(SplitScreenController.this::onStartedWakingUp);
        }

        @Override
+38 −15
Original line number Diff line number Diff line
@@ -1138,14 +1138,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                "onKeyguardVisibilityChanged: active=%b occludingTaskRunning=%b",
                active, occludingTaskRunning);
        setDividerVisibility(!mKeyguardActive, null);

        if (active && occludingTaskRunning) {
            dismissSplitKeepingLastActiveStage(EXIT_REASON_SCREEN_LOCKED_SHOW_ON_TOP);
        }
    }

    void onFinishedWakingUp() {
        ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onFinishedWakingUp");
    void onStartedWakingUp() {
        ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "onStartedWakingUp");
        if (mBreakOnNextWake) {
            dismissSplitKeepingLastActiveStage(EXIT_REASON_DEVICE_FOLDED);
        }
@@ -2431,6 +2427,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            final int transitType = info.getType();
            TransitionInfo.Change pipChange = null;
            int closingSplitTaskId = -1;
            // This array tracks if we are sending stages TO_BACK in this transition.
            // TODO (b/349828130): Update for n apps
            boolean[] stagesSentToBack = new boolean[2];

            for (int iC = 0; iC < info.getChanges().size(); ++iC) {
                final TransitionInfo.Change change = info.getChanges().get(iC);
                if (change.getMode() == TRANSIT_CHANGE
@@ -2498,23 +2498,31 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                    }
                    continue;
                }
                final int taskId = taskInfo.taskId;
                if (isOpeningType(change.getMode())) {
                    if (!stage.containsTask(taskInfo.taskId)) {
                    if (!stage.containsTask(taskId)) {
                        Log.w(TAG, "Expected onTaskAppeared on " + stage + " to have been called"
                                + " with " + taskInfo.taskId + " before startAnimation().");
                        record.addRecord(stage, true, taskInfo.taskId);
                                + " with " + taskId + " before startAnimation().");
                        record.addRecord(stage, true, taskId);
                    }
                } else if (change.getMode() == TRANSIT_CLOSE) {
                    if (stage.containsTask(taskInfo.taskId)) {
                        record.addRecord(stage, false, taskInfo.taskId);
                    if (stage.containsTask(taskId)) {
                        record.addRecord(stage, false, taskId);
                        Log.w(TAG, "Expected onTaskVanished on " + stage + " to have been called"
                                + " with " + taskInfo.taskId + " before startAnimation().");
                                + " with " + taskId + " before startAnimation().");
                    }
                }
                if (isClosingType(change.getMode()) &&
                        getStageOfTask(change.getTaskInfo().taskId) != STAGE_TYPE_UNDEFINED) {
                    // If either one of the 2 stages is closing we're assuming we'll break split
                    closingSplitTaskId = change.getTaskInfo().taskId;
                        getStageOfTask(taskId) != STAGE_TYPE_UNDEFINED) {

                    // Record which stages are getting sent to back
                    if (change.getMode() == TRANSIT_TO_BACK) {
                        stagesSentToBack[getStageOfTask(taskId)] = true;
                    }

                    // (For PiP transitions) If either one of the 2 stages is closing we're assuming
                    // we'll break split
                    closingSplitTaskId = taskId;
                }
            }

@@ -2540,6 +2548,21 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                return true;
            }

            // If keyguard is active, check to see if we have our TO_BACK transitions in order.
            // This array should either be all false (no split stages sent to back) or all true
            // (all stages sent to back). In any other case (which can happen with SHOW_ABOVE_LOCKED
            // apps) we should break split.
            if (mKeyguardActive) {
                boolean isFirstStageSentToBack = stagesSentToBack[0];
                for (boolean b : stagesSentToBack) {
                    // Compare each boolean to the first one. If any are different, break split.
                    if (b != isFirstStageSentToBack) {
                        dismissSplitKeepingLastActiveStage(EXIT_REASON_SCREEN_LOCKED_SHOW_ON_TOP);
                        break;
                    }
                }
            }

            final ArraySet<StageTaskListener> dismissStages = record.getShouldDismissedStage();
            if (mMainStage.getChildCount() == 0 || mSideStage.getChildCount() == 0
                    || dismissStages.size() == 1) {
+1 −1
Original line number Diff line number Diff line
@@ -320,7 +320,7 @@ public class StageCoordinatorTests extends ShellTestCase {

        assertEquals(mStageCoordinator.mLastActiveStage, STAGE_TYPE_MAIN);

        mStageCoordinator.onFinishedWakingUp();
        mStageCoordinator.onStartedWakingUp();

        verify(mTaskOrganizer).startNewTransition(eq(TRANSIT_SPLIT_DISMISS), notNull());
    }
+4 −4
Original line number Diff line number Diff line
@@ -281,13 +281,13 @@ public final class WMShell implements
    void initSplitScreen(SplitScreen splitScreen) {
        mWakefulnessLifecycle.addObserver(new WakefulnessLifecycle.Observer() {
            @Override
            public void onFinishedWakingUp() {
                splitScreen.onFinishedWakingUp();
            public void onStartedGoingToSleep() {
                splitScreen.onStartedGoingToSleep();
            }

            @Override
            public void onStartedGoingToSleep() {
                splitScreen.onStartedGoingToSleep();
            public void onStartedWakingUp() {
                splitScreen.onStartedWakingUp();
            }
        });
        mCommandQueue.addCallback(new CommandQueue.Callbacks() {