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

Commit b6d0af35 authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Fix NPE caused by a null battery history tag

Bug: 206823946
Test: atest CtsDumpsysHostTestCases:BatteryStatsDumpsysTest
Change-Id: I7a5d70137608bf80ec8a0ca4ee161a42a0d96f95
parent e7b54abe
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -7354,9 +7354,11 @@ public abstract class BatteryStats implements Parcelable {
                        pw.print(getHistoryTagPoolUid(i));
                        pw.print(",\"");
                        String str = getHistoryTagPoolString(i);
                        if (str != null) {
                            str = str.replace("\\", "\\\\");
                            str = str.replace("\"", "\\\"");
                            pw.print(str);
                        }
                        pw.print("\"");
                        pw.println();
                    }
+4 −0
Original line number Diff line number Diff line
@@ -3522,6 +3522,10 @@ public class BatteryStatsImpl extends BatteryStats {
     * <code>(index | TAG_FIRST_OCCURRENCE_FLAG)</code>
     */
    private int writeHistoryTag(HistoryTag tag) {
        if (tag.string == null) {
            Slog.wtfStack(TAG, "writeHistoryTag called with null name");
        }
        Integer idxObj = mHistoryTagPool.get(tag);
        int idx;
        if (idxObj != null) {