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

Commit 93a5d636 authored by jinchul.kim's avatar jinchul.kim Committed by Steve Kondik
Browse files

Trim task thumbnail within MAX_RECENT_BITMAPS.

Task thumbnails can be hold as much as length of mRecentTasks because
freeLastThumbnail only works when any task is added and it might cause
the system heavy.

Free lastThumbnail when it reuses exist taskRecord also to keep
thumbnails within MAX_RECENT_BITMAPS.

Change-Id: I932a16c20acb3d8ead2a238ba221a0fa19484b9a
parent 44c8c5b7
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -4209,6 +4209,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        if (task.inRecents) {
            int taskIndex = mRecentTasks.indexOf(task);
            if (taskIndex >= 0) {
                trimRecentBitmaps();
                if (!isAffiliated) {
                    // Simple case: this is not an affiliated task, so we just move it to the front.
                    mRecentTasks.remove(taskIndex);
@@ -4301,6 +4302,16 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    void trimRecentBitmaps() {
        int N = mRecentTasks.size();
        for (int i = 0; i < N; i++) {
            final TaskRecord tr = mRecentTasks.get(i);
            if (i > MAX_RECENT_BITMAPS) {
                tr.freeLastThumbnail();
            }
        }
    }
    /**
     * If needed, remove oldest existing entries in recents that are for the same kind
     * of task as the given one.