Loading apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -1193,7 +1193,7 @@ public class JobSchedulerService extends com.android.server.SystemService private void cancelJobsForNonExistentUsers() { UserManagerInternal umi = LocalServices.getService(UserManagerInternal.class); synchronized (mLock) { mJobs.removeJobsOfNonUsers(umi.getUserIds()); mJobs.removeJobsOfUnlistedUsers(umi.getUserIds()); } } Loading apex/jobscheduler/service/java/com/android/server/job/JobStore.java +9 −10 Original line number Diff line number Diff line Loading @@ -254,11 +254,11 @@ public final class JobStore { } /** * Remove the jobs of users not specified in the whitelist. * @param whitelist Array of User IDs whose jobs are not to be removed. * Remove the jobs of users not specified in the keepUserIds. * @param keepUserIds Array of User IDs whose jobs should be kept and not removed. */ public void removeJobsOfNonUsers(int[] whitelist) { mJobSet.removeJobsOfNonUsers(whitelist); public void removeJobsOfUnlistedUsers(int[] keepUserIds) { mJobSet.removeJobsOfUnlistedUsers(keepUserIds); } @VisibleForTesting Loading Loading @@ -1151,15 +1151,14 @@ public final class JobStore { } /** * Removes the jobs of all users not specified by the whitelist of user ids. * This will remove jobs scheduled *by* non-existent users as well as jobs scheduled *for* * non-existent users * Removes the jobs of all users not specified by the keepUserIds of user ids. * This will remove jobs scheduled *by* and *for* any unlisted users. */ public void removeJobsOfNonUsers(final int[] whitelist) { public void removeJobsOfUnlistedUsers(final int[] keepUserIds) { final Predicate<JobStatus> noSourceUser = job -> !ArrayUtils.contains(whitelist, job.getSourceUserId()); job -> !ArrayUtils.contains(keepUserIds, job.getSourceUserId()); final Predicate<JobStatus> noCallingUser = job -> !ArrayUtils.contains(whitelist, job.getUserId()); job -> !ArrayUtils.contains(keepUserIds, job.getUserId()); removeAll(noSourceUser.or(noCallingUser)); } Loading services/tests/servicestests/src/com/android/server/job/JobSetTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -97,9 +97,9 @@ public class JobSetTest { mJobSet.remove(testJob1); mJobSet.remove(testJob2); assertHaveSameJobs(mJobSet.mJobsPerSourceUid, mJobSet.mJobs); mJobSet.removeJobsOfNonUsers(new int[] {mContext.getUserId(), SECONDARY_USER_ID_1}); mJobSet.removeJobsOfUnlistedUsers(new int[] {mContext.getUserId(), SECONDARY_USER_ID_1}); assertHaveSameJobs(mJobSet.mJobsPerSourceUid, mJobSet.mJobs); mJobSet.removeJobsOfNonUsers(new int[] {mContext.getUserId()}); mJobSet.removeJobsOfUnlistedUsers(new int[] {mContext.getUserId()}); assertTrue("mJobs should be empty", mJobSet.mJobs.size() == 0); assertTrue("mJobsPerSourceUid should be empty", mJobSet.mJobsPerSourceUid.size() == 0); } Loading Loading
apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -1193,7 +1193,7 @@ public class JobSchedulerService extends com.android.server.SystemService private void cancelJobsForNonExistentUsers() { UserManagerInternal umi = LocalServices.getService(UserManagerInternal.class); synchronized (mLock) { mJobs.removeJobsOfNonUsers(umi.getUserIds()); mJobs.removeJobsOfUnlistedUsers(umi.getUserIds()); } } Loading
apex/jobscheduler/service/java/com/android/server/job/JobStore.java +9 −10 Original line number Diff line number Diff line Loading @@ -254,11 +254,11 @@ public final class JobStore { } /** * Remove the jobs of users not specified in the whitelist. * @param whitelist Array of User IDs whose jobs are not to be removed. * Remove the jobs of users not specified in the keepUserIds. * @param keepUserIds Array of User IDs whose jobs should be kept and not removed. */ public void removeJobsOfNonUsers(int[] whitelist) { mJobSet.removeJobsOfNonUsers(whitelist); public void removeJobsOfUnlistedUsers(int[] keepUserIds) { mJobSet.removeJobsOfUnlistedUsers(keepUserIds); } @VisibleForTesting Loading Loading @@ -1151,15 +1151,14 @@ public final class JobStore { } /** * Removes the jobs of all users not specified by the whitelist of user ids. * This will remove jobs scheduled *by* non-existent users as well as jobs scheduled *for* * non-existent users * Removes the jobs of all users not specified by the keepUserIds of user ids. * This will remove jobs scheduled *by* and *for* any unlisted users. */ public void removeJobsOfNonUsers(final int[] whitelist) { public void removeJobsOfUnlistedUsers(final int[] keepUserIds) { final Predicate<JobStatus> noSourceUser = job -> !ArrayUtils.contains(whitelist, job.getSourceUserId()); job -> !ArrayUtils.contains(keepUserIds, job.getSourceUserId()); final Predicate<JobStatus> noCallingUser = job -> !ArrayUtils.contains(whitelist, job.getUserId()); job -> !ArrayUtils.contains(keepUserIds, job.getUserId()); removeAll(noSourceUser.or(noCallingUser)); } Loading
services/tests/servicestests/src/com/android/server/job/JobSetTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -97,9 +97,9 @@ public class JobSetTest { mJobSet.remove(testJob1); mJobSet.remove(testJob2); assertHaveSameJobs(mJobSet.mJobsPerSourceUid, mJobSet.mJobs); mJobSet.removeJobsOfNonUsers(new int[] {mContext.getUserId(), SECONDARY_USER_ID_1}); mJobSet.removeJobsOfUnlistedUsers(new int[] {mContext.getUserId(), SECONDARY_USER_ID_1}); assertHaveSameJobs(mJobSet.mJobsPerSourceUid, mJobSet.mJobs); mJobSet.removeJobsOfNonUsers(new int[] {mContext.getUserId()}); mJobSet.removeJobsOfUnlistedUsers(new int[] {mContext.getUserId()}); assertTrue("mJobs should be empty", mJobSet.mJobs.size() == 0); assertTrue("mJobsPerSourceUid should be empty", mJobSet.mJobsPerSourceUid.size() == 0); } Loading