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

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
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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,9 +119,11 @@ 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);
            }
        }
    }

    /**
     * Idle state tracking, and messaging with the task manager when