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

Commit 6771d0cd authored by Eunae Kim's avatar Eunae Kim Committed by Steve Kondik
Browse files

Fix a bug that the RecentTask list of other’s may show up to non-primary users.



When switching to a newly created user, the user may face this bug when he opens the RecentTask screen.
A possible bug scenario is described as follows:
A user id of a removed user may be recycled when created a new user.
However, mRecentTasks is not correctly controlled so that old information may still remain and be possibly mapped to wrong user.
This patch prevents this bug by explicitly removing old information in mRecentTasks when removing existing user.

Change-Id: I1874dbd604598a5d740ae1e034981e21214c15c6
Signed-off-by: default avatarEunae Kim <eunae.kim@lge.com>
parent afbd0aa9
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -3426,6 +3426,24 @@ public final class ActivityManagerService extends ActivityManagerNative
        return ret;
        return ret;
    }
    }
    //explicitly remove thd old information in mRecentTasks when removing existing user.
    private void removeRecentTaskLocked(int userId) {
        if(userId <= 0) {
            Slog.i(TAG, "Can't remove recent task on user " + userId);
            return;
        }
        for (int i = mRecentTasks.size() - 1; i >= 0; --i) {
            TaskRecord tr = mRecentTasks.get(i);
            if (tr.userId == userId) {
                if(DEBUG_TASKS) Slog.i(TAG, "remove RecentTask " + tr
                                          + " when finishing user" + userId);
                tr.disposeThumbnail();
                mRecentTasks.remove(i);
            }
        }
    }
    final void addRecentTaskLocked(TaskRecord task) {
    final void addRecentTaskLocked(TaskRecord task) {
        int N = mRecentTasks.size();
        int N = mRecentTasks.size();
        // Quick case: check if the top-most recent task is the same.
        // Quick case: check if the top-most recent task is the same.
@@ -16631,6 +16649,8 @@ public final class ActivityManagerService extends ActivityManagerNative
                // Kill all the processes for the user.
                // Kill all the processes for the user.
                forceStopUserLocked(userId, "finish user");
                forceStopUserLocked(userId, "finish user");
            }
            }
            //explicitly remove the old information in mRecentTasks when removing existing user.
            removeRecentTaskLocked(userId);
        }
        }
        for (int i=0; i<callbacks.size(); i++) {
        for (int i=0; i<callbacks.size(); i++) {