From e74b0637c92542cce62ddec7acef07f853eb030a Mon Sep 17 00:00:00 2001 From: Salvador Martinez Date: Wed, 10 May 2017 17:49:51 -0700 Subject: [PATCH] Do not close cursor in onLoadFinished Apparently in cursor loaders you don't need to manually close the cursor because it does it for you at the end. doing so can also cause crashes on device configuration changes since it will call the method again with the same cursor. Test: robotests still pass Bug: 38208727 Change-Id: I285e56546daf726e74b903856b17dc034d6fd538 --- .../android/settings/fuelgauge/PowerUsageSummary.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java index b39fcfc0d9b..710c670c7f4 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java +++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java @@ -181,13 +181,9 @@ public class PowerUsageSummary extends PowerUsageBase implements if (cursor == null) { return; } - try { - if (cursor.moveToFirst()) { - mEnhancedEstimate = - mPowerFeatureProvider.getTimeRemainingEstimate(cursor); - } - } finally { - cursor.close(); + if (cursor.moveToFirst()) { + mEnhancedEstimate = + mPowerFeatureProvider.getTimeRemainingEstimate(cursor); } final long elapsedRealtimeUs = SystemClock.elapsedRealtime() * 1000; Intent batteryBroadcast = getContext().registerReceiver(null,