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

Commit 0b57f310 authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Prevent crash when history event is written w/o a name

Bug: 374412790
Test: presubmit
Flag: EXEMPT_bugfix
Change-Id: I6841b6ce339592bf4aa472aa11888d126f04f625
parent b0c55e8d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1770,6 +1770,10 @@ public class BatteryStatsHistory {

    @GuardedBy("this")
    private void writeHistoryItem(long elapsedRealtimeMs, long uptimeMs, HistoryItem cur) {
        if (cur.eventCode != HistoryItem.EVENT_NONE && cur.eventTag.string == null) {
            Slog.wtfStack(TAG, "Event " + Integer.toHexString(cur.eventCode) + " without a name");
        }

        if (mTracer != null && mTracer.tracingEnabled()) {
            recordTraceEvents(cur.eventCode, cur.eventTag);
            recordTraceCounters(mTraceLastState, cur.states, STATE1_TRACE_MASK,
@@ -2266,6 +2270,7 @@ public class BatteryStatsHistory {
    private int writeHistoryTag(HistoryTag tag) {
        if (tag.string == null) {
            Slog.wtfStack(TAG, "writeHistoryTag called with null name");
            tag.string = "";
        }

        final int stringLength = tag.string.length();