Force update all suggestions but app restriction
When there is configuration change(icicle is not null), still force update all suggestion except app restriction. App restriction is not stateless: state HANDLED only happens when there is anomaly and it disappear in next cycle. So we should only update it when necessary. Change-Id: Ifb7a1c477962a0c78b5455a5fbc078590fd408f2 Fixes: 77973093 Test: RunSettingsRoboTests
This commit is contained in:
@@ -49,6 +49,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.fuelgauge.anomaly.Anomaly;
|
||||
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.XmlTestUtils;
|
||||
@@ -187,7 +188,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateLastFullChargePreference_noAverageTime_showLastFullChargeSummary() {
|
||||
public void updateLastFullChargePreference_noAverageTime_showLastFullChargeSummary() {
|
||||
mFragment.mBatteryInfo = null;
|
||||
when(mFragment.getContext()).thenReturn(mRealContext);
|
||||
doReturn(TIME_SINCE_LAST_FULL_CHARGE_MS).when(
|
||||
@@ -200,7 +201,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateLastFullChargePreference_hasAverageTime_showFullChargeLastSummary() {
|
||||
public void updateLastFullChargePreference_hasAverageTime_showFullChargeLastSummary() {
|
||||
mFragment.mBatteryInfo = mBatteryInfo;
|
||||
mBatteryInfo.averageTimeToDischarge = TIME_SINCE_LAST_FULL_CHARGE_MS;
|
||||
when(mFragment.getContext()).thenReturn(mRealContext);
|
||||
@@ -212,7 +213,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonIndexableKeys_MatchPreferenceKeys() {
|
||||
public void nonIndexableKeys_MatchPreferenceKeys() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
final List<String> niks =
|
||||
PowerUsageSummary.SEARCH_INDEX_DATA_PROVIDER.getNonIndexableKeys(context);
|
||||
@@ -224,7 +225,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||
public void preferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
final PowerUsageSummary fragment = new PowerUsageSummary();
|
||||
final List<String> preferenceScreenKeys =
|
||||
@@ -239,7 +240,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateAnomalySparseArray() {
|
||||
public void updateAnomalySparseArray() {
|
||||
mFragment.mAnomalySparseArray = new SparseArray<>();
|
||||
final List<Anomaly> anomalies = new ArrayList<>();
|
||||
final Anomaly anomaly1 = new Anomaly.Builder().setUid(UID).build();
|
||||
@@ -256,7 +257,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestartBatteryTipLoader() {
|
||||
public void restartBatteryTipLoader() {
|
||||
//TODO: add policy logic here when BatteryTipPolicy is implemented
|
||||
doReturn(mLoaderManager).when(mFragment).getLoaderManager();
|
||||
|
||||
@@ -267,7 +268,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowBothEstimates_summariesAreBothModified() {
|
||||
public void showBothEstimates_summariesAreBothModified() {
|
||||
when(mFeatureFactory.powerUsageFeatureProvider.isEnhancedBatteryPredictionEnabled(any()))
|
||||
.thenReturn(true);
|
||||
doAnswer(new Answer() {
|
||||
@@ -296,7 +297,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDebugMode() {
|
||||
public void debugMode() {
|
||||
doReturn(true).when(mFeatureFactory.powerUsageFeatureProvider).isEstimateDebugEnabled();
|
||||
doReturn(new TextView(mRealContext)).when(mBatteryLayoutPref).findViewById(R.id.summary2);
|
||||
|
||||
@@ -315,7 +316,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestartBatteryStatsLoader_notClearHeader_quickUpdateNotInvoked() {
|
||||
public void restartBatteryStatsLoader_notClearHeader_quickUpdateNotInvoked() {
|
||||
mFragment.mBatteryHeaderPreferenceController = mBatteryHeaderPreferenceController;
|
||||
|
||||
mFragment.restartBatteryStatsLoader(false /* clearHeader */);
|
||||
@@ -324,7 +325,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionsMenu_advancedPageEnabled() {
|
||||
public void optionsMenu_advancedPageEnabled() {
|
||||
when(mFeatureFactory.powerUsageFeatureProvider.isPowerAccountingToggleEnabled())
|
||||
.thenReturn(true);
|
||||
|
||||
@@ -335,7 +336,7 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOptionsMenu_clickAdvancedPage_fireIntent() {
|
||||
public void optionsMenu_clickAdvancedPage_fireIntent() {
|
||||
final ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
|
||||
doAnswer(invocation -> {
|
||||
// Get the intent in which it has the app info bundle
|
||||
@@ -353,13 +354,27 @@ public class PowerUsageSummaryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRefreshUi_deviceRotate_doNotUpdateBatteryTip() {
|
||||
mFragment.mNeedUpdateBatteryTip = false;
|
||||
public void refreshUi_deviceRotate_doNotUpdateBatteryTip() {
|
||||
mFragment.mBatteryTipPreferenceController = mock(BatteryTipPreferenceController.class);
|
||||
when(mFragment.mBatteryTipPreferenceController.needUpdate()).thenReturn(false);
|
||||
mFragment.updateBatteryTipFlag(new Bundle());
|
||||
|
||||
mFragment.refreshUi();
|
||||
|
||||
verify(mFragment, never()).restartBatteryTipLoader();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void refreshUi_tipNeedUpdate_updateBatteryTip() {
|
||||
mFragment.mBatteryTipPreferenceController = mock(BatteryTipPreferenceController.class);
|
||||
when(mFragment.mBatteryTipPreferenceController.needUpdate()).thenReturn(true);
|
||||
mFragment.updateBatteryTipFlag(new Bundle());
|
||||
|
||||
mFragment.refreshUi();
|
||||
|
||||
verify(mFragment).restartBatteryTipLoader();
|
||||
}
|
||||
|
||||
public static class TestFragment extends PowerUsageSummary {
|
||||
private Context mContext;
|
||||
|
||||
|
Reference in New Issue
Block a user