OSDN Git Service

Increase size of BatteryStatsService stats buffer
authorKelly Rossmoyer <krossmo@google.com>
Tue, 13 Mar 2018 20:10:14 +0000 (13:10 -0700)
committerKelly Rossmoyer <krossmo@google.com>
Tue, 13 Mar 2018 20:10:14 +0000 (13:10 -0700)
commit03ad13e587962ad2cadb81df759afca3e7d15dab
treec24a705efc572559ab0b20b0ea296be4b9ab9e8b
parented9ee780a4f2bd1ebf2a00bfef3edbfd66b9f604
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
services/core/java/com/android/server/am/BatteryStatsService.java