Synchronize access to BatteryStatsHistory

This CL closes an overlooked concurrency issue, namely that when
we create a copy of BH we clone the buffer Parcel inside. If the
parcel is resized, especially relocated, during this operation,
we get a disastrous crash.

Bug: 320475371
Test: atest PowerStatsTests
Change-Id: Ied409ea5cd7d083c2f191604530f52dc48999bf1
4 files changed