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

Commit 0812325d authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Add log about adding hidden task

When adding task with the same affinity of another existing task
to recents list, the old task may be trimmed. The log will help
to know where the replacing task comes from.

Also fix potential wrong info of Task#toString that some states
are not constant which shouldn't be cached.

Bug: 169507045
Test: Launch multiple activities with the same task affinity
      and flags NEW_TASK | MULTIPLE_TASK.
Change-Id: I712f0c617d31822c7a4828d740d27677ff7e9d52
parent 8c828565
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1496,6 +1496,7 @@ class RecentTasks {
        final Task removedTask = mTasks.remove(removeIndex);
        if (removedTask != task) {
            if (removedTask.hasChild()) {
                Slog.i(TAG, "Add " + removedTask + " to hidden list because adding " + task);
                // A non-empty task is replaced by a new task. Because the removed task is no longer
                // managed by the recent tasks list, add it to the hidden list to prevent the task
                // from becoming dangling.
+11 −8
Original line number Diff line number Diff line
@@ -4451,8 +4451,17 @@ class Task extends WindowContainer<WindowContainer> {
            sb.append(stringName);
            sb.append(" U=");
            sb.append(mUserId);
            sb.append(" StackId=");
            sb.append(getRootTaskId());
            final Task rootTask = getRootTask();
            if (rootTask != this) {
                sb.append(" rootTaskId=");
                sb.append(rootTask.mTaskId);
            }
            sb.append(" visible=");
            sb.append(shouldBeVisible(null /* starting */));
            sb.append(" mode=");
            sb.append(windowingModeToString(getWindowingMode()));
            sb.append(" translucent=");
            sb.append(isTranslucent(null /* starting */));
            sb.append(" sz=");
            sb.append(getChildCount());
            sb.append('}');
@@ -4462,10 +4471,7 @@ class Task extends WindowContainer<WindowContainer> {
        sb.append(Integer.toHexString(System.identityHashCode(this)));
        sb.append(" #");
        sb.append(mTaskId);
        sb.append(" visible=" + shouldBeVisible(null /* starting */));
        sb.append(" type=" + activityTypeToString(getActivityType()));
        sb.append(" mode=" + windowingModeToString(getWindowingMode()));
        sb.append(" translucent=" + isTranslucent(null /* starting */));
        if (affinity != null) {
            sb.append(" A=");
            sb.append(affinity);
@@ -5188,9 +5194,6 @@ class Task extends WindowContainer<WindowContainer> {

    @Override
    public void setWindowingMode(int windowingMode) {
        // Reset the cached result of toString()
        stringName = null;

        // Calling Task#setWindowingMode() for leaf task since this is the a specialization of
        // {@link #setWindowingMode(int)} for ActivityStack.
        if (!isRootTask()) {