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

Commit 72919d2c authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Untangle creation of Task from addition of AppToken in WM.

Makes it easier to follow what is going on and also clean-up in
preparation of stand way for AM to interact with containers in WM.

Test: Existing tests pass and manual testing
Change-Id: I91754b6d974dce2f696453cdaed175efb0f10c73
parent 00f9a1a4
Loading
Loading
Loading
Loading
+10 −28
Original line number Diff line number Diff line
@@ -89,51 +89,33 @@ interface IWindowManager
    void addWindowToken(IBinder token, int type, int displayId);
    void removeWindowToken(IBinder token, int displayId);
    /**
     * Adds an application token to the specified task Id.
     * Creates the object representation for the application token in the window manager and adds it
     * to the specified task Id.
     *
     * @param addPos The position to add the token to in the task.
     * @param token The token to add.
     * @param taskId The Id of the task we are adding the token to.
     * @param stackId Stack Id to create a new Task with the input task Id on
     *                if the task doesn't exist yet.
     * @param requestedOrientation Orientation to use.
     * @param fullscreen True if the application token is fullscreen.
     * @param showWhenLocked True if the application token should be shown when locked.
     * @param userId Id of user to associate the token with.
     * @param configChanges Input configuration changes.
     * @param voiceInteraction True if the token is in voice interaction mode.
     * @param launchTaskBehind True if the token is been launched from behind.
     * @param taskBounds Bounds to use when creating a new Task with the input task Id if
     *                   the task doesn't exist yet.
     * @param overrideConfig Override configuration that is being used with this task.
     * @param taskResizeMode The resize mode of the task.
     * @param alwaysFocusable True if the app windows are always focusable regardless of the stack
     *                        they are in.
     * @param homeTask True if this is the task.
     * @param targetSdkVersion The application's target SDK version
     * @param isOnTopLauncher True if this task is an on-top launcher.
     */
    void addAppToken(int addPos, IApplicationToken token, int taskId, int stackId,
            int requestedOrientation, boolean fullscreen, boolean showWhenLocked, int userId,
            int configChanges, boolean voiceInteraction, boolean launchTaskBehind,
            in Rect taskBounds, in Configuration overrideConfig, int taskResizeMode,
            boolean alwaysFocusable, boolean homeTask, int targetSdkVersion,
            int rotationAnimationHint, boolean isOnTopLauncher);
    void addAppToken(int addPos, IApplicationToken token, int taskId, int requestedOrientation,
            boolean fullscreen, boolean showWhenLocked, int configChanges, boolean voiceInteraction,
            boolean launchTaskBehind, boolean alwaysFocusable, int targetSdkVersion,
            int rotationAnimationHint);
    /**
     * Adds an already existing application token on the window manager side to the input task id.
     *
     * @param token The token we are adding to the input task Id.
     * @param taskId The Id of the task we are adding the token to.
     * @param stackId Stack Id to create a new Task with the input task Id on
     *                if the task doesn't exist yet.
     * @param taskBounds Bounds to use when creating a new Task with the input task Id if
     *                   the task doesn't exist yet.
     * @param overrideConfig Override configuration that is being used with this task.
     * @param taskResizeMode The resize mode of the task.
     * @param homeTask True if this is the task.
     * @param isOnTopLauncher True if this task is an on-top launcher.
     */
    void setAppTask(IBinder token, int taskId, int stackId, in Rect taskBounds,
            in Configuration overrideConfig, int taskResizeMode, boolean homeTask,
            boolean isOnTopLauncher);
     */
    void addAppToTask(IBinder token, int taskId);
    void setAppOrientation(IApplicationToken token, int requestedOrientation);
    int getAppOrientation(IApplicationToken token);
    void setFocusedApp(IBinder token, boolean moveFocusNow);
+16 −15
Original line number Diff line number Diff line
@@ -2857,7 +2857,7 @@ final class ActivityStack extends ConfigurationContainer {
                } else {
                    targetTask = createTaskRecord(
                            mStackSupervisor.getNextTaskIdForUserLocked(target.userId),
                            target.info, null, null, null, false);
                            target.info, null, null, null, false, target.mActivityType);
                    targetTask.affinityIntent = target.intent;
                    if (DEBUG_TASKS) Slog.v(TAG_TASKS, "Start pushing activity " + target
                            + " out to new task " + target.task);
@@ -4897,9 +4897,9 @@ final class ActivityStack extends ConfigurationContainer {

    TaskRecord createTaskRecord(int taskId, ActivityInfo info, Intent intent,
            IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
            boolean toTop) {
            boolean toTop, int type) {
        TaskRecord task = new TaskRecord(mService, taskId, info, intent, voiceSession,
                voiceInteractor);
                voiceInteractor, type);
        // add the task to stack first, mTaskPositioner might need the stack association
        addTask(task, toTop, "createTaskRecord");
        final boolean isLockscreenShown =
@@ -4908,6 +4908,11 @@ final class ActivityStack extends ConfigurationContainer {
                && !isLockscreenShown) {
            task.updateOverrideConfiguration(mBounds);
        }
        final Rect bounds = task.updateOverrideConfigurationFromLaunchBounds();
        final boolean showForAllUsers = (info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0;
        mWindowManager.addTask(taskId, mStackId, task.userId, bounds,
                task.getOverrideConfiguration(), task.mResizeMode, task.isHomeTask(),
                task.isOnTopLauncher(), toTop, showForAllUsers);
        return task;
    }

@@ -4974,15 +4979,13 @@ final class ActivityStack extends ConfigurationContainer {
    }

    void addConfigOverride(ActivityRecord r, TaskRecord task) {
        final Rect bounds = task.updateOverrideConfigurationFromLaunchBounds();
        task.updateOverrideConfigurationFromLaunchBounds();
        // TODO: VI deal with activity
        mWindowManager.addAppToken(task.mActivities.indexOf(r), r.appToken,
                r.task.taskId, mStackId, r.info.screenOrientation, r.fullscreen,
                (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0, r.userId, r.info.configChanges,
                task.voiceSession != null, r.mLaunchTaskBehind, bounds,
                task.getOverrideConfiguration(), task.mResizeMode, r.isAlwaysFocusable(),
                task.isHomeTask(), r.appInfo.targetSdkVersion, r.mRotationAnimationHint,
                task.isOnTopLauncher());
                r.task.taskId, r.info.screenOrientation, r.fullscreen,
                (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0, r.info.configChanges,
                task.voiceSession != null, r.mLaunchTaskBehind, r.isAlwaysFocusable(),
                r.appInfo.targetSdkVersion, r.mRotationAnimationHint);
        r.onOverrideConfigurationSent();
    }

@@ -5021,7 +5024,7 @@ final class ActivityStack extends ConfigurationContainer {

        final TaskRecord task = createTaskRecord(
                mStackSupervisor.getNextTaskIdForUserLocked(r.userId),
                r.info, r.intent, null, null, true);
                r.info, r.intent, null, null, true, r.mActivityType);
        r.setTask(task, null);
        task.addActivityToTop(r);
        setAppTask(r, task);
@@ -5033,10 +5036,8 @@ final class ActivityStack extends ConfigurationContainer {
    }

    private void setAppTask(ActivityRecord r, TaskRecord task) {
        final Rect bounds = task.updateOverrideConfigurationFromLaunchBounds();
        mWindowManager.setAppTask(r.appToken, task.taskId, mStackId, bounds,
                task.getOverrideConfiguration(), task.mResizeMode, task.isHomeTask(),
                task.isOnTopLauncher());
        task.updateOverrideConfigurationFromLaunchBounds();
        mWindowManager.addAppToTask(r.appToken, task.taskId);
        r.onOverrideConfigurationSent();
    }

+5 −1
Original line number Diff line number Diff line
@@ -2424,7 +2424,11 @@ public class ActivityStackSupervisor extends ConfigurationContainer
            return false;
        }

        stack.addTask(task, false, "restoreRecentTask");
        stack.addTask(task, false /* toTop */, "restoreRecentTask");
        final Rect bounds = task.updateOverrideConfigurationFromLaunchBounds();
        mWindowManager.addTask(task.taskId, stack.mStackId, task.userId, bounds,
                task.getOverrideConfiguration(), task.mResizeMode, task.isHomeTask(),
                task.isOnTopLauncher(), false /* toTop */, true /* showForAllUsers */);
        if (DEBUG_RECENTS) Slog.v(TAG_RECENTS,
                "Added restored task=" + task + " to stack=" + stack);
        final ArrayList<ActivityRecord> activities = task.mActivities;
+4 −4
Original line number Diff line number Diff line
@@ -1642,8 +1642,8 @@ class ActivityStarter {
            final TaskRecord task = mTargetStack.createTaskRecord(
                    mSupervisor.getNextTaskIdForUserLocked(mStartActivity.userId),
                    mNewTaskInfo != null ? mNewTaskInfo : mStartActivity.info,
                    mNewTaskIntent != null ? mNewTaskIntent : mIntent,
                    mVoiceSession, mVoiceInteractor, !mLaunchTaskBehind /* toTop */);
                    mNewTaskIntent != null ? mNewTaskIntent : mIntent, mVoiceSession,
                    mVoiceInteractor, !mLaunchTaskBehind /* toTop */, mStartActivity.mActivityType);
            mStartActivity.setTask(task, taskToAffiliate);
            if (mLaunchBounds != null) {
                final int stackId = mTargetStack.mStackId;
@@ -1817,8 +1817,8 @@ class ActivityStarter {
        }
        final ActivityRecord prev = mTargetStack.topActivity();
        final TaskRecord task = (prev != null) ? prev.task : mTargetStack.createTaskRecord(
                        mSupervisor.getNextTaskIdForUserLocked(mStartActivity.userId),
                        mStartActivity.info, mIntent, null, null, true);
                mSupervisor.getNextTaskIdForUserLocked(mStartActivity.userId), mStartActivity.info,
                mIntent, null, null, true, mStartActivity.mActivityType);
        mStartActivity.setTask(task, null);
        mWindowManager.moveTaskToTop(mStartActivity.task.taskId);
        if (DEBUG_TASKS) Slog.v(TAG_TASKS,
+2 −2
Original line number Diff line number Diff line
@@ -281,7 +281,7 @@ final class TaskRecord extends ConfigurationContainer {
    private Configuration mTmpConfig = new Configuration();

    TaskRecord(ActivityManagerService service, int _taskId, ActivityInfo info, Intent _intent,
            IVoiceInteractionSession _voiceSession, IVoiceInteractor _voiceInteractor) {
            IVoiceInteractionSession _voiceSession, IVoiceInteractor _voiceInteractor, int type) {
        mService = service;
        mFilename = String.valueOf(_taskId) + TASK_THUMBNAIL_SUFFIX +
                TaskPersister.IMAGE_EXTENSION;
@@ -296,6 +296,7 @@ final class TaskRecord extends ConfigurationContainer {
        mActivities = new ArrayList<>();
        mCallingUid = info.applicationInfo.uid;
        mCallingPackage = info.packageName;
        taskType = type;
        setIntent(_intent, info);
        setMinDimensions(info);
        touchActiveTime();
@@ -321,7 +322,6 @@ final class TaskRecord extends ConfigurationContainer {
        setIntent(_intent, info);
        setMinDimensions(info);

        taskType = ActivityRecord.APPLICATION_ACTIVITY_TYPE;
        isPersistable = true;
        // Clamp to [1, max].
        maxRecents = Math.min(Math.max(info.maxRecents, 1),
Loading