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

Commit a729a34a authored by Craig Mautner's avatar Craig Mautner Committed by Android (Google) Code Review
Browse files

Merge "Convert mHistory to mTaskHistory (8)"

parents a0dbf0ec aab647ed
Loading
Loading
Loading
Loading
+105 −95
Original line number Diff line number Diff line
@@ -4495,9 +4495,8 @@ final class ActivityStack {
    }

    final boolean findTaskToMoveToFrontLocked(int taskId, int flags, Bundle options) {
        for (int i = mHistory.size() - 1; i >= 0; i--) {
            ActivityRecord hr = mHistory.get(i);
            if (hr.task.taskId == taskId) {
        final TaskRecord task = mTaskIdToTaskRecord.get(taskId);
        if (mTaskHistory.contains(task)) {
            if ((flags & ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
                mUserLeaving = true;
            }
@@ -4506,10 +4505,9 @@ final class ActivityStack {
                // we'll just move the home task to the top first.
                moveHomeToFrontLocked();
            }
                moveTaskToFrontLocked(hr.task, null, options);
            moveTaskToFrontLocked(task, null, options);
            return true;
        }
        }
        return false;
    }

@@ -5074,21 +5072,20 @@ final class ActivityStack {
    ActivityRecord getTasksLocked(int maxNum, IThumbnailReceiver receiver,
            PendingThumbnailsRecord pending, List<RunningTaskInfo> list) {
        ActivityRecord topRecord = null;
        int pos = mHistory.size() - 1;
        ActivityRecord next = pos >= 0 ? mHistory.get(pos) : null;
        for (int taskNdx = mTaskHistory.size() - 1; maxNum > 0 && taskNdx >= 0;
                --maxNum, --taskNdx) {
            final TaskRecord task = mTaskHistory.get(taskNdx);
            ActivityRecord r = null;
            ActivityRecord top = null;
        TaskRecord curTask = null;
            int numActivities = 0;
            int numRunning = 0;
        while (pos >= 0 && maxNum > 0) {
            final ActivityRecord r = next;
            pos--;
            next = pos >= 0 ? mHistory.get(pos) : null;
            final ArrayList<ActivityRecord> activities = task.mActivities;
            for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                r = activities.get(activityNdx);

                // Initialize state for next task if needed.
            if (top == null || (top.state == ActivityState.INITIALIZING && top.task == r.task)) {
                if (top == null || (top.state == ActivityState.INITIALIZING)) {
                    top = r;
                curTask = r.task;
                    numActivities = numRunning = 0;
                }

@@ -5101,12 +5098,10 @@ final class ActivityStack {
                if (localLOGV) Slog.v(
                    TAG, r.intent.getComponent().flattenToShortString()
                    + ": task=" + r.task);
            }

            // If the next one is a different task, generate a new
            // TaskInfo entry for what we have.
            if (next == null || next.task != curTask) {
            RunningTaskInfo ci = new RunningTaskInfo();
                ci.id = curTask.taskId;
            ci.id = task.taskId;
            ci.baseActivity = r.intent.getComponent();
            ci.topActivity = top.intent.getComponent();
            if (top.thumbHolder != null) {
@@ -5131,20 +5126,21 @@ final class ActivityStack {
                pending.pendingRecords.add(top);
            }
            list.add(ci);
                maxNum--;
                top = null;
            }
        }
        return topRecord;
    }

    public void unhandledBackLocked() {
        int top = mHistory.size() - 1;
        final int top = mTaskHistory.size() - 1;
        if (DEBUG_SWITCH) Slog.d(
            TAG, "Performing unhandledBack(): top activity at " + top);
        if (top > 0) {
            finishActivityLocked(mHistory.get(top),
                        Activity.RESULT_CANCELED, null, "unhandled-back", true);
        if (top >= 0) {
            final ArrayList<ActivityRecord> activities = mTaskHistory.get(top).mActivities;
            int activityTop = activities.size() - 1;
            if (activityTop > 0) {
                finishActivityLocked(activities.get(activityTop), Activity.RESULT_CANCELED, null,
                        "unhandled-back", true);
            }
        }
    }

@@ -5165,32 +5161,42 @@ final class ActivityStack {

    void dumpActivitiesLocked(FileDescriptor fd, PrintWriter pw, boolean dumpAll,
            boolean dumpClient, String dumpPackage) {
        ActivityManagerService.dumpHistoryList(fd, pw, mHistory, "  ", "Hist", true, !dumpAll,
            dumpClient, dumpPackage);
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
            final TaskRecord task = mTaskHistory.get(taskNdx);
            pw.print("  Task "); pw.print(taskNdx); pw.print(": id #"); pw.println(task.taskId);
            ActivityManagerService.dumpHistoryList(fd, pw, mTaskHistory.get(taskNdx).mActivities,
                "    ", "Hist", true, !dumpAll, dumpClient, dumpPackage);
        }
    }

    ArrayList<ActivityRecord> getDumpActivitiesLocked(String name) {
        ArrayList<ActivityRecord> activities = new ArrayList<ActivityRecord>();

        if ("all".equals(name)) {
            for (ActivityRecord r1 : mHistory) {
                activities.add(r1);
            for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
                activities.addAll(mTaskHistory.get(taskNdx).mActivities);
            }
        } else if ("top".equals(name)) {
            final int N = mHistory.size();
            if (N > 0) {
                activities.add(mHistory.get(N-1));
            final int top = mTaskHistory.size() - 1;
            if (top >= 0) {
                final ArrayList<ActivityRecord> list = mTaskHistory.get(top).mActivities;
                int listTop = list.size() - 1;
                if (listTop >= 0) {
                    activities.add(list.get(listTop));
                }
            }
        } else {
            ItemMatcher matcher = new ItemMatcher();
            matcher.build(name);

            for (ActivityRecord r1 : mHistory) {
            for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
                for (ActivityRecord r1 : mTaskHistory.get(taskNdx).mActivities) {
                    if (matcher.match(r1, r1.intent.getComponent())) {
                        activities.add(r1);
                    }
                }
            }
        }

        return activities;
    }
@@ -5200,12 +5206,16 @@ final class ActivityStack {

        // All activities that came from the package must be
        // restarted as if there was a config change.
        for (int i = mHistory.size() - 1; i >= 0; i--) {
            ActivityRecord a = mHistory.get(i);
        for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
            final ArrayList<ActivityRecord> activities = mTaskHistory.get(taskNdx).mActivities;
            for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
                final ActivityRecord a = activities.get(activityNdx);
                if (a.info.packageName.equals(packageName)) {
                    a.forceNewConfig = true;
                    if (starting != null && a == starting && a.visible) {
                    a.startFreezingScreenLocked(starting.app, ActivityInfo.CONFIG_SCREEN_LAYOUT);
                        a.startFreezingScreenLocked(starting.app,
                                ActivityInfo.CONFIG_SCREEN_LAYOUT);
                    }
                }
            }
        }