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

Commit 66f8ae70 authored by Kweku Adams's avatar Kweku Adams
Browse files

Rename JobStore method and parameter.

Renaming the method and parameter to make it clearer what the method
does.

Bug: 141645789
Bug: 162432774
Test: atest JobSetTest
Change-Id: I2580870f3e69fd967039f9d5eac67030a05249e6
parent c47d6cdf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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());
        }
    }

+9 −10
Original line number Diff line number Diff line
@@ -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));
        }

+2 −2
Original line number Diff line number Diff line
@@ -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);
    }