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

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

Merge "BackgroundDexOptService: skip low battery check if not present"

parents 85ef115e 1cd7cc85
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -146,6 +146,12 @@ public class BackgroundDexOptService extends JobService {
        Intent intent = registerReceiver(null, filter);
        int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
        int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
        boolean present = intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, true);

        if (!present) {
            // No battery, treat as if 100%, no possibility of draining battery.
            return 100;
        }

        if (level < 0 || scale <= 0) {
            // Battery data unavailable. This should never happen, so assume the worst.