From 5c56588d594bf239d4b63041c770504e7847efb4 Mon Sep 17 00:00:00 2001 From: jackqdyulei Date: Tue, 2 Jan 2018 10:44:48 -0800 Subject: [PATCH] Remove toggles in battery settings. In Android P, we only show "Battery saver" and "Power management" in battery settings. So we need to remove other preferences. Keep "Battery percentage" toggle for now because it is not cross-listed in other places. Bug: 71502850 Test: Screenshot Change-Id: Ia3c919f61239ff71f9343f2bce961aa4b89533c0 --- res/xml/power_usage_summary.xml | 52 ++++++------------- .../settings/fuelgauge/PowerUsageSummary.java | 15 +----- .../PowerUsageSummaryLegacyTest.java | 12 ----- 3 files changed, 16 insertions(+), 63 deletions(-) diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml index 0aec18fcf5e..5d6c9e966ce 100644 --- a/res/xml/power_usage_summary.xml +++ b/res/xml/power_usage_summary.xml @@ -30,6 +30,21 @@ android:key="battery_tip" android:layout="@layout/preference_category_no_title"/> + + + + + + + + @@ -45,43 +60,6 @@ - - - - - - - - - - - - - - - - - diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java index a5b6c08ae42..0315f032e66 100644 --- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java +++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java @@ -84,10 +84,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList private static final String KEY_SCREEN_USAGE = "screen_usage"; private static final String KEY_TIME_SINCE_LAST_FULL_CHARGE = "last_full_charge"; - - private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness_battery"; - private static final String KEY_SCREEN_TIMEOUT = "screen_timeout_battery"; - private static final String KEY_AMBIENT_DISPLAY = "ambient_display_battery"; private static final String KEY_BATTERY_SAVER_SUMMARY = "battery_saver_summary"; @VisibleForTesting @@ -272,14 +268,9 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList mBatteryTipPreferenceController = new BatteryTipPreferenceController(context, KEY_BATTERY_TIP, this); controllers.add(mBatteryTipPreferenceController); - controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS)); - controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT)); controllers.add(new BatterySaverController(context, getLifecycle())); controllers.add(new BatteryPercentagePreferenceController(context)); - controllers.add(new AmbientDisplayPreferenceController( - context, - new AmbientDisplayConfiguration(context), - KEY_AMBIENT_DISPLAY)); + return controllers; } @@ -544,10 +535,6 @@ public class PowerUsageSummary extends PowerUsageBase implements OnLongClickList public List getNonIndexableKeys(Context context) { List niks = super.getNonIndexableKeys(context); niks.add(KEY_BATTERY_SAVER_SUMMARY); - // Duplicates in display - niks.add(KEY_AUTO_BRIGHTNESS); - niks.add(KEY_SCREEN_TIMEOUT); - niks.add(KEY_AMBIENT_DISPLAY); return niks; } }; diff --git a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java index bc5b1d7a025..45448a94528 100644 --- a/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java +++ b/tests/robotests/src/com/android/settings/fuelgauge/PowerUsageSummaryLegacyTest.java @@ -400,18 +400,6 @@ public class PowerUsageSummaryLegacyTest { assertThat(percent).isWithin(PRECISION).of(POWER_USAGE_PERCENTAGE); } - @Test - public void testNonIndexableKeys_MatchPreferenceKeys() { - final Context context = RuntimeEnvironment.application; - final List niks = PowerUsageSummary.SEARCH_INDEX_DATA_PROVIDER - .getNonIndexableKeys(context); - - final List keys = XmlTestUtils.getKeysFromPreferenceXml(context, - R.xml.power_usage_summary); - - assertThat(keys).containsAllIn(niks); - } - @Test public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() { final Context context = RuntimeEnvironment.application;