Do not cache battery stats iterator and make it safer

Avoid heap explosion in case the history parcel is corrupted.

Bug: 261622968
Test: atest FrameworksServicesTests:BatteryStatsTests
Change-Id: Ic593062b3ac40c559ec8fcdb1b7e5b9935ee147b
8 files changed