Merge "Rename JobStore method and parameter."
This commit is contained in:
committed by
Android (Google) Code Review
commit
55bb763900
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user