Skip to content
Commit 03ad13e5 authored by Kelly Rossmoyer's avatar Kelly Rossmoyer
Browse files

Increase size of BatteryStatsService stats buffer

Increases the size of the buffer used to return data from JNI call to
PowerHAL::getSubsystemLowPowerStats() from 512 bytes to 2048 bytes.

As a rough calculation, the substring for a single subsystem sleep state
will typically fit within ~105 characters, such as:
  "subsystem_2 name=Citadel state_1 name=Sleep time=99999999999
   count=99999999999 last entry=99999999999 "

Those numerical values work out to ~1157 days, so while the underlying
data type can hold values larger than that, it seems like a reasonable
basis for capacity estimation.

Most currently known state names are either "Sleep" or "Deep-Sleep", and
"Citadel" and "DISPLAY" are the longest currently known subsystem names,
with the others more typically 3 or 4 characters long.

There are up to 7 masters that each export data for a single sleep state
and 4 currently anticipated subsystems that will probably each export
data for 2 sleep states, which works out to 15 known/expected sleep
states, which works out to 1575 characters.  Add ~45 more chars for the
header string at the beginning of the output:
  ",SubsystemPowerState SubsystemPowerState "

And that leaves ~428 spare bytes from an allocation of 2048, which is
enough to allow 4 more sleep states or 3 more and a slightly higher
average number of characters per state.

Test: Ran along with ag/3718639 code that implements 2018 PowerHAL
low power stats, took a bugreport, and verified that truncation was
addressed.
Test: Calculated capacity of new buffer size to verify expected output
will fit with some spare room left over.
Bug:74594445

Change-Id: I5919388ada1c47b11e594582691e0faf1575faaa
parent ed9ee780
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment