Export BatteryStats state bitmaps to ATrace

This uses logic similar to printBitDescriptions to parse the state
bitmask along with the BitDescriptions to report the information as
a trace counter.

Due to current tracing limitations, values are not remembered outside of
or between tracing. For slow moving things (like wifi enabled/disabled),
we would miss the counter in most traces if using `traceCounter` alone.
The Perfetto team's current solution is to read system properties when
the trace starts in order to fill in the initial value. To limit the
impact of this, this aspect is only enabled in userdebug.

Bug: 245749764
Test: presubmit and local perfetto tracing
Change-Id: Iaae4e9796a44be3ffdaee31b956bbb3e87735ead
2 files changed