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

Commit 168c204f authored by Jerry Chang's avatar Jerry Chang Committed by Android (Google) Code Review
Browse files

Merge "Make multi-instances split opt-in based" into tm-qpr-dev

parents 58433220 e444ffb1
Loading
Loading
Loading
Loading
+8 −10
Original line number Original line Diff line number Diff line
@@ -548,15 +548,13 @@ public class SystemUiProxy implements ISystemUiProxy {
        }
        }
    }
    }


    public void startIntentAndTask(PendingIntent pendingIntent, Intent fillInIntent,
    public void startIntentAndTask(PendingIntent pendingIntent, Bundle options1, int taskId,
            Bundle options1, int taskId, Bundle options2,
            Bundle options2, @SplitConfigurationOptions.StagePosition int splitPosition,
            @SplitConfigurationOptions.StagePosition int splitPosition, float splitRatio,
            float splitRatio, RemoteTransition remoteTransition, InstanceId instanceId) {
            RemoteTransition remoteTransition, InstanceId instanceId) {
        if (mSystemUiProxy != null) {
        if (mSystemUiProxy != null) {
            try {
            try {
                mSplitScreen.startIntentAndTask(pendingIntent, fillInIntent, options1,
                mSplitScreen.startIntentAndTask(pendingIntent, options1, taskId, options2,
                        taskId, options2, splitPosition, splitRatio,
                        splitPosition, splitRatio, remoteTransition, instanceId);
                        remoteTransition, instanceId);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call startIntentAndTask");
                Log.w(TAG, "Failed call startIntentAndTask");
            }
            }
@@ -593,13 +591,13 @@ public class SystemUiProxy implements ISystemUiProxy {
    }
    }


    public void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent,
    public void startIntentAndTaskWithLegacyTransition(PendingIntent pendingIntent,
            Intent fillInIntent, Bundle options1, int taskId, Bundle options2,
            Bundle options1, int taskId, Bundle options2,
            @SplitConfigurationOptions.StagePosition int splitPosition, float splitRatio,
            @SplitConfigurationOptions.StagePosition int splitPosition, float splitRatio,
            RemoteAnimationAdapter adapter, InstanceId instanceId) {
            RemoteAnimationAdapter adapter, InstanceId instanceId) {
        if (mSystemUiProxy != null) {
        if (mSystemUiProxy != null) {
            try {
            try {
                mSplitScreen.startIntentAndTaskWithLegacyTransition(pendingIntent, fillInIntent,
                mSplitScreen.startIntentAndTaskWithLegacyTransition(pendingIntent, options1, taskId,
                        options1, taskId, options2, splitPosition, splitRatio, adapter, instanceId);
                        options2, splitPosition, splitRatio, adapter, instanceId);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.w(TAG, "Failed call startIntentAndTaskWithLegacyTransition");
                Log.w(TAG, "Failed call startIntentAndTaskWithLegacyTransition");
            }
            }
+20 −47
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Log;
import android.util.Log;
import android.util.Pair;
import android.util.Pair;
import android.view.RemoteAnimationAdapter;
import android.view.RemoteAnimationAdapter;
@@ -88,10 +87,8 @@ public class SplitSelectStateController {
    private ItemInfo mItemInfo;
    private ItemInfo mItemInfo;
    private Intent mInitialTaskIntent;
    private Intent mInitialTaskIntent;
    private int mInitialTaskId = INVALID_TASK_ID;
    private int mInitialTaskId = INVALID_TASK_ID;
    private String mInitialTaskPackageName;
    private Intent mSecondTaskIntent;
    private Intent mSecondTaskIntent;
    private int mSecondTaskId = INVALID_TASK_ID;
    private int mSecondTaskId = INVALID_TASK_ID;
    private String mSecondTaskPackageName;
    private boolean mRecentsAnimationRunning;
    private boolean mRecentsAnimationRunning;
    @Nullable
    @Nullable
    private UserHandle mUser;
    private UserHandle mUser;
@@ -119,7 +116,6 @@ public class SplitSelectStateController {
    public void setInitialTaskSelect(Task task, @StagePosition int stagePosition,
    public void setInitialTaskSelect(Task task, @StagePosition int stagePosition,
            StatsLogManager.EventEnum splitEvent, ItemInfo itemInfo) {
            StatsLogManager.EventEnum splitEvent, ItemInfo itemInfo) {
        mInitialTaskId = task.key.id;
        mInitialTaskId = task.key.id;
        mInitialTaskPackageName = task.getTopComponent().getPackageName();
        setInitialData(stagePosition, splitEvent, itemInfo);
        setInitialData(stagePosition, splitEvent, itemInfo);
    }
    }


@@ -131,7 +127,6 @@ public class SplitSelectStateController {
        mInitialTaskIntent = intent;
        mInitialTaskIntent = intent;
        mUser = itemInfo.user;
        mUser = itemInfo.user;
        mItemInfo = itemInfo;
        mItemInfo = itemInfo;
        mInitialTaskPackageName = intent.getComponent().getPackageName();
        setInitialData(stagePosition, splitEvent, itemInfo);
        setInitialData(stagePosition, splitEvent, itemInfo);
    }
    }


@@ -143,7 +138,6 @@ public class SplitSelectStateController {
            @StagePosition int stagePosition, @NonNull ItemInfo itemInfo,
            @StagePosition int stagePosition, @NonNull ItemInfo itemInfo,
            StatsLogManager.EventEnum splitEvent) {
            StatsLogManager.EventEnum splitEvent) {
        mInitialTaskId = info.taskId;
        mInitialTaskId = info.taskId;
        mInitialTaskPackageName = info.topActivity.getPackageName();
        setInitialData(stagePosition, splitEvent, itemInfo);
        setInitialData(stagePosition, splitEvent, itemInfo);
    }
    }


@@ -161,9 +155,9 @@ public class SplitSelectStateController {
    public void launchSplitTasks(Consumer<Boolean> callback) {
    public void launchSplitTasks(Consumer<Boolean> callback) {
        Pair<InstanceId, com.android.launcher3.logging.InstanceId> instanceIds =
        Pair<InstanceId, com.android.launcher3.logging.InstanceId> instanceIds =
                LogUtils.getShellShareableInstanceId();
                LogUtils.getShellShareableInstanceId();
        launchTasks(mInitialTaskId, mInitialTaskIntent, mInitialTaskPackageName, mSecondTaskId,
        launchTasks(mInitialTaskId, mInitialTaskIntent, mSecondTaskId, mSecondTaskIntent,
                mSecondTaskIntent, mSecondTaskPackageName, mStagePosition, callback,
                mStagePosition, callback, false /* freezeTaskList */, DEFAULT_SPLIT_RATIO,
                false /* freezeTaskList */, DEFAULT_SPLIT_RATIO, instanceIds.first);
                instanceIds.first);


        mStatsLogManager.logger()
        mStatsLogManager.logger()
                .withItemInfo(mItemInfo)
                .withItemInfo(mItemInfo)
@@ -177,12 +171,10 @@ public class SplitSelectStateController {
     */
     */
    public void setSecondTask(Task task) {
    public void setSecondTask(Task task) {
        mSecondTaskId = task.key.id;
        mSecondTaskId = task.key.id;
        mSecondTaskPackageName = task.getTopComponent().getPackageName();
    }
    }


    public void setSecondTask(Intent intent) {
    public void setSecondTask(Intent intent) {
        mSecondTaskIntent = intent;
        mSecondTaskIntent = intent;
        mSecondTaskPackageName = intent.getComponent().getPackageName();
    }
    }


    /**
    /**
@@ -205,9 +197,8 @@ public class SplitSelectStateController {
     */
     */
    public void launchTasks(int taskId1, int taskId2, @StagePosition int stagePosition,
    public void launchTasks(int taskId1, int taskId2, @StagePosition int stagePosition,
            Consumer<Boolean> callback, boolean freezeTaskList, float splitRatio) {
            Consumer<Boolean> callback, boolean freezeTaskList, float splitRatio) {
        launchTasks(taskId1, null /* intent1 */, null /* packageName1 */, taskId2,
        launchTasks(taskId1, null /* intent1 */, taskId2, null /* intent2 */, stagePosition,
                null /* intent2 */, null /* packageName2 */, stagePosition, callback,
                callback, freezeTaskList, splitRatio, null);
                freezeTaskList, splitRatio, null);
    }
    }


    /**
    /**
@@ -220,8 +211,8 @@ public class SplitSelectStateController {
     *                   a split instance, null for cases that bring existing instaces to the
     *                   a split instance, null for cases that bring existing instaces to the
     *                   foreground (quickswitch, launching previous pairs from overview)
     *                   foreground (quickswitch, launching previous pairs from overview)
     */
     */
    public void launchTasks(int taskId1, @Nullable Intent intent1, String packageName1, int taskId2,
    public void launchTasks(int taskId1, @Nullable Intent intent1, int taskId2,
            @Nullable Intent intent2, String packageName2, @StagePosition int stagePosition,
            @Nullable Intent intent2, @StagePosition int stagePosition,
            Consumer<Boolean> callback, boolean freezeTaskList, float splitRatio,
            Consumer<Boolean> callback, boolean freezeTaskList, float splitRatio,
            @Nullable InstanceId shellInstanceId) {
            @Nullable InstanceId shellInstanceId) {
        TestLogging.recordEvent(
        TestLogging.recordEvent(
@@ -240,10 +231,10 @@ public class SplitSelectStateController {
                        null /* options2 */, stagePosition, splitRatio, remoteTransition,
                        null /* options2 */, stagePosition, splitRatio, remoteTransition,
                        shellInstanceId);
                        shellInstanceId);
            } else if (intent2 == null) {
            } else if (intent2 == null) {
                launchIntentOrShortcut(intent1, packageName2, options1, taskId2, stagePosition,
                launchIntentOrShortcut(intent1, options1, taskId2, stagePosition, splitRatio,
                        splitRatio, remoteTransition, shellInstanceId);
                        remoteTransition, shellInstanceId);
            } else if (intent1 == null) {
            } else if (intent1 == null) {
                launchIntentOrShortcut(intent2, packageName1, options1, taskId1,
                launchIntentOrShortcut(intent2, options1, taskId1,
                        getOppositeStagePosition(stagePosition), splitRatio, remoteTransition,
                        getOppositeStagePosition(stagePosition), splitRatio, remoteTransition,
                        shellInstanceId);
                        shellInstanceId);
            } else {
            } else {
@@ -261,10 +252,10 @@ public class SplitSelectStateController {
                        taskId2, null /* options2 */, stagePosition, splitRatio, adapter,
                        taskId2, null /* options2 */, stagePosition, splitRatio, adapter,
                        shellInstanceId);
                        shellInstanceId);
            } else if (intent2 == null) {
            } else if (intent2 == null) {
                launchIntentOrShortcutLegacy(intent1, packageName2, options1, taskId2,
                launchIntentOrShortcutLegacy(intent1, options1, taskId2, stagePosition, splitRatio,
                        stagePosition, splitRatio, adapter, shellInstanceId);
                        adapter, shellInstanceId);
            } else if (intent1 == null) {
            } else if (intent1 == null) {
                launchIntentOrShortcutLegacy(intent2, packageName1, options1, taskId1,
                launchIntentOrShortcutLegacy(intent2, options1, taskId1,
                        getOppositeStagePosition(stagePosition), splitRatio, adapter,
                        getOppositeStagePosition(stagePosition), splitRatio, adapter,
                        shellInstanceId);
                        shellInstanceId);
            } else {
            } else {
@@ -273,9 +264,8 @@ public class SplitSelectStateController {
        }
        }
    }
    }


    private void launchIntentOrShortcut(Intent intent, String otherTaskPackageName,
    private void launchIntentOrShortcut(Intent intent, ActivityOptions options1, int taskId,
            ActivityOptions options1, int taskId, @StagePosition int stagePosition,
            @StagePosition int stagePosition, float splitRatio, RemoteTransition remoteTransition,
            float splitRatio, RemoteTransition remoteTransition,
            @Nullable InstanceId shellInstanceId) {
            @Nullable InstanceId shellInstanceId) {
        PendingIntent pendingIntent = getPendingIntent(intent);
        PendingIntent pendingIntent = getPendingIntent(intent);
        final ShortcutInfo shortcutInfo = getShortcutInfo(intent,
        final ShortcutInfo shortcutInfo = getShortcutInfo(intent,
@@ -285,16 +275,14 @@ public class SplitSelectStateController {
                    options1.toBundle(), taskId, null /* options2 */, stagePosition,
                    options1.toBundle(), taskId, null /* options2 */, stagePosition,
                    splitRatio, remoteTransition, shellInstanceId);
                    splitRatio, remoteTransition, shellInstanceId);
        } else {
        } else {
            mSystemUiProxy.startIntentAndTask(pendingIntent,
            mSystemUiProxy.startIntentAndTask(pendingIntent, options1.toBundle(), taskId,
                    getFillInIntent(intent, otherTaskPackageName), options1.toBundle(), taskId,
                    null /* options2 */, stagePosition, splitRatio, remoteTransition,
                    null /* options2 */, stagePosition, splitRatio, remoteTransition,
                    shellInstanceId);
                    shellInstanceId);
        }
        }
    }
    }


    private void launchIntentOrShortcutLegacy(Intent intent, String otherTaskPackageName,
    private void launchIntentOrShortcutLegacy(Intent intent, ActivityOptions options1, int taskId,
            ActivityOptions options1, int taskId, @StagePosition int stagePosition,
            @StagePosition int stagePosition, float splitRatio, RemoteAnimationAdapter adapter,
            float splitRatio, RemoteAnimationAdapter adapter,
            @Nullable InstanceId shellInstanceId) {
            @Nullable InstanceId shellInstanceId) {
        PendingIntent pendingIntent = getPendingIntent(intent);
        PendingIntent pendingIntent = getPendingIntent(intent);
        final ShortcutInfo shortcutInfo = getShortcutInfo(intent,
        final ShortcutInfo shortcutInfo = getShortcutInfo(intent,
@@ -305,9 +293,8 @@ public class SplitSelectStateController {
                    splitRatio, adapter, shellInstanceId);
                    splitRatio, adapter, shellInstanceId);
        } else {
        } else {
            mSystemUiProxy.startIntentAndTaskWithLegacyTransition(pendingIntent,
            mSystemUiProxy.startIntentAndTaskWithLegacyTransition(pendingIntent,
                    getFillInIntent(intent, otherTaskPackageName), options1.toBundle(), taskId,
                    options1.toBundle(), taskId, null /* options2 */, stagePosition, splitRatio,
                    null /* options2 */, stagePosition, splitRatio, adapter,
                    adapter, shellInstanceId);
                    shellInstanceId);
        }
        }
    }
    }


@@ -318,18 +305,6 @@ public class SplitSelectStateController {
                : PendingIntent.getActivity(mContext, 0, intent, FLAG_MUTABLE));
                : PendingIntent.getActivity(mContext, 0, intent, FLAG_MUTABLE));
    }
    }


    private Intent getFillInIntent(Intent intent, String otherTaskPackageName) {
        if (intent == null) {
            return null;
        }

        Intent fillInIntent = new Intent();
        if (TextUtils.equals(intent.getComponent().getPackageName(), otherTaskPackageName)) {
            fillInIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
        }
        return fillInIntent;
    }



    public @StagePosition int getActiveSplitStagePosition() {
    public @StagePosition int getActiveSplitStagePosition() {
        return mStagePosition;
        return mStagePosition;
@@ -464,10 +439,8 @@ public class SplitSelectStateController {
    public void resetState() {
    public void resetState() {
        mInitialTaskId = INVALID_TASK_ID;
        mInitialTaskId = INVALID_TASK_ID;
        mInitialTaskIntent = null;
        mInitialTaskIntent = null;
        mInitialTaskPackageName = null;
        mSecondTaskId = INVALID_TASK_ID;
        mSecondTaskId = INVALID_TASK_ID;
        mSecondTaskIntent = null;
        mSecondTaskIntent = null;
        mSecondTaskPackageName = null;
        mStagePosition = SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
        mStagePosition = SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
        mRecentsAnimationRunning = false;
        mRecentsAnimationRunning = false;
        mLaunchingTaskView = null;
        mLaunchingTaskView = null;