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

Cherry-pick from aosp to lmp-dev.

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: Eunae Kim <eunae.kim@lge.com>

Conflicts:
	services/java/com/android/server/am/ActivityManagerService.java
This commit is contained in:
Eunae Kim
2014-07-25 09:16:13 +09:00
committed by Craig Mautner
parent 214be42ea6
commit ad3aa32fee

View File

@@ -3638,6 +3638,27 @@ public final class ActivityManagerService extends ActivityManagerNative
return ret;
}
//explicitly remove thd old information in mRecentTasks when removing existing user.
private void removeRecentTasksForUser(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);
}
}
// Remove tasks from persistent storage.
mTaskPersister.wakeup(null, true);
}
final void addRecentTaskLocked(TaskRecord task) {
int N = mRecentTasks.size();
// Quick case: check if the top-most recent task is the same.
@@ -17642,6 +17663,9 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
// Explicitly remove the old information in mRecentTasks.
removeRecentTasksForUser(userId);
for (int i=0; i<callbacks.size(); i++) {
try {
if (stopped) callbacks.get(i).userStopped(userId);