Make flag "showAllapps" persistent in PowerUsageSummary

This flag is used to decide whether to show all the apps
(including system app, service..) in battery settings

Handle it in onCreate() and onSaveInstanceState()

Bug: 62422948
Test: RunSettingsRoboTests
Change-Id: I30c0d6e1e25902f1192fc2564aa09d635b5e0f4f
This commit is contained in:
jackqdyulei
2017-06-08 14:26:39 -07:00
parent 377907ebad
commit f9a5c39c4c
2 changed files with 30 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.content.ContentResolver;
import android.os.PowerManager;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.SparseArray;
@@ -145,6 +146,8 @@ public class PowerUsageSummaryTest {
private LoaderManager mLoaderManager;
@Mock
private ContentResolver mContentResolver;
@Mock
private PreferenceScreen mPreferenceScreen;
private List<BatterySipper> mUsageList;
private Context mRealContext;
@@ -466,6 +469,18 @@ public class PowerUsageSummaryTest {
assertThat(summary1.getText().toString().contains(OLD_EST_SUFFIX));
}
@Test
public void testSaveInstanceState_showAllAppsRestored() {
Bundle bundle = new Bundle();
mFragment.mShowAllApps = true;
doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
mFragment.onSaveInstanceState(bundle);
mFragment.restoreSavedInstance(bundle);
assertThat(mFragment.mShowAllApps).isTrue();
}
public static class TestFragment extends PowerUsageSummary {
private Context mContext;