From 4bbb4915876f54152f21f39908b1676d7fd7e614 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Sun, 28 Jan 2018 23:19:00 +0000 Subject: [PATCH 01/17] Update Inactive Apps screen to show buckets Show the standby bucket state and allow toggling between the buckets. EXEMPTED/NEVER state cannot be changed and item will be grayed out. Bug: 72728900 Test: Settings>Dev>Standby apps Change-Id: Id38e6c6483b9b6aaafca5e2a0b6b82756fb28b1f --- .../settings/fuelgauge/InactiveApps.java | 67 +++++++++++++++---- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/src/com/android/settings/fuelgauge/InactiveApps.java b/src/com/android/settings/fuelgauge/InactiveApps.java index f91a5c6902b..ac09a575685 100644 --- a/src/com/android/settings/fuelgauge/InactiveApps.java +++ b/src/com/android/settings/fuelgauge/InactiveApps.java @@ -16,12 +16,21 @@ package com.android.settings.fuelgauge; +import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_ACTIVE; +import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_EXEMPTED; +import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_FREQUENT; +import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_NEVER; +import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_RARE; +import static android.app.usage.UsageStatsManager.STANDBY_BUCKET_WORKING_SET; + import android.app.usage.UsageStatsManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; +import android.content.res.Resources; import android.os.Bundle; +import android.support.v7.preference.ListPreference; import android.support.v7.preference.Preference; import android.support.v7.preference.Preference.OnPreferenceClickListener; import android.support.v7.preference.PreferenceGroup; @@ -29,10 +38,22 @@ import android.support.v7.preference.PreferenceGroup; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.widget.RadioButtonPreference; import java.util.List; -public class InactiveApps extends SettingsPreferenceFragment implements OnPreferenceClickListener { +public class InactiveApps extends SettingsPreferenceFragment + implements Preference.OnPreferenceChangeListener { + + private static final CharSequence[] SETTABLE_BUCKETS_NAMES = + {"ACTIVE", "WORKING_SET", "FREQUENT", "RARE"}; + + private static final CharSequence[] SETTABLE_BUCKETS_VALUES = { + Integer.toString(STANDBY_BUCKET_ACTIVE), + Integer.toString(STANDBY_BUCKET_WORKING_SET), + Integer.toString(STANDBY_BUCKET_FREQUENT), + Integer.toString(STANDBY_BUCKET_RARE) + }; private UsageStatsManager mUsageStats; @@ -68,29 +89,51 @@ public class InactiveApps extends SettingsPreferenceFragment implements OnPrefer List apps = pm.queryIntentActivities(launcherIntent, 0); for (ResolveInfo app : apps) { String packageName = app.activityInfo.applicationInfo.packageName; - Preference p = new Preference(getPrefContext()); + ListPreference p = new ListPreference(getPrefContext()); p.setTitle(app.loadLabel(pm)); p.setIcon(app.loadIcon(pm)); p.setKey(packageName); + p.setEntries(SETTABLE_BUCKETS_NAMES); + p.setEntryValues(SETTABLE_BUCKETS_VALUES); updateSummary(p); - p.setOnPreferenceClickListener(this); + p.setOnPreferenceChangeListener(this); screen.addPreference(p); } } - private void updateSummary(Preference p) { - boolean inactive = mUsageStats.isAppInactive(p.getKey()); - p.setSummary(inactive - ? R.string.inactive_app_inactive_summary - : R.string.inactive_app_active_summary); + static String bucketToName(int bucket) { + switch (bucket) { + case STANDBY_BUCKET_EXEMPTED: return "EXEMPTED"; + case STANDBY_BUCKET_ACTIVE: return "ACTIVE"; + case STANDBY_BUCKET_WORKING_SET: return "WORKING_SET"; + case STANDBY_BUCKET_FREQUENT: return "FREQUENT"; + case STANDBY_BUCKET_RARE: return "RARE"; + case STANDBY_BUCKET_NEVER: return "NEVER"; + } + return ""; + } + + private void updateSummary(ListPreference p) { + final Resources res = getActivity().getResources(); + final int appBucket = mUsageStats.getAppStandbyBucket(p.getKey()); + final String bucketName = bucketToName(appBucket); + p.setSummary(res.getString(R.string.standby_bucket_summary, bucketName)); + // Buckets outside of the range of the dynamic ones are only used for special + // purposes and can either not be changed out of, or might have undesirable + // side-effects in combination with other assumptions. + final boolean changeable = appBucket >= STANDBY_BUCKET_ACTIVE + && appBucket <= STANDBY_BUCKET_RARE; + if (changeable) { + p.setValue(Integer.toString(appBucket)); + } + p.setEnabled(changeable); } @Override - public boolean onPreferenceClick(Preference preference) { - String packageName = preference.getKey(); - mUsageStats.setAppInactive(packageName, !mUsageStats.isAppInactive(packageName)); - updateSummary(preference); + public boolean onPreferenceChange(Preference preference, Object newValue) { + mUsageStats.setAppStandbyBucket(preference.getKey(), Integer.parseInt((String) newValue)); + updateSummary((ListPreference) preference); return false; } } From cd7e9bcb33016a2eab3f5f2a10fde369f13541fe Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 6 Feb 2018 15:09:43 -0500 Subject: [PATCH 02/17] Apply checkbox enable state on viewholder bind Change-Id: I5b263f02fb6a1779fd567eade3776044fddb6b11 Fixes: 72809700 Test: SettingsRoboTests --- .../widget/MasterCheckBoxPreference.java | 1 + .../widget/MasterCheckBoxPreferenceTest.java | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/com/android/settings/widget/MasterCheckBoxPreference.java b/src/com/android/settings/widget/MasterCheckBoxPreference.java index 552f51c115f..fceeac22f00 100644 --- a/src/com/android/settings/widget/MasterCheckBoxPreference.java +++ b/src/com/android/settings/widget/MasterCheckBoxPreference.java @@ -83,6 +83,7 @@ public class MasterCheckBoxPreference extends TwoTargetPreference { if (mCheckBox != null) { mCheckBox.setContentDescription(getTitle()); mCheckBox.setChecked(mChecked); + mCheckBox.setEnabled(mEnableCheckBox); } } diff --git a/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java index ac3e0b64471..55ce27f6db8 100644 --- a/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java +++ b/tests/robotests/src/com/android/settings/widget/MasterCheckBoxPreferenceTest.java @@ -105,6 +105,24 @@ public class MasterCheckBoxPreferenceTest { assertThat(checkBox.isEnabled()).isTrue(); } + @Test + public void onBindViewHolder_shouldSetCheckboxEnabledState() { + final PreferenceViewHolder holder = PreferenceViewHolder.createInstanceForTests( + LayoutInflater.from(mContext).inflate( + R.layout.preference_widget_master_checkbox, null)); + final CheckBox checkBox = (CheckBox) holder.findViewById(R.id.checkboxWidget); + + mPreference.setCheckBoxEnabled(false); + mPreference.onBindViewHolder(holder); + + assertThat(mPreference.isEnabled()).isTrue(); + assertThat(checkBox.isEnabled()).isFalse(); + + mPreference.setCheckBoxEnabled(true); + assertThat(mPreference.isEnabled()).isTrue(); + assertThat(checkBox.isEnabled()).isTrue(); + } + @Test public void clickWidgetView_shouldToggleCheckBox() { final LayoutInflater inflater = LayoutInflater.from(mContext); From 700c113218b9f360e47dd8631ee0a62ef7ef8e0f Mon Sep 17 00:00:00 2001 From: Matthew Fritze Date: Fri, 26 Jan 2018 10:15:49 -0800 Subject: [PATCH 03/17] Add Toggle Controllers to XML Autobrightness preference controller was accidentally removed from display_settings.xml. Given that no tests were broken and this would be a disaster for phone buddy & inline actions, I have added another test which keeps a list of valid controllers that should exist in xml. When more inline controllers types are added, they will be included in this test. Fixes: 72564979 Test: robotests Change-Id: I40fe18f9118af9cec1c201632742d2949ff64be5 --- res/xml/battery_saver_settings.xml | 6 +- res/xml/connected_devices_advanced.xml | 5 +- res/xml/display_settings.xml | 3 +- res/xml/security_dashboard_settings.xml | 6 +- res/xml/security_lockscreen_settings.xml | 4 +- .../core/BasePreferenceController.java | 2 + ...blePatternProfilePreferenceController.java | 5 + .../grandfather_slice_controller_not_in_xml | 1 + .../slices/SettingsSliceProviderTest.java | 1 + .../slices/SliceBroadcastReceiverTest.java | 1 + .../slices/SliceBuilderUtilsTest.java | 1 + .../slices/SliceControllerInXmlTest.java | 201 ++++++++++++++++++ .../FakeToggleController.java | 2 +- 13 files changed, 230 insertions(+), 8 deletions(-) create mode 100644 tests/robotests/assets/grandfather_slice_controller_not_in_xml create mode 100644 tests/robotests/src/com/android/settings/slices/SliceControllerInXmlTest.java rename tests/robotests/src/com/android/settings/{slices => testutils}/FakeToggleController.java (97%) diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml index 47199c2d66e..9e32440cba0 100644 --- a/res/xml/battery_saver_settings.xml +++ b/res/xml/battery_saver_settings.xml @@ -16,6 +16,7 @@ @@ -23,12 +24,15 @@ + android:summary="@string/battery_saver_auto_summary" + settings:controller="com.android.settings.fuelgauge.batterysaver.AutoBatterySaverPreferenceController"/> + + + android:order="-7" + settings:controller="com.android.settings.bluetooth.BluetoothSwitchPreferenceController"/> diff --git a/res/xml/security_dashboard_settings.xml b/res/xml/security_dashboard_settings.xml index dafd36c54b9..00eaa7e10f1 100644 --- a/res/xml/security_dashboard_settings.xml +++ b/res/xml/security_dashboard_settings.xml @@ -79,7 +79,8 @@ + android:title="@string/lockpattern_settings_enable_visible_pattern_title_profile" + settings:controller="com.android.settings.security.VisiblePatternProfilePreferenceController"/> + android:summary="@string/show_password_summary" + settings:controller="com.android.settings.security.ShowPasswordPreferenceController"/> diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml index 1da1de5eccf..3d3bfd064b8 100644 --- a/res/xml/security_lockscreen_settings.xml +++ b/res/xml/security_lockscreen_settings.xml @@ -16,6 +16,7 @@ @@ -36,7 +37,8 @@ + android:summary="@string/lockdown_settings_summary" + settings:controller="com.android.settings.security.LockdownButtonPreferenceController"/> mSliceControllerClasses = new ArrayList<>(Arrays.asList( + TogglePreferenceController.class + )); + + private final List mXmlDeclaredControllers = new ArrayList<>(); + private final List mGrandfatheredClasses = new ArrayList<>(); + + private final String ERROR_MISSING_CONTROLLER = + "The following controllers were expected to be declared by " + + "'settings:controller=Controller_Class_Name' in their corresponding Xml. " + + "If it should not appear in XML, add the controller's classname to " + + "grandfather_slice_controller_not_in_xml. Controllers:\n"; + + private Context mContext; + + SearchFeatureProvider mSearchProvider; + private FakeFeatureFactory mFakeFeatureFactory; + + @Before + public void setUp() { + mContext = spy(RuntimeEnvironment.application); + + mSearchProvider = new SearchFeatureProviderImpl(); + mFakeFeatureFactory = FakeFeatureFactory.setupForTest(); + mFakeFeatureFactory.searchFeatureProvider = mSearchProvider; + + CodeInspector.initializeGrandfatherList(mGrandfatheredClasses, + "grandfather_slice_controller_not_in_xml"); + initDeclaredControllers(); + } + + private void initDeclaredControllers() { + final List xmlResources = getIndexableXml(); + XmlResourceParser parser; + + for (int xmlResId : xmlResources) { + try { + parser = mContext.getResources().getXml(xmlResId); + + int type; + while ((type = parser.next()) != XmlPullParser.END_DOCUMENT + && type != XmlPullParser.START_TAG) { + // Parse next until start tag is found + } + + final int outerDepth = parser.getDepth(); + final AttributeSet attrs = Xml.asAttributeSet(parser); + String controllerClassName; + while ((type = parser.next()) != XmlPullParser.END_DOCUMENT + && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { + if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { + continue; + } + controllerClassName = XmlParserUtils.getController(mContext, attrs); + + if (!TextUtils.isEmpty(controllerClassName)) { + mXmlDeclaredControllers.add(controllerClassName); + } + } + } catch (Exception e) { + // Assume an issue with robolectric resources + } + } + } + + @Test + public void testAllControllersDeclaredInXml() throws Exception { + final List> classes = new ClassScanner().getClassesForPackage( + mContext.getPackageName()); + final List missingControllersInXml = new ArrayList<>(); + + for (Class clazz : classes) { + if (!isInlineSliceClass(clazz)) { + // Only care about inline-slice controller classes. + continue; + } + + if (!mXmlDeclaredControllers.contains(clazz.getName())) { + // Class clazz should have been declared in XML (unless whitelisted). + missingControllersInXml.add(clazz.getName()); + } + } + + // Removed whitelisted classes + missingControllersInXml.removeAll(mGrandfatheredClasses); + + final String missingControllerError = buildErrorMessage(ERROR_MISSING_CONTROLLER, + missingControllersInXml); + + assertWithMessage(missingControllerError).that(missingControllersInXml).isEmpty(); + } + + private boolean isInlineSliceClass(Class clazz) { + while (clazz != null) { + clazz = clazz.getSuperclass(); + if (mSliceControllerClasses.contains(clazz)) { + return true; + } + } + return false; + } + + private String buildErrorMessage(String errorSummary, List errorClasses) { + final StringBuilder error = new StringBuilder(errorSummary); + for (String c : errorClasses) { + error.append(c).append("\n"); + } + return error.toString(); + } + + private List getIndexableXml() { + final List xmlResSet = new ArrayList<>(); + + final Collection indexableClasses = FeatureFactory.getFactory( + mContext).getSearchFeatureProvider().getSearchIndexableResources() + .getProviderValues(); + + for (Class clazz : indexableClasses) { + + Indexable.SearchIndexProvider provider = DatabaseIndexingUtils.getSearchIndexProvider( + clazz); + + if (provider == null) { + continue; + } + + List resources = provider.getXmlResourcesToIndex(mContext, + true); + + if (resources == null) { + continue; + } + + for (SearchIndexableResource resource : resources) { + // Add '0's anyway. It won't break the test. + xmlResSet.add(resource.xmlResId); + } + } + return xmlResSet; + } +} diff --git a/tests/robotests/src/com/android/settings/slices/FakeToggleController.java b/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java similarity index 97% rename from tests/robotests/src/com/android/settings/slices/FakeToggleController.java rename to tests/robotests/src/com/android/settings/testutils/FakeToggleController.java index 1b08e3566aa..c984c6ceca4 100644 --- a/tests/robotests/src/com/android/settings/slices/FakeToggleController.java +++ b/tests/robotests/src/com/android/settings/testutils/FakeToggleController.java @@ -15,7 +15,7 @@ * */ -package com.android.settings.slices; +package com.android.settings.testutils; import android.content.Context; import android.provider.Settings; From 6dd7f2eb38c88d83bc1508c4a78849177936099d Mon Sep 17 00:00:00 2001 From: jackqdyulei Date: Wed, 7 Feb 2018 17:49:09 -0800 Subject: [PATCH 04/17] Make ConnectedDevice page handles bt intent Fixes: 73088883 Test: Manual - click the bt tile in quick settings Change-Id: I147a9a83b37fff4a7573f792cd9172fef84110f2 --- AndroidManifest.xml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c526d6fc245..64fffba84c6 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -190,6 +190,10 @@ + + + + @@ -429,13 +433,10 @@ - - - - + android:label="@string/bluetooth_settings_title" + android:icon="@drawable/ic_settings_bluetooth" + android:enabled="false" + android:taskAffinity=""> From 155d6829e9f5444f524f147c82c500556d37a31f Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Wed, 7 Feb 2018 12:59:22 -0800 Subject: [PATCH 05/17] Move restriction check for dev settings into controller Change-Id: I99dae6e82aca40b92e1965ba7db2c54f3c59d33f Fixes: 72815875 Test: robotests --- .../android/settings/SettingsActivity.java | 1 - .../AppMemoryPreferenceControllerTest.java | 12 +++++++- ...elopmentSettingsDashboardFragmentTest.java | 29 ++++++++++++++++--- .../DevelopmentSwitchBarControllerTest.java | 6 +++- .../BuildNumberPreferenceControllerTest.java | 6 +++- 5 files changed, 46 insertions(+), 8 deletions(-) diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index 7328c76497b..e80b253611a 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -813,7 +813,6 @@ public class SettingsActivity extends SettingsDrawerActivity || somethingChanged; final boolean showDev = DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this) - && !um.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES) && !Utils.isMonkeyRunning(); somethingChanged = setTileEnabled(new ComponentName(packageName, diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java index fd136c1a6c3..532522c3db3 100644 --- a/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppMemoryPreferenceControllerTest.java @@ -37,7 +37,9 @@ import com.android.settings.TestConfig; import com.android.settings.applications.ProcStatsData; import com.android.settings.applications.ProcessStatsDetail; import com.android.settings.testutils.SettingsRobolectricTestRunner; +import com.android.settings.testutils.shadow.ShadowUserManager; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -48,7 +50,9 @@ import org.robolectric.annotation.Config; import org.robolectric.util.ReflectionHelpers; @RunWith(SettingsRobolectricTestRunner.class) -@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) +@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = { + ShadowUserManager.class +}) public class AppMemoryPreferenceControllerTest { @Mock @@ -67,6 +71,7 @@ public class AppMemoryPreferenceControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; + ShadowUserManager.getShadow().setIsAdminUser(true); mController = spy(new AppMemoryPreferenceController(mContext, mFragment, null /* lifecycle */)); when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference); @@ -75,6 +80,11 @@ public class AppMemoryPreferenceControllerTest { when(mFragment.getActivity()).thenReturn(mActivity); } + @After + public void tearDown() { + ShadowUserManager.getShadow().reset(); + } + @Test public void getAvailabilityStatus_developmentSettingsEnabled_shouldReturnAvailable() { Settings.Global.putInt(mContext.getContentResolver(), diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java index 881ee84f8c7..640e9d5e338 100644 --- a/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java +++ b/tests/robotests/src/com/android/settings/development/DevelopmentSettingsDashboardFragmentTest.java @@ -17,7 +17,6 @@ package com.android.settings.development; import static com.google.common.truth.Truth.assertThat; - import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -33,6 +32,7 @@ import com.android.settings.R; import com.android.settings.TestConfig; import com.android.settings.testutils.SettingsRobolectricTestRunner; import com.android.settings.testutils.shadow.SettingsShadowResources; +import com.android.settings.testutils.shadow.ShadowUserManager; import com.android.settings.widget.SwitchBar; import com.android.settings.widget.ToggleSwitch; import com.android.settingslib.development.AbstractEnableAdbPreferenceController; @@ -52,7 +52,9 @@ import org.robolectric.util.ReflectionHelpers; import java.util.List; @RunWith(SettingsRobolectricTestRunner.class) -@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION) +@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = { + ShadowUserManager.class +}) public class DevelopmentSettingsDashboardFragmentTest { private SwitchBar mSwitchBar; @@ -68,11 +70,13 @@ public class DevelopmentSettingsDashboardFragmentTest { mSwitch = mSwitchBar.getSwitch(); mDashboard = spy(new DevelopmentSettingsDashboardFragment()); ReflectionHelpers.setField(mDashboard, "mSwitchBar", mSwitchBar); + ShadowUserManager.getShadow().setIsAdminUser(true); } @After public void tearDown() { ShadowEnableDevelopmentSettingWarningDialog.reset(); + ShadowUserManager.getShadow().reset(); } @Test @@ -101,7 +105,7 @@ public class DevelopmentSettingsDashboardFragmentTest { SettingsShadowResources.class, SettingsShadowResources.SettingsShadowTheme.class }) - public void searchIndex_pageDisabled_shouldAddAllKeysToNonIndexable() { + public void searchIndex_pageDisabledBySetting_shouldAddAllKeysToNonIndexable() { final Context appContext = RuntimeEnvironment.application; DevelopmentSettingsEnabler.setDevelopmentSettingsEnabled(appContext, false); @@ -109,7 +113,24 @@ public class DevelopmentSettingsDashboardFragmentTest { DevelopmentSettingsDashboardFragment.SEARCH_INDEX_DATA_PROVIDER .getNonIndexableKeys(appContext); - assertThat(nonIndexableKeys).contains("development_prefs_screen"); + assertThat(nonIndexableKeys).contains("enable_adb"); + } + + @Test + @Config(shadows = { + SettingsShadowResources.class, + SettingsShadowResources.SettingsShadowTheme.class + }) + public void searchIndex_pageDisabledForNonAdmin_shouldAddAllKeysToNonIndexable() { + final Context appContext = RuntimeEnvironment.application; + DevelopmentSettingsEnabler.setDevelopmentSettingsEnabled(appContext, true); + ShadowUserManager.getShadow().setIsAdminUser(false); + + final List nonIndexableKeys = + DevelopmentSettingsDashboardFragment.SEARCH_INDEX_DATA_PROVIDER + .getNonIndexableKeys(appContext); + + assertThat(nonIndexableKeys).contains("enable_adb"); } @Test diff --git a/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java b/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java index a5dfa56d3c6..95fd0ddeceb 100644 --- a/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java +++ b/tests/robotests/src/com/android/settings/development/DevelopmentSwitchBarControllerTest.java @@ -28,6 +28,7 @@ import android.content.Context; import com.android.settings.TestConfig; import com.android.settings.testutils.SettingsRobolectricTestRunner; +import com.android.settings.testutils.shadow.ShadowUserManager; import com.android.settings.testutils.shadow.ShadowUtils; import com.android.settings.widget.SwitchBar; import com.android.settingslib.core.lifecycle.Lifecycle; @@ -47,7 +48,8 @@ import java.util.ArrayList; @RunWith(SettingsRobolectricTestRunner.class) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = { - ShadowUtils.class + ShadowUtils.class, + ShadowUserManager.class }) public class DevelopmentSwitchBarControllerTest { @@ -63,6 +65,7 @@ public class DevelopmentSwitchBarControllerTest { public void setUp() { MockitoAnnotations.initMocks(this); mContext = RuntimeEnvironment.application; + ShadowUserManager.getShadow().setIsAdminUser(true); mLifecycleOwner = () -> mLifecycle; mLifecycle = new Lifecycle(mLifecycleOwner); mSwitchBar = new SwitchBar(mContext); @@ -72,6 +75,7 @@ public class DevelopmentSwitchBarControllerTest { @After public void tearDown() { ShadowUtils.reset(); + ShadowUserManager.getShadow().reset(); } @Test diff --git a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java index ee5d5d05f78..17122ae1afb 100644 --- a/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/deviceinfo/BuildNumberPreferenceControllerTest.java @@ -43,6 +43,7 @@ import com.android.settings.search.DatabaseIndexingManager; import com.android.settings.testutils.FakeFeatureFactory; import com.android.settings.testutils.SettingsRobolectricTestRunner; import com.android.settings.testutils.shadow.ShadowUtils; +import com.android.settings.testutils.shadow.ShadowUserManager; import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.development.DevelopmentSettingsEnabler; @@ -60,7 +61,8 @@ import org.robolectric.util.ReflectionHelpers; @RunWith(SettingsRobolectricTestRunner.class) @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION, shadows = { - ShadowUtils.class + ShadowUtils.class, + ShadowUserManager.class, }) public class BuildNumberPreferenceControllerTest { @@ -84,6 +86,7 @@ public class BuildNumberPreferenceControllerTest { @Before public void setUp() { MockitoAnnotations.initMocks(this); + ShadowUserManager.getShadow().setIsAdminUser(true); mFactory = FakeFeatureFactory.setupForTest(); mLifecycleOwner = () -> mLifecycle; mLifecycle = new Lifecycle(mLifecycleOwner); @@ -98,6 +101,7 @@ public class BuildNumberPreferenceControllerTest { @After public void tearDown() { ShadowUtils.reset(); + ShadowUserManager.getShadow().reset(); } @Test From 4fbe0f83541fcea18daa549bd9c990247a3712e8 Mon Sep 17 00:00:00 2001 From: Jan Nordqvist Date: Mon, 22 Jan 2018 14:43:43 -0800 Subject: [PATCH 06/17] Update DataUsageSummary to include carrier provided information. This CL augments the existing data usage display with carrier provided information about data usage and plans when available from the new frameworks API. Test: manual Test: make RunSettingsRoboTests Bug: 70950124 Change-Id: Idde1ff786e8c5dbc04e58ffbcc0fd18789682699 --- res/layout/data_usage_summary_preference.xml | 112 +++++++ res/values/strings.xml | 23 ++ res/xml/data_usage.xml | 18 +- .../settings/datausage/DataUsageSummary.java | 106 +++---- .../datausage/DataUsageSummaryPreference.java | 117 +++++++ .../DataUsageSummaryPreferenceController.java | 286 ++++++++++++++++++ ...aUsageSummaryPreferenceControllerTest.java | 175 +++++++++++ .../DataUsageSummaryPreferenceTest.java | 172 +++++++++++ .../search/BaseSearchIndexProviderTest.java | 3 +- 9 files changed, 929 insertions(+), 83 deletions(-) create mode 100644 res/layout/data_usage_summary_preference.xml create mode 100644 src/com/android/settings/datausage/DataUsageSummaryPreference.java create mode 100644 src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java create mode 100644 tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java create mode 100644 tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java diff --git a/res/layout/data_usage_summary_preference.xml b/res/layout/data_usage_summary_preference.xml new file mode 100644 index 00000000000..445e7cdd468 --- /dev/null +++ b/res/layout/data_usage_summary_preference.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +