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
This commit is contained in:
Salvador Martinez
2017-05-10 17:49:51 -07:00
parent 6f33a52d32
commit e74b0637c9

View File

@@ -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,