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
This commit is contained in:
Kweku Adams
2021-07-20 07:33:54 -07:00
parent 7efcc4dfc7
commit 8d3c8782c1

View File

@@ -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.