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

Commit 33fe1ed5 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Clearing tasks along with application data. (Bug 16952119)" into lmp-dev

parents 4ebcdfdd 93baa0ed
Loading
Loading
Loading
Loading
+15 −3
Original line number Original line Diff line number Diff line
@@ -4665,14 +4665,26 @@ public final class ActivityManagerService extends ActivityManagerNative
                            + android.Manifest.permission.CLEAR_APP_USER_DATA + " to clear data"
                            + android.Manifest.permission.CLEAR_APP_USER_DATA + " to clear data"
                                    + " of package " + packageName);
                                    + " of package " + packageName);
                }
                }
                // Remove all tasks match the cleared application package and user
                for (int i = mRecentTasks.size() - 1; i >= 0; i--) {
                    final TaskRecord tr = mRecentTasks.get(i);
                    final String taskPackageName =
                            tr.getBaseIntent().getComponent().getPackageName();
                    if (tr.userId != userId) continue;
                    if (!taskPackageName.equals(packageName)) continue;
                    removeTaskByIdLocked(tr.taskId, 0);
                }
            }
            }
            try {
            try {
                // Clear application user data
                // Clear application user data
                pm.clearApplicationUserData(packageName, observer, userId);
                pm.clearApplicationUserData(packageName, observer, userId);
                synchronized(this) {
                    // Remove all permissions granted from/to this package
                    // Remove all permissions granted from/to this package
                    removeUriPermissionsForPackageLocked(packageName, userId, true);
                    removeUriPermissionsForPackageLocked(packageName, userId, true);
                }
                Intent intent = new Intent(Intent.ACTION_PACKAGE_DATA_CLEARED,
                Intent intent = new Intent(Intent.ACTION_PACKAGE_DATA_CLEARED,
                        Uri.fromParts("package", packageName, null));
                        Uri.fromParts("package", packageName, null));
@@ -7410,7 +7422,7 @@ public final class ActivityManagerService extends ActivityManagerNative
                final int N = mRecentTasks.size();
                final int N = mRecentTasks.size();
                for (int i = 0; i < N; i++) {
                for (int i = 0; i < N; i++) {
                    TaskRecord tr = mRecentTasks.get(i);
                    TaskRecord tr = mRecentTasks.get(i);
                    // Skip tasks that are not created by the caller
                    // Skip tasks that do not match the package name
                    if (packages.contains(tr.getBaseIntent().getComponent().getPackageName())) {
                    if (packages.contains(tr.getBaseIntent().getComponent().getPackageName())) {
                        ActivityManager.RecentTaskInfo taskInfo =
                        ActivityManager.RecentTaskInfo taskInfo =
                                createRecentTaskInfoFromTaskRecord(tr);
                                createRecentTaskInfoFromTaskRecord(tr);