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

Commit b3a81a1f authored by Mike Ma's avatar Mike Ma
Browse files

Fix a NPE in BatteryStatsImpl

ServiceManager.getService("batteryproperties")) may return null for some
devices right after boot. (We don't know why, need further investigation)
This causes async batterystats update to crash, leaving BatteryStats in a
bad state (OnBattery() == true, but mOnBatteryTimeBase is not running),
which does not accept aggregated stats update anymore.

Bug: 109930230
Test: manual
Change-Id: I0654beff95f0a2b9df2567f1a2efffd3330e58ff
(cherry picked from commit c6dfed1ce06c18097a81275eeeeb6e6e66d8e932)
parent 704a0d61
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -4021,7 +4021,9 @@ public class BatteryStatsImpl extends BatteryStats {
        try {
        try {
            IBatteryPropertiesRegistrar registrar = IBatteryPropertiesRegistrar.Stub.asInterface(
            IBatteryPropertiesRegistrar registrar = IBatteryPropertiesRegistrar.Stub.asInterface(
                    ServiceManager.getService("batteryproperties"));
                    ServiceManager.getService("batteryproperties"));
            if (registrar != null) {
                registrar.scheduleUpdate();
                registrar.scheduleUpdate();
            }
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            // Ignore.
            // Ignore.
        }
        }