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

Commit bb2af291 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Deal gracefully with cancel of nonexistent jobs"

parents 675600bd 19a2f24e
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1052,13 +1052,18 @@ public final class JobStore {
            final ArraySet<JobStatus> jobs = mJobs.get(uid);
            final int sourceUid = job.getSourceUid();
            final ArraySet<JobStatus> jobsForSourceUid = mJobsPerSourceUid.get(sourceUid);
            boolean didRemove = jobs != null && jobs.remove(job) && jobsForSourceUid.remove(job);
            if (didRemove) {
                if (jobs.size() == 0) {
                    // no more jobs for this uid; let the now-empty set object be GC'd.
            final boolean didRemove = jobs != null && jobs.remove(job);
            final boolean sourceRemove = jobsForSourceUid != null && jobsForSourceUid.remove(job);
            if (didRemove != sourceRemove) {
                Slog.wtf(TAG, "Job presence mismatch; caller=" + didRemove
                        + " source=" + sourceRemove);
            }
            if (didRemove || sourceRemove) {
                // no more jobs for this uid?  let the now-empty set objects be GC'd.
                if (jobs != null && jobs.size() == 0) {
                    mJobs.remove(uid);
                }
                if (jobsForSourceUid.size() == 0) {
                if (jobsForSourceUid != null && jobsForSourceUid.size() == 0) {
                    mJobsPerSourceUid.remove(sourceUid);
                }
                return true;