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

Commit 31d99ef2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Replace tasks in the same split with the dropping app" into sc-v2-dev...

Merge "Replace tasks in the same split with the dropping app" into sc-v2-dev am: 3d13d0cb am: 57020f34

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16062196

Change-Id: I3ba2846070c895baf3c18b3ae4499d4147895ff7
parents 97f56af8 57020f34
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.wm.shell.splitscreen;

import static android.app.ActivityManager.START_SUCCESS;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.RemoteAnimationTarget.MODE_OPENING;

@@ -213,7 +215,11 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
        options = mStageCoordinator.resolveStartStage(stage, position, options, null /* wct */);

        try {
            final int result =
                    ActivityTaskManager.getService().startActivityFromRecents(taskId, options);
            if (result == START_SUCCESS || result == START_TASK_TO_FRONT) {
                mStageCoordinator.evictOccludedChildren(position);
            }
        } catch (RemoteException e) {
            Slog.e(TAG, "Failed to launch task", e);
        }
@@ -229,6 +235,7 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
                    mContext.getSystemService(LauncherApps.class);
            launcherApps.startShortcut(packageName, shortcutId, null /* sourceBounds */,
                    options, user);
            mStageCoordinator.evictOccludedChildren(position);
        } catch (ActivityNotFoundException e) {
            Slog.e(TAG, "Failed to launch shortcut", e);
        }
@@ -272,6 +279,10 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
                        Slog.e(TAG, "Error finishing legacy transition: ", e);
                    }
                }

                // Launching a new app into a specific split evicts tasks previously in the same
                // split.
                mStageCoordinator.evictOccludedChildren(position);
            }
        };
        WindowContainerTransaction wct = new WindowContainerTransaction();
+6 −0
Original line number Diff line number Diff line
@@ -394,6 +394,12 @@ class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE, wct, remoteTransition, this);
    }

    void evictOccludedChildren(@SplitPosition int position) {
        final WindowContainerTransaction wct = new WindowContainerTransaction();
        (position == mSideStagePosition ? mSideStage : mMainStage).evictOccludedChildren(wct);
        mTaskOrganizer.applyTransaction(wct);
    }

    Bundle resolveStartStage(@SplitScreen.StageType int stage,
            @SplitPosition int position, @androidx.annotation.Nullable Bundle options,
            @androidx.annotation.Nullable WindowContainerTransaction wct) {
+10 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
        void onChildTaskStatusChanged(int taskId, boolean present, boolean visible);

        void onRootTaskVanished();

        void onNoLongerSupportMultiWindow();
    }

@@ -247,6 +248,15 @@ class StageTaskListener implements ShellTaskOrganizer.TaskListener {
        wct.reorder(mChildrenTaskInfo.get(taskId).token, onTop /* onTop */);
    }

    void evictOccludedChildren(WindowContainerTransaction wct) {
        for (int i = mChildrenTaskInfo.size() - 1; i >= 0; i--) {
            final ActivityManager.RunningTaskInfo taskInfo = mChildrenTaskInfo.valueAt(i);
            if (!taskInfo.isVisible) {
                wct.reparent(taskInfo.token, null /* parent */, false /* onTop */);
            }
        }
    }

    void setVisibility(boolean visible, WindowContainerTransaction wct) {
        wct.reorder(mRootTaskInfo.token, visible /* onTop */);
    }