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

Commit e099571e authored by wilsonshih's avatar wilsonshih
Browse files

Remove task thumbnail from cache when receiving onRecentTaskRemoved(1/2)

This is necessary because the original task is removed when launching a
new task.

Bug: 432199332
Flag: EXEMPT Bugfix
Test: dump heap memory after launch new task, verify the thumbnail of
removed task will be removed.

Change-Id: I122a1e4c7eaefec9d1c7c1eb0a05d728f6f9e064
parent f5b74ac9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -114,4 +114,10 @@ public interface TaskStackChangeListener {
     * LockTaskController.
     */
    default void onLockTaskModeChanged(int mode) { }

    /**
     * Called when a task is removed due to launching a new task. This normally means the previous
     * task is being replaced with a new one.
     */
    default void onRecentTaskRemovedForAddTask(int taskId) { }
}
+12 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ public class TaskStackChangeListeners {
        private static final int ON_ACTIVITY_ROTATION = 22;
        private static final int ON_LOCK_TASK_MODE_CHANGED = 23;
        private static final int ON_TASK_SNAPSHOT_INVALIDATED = 24;
        private static final int ON_RECENTS_TASK_REMOVED_FOR_ADD_TASK = 25;

        /**
         * List of {@link TaskStackChangeListener} registered from {@link #addListener}.
@@ -283,6 +284,11 @@ public class TaskStackChangeListeners {
            mHandler.obtainMessage(ON_TASK_CREATED, taskId, 0, componentName).sendToTarget();
        }

        @Override
        public void onRecentTaskRemovedForAddTask(int taskId) {
            mHandler.obtainMessage(ON_RECENTS_TASK_REMOVED_FOR_ADD_TASK, taskId, 0).sendToTarget();
        }

        @Override
        public void onTaskRemoved(int taskId) {
            mHandler.obtainMessage(ON_TASK_REMOVED, taskId, 0).sendToTarget();
@@ -512,6 +518,12 @@ public class TaskStackChangeListeners {
                        Trace.endSection();
                        break;
                    }
                    case ON_RECENTS_TASK_REMOVED_FOR_ADD_TASK: {
                        for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
                            mTaskStackListeners.get(i).onRecentTaskRemovedForAddTask(msg.arg1);
                        }
                        break;
                    }
                }
            }
            if (msg.obj instanceof SomeArgs) {