Fix an NPE on overflow in BatteryStats history.

When the battery stats buffer hits 128KB, it hits a code path
that causes an NPE. This can happen depending on usage and charging
patterns and manifest in bad ways, such as failure to boot up
or random crashes, or refusing to go to sleep.

Bug: 5645407
Change-Id: I21d5d189431f776f25bcb7d598c86e598ad8cb17
1 file changed