Remove unnecessary onDeveloperOptionsSwitchEnabled/Disabled override.

- default implementation has been added in the super class to handle
enabling/disabling the preference when the master developer options
switch it turned on/off. Removing all subclass that originally
implemented the methods that only contains the default behavior.

Bug: 73955632
Test: make RunSettingsRoboTests
Change-Id: I13c372c2ab498a5786b40cdc1ad3b5f3424abb5a
This commit is contained in:
Doris Ling
2018-03-01 10:33:14 -08:00
parent 46d6ecc2b1
commit 4fbf04cd10
131 changed files with 489 additions and 1699 deletions

View File

@@ -24,7 +24,6 @@ import android.os.ServiceManager;
import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -45,7 +44,6 @@ public class HardwareOverlaysPreferenceController extends DeveloperOptionsPrefer
private static final String SURFACE_COMPOSER_INTERFACE_KEY = "android.ui.ISurfaceComposer";
private final IBinder mSurfaceFlinger;
private SwitchPreference mPreference;
public HardwareOverlaysPreferenceController(Context context) {
super(context);
@@ -57,13 +55,6 @@ public class HardwareOverlaysPreferenceController extends DeveloperOptionsPrefer
return DISABLE_OVERLAYS_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -76,20 +67,16 @@ public class HardwareOverlaysPreferenceController extends DeveloperOptionsPrefer
updateHardwareOverlaysSetting();
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
if (mPreference.isChecked()) {
super.onDeveloperOptionsSwitchDisabled();
final SwitchPreference switchPreference = (SwitchPreference) mPreference;
if (switchPreference.isChecked()) {
// Writing false to the preference when the setting is already off will have a
// side effect of turning on the preference that we wish to avoid
writeHardwareOverlaysSetting(false);
mPreference.setChecked(false);
switchPreference.setChecked(false);
}
mPreference.setEnabled(false);
}
@VisibleForTesting
@@ -108,7 +95,7 @@ public class HardwareOverlaysPreferenceController extends DeveloperOptionsPrefer
@SuppressWarnings("unused") final int showUpdates = reply.readInt();
@SuppressWarnings("unused") final int showBackground = reply.readInt();
final int disableOverlays = reply.readInt();
mPreference.setChecked(disableOverlays != SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(disableOverlays != SETTING_VALUE_OFF);
reply.recycle();
data.recycle();
} catch (RemoteException ex) {