Merge "Skip cursor loader if not needed"
This commit is contained in:
committed by
Android (Google) Code Review
commit
b287dc93d5
@@ -113,7 +113,8 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
|
||||
@VisibleForTesting
|
||||
static final int ANOMALY_LOADER = 1;
|
||||
private static final int BATTERY_ESTIMATE_LOADER = 2;
|
||||
@VisibleForTesting
|
||||
static final int BATTERY_ESTIMATE_LOADER = 2;
|
||||
private static final int MENU_STATS_TYPE = Menu.FIRST;
|
||||
@VisibleForTesting
|
||||
static final int MENU_HIGH_POWER_APPS = Menu.FIRST + 3;
|
||||
@@ -182,6 +183,7 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) {
|
||||
final Uri queryUri = mPowerFeatureProvider.getEnhancedBatteryPredictionUri();
|
||||
|
||||
return new CursorLoader(getContext(), queryUri, null, null, null, null);
|
||||
}
|
||||
|
||||
@@ -228,10 +230,7 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
mAnomalySparseArray = new SparseArray<>();
|
||||
|
||||
initFeatureProvider();
|
||||
if (mPowerFeatureProvider != null) {
|
||||
getLoaderManager().initLoader(BATTERY_ESTIMATE_LOADER, Bundle.EMPTY,
|
||||
mBatteryPredictionLoaderCallbacks);
|
||||
}
|
||||
initializeBatteryEstimateLoader();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -815,6 +814,15 @@ public class PowerUsageSummary extends PowerUsageBase implements
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void initializeBatteryEstimateLoader() {
|
||||
if (mPowerFeatureProvider != null
|
||||
&& mPowerFeatureProvider.isEnhancedBatteryPredictionEnabled(getContext())) {
|
||||
getLoaderManager().initLoader(BATTERY_ESTIMATE_LOADER, Bundle.EMPTY,
|
||||
mBatteryPredictionLoaderCallbacks);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<BatterySipper> getFakeStats() {
|
||||
ArrayList<BatterySipper> stats = new ArrayList<>();
|
||||
float use = 5;
|
||||
|
Reference in New Issue
Block a user