Make BatterySettings Asynchronous and use enhanced estimate
this CL changes BatteryInfo methods to all use the async style callback approach it had for one of the methods. Non-async methods are now annotated to only be used in worker threads. BatteryInfo can now be obtained via callback by calling one of the async methods. Alternatively if there is a worker thread available the synchronous methods similar to the old ones can be used. The callback methods have all been changed so that they cascade to a async method that takes all the required info as paremeters. This will minimize the amount of churn in files that currently use BatteryInfo. A new loader was created that can be used to get BatteryInfo in places that wish to get it. This loader is used in PowerUsageSummary to get the BatteryInfo. Test: Robotests Bug: 38399275 Bug: 38398949 Bug: 38399654 Change-Id: Ic5a82d8ca4c85fad1b883226327ec083badf861d
This commit is contained in:
@@ -438,24 +438,6 @@ public class PowerUsageSummaryTest {
|
||||
assertThat(mFragment.mAnomalySparseArray.get(UID_2)).containsExactly(anomaly3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatteryPredictionLoaderCallbacks_DoesNotCrashOnNull() {
|
||||
// Sanity test to check for crash
|
||||
mFragment.mBatteryPredictionLoaderCallbacks.onLoadFinished(null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnCreate_BatteryPredictionSkippedWhenDisabled() {
|
||||
PowerUsageFeatureProvider provider = mFeatureFactory.getPowerUsageFeatureProvider(mContext);
|
||||
when(provider.isEnhancedBatteryPredictionEnabled(any())).thenReturn(false);
|
||||
mFragment.mPowerFeatureProvider = provider;
|
||||
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
|
||||
mFragment.initializeBatteryEstimateLoader();
|
||||
|
||||
verify(mLoaderManager, never()).initLoader(eq(PowerUsageSummary.BATTERY_ESTIMATE_LOADER),
|
||||
eq(Bundle.EMPTY), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitAnomalyDetectionIfPossible_detectionEnabled_init() {
|
||||
when(mFeatureFactory.powerUsageFeatureProvider.isAnomalyDetectionEnabled()).thenReturn(
|
||||
|
Reference in New Issue
Block a user