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

Commit a36f50fa authored by Bryce Lee's avatar Bryce Lee Committed by android-build-merger
Browse files

Merge "Clean up activity/stack associations." into oc-dev

am: 9f467df8

Change-Id: I1c7d75fec994d50cdb55fb798e4ed0c9beadab09
parents bfdb7307 9f467df8
Loading
Loading
Loading
Loading
+35 −25
Original line number Diff line number Diff line
@@ -2849,7 +2849,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        mTempConfig.setToDefaults();
        mTempConfig.setLocales(LocaleList.getDefault());
        mConfigurationSeq = mTempConfig.seq = 1;
        mStackSupervisor = new ActivityStackSupervisor(this);
        mStackSupervisor = createStackSupervisor();
        mStackSupervisor.onConfigurationChanged(mTempConfig);
        mKeyguardController = mStackSupervisor.mKeyguardController;
        mCompatModePackages = new CompatModePackages(this, systemDir, mHandler);
@@ -2897,6 +2897,10 @@ public class ActivityManagerService extends IActivityManager.Stub
        Watchdog.getInstance().addThread(mHandler);
    }
    protected ActivityStackSupervisor createStackSupervisor() {
        return new ActivityStackSupervisor(this, mHandler.getLooper());
    }
    public void setSystemServiceManager(SystemServiceManager mgr) {
        mSystemServiceManager = mgr;
    }
@@ -3151,7 +3155,8 @@ public class ActivityManagerService extends IActivityManager.Stub
     * {@link ActivityStack#setResumedActivityLocked} when an activity is resumed.
     */
    void setResumedActivityUncheckLocked(ActivityRecord r, String reason) {
        if (r.task.isApplicationTask()) {
        final TaskRecord task = r.getTask();
        if (task.isApplicationTask()) {
            if (mCurAppTimeTracker != r.appTimeTracker) {
                // We are switching app tracking.  Complete the current one.
                if (mCurAppTimeTracker != null) {
@@ -3174,17 +3179,18 @@ public class ActivityManagerService extends IActivityManager.Stub
        // TODO: VI Maybe r.task.voiceInteractor || r.voiceInteractor != null
        // TODO: Probably not, because we don't want to resume voice on switching
        // back to this activity
        if (r.task.voiceInteractor != null) {
            startRunningVoiceLocked(r.task.voiceSession, r.info.applicationInfo.uid);
        if (task.voiceInteractor != null) {
            startRunningVoiceLocked(task.voiceSession, r.info.applicationInfo.uid);
        } else {
            finishRunningVoiceLocked();
            if (mLastResumedActivity != null) {
                final IVoiceInteractionSession session;
                if (mLastResumedActivity.task != null
                        && mLastResumedActivity.task.voiceSession != null) {
                    session = mLastResumedActivity.task.voiceSession;
                final TaskRecord lastResumedActivityTask = mLastResumedActivity.getTask();
                if (lastResumedActivityTask != null
                        && lastResumedActivityTask.voiceSession != null) {
                    session = lastResumedActivityTask.voiceSession;
                } else {
                    session = mLastResumedActivity.voiceSession;
                }
@@ -3317,7 +3323,7 @@ public class ActivityManagerService extends IActivityManager.Stub
    final void showAskCompatModeDialogLocked(ActivityRecord r) {
        Message msg = Message.obtain();
        msg.what = SHOW_COMPAT_MODE_DIALOG_UI_MSG;
        msg.obj = r.task.askedCompatMode ? null : r;
        msg.obj = r.getTask().askedCompatMode ? null : r;
        mUiHandler.sendMessage(msg);
    }
@@ -4723,7 +4729,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            if (ActivityRecord.forTokenLocked(callingActivity) != activity) {
                throw new SecurityException("Only focused activity can call startVoiceInteraction");
            }
            if (mRunningVoice != null || activity.task.voiceSession != null
            if (mRunningVoice != null || activity.getTask().voiceSession != null
                    || activity.voiceSession != null) {
                Slog.w(TAG, "Already in a voice interaction, cannot start new voice interaction");
                return;
@@ -5033,7 +5039,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                return true;
            }
            // Keep track of the root activity of the task before we finish it
            TaskRecord tr = r.task;
            TaskRecord tr = r.getTask();
            ActivityRecord rootR = tr.getRootActivity();
            if (rootR == null) {
                Slog.w(TAG, "Finishing task with all activities already finished");
@@ -5170,7 +5176,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                // Do not allow task to finish if last task in lockTask mode. Launchable priv-apps
                // can finish.
                final TaskRecord task = r.task;
                final TaskRecord task = r.getTask();
                if (task.mLockTaskAuth != LOCK_TASK_AUTH_LAUNCHABLE_PRIV &&
                        mStackSupervisor.isLastLockedTask(task) && task.getRootActivity() == r) {
                    mStackSupervisor.showLockTaskToast();
@@ -7834,7 +7840,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    return false;
                }
                // An activity is consider to be in multi-window mode if its task isn't fullscreen.
                return !r.task.mFullscreen;
                return !r.getTask().mFullscreen;
            }
        } finally {
            Binder.restoreCallingIdentity(origId);
@@ -9927,8 +9933,9 @@ public class ActivityManagerService extends IActivityManager.Stub
            ActivityRecord r = ActivityRecord.isInStackLocked(token);
            if (r != null) {
                r.setTaskDescription(td);
                r.task.updateTaskDescription();
                mTaskChangeNotificationController.notifyTaskDescriptionChanged(r.task.taskId, td);
                final TaskRecord task = r.getTask();
                task.updateTaskDescription();
                mTaskChangeNotificationController.notifyTaskDescriptionChanged(task.taskId, td);
            }
        }
    }
@@ -10378,8 +10385,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                }
                if (DEBUG_STACK) Slog.d(TAG_STACK, "exitFreeformMode: " + r);
                r.task.reparent(FULLSCREEN_WORKSPACE_STACK_ID, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT,
                        ANIMATE, !DEFER_RESUME, "exitFreeformMode");
                r.getTask().reparent(FULLSCREEN_WORKSPACE_STACK_ID, ON_TOP,
                        REPARENT_KEEP_STACK_AT_FRONT, ANIMATE, !DEFER_RESUME, "exitFreeformMode");
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
@@ -10760,7 +10767,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            if (r == null) {
                return;
            }
            final TaskRecord task = r.task;
            final TaskRecord task = r.getTask();
            if (task != null) {
                startLockTaskModeLocked(task);
            }
@@ -10859,7 +10866,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            if (r == null) {
                return;
            }
            mStackSupervisor.showLockTaskEscapeMessageLocked(r.task);
            mStackSupervisor.showLockTaskEscapeMessageLocked(r.getTask());
        }
    }
@@ -13121,9 +13128,10 @@ public class ActivityManagerService extends IActivityManager.Stub
                if (r == null) {
                    return false;
                }
                int index = r.task.mActivities.lastIndexOf(r);
                final TaskRecord task = r.getTask();
                int index = task.mActivities.lastIndexOf(r);
                if (index > 0) {
                    ActivityRecord under = r.task.mActivities.get(index - 1);
                    ActivityRecord under = task.mActivities.get(index - 1);
                    under.returningOptions = ActivityOptions.fromBundle(options);
                }
                final boolean translucentChanged = r.changeWindowTranslucency(false);
@@ -13410,7 +13418,7 @@ public class ActivityManagerService extends IActivityManager.Stub
            if (r == null) {
                throw new IllegalArgumentException();
            }
            return r.task.getTopActivity() == r;
            return r.getTask().getTopActivity() == r;
        }
    }
@@ -15928,8 +15936,9 @@ public class ActivityManagerService extends IActivityManager.Stub
            }
            needSep = true;
            synchronized (this) {
                if (lastTask != r.task) {
                    lastTask = r.task;
                final TaskRecord task = r.getTask();
                if (lastTask != task) {
                    lastTask = task;
                    pw.print("TASK "); pw.print(lastTask.affinity);
                            pw.print(" id="); pw.print(lastTask.taskId);
                            pw.print(" userId="); pw.println(lastTask.userId);
@@ -20561,8 +20570,9 @@ public class ActivityManagerService extends IActivityManager.Stub
                    app.cached = false;
                    app.empty = false;
                    foregroundActivities = true;
                    if (r.task != null && minLayer > 0) {
                        final int layer = r.task.mLayerRank;
                    final TaskRecord task = r.getTask();
                    if (task != null && minLayer > 0) {
                        final int layer = task.mLayerRank;
                        if (layer >= 0 && minLayer > layer) {
                            minLayer = layer;
                        }
+42 −3
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
    private int theme;              // resource identifier of activity's theme.
    private int realTheme;          // actual theme resource we will use, never 0.
    private int windowFlags;        // custom window flags for preview window.
    TaskRecord task;        // the task this is in.
    private TaskRecord task;        // the task this is in.
    private long createTime = System.currentTimeMillis();
    long displayStartTime;  // when we started launching this activity
    long fullyDrawnStartTime; // when we started launching this activity
@@ -686,9 +686,48 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo

    @Override
    protected ConfigurationContainer getParent() {
        return getTask();
    }

    TaskRecord getTask() {
        return task;
    }

    /**
     * Sets reference to the {@link TaskRecord} the {@link ActivityRecord} will treat as its parent.
     * Note that this does not actually add the {@link ActivityRecord} as a {@link TaskRecord}
     * children. However, this method will clean up references to this {@link ActivityRecord} in
     * {@link ActivityStack}.
     * @param task The new parent {@link TaskRecord}.
     */
    void setTask(TaskRecord task) {
        setTask(task, false /*reparenting*/);
    }

    /**
     * This method should only be called by {@link TaskRecord#removeActivity(ActivityRecord)}.
     */
    void setTask(TaskRecord task, boolean reparenting) {
        // Do nothing if the {@link TaskRecord} is the same as the current {@link getTask}.
        if (task != null && task == getTask()) {
            return;
        }

        final ActivityStack stack = getStack();

        // If the new {@link TaskRecord} is from a different {@link ActivityStack}, remove this
        // {@link ActivityRecord} from its current {@link ActivityStack}.
        if (!reparenting && stack != null && (task == null || stack != task.getStack())) {
            stack.onActivityRemovedFromStack(this);
        }

        this.task = task;

        if (!reparenting) {
            onParentChanged();
        }
    }

    static class Token extends IApplicationToken.Stub {
        private final WeakReference<ActivityRecord> weakActivity;

@@ -925,8 +964,8 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
        // Must reparent first in window manager
        mWindowContainerController.reparent(newTask.getWindowContainerController(), position);

        // Remove the activity from the old task and add it to the new task
        prevTask.removeActivity(this);
        // Remove the activity from the old task and add it to the new task.
        prevTask.removeActivity(this, true /*reparenting*/);

        newTask.addActivityAtIndex(position, this);
    }
Loading