Skip to content
Snippets Groups Projects
Commit a8e15e02 authored by lijilou's avatar lijilou Committed by Jilou li
Browse files

JobSchedulerService:fix arrayIndexOutOfBoundsException to aviod

systemServer crash.

As can be seen from the AOSP code, the set collection mTrackedTasks is accessed under mLock, but there is no mLock lock in the reportNewIdleState function. Therefore, we should put onControllerStateChanged into the mLock lock for execution, just like all other Controllers calling this method with mLock, there is no risk of deadlock.

Test: OEM monkey test
Bug: 342554438
Change-Id: I596defa8ca018a7161cd149a54a029f6adb96937
parent eacb2c63
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,7 @@ public final class IdleController extends RestrictingController implements Idlen
private static final String TAG = "JobScheduler.IdleController";
// Policy: we decide that we're "idle" if the device has been unused /
// screen off or dreaming or wireless charging dock idle for at least this long
@GuardedBy("mLock")
final ArraySet<JobStatus> mTrackedTasks = new ArraySet<>();
IdlenessTracker mIdleTracker;
private final FlexibilityController mFlexibilityController;
......@@ -118,8 +119,10 @@ public final class IdleController extends RestrictingController implements Idlen
for (int i = mTrackedTasks.size()-1; i >= 0; i--) {
mTrackedTasks.valueAt(i).setIdleConstraintSatisfied(nowElapsed, isIdle);
}
if (!mTrackedTasks.isEmpty()) {
mStateChangedListener.onControllerStateChanged(mTrackedTasks);
}
}
mStateChangedListener.onControllerStateChanged(mTrackedTasks);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment