Remove duplicates between battery and display settings
Change preference keys of duplicate settings between
display and battery to avoid duplication in search.
Bug: 33701673
Test: make RunSettingsRoboTests
Change-Id: I56c82e9e7f163d345065ca478849de9b14c173fe
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java
index 1230ae5..17bacdc 100644
--- a/src/com/android/settings/DisplaySettings.java
+++ b/src/com/android/settings/DisplaySettings.java
@@ -51,6 +51,9 @@
public class DisplaySettings extends DashboardFragment {
private static final String TAG = "DisplaySettings";
+ public static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
+ private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
+
@Override
public int getMetricsCategory() {
return MetricsEvent.DISPLAY;
@@ -85,7 +88,7 @@
private static List<PreferenceController> buildPreferenceControllers(
Context context, Lifecycle lifecycle) {
final List<PreferenceController> controllers = new ArrayList<>();
- controllers.add(new AutoBrightnessPreferenceController(context));
+ controllers.add(new AutoBrightnessPreferenceController(context, KEY_AUTO_BRIGHTNESS));
controllers.add(new AutoRotatePreferenceController(context));
controllers.add(new CameraGesturePreferenceController(context));
controllers.add(new DozePreferenceController(context));
@@ -100,7 +103,7 @@
controllers.add(new DoubleTapScreenPreferenceController(
context, lifecycle, ambientDisplayConfig, UserHandle.myUserId()));
controllers.add(new TapToWakePreferenceController(context));
- controllers.add(new TimeoutPreferenceController(context));
+ controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
controllers.add(new VrDisplayPreferenceController(context));
controllers.add(new WallpaperPreferenceController(context));
controllers.add(new ThemePreferenceController(context));
diff --git a/src/com/android/settings/display/AutoBrightnessPreferenceController.java b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
index 869c8f0..f36ed36 100644
--- a/src/com/android/settings/display/AutoBrightnessPreferenceController.java
+++ b/src/com/android/settings/display/AutoBrightnessPreferenceController.java
@@ -36,10 +36,11 @@
public class AutoBrightnessPreferenceController extends PreferenceController implements
Preference.OnPreferenceChangeListener {
- private static final String KEY_AUTO_BRIGHTNESS = "auto_brightness";
+ private final String mAutoBrightnessKey;
- public AutoBrightnessPreferenceController(Context context) {
+ public AutoBrightnessPreferenceController(Context context, String key) {
super(context);
+ mAutoBrightnessKey = key;
}
@Override
@@ -50,7 +51,7 @@
@Override
public String getPreferenceKey() {
- return KEY_AUTO_BRIGHTNESS;
+ return mAutoBrightnessKey;
}
@Override
@@ -75,7 +76,7 @@
valueMap.put(SCREEN_BRIGHTNESS_MODE_MANUAL, false);
final Intent intent = DatabaseIndexingUtils.buildSubsettingIntent(mContext,
- getClass().getName(), KEY_AUTO_BRIGHTNESS,
+ getClass().getName(), mAutoBrightnessKey,
mContext.getString(R.string.display_settings));
return new InlineSwitchPayload(SCREEN_BRIGHTNESS_MODE,
diff --git a/src/com/android/settings/display/TimeoutPreferenceController.java b/src/com/android/settings/display/TimeoutPreferenceController.java
index d409656..b2890c2 100644
--- a/src/com/android/settings/display/TimeoutPreferenceController.java
+++ b/src/com/android/settings/display/TimeoutPreferenceController.java
@@ -35,10 +35,11 @@
/** If there is no setting in the provider, use this. */
public static final int FALLBACK_SCREEN_TIMEOUT_VALUE = 30000;
- private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
+ private final String mScreenTimeoutKey;
- public TimeoutPreferenceController(Context context) {
+ public TimeoutPreferenceController(Context context, String key) {
super(context);
+ mScreenTimeoutKey = key;
}
@Override
@@ -48,7 +49,7 @@
@Override
public String getPreferenceKey() {
- return KEY_SCREEN_TIMEOUT;
+ return mScreenTimeoutKey;
}
@Override
diff --git a/src/com/android/settings/fuelgauge/BatterySaverController.java b/src/com/android/settings/fuelgauge/BatterySaverController.java
index 08d570a..34c9a26 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverController.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverController.java
@@ -43,7 +43,7 @@
public class BatterySaverController extends PreferenceController implements
Preference.OnPreferenceChangeListener, LifecycleObserver, OnStart, OnStop {
- private static final String KEY_BATTERY_SAVER = "battery_saver";
+ private static final String KEY_BATTERY_SAVER = "battery_saver_summary";
private static final String TAG = "BatterySaverController";
private static final boolean DEBUG = false;
diff --git a/src/com/android/settings/fuelgauge/PowerUsageSummary.java b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
index ac041b8..624a284 100644
--- a/src/com/android/settings/fuelgauge/PowerUsageSummary.java
+++ b/src/com/android/settings/fuelgauge/PowerUsageSummary.java
@@ -86,6 +86,9 @@
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_BATTERY_SAVER_SUMMARY = "battery_saver_summary";
private static final int MENU_STATS_TYPE = Menu.FIRST;
@VisibleForTesting
@@ -185,8 +188,8 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
final List<PreferenceController> controllers = new ArrayList<>();
- controllers.add(new AutoBrightnessPreferenceController(context));
- controllers.add(new TimeoutPreferenceController(context));
+ 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));
return controllers;
@@ -712,6 +715,16 @@
sir.xmlResId = R.xml.power_usage_summary;
return Arrays.asList(sir);
}
+
+ @Override
+ public List<String> getNonIndexableKeys(Context context) {
+ List<String> niks = new ArrayList<>();
+ // Duplicates in display
+ niks.add(KEY_AUTO_BRIGHTNESS);
+ niks.add(KEY_SCREEN_TIMEOUT);
+ niks.add(KEY_BATTERY_SAVER_SUMMARY);
+ return niks;
+ }
};
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY