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

Commit c59b4f6f authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Don't send userLeaving hint when entering split-screen mode.

If the current activity stack we are resuming is in multi-window mode
and the last resumed activity stack should still be visible, then don't
send userLeaving hint as the activity will still be visible to the user
after onPause is called.
Also, added option to say if recents activity should be shown when
split-screen is activated. starting the recents activity during
CTS testing can cause timing issues since the recents activity might
be started after the activity we are trying to launch adjacent to
split-screen.

Change-Id: Iba1d0749062e7365a207ba1172705b5ab70cb869
Fixes: 69419620
Test: ActivityManagerSplitScreenTests.testNoUserLeaveHintOnMultiWindowModeChanged
parent 9f3d06b7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package android.app {
    method public void removeStacksWithActivityTypes(int[]) throws java.lang.SecurityException;
    method public void resizeStack(int, android.graphics.Rect) throws java.lang.SecurityException;
    method public void setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException;
    method public void setTaskWindowingModeSplitScreenPrimary(int, int, boolean, boolean, android.graphics.Rect) throws java.lang.SecurityException;
    method public void setTaskWindowingModeSplitScreenPrimary(int, int, boolean, boolean, android.graphics.Rect, boolean) throws java.lang.SecurityException;
    method public static boolean supportsMultiWindow(android.content.Context);
    method public static boolean supportsSplitScreenMultiWindow(android.content.Context);
    field public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1; // 0x1
+4 −2
Original line number Diff line number Diff line
@@ -1944,15 +1944,17 @@ public class ActivityManager {
     * @param animate Whether we should play an animation for the moving the task
     * @param initialBounds If the primary stack gets created, it will use these bounds for the
     *                      docked stack. Pass {@code null} to use default bounds.
     * @param showRecents If the recents activity should be shown on the other side of the task
     *                    going into split-screen mode.
     * @hide
     */
    @TestApi
    @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
    public void setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
            boolean animate, Rect initialBounds) throws SecurityException {
            boolean animate, Rect initialBounds, boolean showRecents) throws SecurityException {
        try {
            getService().setTaskWindowingModeSplitScreenPrimary(taskId, createMode, toTop, animate,
                    initialBounds);
                    initialBounds, showRecents);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+1 −1
Original line number Diff line number Diff line
@@ -502,7 +502,7 @@ interface IActivityManager {
    void reportSizeConfigurations(in IBinder token, in int[] horizontalSizeConfiguration,
            in int[] verticalSizeConfigurations, in int[] smallestWidthConfigurations);
    boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
            boolean animate, in Rect initialBounds);
            boolean animate, in Rect initialBounds, boolean showRecents);
    /**
     * Dismisses split-screen multi-window mode.
     * {@param toTop} If true the current primary split-screen stack will be placed or left on top.
+1 −1
Original line number Diff line number Diff line
@@ -267,7 +267,7 @@ public class SystemServicesProxy {

        try {
            return mIam.setTaskWindowingModeSplitScreenPrimary(taskId, createMode, true /* onTop */,
                    false /* animate */, initialBounds);
                    false /* animate */, initialBounds, true /* showRecents */);
        } catch (RemoteException e) {
            e.printStackTrace();
        }
+6 −3
Original line number Diff line number Diff line
@@ -414,6 +414,7 @@ import com.android.server.SystemServiceManager;
import com.android.server.ThreadPriorityBooster;
import com.android.server.Watchdog;
import com.android.server.am.ActivityStack.ActivityState;
import com.android.server.am.EventLogTags;
import com.android.server.am.proto.ActivityManagerServiceProto;
import com.android.server.am.proto.BroadcastProto;
import com.android.server.am.proto.GrantUriProto;
@@ -10501,7 +10502,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) {
        if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
            setTaskWindowingModeSplitScreenPrimary(taskId, SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT,
                    toTop, ANIMATE, null /* initialBounds */);
                    toTop, ANIMATE, null /* initialBounds */, true /* showRecents */);
            return;
        }
        enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "setTaskWindowingMode()");
@@ -10547,10 +10548,12 @@ public class ActivityManagerService extends IActivityManager.Stub
     * @param animate Whether we should play an animation for the moving the task.
     * @param initialBounds If the primary stack gets created, it will use these bounds for the
     *                      stack. Pass {@code null} to use default bounds.
     * @param showRecents If the recents activity should be shown on the other side of the task
     *                    going into split-screen mode.
     */
    @Override
    public boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
            boolean animate, Rect initialBounds) {
            boolean animate, Rect initialBounds, boolean showRecents) {
        enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
                "setTaskWindowingModeSplitScreenPrimary()");
        synchronized (this) {
@@ -10575,7 +10578,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                if (toTop) {
                    stack.moveToFront("setTaskWindowingModeSplitScreenPrimary", task);
                }
                stack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, animate);
                stack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, animate, showRecents);
                return windowingMode != task.getWindowingMode();
            } finally {
                Binder.restoreCallingIdentity(ident);
Loading