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

Commit 4b3d425b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE that occurs after battery reset" into main

parents 0b34ec06 8a81174d
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStat
    private int mScreenState;

    @GuardedBy("this")
    private int[] mPerDisplayScreenStates = null;
    private int[] mPerDisplayScreenStates;

    @GuardedBy("this")
    private boolean mUseLatestStates = true;
@@ -243,6 +243,7 @@ public class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStat
            }
            synchronized (mStats) {
                mStats.initEnergyConsumerStatsLocked(supportedStdBuckets, customBucketNames);
                mPerDisplayScreenStates = new int[mStats.getDisplayCount()];
            }
        }
    }
@@ -490,6 +491,12 @@ public class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStat
                                onBatteryScreenOff, screenState, displayScreenStates,
                                useLatestStates);
                    } finally {
                        if ((updateFlags & UPDATE_ALL) == UPDATE_ALL) {
                            synchronized (mStats) {
                                // This helps mStats deal with ignoring data from prior to resets.
                                mStats.informThatAllExternalStatsAreFlushed();
                            }
                        }
                        if (DEBUG) {
                            Slog.d(TAG, "end updateExternalStatsSync");
                        }
@@ -767,7 +774,6 @@ public class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStat

        // WiFi and Modem state are updated without the mStats lock held, because they
        // do some network stats retrieval before internally grabbing the mStats lock.

        if (wifiInfo != null) {
            if (wifiInfo.isValid()) {
                final long wifiChargeUC =
@@ -790,11 +796,6 @@ public class BatteryExternalStatsWorker implements BatteryStatsImpl.ExternalStat
            mStats.noteModemControllerActivity(modemInfo, mobileRadioChargeUC, elapsedRealtime,
                    uptime, networkStatsManager);
        }

        if ((updateFlags & UPDATE_ALL) == UPDATE_ALL) {
            // This helps mStats deal with ignoring data from prior to resets.
            mStats.informThatAllExternalStatsAreFlushed();
        }
    }

    /**