Close InputStream in BatteryStatsHelper
Bug: 17760659
Bug: 27376093
Change-Id: I5e6471f73b3258067fb670a4b66ddc51be62b6ec
(cherry picked from commit e618b53081d9a173305b7c72cab4c2ed6ca2dcec)
diff --git a/core/java/com/android/internal/os/BatteryStatsHelper.java b/core/java/com/android/internal/os/BatteryStatsHelper.java
index f178c8c..1b52146 100644
--- a/core/java/com/android/internal/os/BatteryStatsHelper.java
+++ b/core/java/com/android/internal/os/BatteryStatsHelper.java
@@ -754,8 +754,7 @@
try {
ParcelFileDescriptor pfd = service.getStatisticsStream();
if (pfd != null) {
- FileInputStream fis = new ParcelFileDescriptor.AutoCloseInputStream(pfd);
- try {
+ try (FileInputStream fis = new ParcelFileDescriptor.AutoCloseInputStream(pfd)) {
byte[] data = readFully(fis, MemoryFile.getSize(pfd.getFileDescriptor()));
Parcel parcel = Parcel.obtain();
parcel.unmarshall(data, 0, data.length);