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

Commit 8d3c8782 authored by Kweku Adams's avatar Kweku Adams
Browse files

Fix charging reporting logic.

The JobStatus.set*Satisfied APIs return whether the value changed, not
the previous value. Fix BatteryController's perception and logic of the
returned value. BC ended up notifying JobSchedulerService about changes
anyway, but this now has more correct logic.

Bug: 141645789
Test: atest CtsJobSchedulerTestCases
Change-Id: I2632977f8869470416c5223574cf42d107e71128
parent 7efcc4df
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -103,14 +103,8 @@ public final class BatteryController extends RestrictingController {
        boolean reportChange = false;
        for (int i = mTrackedTasks.size() - 1; i >= 0; i--) {
            final JobStatus ts = mTrackedTasks.valueAt(i);
            boolean previous = ts.setChargingConstraintSatisfied(nowElapsed, stablePower);
            if (previous != stablePower) {
                reportChange = true;
            }
            previous = ts.setBatteryNotLowConstraintSatisfied(nowElapsed, batteryNotLow);
            if (previous != batteryNotLow) {
                reportChange = true;
            }
            reportChange |= ts.setChargingConstraintSatisfied(nowElapsed, stablePower);
            reportChange |= ts.setBatteryNotLowConstraintSatisfied(nowElapsed, batteryNotLow);
        }
        if (stablePower || batteryNotLow) {
            // If one of our conditions has been satisfied, always schedule any newly ready jobs.