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:
@@ -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;
|
||||
@@ -46,7 +45,6 @@ public class ShowSurfaceUpdatesPreferenceController extends DeveloperOptionsPref
|
||||
private static final String SURFACE_COMPOSER_INTERFACE_KEY = "android.ui.ISurfaceComposer";
|
||||
|
||||
private final IBinder mSurfaceFlinger;
|
||||
private SwitchPreference mPreference;
|
||||
|
||||
public ShowSurfaceUpdatesPreferenceController(Context context) {
|
||||
super(context);
|
||||
@@ -58,13 +56,6 @@ public class ShowSurfaceUpdatesPreferenceController extends DeveloperOptionsPref
|
||||
return SHOW_SCREEN_UPDATES_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;
|
||||
@@ -77,20 +68,16 @@ public class ShowSurfaceUpdatesPreferenceController extends DeveloperOptionsPref
|
||||
updateShowUpdatesSetting();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDeveloperOptionsSwitchEnabled() {
|
||||
mPreference.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDeveloperOptionsSwitchDisabled() {
|
||||
if (mPreference.isChecked()) {
|
||||
super.onDeveloperOptionsSwitchDisabled();
|
||||
final SwitchPreference preference = (SwitchPreference) mPreference;
|
||||
if (preference.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
|
||||
writeShowUpdatesSetting(false);
|
||||
mPreference.setChecked(false);
|
||||
preference.setChecked(false);
|
||||
}
|
||||
mPreference.setEnabled(false);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -105,7 +92,7 @@ public class ShowSurfaceUpdatesPreferenceController extends DeveloperOptionsPref
|
||||
@SuppressWarnings("unused") final int showCpu = reply.readInt();
|
||||
@SuppressWarnings("unused") final int enableGL = reply.readInt();
|
||||
final int showUpdates = reply.readInt();
|
||||
mPreference.setChecked(showUpdates != SETTING_VALUE_OFF);
|
||||
((SwitchPreference) mPreference).setChecked(showUpdates != SETTING_VALUE_OFF);
|
||||
reply.recycle();
|
||||
data.recycle();
|
||||
}
|
||||
|
Reference in New Issue
Block a user