Revert "Revert "Revert "Replace dynamic summary text for SettingPref"""

This reverts commit c1e9f8787f02df0d38a9d4e93f7996318fc46355.

Reason for revert: There is an issue when dropdown menu text has a '%' sign in it.
Despite testing it on my own devices, the bug did not show up immediately.

Instead of continuing down this path for OC, we'll just revert
this patch, and then as an ugly, band-aid solution, check the
summary text for the "%s" substring, and hide it when found.
In O-DR onward, we'll look for a more permanent solution.

Change-Id: Ia7a04bfb7b09c436dc0f13564f2134a1f0c436e2
Bug: 36101902
Fix: 62211676
(cherry picked from commit ed761c4e743bcad72c23e2d37f479474850a42c8)
diff --git a/res/xml/battery_saver_settings.xml b/res/xml/battery_saver_settings.xml
index 52f6793..1720c73 100644
--- a/res/xml/battery_saver_settings.xml
+++ b/res/xml/battery_saver_settings.xml
@@ -22,6 +22,6 @@
     <DropDownPreference
             android:key="turn_on_automatically"
             android:title="@string/battery_saver_turn_on_automatically_title"
-            android:summary="@string/summary_placeholder" />
+            android:summary="%s" />
 
 </PreferenceScreen>
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index 33c1b0a..d288a9d 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -124,7 +124,7 @@
         <DropDownPreference
           android:key="dock_audio_media"
           android:title="@string/dock_audio_media_title"
-          android:summary="@string/summary_placeholder" />
+          android:summary="%s" />
 
         <!-- Boot sounds -->
         <SwitchPreference
@@ -135,7 +135,7 @@
         <DropDownPreference
           android:key="emergency_tone"
           android:title="@string/emergency_tone_title"
-          android:summary="@string/summary_placeholder" />
+          android:summary="%s" />
 
         <com.android.settingslib.RestrictedPreference
           android:key="cell_broadcast_settings"
diff --git a/src/com/android/settings/fuelgauge/BatterySaverSettings.java b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
index 45d0db2..6b7ddf9 100644
--- a/src/com/android/settings/fuelgauge/BatterySaverSettings.java
+++ b/src/com/android/settings/fuelgauge/BatterySaverSettings.java
@@ -99,6 +99,7 @@
             }
         };
         mTriggerPref.init(this);
+
         mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
     }
 
diff --git a/src/com/android/settings/notification/SettingPref.java b/src/com/android/settings/notification/SettingPref.java
index cdbd5b3..18efc33 100644
--- a/src/com/android/settings/notification/SettingPref.java
+++ b/src/com/android/settings/notification/SettingPref.java
@@ -121,19 +121,6 @@
         if (mTwoState != null) {
             mTwoState.setChecked(val != 0);
         } else if (mDropDown != null) {
-            if (mValues != null) {
-                int index = 0;
-                for (int len = mValues.length; index < len; index++) {
-                    if (mValues[index] == val) {
-                        break;
-                    }
-                }
-
-                if (index < mValues.length) {
-                    CharSequence entry = mDropDown.getEntries()[index];
-                    mDropDown.setSummary(entry);
-                }
-            }
             mDropDown.setValue(Integer.toString(val));
         }
     }
diff --git a/tests/robotests/src/com/android/settings/notification/SettingPrefTest.java b/tests/robotests/src/com/android/settings/notification/SettingPrefTest.java
deleted file mode 100644
index 39f1377..0000000
--- a/tests/robotests/src/com/android/settings/notification/SettingPrefTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.android.settings.notification;
-
-import android.content.res.Resources;
-
-import android.content.Context;
-import android.provider.Settings;
-import android.support.v7.preference.DropDownPreference;
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.spy;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class SettingPrefTest {
-
-    @Test
-    public void update_setsDropDownSummaryText() {
-        Context context = RuntimeEnvironment.application;
-        String testSetting = "test_setting";
-        int[] values = new int[] {1,2,3};
-        String[] entries = new String[] {"one", "two", "three"};
-        SettingPref settingPref =
-                spy(new SettingPref(SettingPref.TYPE_GLOBAL, "key", testSetting, 0, values) {
-                    @Override
-                    protected String getCaption(Resources res, int value) {
-                        return "temp";
-                    }
-                });
-        DropDownPreference dropdownPref = spy(new DropDownPreference(context));
-        dropdownPref.setEntries(entries);
-        settingPref.mDropDown = dropdownPref;
-        Settings.Global.putInt(context.getContentResolver(), testSetting, values[2]);
-
-        settingPref.update(context);
-
-        assertThat(settingPref.mDropDown.getSummary()).isEqualTo(entries[2]);
-    }
-
-    @Test
-    public void update_setsDropDownSummaryText_noMatch_noError() {
-        Context context = RuntimeEnvironment.application;
-        String testSetting = "test_setting";
-        int[] values = new int[] {1,2,3};
-        String[] entries = new String[] {"one", "two", "three"};
-        SettingPref settingPref =
-                spy(new SettingPref(SettingPref.TYPE_GLOBAL, "key", testSetting, 0, values) {
-                    @Override
-                    protected String getCaption(Resources res, int value) {
-                        return "temp";
-                    }
-                });
-        DropDownPreference dropdownPref = spy(new DropDownPreference(context));
-        dropdownPref.setEntries(entries);
-        settingPref.mDropDown = dropdownPref;
-        Settings.Global.putInt(context.getContentResolver(), testSetting, -1);
-
-        settingPref.update(context);
-
-        assertThat(settingPref.mDropDown.getSummary()).isNull();
-    }
-}