Merge "Remove unused listener" into udc-dev
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
index 274817e..73ec42b 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -22,9 +22,7 @@
 import android.os.Handler;
 import android.os.Looper;
 import android.os.PowerManager;
-import android.provider.Settings;
 import android.provider.SettingsSlicesContract;
-import android.widget.Switch;
 
 import androidx.preference.PreferenceScreen;
 
@@ -36,15 +34,13 @@
 import com.android.settingslib.core.lifecycle.events.OnStop;
 import com.android.settingslib.fuelgauge.BatterySaverUtils;
 import com.android.settingslib.widget.MainSwitchPreference;
-import com.android.settingslib.widget.OnMainSwitchChangeListener;
-
 
 /**
  * Controller to update the battery saver button
  */
 public class BatterySaverButtonPreferenceController extends
-        TogglePreferenceController implements OnMainSwitchChangeListener, LifecycleObserver,
-        OnStart, OnStop, BatterySaverReceiver.BatterySaverListener {
+        TogglePreferenceController implements LifecycleObserver, OnStart, OnStop,
+        BatterySaverReceiver.BatterySaverListener {
     private static final long SWITCH_ANIMATION_DURATION = 350L;
 
     private final BatterySaverReceiver mBatterySaverReceiver;
@@ -96,21 +92,10 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreference = screen.findPreference(getPreferenceKey());
-        mPreference.addOnSwitchChangeListener(this);
         mPreference.updateStatus(isChecked());
     }
 
     @Override
-    public void onSwitchChanged(Switch switchView, boolean isChecked) {
-        // Cancel preference's check state once it's first time launch
-        if (isChecked && (Settings.Secure.getInt(mContext.getContentResolver(),
-                Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED, 0) == 0)) {
-            mPreference.setChecked(false);
-        }
-        setChecked(isChecked);
-    }
-
-    @Override
     public boolean isChecked() {
         return mPowerManager.isPowerSaveMode();
     }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
index 9a7ef40..7398e5c 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceControllerTest.java
@@ -26,7 +26,6 @@
 
 import android.content.Context;
 import android.os.PowerManager;
-import android.provider.Settings;
 import android.provider.SettingsSlicesContract;
 
 import androidx.preference.PreferenceScreen;
@@ -73,24 +72,6 @@
     }
 
     @Test
-    public void onSwitchChanged_isCheckedButNotAcked_preferenceIsUnchecked() {
-        setLowPowerWarningAcked(/* acked= */ 0);
-
-        mController.onSwitchChanged(/* switchView= */ null, /* isChecked= */ true);
-
-        assertThat(mPreference.isChecked()).isFalse();
-    }
-
-    @Test
-    public void onSwitchChanged_isCheckedAndAcked_setPowerSaveMode() {
-        setLowPowerWarningAcked(/* acked= */ 1);
-
-        mController.onSwitchChanged(/* switchView= */ null, /* isChecked= */ true);
-
-        verify(mPowerManager).setPowerSaveModeEnabled(true);
-    }
-
-    @Test
     public void updateState_lowPowerOn_preferenceIsChecked() {
         when(mPowerManager.isPowerSaveMode()).thenReturn(true);
 
@@ -140,16 +121,4 @@
     public void isPublicSlice_returnsTrue() {
         assertThat(mController.isPublicSlice()).isTrue();
     }
-
-    // 0 means not acked, 1 means acked.
-    private void setLowPowerWarningAcked(int acked) {
-        Settings.Secure.putInt(
-                mContext.getContentResolver(),
-                Settings.Secure.LOW_POWER_WARNING_ACKNOWLEDGED,
-                acked);
-        Settings.Secure.putInt(
-                mContext.getContentResolver(),
-                Settings.Secure.EXTRA_LOW_POWER_WARNING_ACKNOWLEDGED,
-                acked);
-    }
 }