@@ -4665,14 +4665,26 @@ public boolean clearApplicationUserData(final String packageName,
46654665 + android.Manifest.permission.CLEAR_APP_USER_DATA + " to clear data"
46664666 + " of package " + packageName);
46674667 }
4668+
4669+ // Remove all tasks match the cleared application package and user
4670+ for (int i = mRecentTasks.size() - 1; i >= 0; i--) {
4671+ final TaskRecord tr = mRecentTasks.get(i);
4672+ final String taskPackageName =
4673+ tr.getBaseIntent().getComponent().getPackageName();
4674+ if (tr.userId != userId) continue;
4675+ if (!taskPackageName.equals(packageName)) continue;
4676+ removeTaskByIdLocked(tr.taskId, 0);
4677+ }
46684678 }
46694679
46704680 try {
46714681 // Clear application user data
46724682 pm.clearApplicationUserData(packageName, observer, userId);
46734683
4674- // Remove all permissions granted from/to this package
4675- removeUriPermissionsForPackageLocked(packageName, userId, true);
4684+ synchronized(this) {
4685+ // Remove all permissions granted from/to this package
4686+ removeUriPermissionsForPackageLocked(packageName, userId, true);
4687+ }
46764688
46774689 Intent intent = new Intent(Intent.ACTION_PACKAGE_DATA_CLEARED,
46784690 Uri.fromParts("package", packageName, null));
@@ -7410,7 +7422,7 @@ public List<IAppTask> getAppTasks() {
74107422 final int N = mRecentTasks.size();
74117423 for (int i = 0; i < N; i++) {
74127424 TaskRecord tr = mRecentTasks.get(i);
7413- // Skip tasks that are not created by the caller
7425+ // Skip tasks that do not match the package name
74147426 if (packages.contains(tr.getBaseIntent().getComponent().getPackageName())) {
74157427 ActivityManager.RecentTaskInfo taskInfo =
74167428 createRecentTaskInfoFromTaskRecord(tr);
0 commit comments