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

@@ -147,16 +147,6 @@ public abstract class AbstractBluetoothA2dpPreferenceController extends
mBluetoothA2dp = null; mBluetoothA2dp = null;
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
/** /**
* @return an array of string values that correspond to the current {@link ListPreference}. * @return an array of string values that correspond to the current {@link ListPreference}.
*/ */

View File

@@ -58,15 +58,10 @@ public class AdbPreferenceController extends AbstractEnableAdbPreferenceControll
return false; return false;
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeAdbSetting(false); writeAdbSetting(false);
mPreference.setEnabled(false);
mPreference.setChecked(false); mPreference.setChecked(false);
} }
} }

View File

@@ -21,14 +21,12 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class AllowAppsOnExternalPreferenceController extends public class AllowAppsOnExternalPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String FORCE_ALLOW_ON_EXTERNAL_KEY = "force_allow_on_external"; private static final String FORCE_ALLOW_ON_EXTERNAL_KEY = "force_allow_on_external";
@@ -37,8 +35,6 @@ public class AllowAppsOnExternalPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_ON = 1; static final int SETTING_VALUE_ON = 1;
private SwitchPreference mPreference;
public AllowAppsOnExternalPreferenceController(Context context) { public AllowAppsOnExternalPreferenceController(Context context) {
super(context); super(context);
} }
@@ -48,13 +44,6 @@ public class AllowAppsOnExternalPreferenceController extends
return FORCE_ALLOW_ON_EXTERNAL_KEY; return FORCE_ALLOW_ON_EXTERNAL_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -69,19 +58,14 @@ public class AllowAppsOnExternalPreferenceController extends
final int mode = Settings.Global.getInt(mContext.getContentResolver(), final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.FORCE_ALLOW_ON_EXTERNAL, SETTING_VALUE_OFF); Settings.Global.FORCE_ALLOW_ON_EXTERNAL, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.FORCE_ALLOW_ON_EXTERNAL, SETTING_VALUE_OFF); Settings.Global.FORCE_ALLOW_ON_EXTERNAL, SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -22,16 +22,14 @@ import android.os.ServiceManager;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.IWindowManager; import android.view.IWindowManager;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class AnimatorDurationScalePreferenceController extends public class AnimatorDurationScalePreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale"; private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale";
@@ -44,8 +42,6 @@ public class AnimatorDurationScalePreferenceController extends
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public AnimatorDurationScalePreferenceController(Context context) { public AnimatorDurationScalePreferenceController(Context context) {
super(context); super(context);
@@ -61,13 +57,6 @@ public class AnimatorDurationScalePreferenceController extends
return ANIMATOR_DURATION_SCALE_KEY; return ANIMATOR_DURATION_SCALE_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
writeAnimationScaleOption(newValue); writeAnimationScaleOption(newValue);
@@ -79,15 +68,10 @@ public class AnimatorDurationScalePreferenceController extends
updateAnimationScaleValue(); updateAnimationScaleValue();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeAnimationScaleOption(null); writeAnimationScaleOption(null);
mPreference.setEnabled(false);
} }
private void writeAnimationScaleOption(Object newValue) { private void writeAnimationScaleOption(Object newValue) {
@@ -111,8 +95,9 @@ public class AnimatorDurationScalePreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); final ListPreference listPreference = (ListPreference) mPreference;
mPreference.setSummary(mListSummaries[index]); listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
} catch (RemoteException e) { } catch (RemoteException e) {
// intentional no-op // intentional no-op
} }

View File

@@ -20,14 +20,12 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class AppsNotRespondingPreferenceController extends public class AppsNotRespondingPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String SHOW_ALL_ANRS_KEY = "show_all_anrs"; private static final String SHOW_ALL_ANRS_KEY = "show_all_anrs";
@@ -36,8 +34,6 @@ public class AppsNotRespondingPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public AppsNotRespondingPreferenceController(Context context) { public AppsNotRespondingPreferenceController(Context context) {
super(context); super(context);
} }
@@ -47,13 +43,6 @@ public class AppsNotRespondingPreferenceController extends
return SHOW_ALL_ANRS_KEY; return SHOW_ALL_ANRS_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -67,19 +56,14 @@ public class AppsNotRespondingPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(mContext.getContentResolver(), final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.ANR_SHOW_BACKGROUND, SETTING_VALUE_OFF); Settings.Secure.ANR_SHOW_BACKGROUND, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.ANR_SHOW_BACKGROUND, SETTING_VALUE_OFF); Settings.Secure.ANR_SHOW_BACKGROUND, SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -23,7 +23,6 @@ import android.os.RemoteException;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
@@ -37,7 +36,6 @@ public class BackgroundProcessLimitPreferenceController extends
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public BackgroundProcessLimitPreferenceController(Context context) { public BackgroundProcessLimitPreferenceController(Context context) {
super(context); super(context);
@@ -51,13 +49,6 @@ public class BackgroundProcessLimitPreferenceController extends
return APP_PROCESS_LIMIT_KEY; return APP_PROCESS_LIMIT_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
writeAppProcessLimitOptions(newValue); writeAppProcessLimitOptions(newValue);
@@ -70,15 +61,10 @@ public class BackgroundProcessLimitPreferenceController extends
updateAppProcessLimitOptions(); updateAppProcessLimitOptions();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeAppProcessLimitOptions(null); writeAppProcessLimitOptions(null);
mPreference.setEnabled(false);
} }
private void updateAppProcessLimitOptions() { private void updateAppProcessLimitOptions() {
@@ -92,8 +78,9 @@ public class BackgroundProcessLimitPreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); final ListPreference listPreference = (ListPreference) mPreference;
mPreference.setSummary(mListSummaries[index]); listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
} catch (RemoteException e) { } catch (RemoteException e) {
// intentional no-op // intentional no-op
} }

View File

@@ -21,7 +21,6 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -36,8 +35,6 @@ public class BluetoothAbsoluteVolumePreferenceController extends
static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY = static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY =
"persist.bluetooth.disableabsvol"; "persist.bluetooth.disableabsvol";
private SwitchPreference mPreference;
public BluetoothAbsoluteVolumePreferenceController(Context context) { public BluetoothAbsoluteVolumePreferenceController(Context context) {
super(context); super(context);
} }
@@ -47,13 +44,6 @@ public class BluetoothAbsoluteVolumePreferenceController extends
return BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY; return BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -66,18 +56,13 @@ public class BluetoothAbsoluteVolumePreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean( final boolean isEnabled = SystemProperties.getBoolean(
BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY, false /* default */); BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY, false /* default */);
mPreference.setChecked(isEnabled); ((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY, "false"); SystemProperties.set(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY, "false");
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -21,16 +21,14 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class BluetoothAvrcpVersionPreferenceController extends public class BluetoothAvrcpVersionPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String BLUETOOTH_SELECT_AVRCP_VERSION_KEY = private static final String BLUETOOTH_SELECT_AVRCP_VERSION_KEY =
"bluetooth_select_avrcp_version"; "bluetooth_select_avrcp_version";
@@ -40,7 +38,6 @@ public class BluetoothAvrcpVersionPreferenceController extends
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public BluetoothAvrcpVersionPreferenceController(Context context) { public BluetoothAvrcpVersionPreferenceController(Context context) {
super(context); super(context);
@@ -54,13 +51,6 @@ public class BluetoothAvrcpVersionPreferenceController extends
return BLUETOOTH_SELECT_AVRCP_VERSION_KEY; return BLUETOOTH_SELECT_AVRCP_VERSION_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
SystemProperties.set(BLUETOOTH_AVRCP_VERSION_PROPERTY, newValue.toString()); SystemProperties.set(BLUETOOTH_AVRCP_VERSION_PROPERTY, newValue.toString());
@@ -70,6 +60,7 @@ public class BluetoothAvrcpVersionPreferenceController extends
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
final ListPreference listPreference = (ListPreference) preference;
final String currentValue = SystemProperties.get(BLUETOOTH_AVRCP_VERSION_PROPERTY); final String currentValue = SystemProperties.get(BLUETOOTH_AVRCP_VERSION_PROPERTY);
int index = 0; // Defaults to AVRCP 1.4 int index = 0; // Defaults to AVRCP 1.4
for (int i = 0; i < mListValues.length; i++) { for (int i = 0; i < mListValues.length; i++) {
@@ -78,17 +69,7 @@ public class BluetoothAvrcpVersionPreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); listPreference.setValue(mListValues[index]);
mPreference.setSummary(mListSummaries[index]); listPreference.setSummary(mListSummaries[index]);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
} }
} }

View File

@@ -21,14 +21,12 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class BluetoothDelayReportsPreferenceController extends public class BluetoothDelayReportsPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String BLUETOOTH_ENABLE_AVDTP_DELAY_REPORT_KEY = private static final String BLUETOOTH_ENABLE_AVDTP_DELAY_REPORT_KEY =
"bluetooth_enable_avdtp_delay_reports"; "bluetooth_enable_avdtp_delay_reports";
@@ -36,8 +34,6 @@ public class BluetoothDelayReportsPreferenceController extends
static final String BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY = static final String BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY =
"persist.bluetooth.enabledelayreports"; "persist.bluetooth.enabledelayreports";
private SwitchPreference mPreference;
public BluetoothDelayReportsPreferenceController(Context context) { public BluetoothDelayReportsPreferenceController(Context context) {
super(context); super(context);
} }
@@ -47,13 +43,6 @@ public class BluetoothDelayReportsPreferenceController extends
return BLUETOOTH_ENABLE_AVDTP_DELAY_REPORT_KEY; return BLUETOOTH_ENABLE_AVDTP_DELAY_REPORT_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -66,19 +55,14 @@ public class BluetoothDelayReportsPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean( final boolean isEnabled = SystemProperties.getBoolean(
BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */); BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
mPreference.setChecked(isEnabled); ((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false); super.onDeveloperOptionsSwitchDisabled();
// the default setting for this preference is the disabled state // the default setting for this preference is the disabled state
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, "false"); SystemProperties.set(BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, "false");
} }

View File

@@ -21,7 +21,6 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -36,8 +35,6 @@ public class BluetoothDeviceNoNamePreferenceController extends
static final String BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY = static final String BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY =
"persist.bluetooth.showdeviceswithoutnames"; "persist.bluetooth.showdeviceswithoutnames";
private SwitchPreference mPreference;
public BluetoothDeviceNoNamePreferenceController(Context context) { public BluetoothDeviceNoNamePreferenceController(Context context) {
super(context); super(context);
} }
@@ -47,13 +44,6 @@ public class BluetoothDeviceNoNamePreferenceController extends
return BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_KEY; return BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -66,18 +56,13 @@ public class BluetoothDeviceNoNamePreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean( final boolean isEnabled = SystemProperties.getBoolean(
BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, false /* default */); BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, false /* default */);
mPreference.setChecked(isEnabled); ((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, "false"); SystemProperties.set(BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, "false");
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -22,14 +22,12 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class BluetoothInbandRingingPreferenceController extends public class BluetoothInbandRingingPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String BLUETOOTH_DISABLE_INBAND_RINGING_KEY = private static final String BLUETOOTH_DISABLE_INBAND_RINGING_KEY =
"bluetooth_disable_inband_ringing"; "bluetooth_disable_inband_ringing";
@@ -37,8 +35,6 @@ public class BluetoothInbandRingingPreferenceController extends
static final String BLUETOOTH_DISABLE_INBAND_RINGING_PROPERTY = static final String BLUETOOTH_DISABLE_INBAND_RINGING_PROPERTY =
"persist.bluetooth.disableinbandringing"; "persist.bluetooth.disableinbandringing";
private SwitchPreference mPreference;
public BluetoothInbandRingingPreferenceController(Context context) { public BluetoothInbandRingingPreferenceController(Context context) {
super(context); super(context);
} }
@@ -53,13 +49,6 @@ public class BluetoothInbandRingingPreferenceController extends
return BLUETOOTH_DISABLE_INBAND_RINGING_KEY; return BLUETOOTH_DISABLE_INBAND_RINGING_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isChecked = (Boolean) newValue; final boolean isChecked = (Boolean) newValue;
@@ -72,18 +61,13 @@ public class BluetoothInbandRingingPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean( final boolean isEnabled = SystemProperties.getBoolean(
BLUETOOTH_DISABLE_INBAND_RINGING_PROPERTY, false /* default */); BLUETOOTH_DISABLE_INBAND_RINGING_PROPERTY, false /* default */);
mPreference.setChecked(isEnabled); ((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false); super.onDeveloperOptionsSwitchDisabled();
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
SystemProperties.set(BLUETOOTH_DISABLE_INBAND_RINGING_PROPERTY, "false"); SystemProperties.set(BLUETOOTH_DISABLE_INBAND_RINGING_PROPERTY, "false");
} }

View File

@@ -38,7 +38,6 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
"persist.bluetooth.maxconnectedaudiodevices"; "persist.bluetooth.maxconnectedaudiodevices";
private final int mDefaultMaxConnectedAudioDevices; private final int mDefaultMaxConnectedAudioDevices;
private ListPreference mPreference;
public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) { public BluetoothMaxConnectedAudioDevicesPreferenceController(Context context) {
super(context); super(context);
@@ -54,10 +53,10 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
@Override @Override
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey()); final ListPreference listPreference = (ListPreference) mPreference;
final CharSequence[] entries = mPreference.getEntries(); final CharSequence[] entries = listPreference.getEntries();
entries[0] = String.format(entries[0].toString(), mDefaultMaxConnectedAudioDevices); entries[0] = String.format(entries[0].toString(), mDefaultMaxConnectedAudioDevices);
mPreference.setEntries(entries); listPreference.setEntries(entries);
} }
@Override @Override
@@ -93,13 +92,13 @@ public class BluetoothMaxConnectedAudioDevicesPreferenceController extends
@Override @Override
protected void onDeveloperOptionsSwitchEnabled() { protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true); super.onDeveloperOptionsSwitchEnabled();
updateState(mPreference); updateState(mPreference);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false); super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, ""); SystemProperties.set(MAX_CONNECTED_AUDIO_DEVICES_PROPERTY, "");
updateState(mPreference); updateState(mPreference);
} }

View File

@@ -21,22 +21,18 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class BluetoothSnoopLogPreferenceController extends public class BluetoothSnoopLogPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String PREFERENCE_KEY = "bt_hci_snoop_log"; private static final String PREFERENCE_KEY = "bt_hci_snoop_log";
@VisibleForTesting @VisibleForTesting
static final String BLUETOOTH_BTSNOOP_ENABLE_PROPERTY = static final String BLUETOOTH_BTSNOOP_ENABLE_PROPERTY =
"persist.bluetooth.btsnoopenable"; "persist.bluetooth.btsnoopenable";
private SwitchPreference mPreference;
public BluetoothSnoopLogPreferenceController(Context context) { public BluetoothSnoopLogPreferenceController(Context context) {
super(context); super(context);
} }
@@ -46,12 +42,6 @@ public class BluetoothSnoopLogPreferenceController extends
return PREFERENCE_KEY; return PREFERENCE_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean enableBtSnoopLog = (Boolean) newValue; final boolean enableBtSnoopLog = (Boolean) newValue;
@@ -64,18 +54,13 @@ public class BluetoothSnoopLogPreferenceController extends
super.updateState(preference); super.updateState(preference);
final boolean enableBtSnoopLog = SystemProperties.getBoolean( final boolean enableBtSnoopLog = SystemProperties.getBoolean(
BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, false /* def */); BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, false /* def */);
mPreference.setChecked(enableBtSnoopLog); ((SwitchPreference) mPreference).setChecked(enableBtSnoopLog);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, Boolean.toString(false)); SystemProperties.set(BLUETOOTH_BTSNOOP_ENABLE_PROPERTY, Boolean.toString(false));
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -16,14 +16,12 @@
package com.android.settings.development; package com.android.settings.development;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.os.UserManager; import android.os.UserManager;
import android.provider.Settings; import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -40,7 +38,6 @@ public class BugReportInPowerPreferenceController extends
static int SETTING_VALUE_OFF = 0; static int SETTING_VALUE_OFF = 0;
private final UserManager mUserManager; private final UserManager mUserManager;
private SwitchPreference mPreference;
public BugReportInPowerPreferenceController(Context context) { public BugReportInPowerPreferenceController(Context context) {
super(context); super(context);
@@ -57,13 +54,6 @@ public class BugReportInPowerPreferenceController extends
return KEY_BUGREPORT_IN_POWER; return KEY_BUGREPORT_IN_POWER;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(KEY_BUGREPORT_IN_POWER);
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -77,18 +67,14 @@ public class BugReportInPowerPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(mContext.getContentResolver(), final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Global.BUGREPORT_IN_POWER_MENU, SETTING_VALUE_OFF); Settings.Global.BUGREPORT_IN_POWER_MENU, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
// no-op because this preference can never be disabled
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Global.BUGREPORT_IN_POWER_MENU, SETTING_VALUE_OFF); Settings.Global.BUGREPORT_IN_POWER_MENU, SETTING_VALUE_OFF);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
} }
} }

View File

@@ -14,14 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
package com.android.settings.development; package com.android.settings.development;
import android.content.Context; import android.content.Context;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting;
@@ -29,9 +27,8 @@ import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class CameraLaserSensorPreferenceController extends public class CameraLaserSensorPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String KEY_CAMERA_LASER_SENSOR_SWITCH = "camera_laser_sensor_switch"; private static final String KEY_CAMERA_LASER_SENSOR_SWITCH = "camera_laser_sensor_switch";
@VisibleForTesting @VisibleForTesting
@@ -49,8 +46,6 @@ public class CameraLaserSensorPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final String USER_BUILD = "user"; static final String USER_BUILD = "user";
private SwitchPreference mPreference;
public CameraLaserSensorPreferenceController(Context context) { public CameraLaserSensorPreferenceController(Context context) {
super(context); super(context);
} }
@@ -65,13 +60,6 @@ public class CameraLaserSensorPreferenceController extends
return KEY_CAMERA_LASER_SENSOR_SWITCH; return KEY_CAMERA_LASER_SENSOR_SWITCH;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -83,19 +71,14 @@ public class CameraLaserSensorPreferenceController extends
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean enabled = isLaserSensorEnabled(); final boolean enabled = isLaserSensorEnabled();
mPreference.setChecked(enabled); ((SwitchPreference) mPreference).setChecked(enabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(PROPERTY_CAMERA_LASER_SENSOR, Integer.toString(DISABLED)); SystemProperties.set(PROPERTY_CAMERA_LASER_SENSOR, Integer.toString(DISABLED));
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
private boolean isLaserSensorEnabled() { private boolean isLaserSensorEnabled() {

View File

@@ -32,8 +32,8 @@ import com.android.settings.Utils;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class ClearAdbKeysPreferenceController extends public class ClearAdbKeysPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements PreferenceControllerMixin { implements PreferenceControllerMixin {
private static final String TAG = "ClearAdbPrefCtrl"; private static final String TAG = "ClearAdbPrefCtrl";
private static final String CLEAR_ADB_KEYS = "clear_adb_keys"; private static final String CLEAR_ADB_KEYS = "clear_adb_keys";
@@ -44,8 +44,6 @@ public class ClearAdbKeysPreferenceController extends
private final IUsbManager mUsbManager; private final IUsbManager mUsbManager;
private final DevelopmentSettingsDashboardFragment mFragment; private final DevelopmentSettingsDashboardFragment mFragment;
private Preference mPreference;
public ClearAdbKeysPreferenceController(Context context, public ClearAdbKeysPreferenceController(Context context,
DevelopmentSettingsDashboardFragment fragment) { DevelopmentSettingsDashboardFragment fragment) {
super(context); super(context);
@@ -68,7 +66,6 @@ public class ClearAdbKeysPreferenceController extends
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
if (mPreference != null && !isAdminUser()) { if (mPreference != null && !isAdminUser()) {
mPreference.setEnabled(false); mPreference.setEnabled(false);
} }
@@ -94,11 +91,6 @@ public class ClearAdbKeysPreferenceController extends
} }
} }
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
public void onClearAdbKeysConfirmed() { public void onClearAdbKeysConfirmed() {
try { try {
mUsbManager.clearUsbDebuggingKeys(); mUsbManager.clearUsbDebuggingKeys();

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import android.widget.Toast; import android.widget.Toast;
@@ -29,9 +28,8 @@ import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class ConnectivityMonitorPreferenceController extends public class ConnectivityMonitorPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String KEY_CONNECTIVITY_MONITOR_SWITCH = "connectivity_monitor_switch"; private static final String KEY_CONNECTIVITY_MONITOR_SWITCH = "connectivity_monitor_switch";
@VisibleForTesting @VisibleForTesting
@@ -53,19 +51,10 @@ public class ConnectivityMonitorPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final String ENG_BUILD = "eng"; static final String ENG_BUILD = "eng";
private SwitchPreference mPreference;
public ConnectivityMonitorPreferenceController(Context context) { public ConnectivityMonitorPreferenceController(Context context) {
super(context); super(context);
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(KEY_CONNECTIVITY_MONITOR_SWITCH);
}
@Override @Override
public String getPreferenceKey() { public String getPreferenceKey() {
return KEY_CONNECTIVITY_MONITOR_SWITCH; return KEY_CONNECTIVITY_MONITOR_SWITCH;
@@ -92,19 +81,14 @@ public class ConnectivityMonitorPreferenceController extends
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean enabled = isConnectivityMonitorEnabled(); final boolean enabled = isConnectivityMonitorEnabled();
mPreference.setChecked(enabled); ((SwitchPreference) mPreference).setChecked(enabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(PROPERTY_CONNECTIVITY_MONITOR, USER_DISABLED_STATUS); SystemProperties.set(PROPERTY_CONNECTIVITY_MONITOR, USER_DISABLED_STATUS);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
private boolean isConnectivityMonitorEnabled() { private boolean isConnectivityMonitorEnabled() {

View File

@@ -21,7 +21,6 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.widget.Toast; import android.widget.Toast;
import com.android.settings.R; import com.android.settings.R;
@@ -29,17 +28,14 @@ import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker; import com.android.settingslib.development.SystemPropPoker;
public class CoolColorTemperaturePreferenceController extends public class CoolColorTemperaturePreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String COLOR_TEMPERATURE_KEY = "color_temperature"; private static final String COLOR_TEMPERATURE_KEY = "color_temperature";
@VisibleForTesting @VisibleForTesting
static final String COLOR_TEMPERATURE_PROPERTY = "persist.sys.debug.color_temp"; static final String COLOR_TEMPERATURE_PROPERTY = "persist.sys.debug.color_temp";
private SwitchPreference mPreference;
public CoolColorTemperaturePreferenceController(Context context) { public CoolColorTemperaturePreferenceController(Context context) {
super(context); super(context);
} }
@@ -54,12 +50,6 @@ public class CoolColorTemperaturePreferenceController extends
return COLOR_TEMPERATURE_KEY; return COLOR_TEMPERATURE_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isColorTemperatureEnabled = (Boolean) newValue; final boolean isColorTemperatureEnabled = (Boolean) newValue;
@@ -74,19 +64,14 @@ public class CoolColorTemperaturePreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean enableColorTemperature = SystemProperties.getBoolean( final boolean enableColorTemperature = SystemProperties.getBoolean(
COLOR_TEMPERATURE_PROPERTY, false /* default */); COLOR_TEMPERATURE_PROPERTY, false /* default */);
mPreference.setChecked(enableColorTemperature); ((SwitchPreference) mPreference).setChecked(enableColorTemperature);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(COLOR_TEMPERATURE_PROPERTY, Boolean.toString(false)); SystemProperties.set(COLOR_TEMPERATURE_PROPERTY, Boolean.toString(false));
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -26,9 +26,8 @@ import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class DarkUIPreferenceController extends public class DarkUIPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String DARK_UI_KEY = "dark_ui_mode"; private static final String DARK_UI_KEY = "dark_ui_mode";
private final UiModeManager mUiModeManager; private final UiModeManager mUiModeManager;

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.ThreadedRenderer; import android.view.ThreadedRenderer;
@@ -37,7 +36,6 @@ public class DebugGpuOverdrawPreferenceController extends
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public DebugGpuOverdrawPreferenceController(Context context) { public DebugGpuOverdrawPreferenceController(Context context) {
super(context); super(context);
@@ -51,13 +49,6 @@ public class DebugGpuOverdrawPreferenceController extends
return DEBUG_HW_OVERDRAW_KEY; return DEBUG_HW_OVERDRAW_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
writeDebugHwOverdrawOptions(newValue); writeDebugHwOverdrawOptions(newValue);
@@ -70,16 +61,6 @@ public class DebugGpuOverdrawPreferenceController extends
updateDebugHwOverdrawOptions(); updateDebugHwOverdrawOptions();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
private void writeDebugHwOverdrawOptions(Object newValue) { private void writeDebugHwOverdrawOptions(Object newValue) {
SystemProperties.set(ThreadedRenderer.DEBUG_OVERDRAW_PROPERTY, SystemProperties.set(ThreadedRenderer.DEBUG_OVERDRAW_PROPERTY,
newValue == null ? "" : newValue.toString()); newValue == null ? "" : newValue.toString());
@@ -97,7 +78,8 @@ public class DebugGpuOverdrawPreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); final ListPreference listPreference = (ListPreference) mPreference;
mPreference.setSummary(mListSummaries[index]); listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
} }
} }

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.ThreadedRenderer; import android.view.ThreadedRenderer;
@@ -37,7 +36,6 @@ public class DebugNonRectClipOperationsPreferenceController extends
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public DebugNonRectClipOperationsPreferenceController(Context context) { public DebugNonRectClipOperationsPreferenceController(Context context) {
super(context); super(context);
@@ -51,13 +49,6 @@ public class DebugNonRectClipOperationsPreferenceController extends
return SHOW_NON_RECTANGULAR_CLIP_KEY; return SHOW_NON_RECTANGULAR_CLIP_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
writeShowNonRectClipOptions(newValue); writeShowNonRectClipOptions(newValue);
@@ -70,16 +61,6 @@ public class DebugNonRectClipOperationsPreferenceController extends
updateShowNonRectClipOptions(); updateShowNonRectClipOptions();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
private void writeShowNonRectClipOptions(Object newValue) { private void writeShowNonRectClipOptions(Object newValue) {
SystemProperties.set(ThreadedRenderer.DEBUG_SHOW_NON_RECTANGULAR_CLIP_PROPERTY, SystemProperties.set(ThreadedRenderer.DEBUG_SHOW_NON_RECTANGULAR_CLIP_PROPERTY,
newValue == null ? "" : newValue.toString()); newValue == null ? "" : newValue.toString());
@@ -97,7 +78,8 @@ public class DebugNonRectClipOperationsPreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); final ListPreference listPreference = (ListPreference) mPreference;
mPreference.setSummary(mListSummaries[index]); listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
} }
} }

View File

@@ -21,7 +21,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -37,8 +36,6 @@ public class DebugViewAttributesPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public DebugViewAttributesPreferenceController(Context context) { public DebugViewAttributesPreferenceController(Context context) {
super(context); super(context);
} }
@@ -48,13 +45,6 @@ public class DebugViewAttributesPreferenceController extends
return DEBUG_VIEW_ATTRIBUTES_KEY; return DEBUG_VIEW_ATTRIBUTES_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean showViewAttr = (Boolean) newValue; final boolean showViewAttr = (Boolean) newValue;
@@ -68,19 +58,14 @@ public class DebugViewAttributesPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int debugViewAttrMode = Settings.Global.getInt(mContext.getContentResolver(), final int debugViewAttrMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEBUG_VIEW_ATTRIBUTES, 0 /* default */); Settings.Global.DEBUG_VIEW_ATTRIBUTES, 0 /* default */);
mPreference.setChecked(debugViewAttrMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(debugViewAttrMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEBUG_VIEW_ATTRIBUTES, SETTING_VALUE_OFF); Settings.Global.DEBUG_VIEW_ATTRIBUTES, SETTING_VALUE_OFF);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -21,7 +21,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -32,8 +31,6 @@ public class DisableAutomaticUpdatesPreferenceController extends
private static final String OTA_DISABLE_AUTOMATIC_UPDATE_KEY = "ota_disable_automatic_update"; private static final String OTA_DISABLE_AUTOMATIC_UPDATE_KEY = "ota_disable_automatic_update";
private SwitchPreference mPreference;
// We use the "disabled status" in code, but show the opposite text // We use the "disabled status" in code, but show the opposite text
// "Automatic system updates" on screen. So a value 0 indicates the // "Automatic system updates" on screen. So a value 0 indicates the
// automatic update is enabled. // automatic update is enabled.
@@ -51,13 +48,6 @@ public class DisableAutomaticUpdatesPreferenceController extends
return OTA_DISABLE_AUTOMATIC_UPDATE_KEY; return OTA_DISABLE_AUTOMATIC_UPDATE_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean updatesEnabled = (Boolean) newValue; final boolean updatesEnabled = (Boolean) newValue;
@@ -72,19 +62,14 @@ public class DisableAutomaticUpdatesPreferenceController extends
final int updatesEnabled = Settings.Global.getInt(mContext.getContentResolver(), final int updatesEnabled = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, 0 /* default */); Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, 0 /* default */);
mPreference.setChecked(updatesEnabled != DISABLE_UPDATES_SETTING); ((SwitchPreference) mPreference).setChecked(updatesEnabled != DISABLE_UPDATES_SETTING);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, DISABLE_UPDATES_SETTING); Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE, DISABLE_UPDATES_SETTING);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -156,16 +156,11 @@ public class EmulateDisplayCutoutPreferenceController extends
return overlayInfos.toArray(new OverlayInfo[overlayInfos.size()]); return overlayInfos.toArray(new OverlayInfo[overlayInfos.size()]);
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
setEmulationOverlay(""); setEmulationOverlay("");
updateState(mPreference); updateState(mPreference);
mPreference.setEnabled(false);
} }
} }

View File

@@ -21,7 +21,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -36,8 +35,6 @@ public class EnableGnssRawMeasFullTrackingPreferenceController extends
static final int SETTING_VALUE_ON = 1; static final int SETTING_VALUE_ON = 1;
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public EnableGnssRawMeasFullTrackingPreferenceController(Context context) { public EnableGnssRawMeasFullTrackingPreferenceController(Context context) {
super(context); super(context);
} }
@@ -47,13 +44,6 @@ public class EnableGnssRawMeasFullTrackingPreferenceController extends
return ENABLE_GNSS_RAW_MEAS_FULL_TRACKING_KEY; return ENABLE_GNSS_RAW_MEAS_FULL_TRACKING_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -69,19 +59,14 @@ public class EnableGnssRawMeasFullTrackingPreferenceController extends
final int enableGnssRawMeasFullTrackingMode = final int enableGnssRawMeasFullTrackingMode =
Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING, SETTING_VALUE_OFF); Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING, SETTING_VALUE_OFF);
mPreference.setChecked(enableGnssRawMeasFullTrackingMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(enableGnssRawMeasFullTrackingMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING, SETTING_VALUE_OFF); Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING, SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -21,14 +21,12 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class EnableGpuDebugLayersPreferenceController extends public class EnableGpuDebugLayersPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String ENABLE_GPU_DEBUG_LAYERS_KEY = "enable_gpu_debug_layers"; private static final String ENABLE_GPU_DEBUG_LAYERS_KEY = "enable_gpu_debug_layers";
@@ -37,8 +35,6 @@ public class EnableGpuDebugLayersPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public EnableGpuDebugLayersPreferenceController(Context context) { public EnableGpuDebugLayersPreferenceController(Context context) {
super(context); super(context);
} }
@@ -48,13 +44,6 @@ public class EnableGpuDebugLayersPreferenceController extends
return ENABLE_GPU_DEBUG_LAYERS_KEY; return ENABLE_GPU_DEBUG_LAYERS_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -68,19 +57,14 @@ public class EnableGpuDebugLayersPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int enableGpuDebugLayersMode = Settings.Global.getInt(mContext.getContentResolver(), final int enableGpuDebugLayersMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ENABLE_GPU_DEBUG_LAYERS, SETTING_VALUE_OFF); Settings.Global.ENABLE_GPU_DEBUG_LAYERS, SETTING_VALUE_OFF);
mPreference.setChecked(enableGpuDebugLayersMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(enableGpuDebugLayersMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.ENABLE_GPU_DEBUG_LAYERS, SETTING_VALUE_OFF); Settings.Global.ENABLE_GPU_DEBUG_LAYERS, SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -23,15 +23,14 @@ import android.os.SystemProperties;
import android.os.storage.IStorageManager; import android.os.storage.IStorageManager;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class FileEncryptionPreferenceController extends public class FileEncryptionPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements PreferenceControllerMixin { implements PreferenceControllerMixin {
private static final String KEY_CONVERT_FBE = "convert_to_file_encryption"; private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";
private static final String KEY_STORAGE_MANAGER = "mount"; private static final String KEY_STORAGE_MANAGER = "mount";
@@ -41,8 +40,6 @@ public class FileEncryptionPreferenceController extends
private final IStorageManager mStorageManager; private final IStorageManager mStorageManager;
private Preference mPreference;
public FileEncryptionPreferenceController(Context context) { public FileEncryptionPreferenceController(Context context) {
super(context); super(context);
@@ -67,13 +64,6 @@ public class FileEncryptionPreferenceController extends
return KEY_CONVERT_FBE; return KEY_CONVERT_FBE;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
}
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
if (!TextUtils.equals("file", if (!TextUtils.equals("file",

View File

@@ -21,23 +21,19 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker; import com.android.settingslib.development.SystemPropPoker;
public class ForceGpuRenderingPreferenceController extends public class ForceGpuRenderingPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui"; private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
@VisibleForTesting @VisibleForTesting
static final String HARDWARE_UI_PROPERTY = "persist.sys.ui.hw"; static final String HARDWARE_UI_PROPERTY = "persist.sys.ui.hw";
private SwitchPreference mPreference;
public ForceGpuRenderingPreferenceController(Context context) { public ForceGpuRenderingPreferenceController(Context context) {
super(context); super(context);
} }
@@ -47,13 +43,6 @@ public class ForceGpuRenderingPreferenceController extends
return FORCE_HARDWARE_UI_KEY; return FORCE_HARDWARE_UI_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -67,18 +56,13 @@ public class ForceGpuRenderingPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(HARDWARE_UI_PROPERTY, final boolean isEnabled = SystemProperties.getBoolean(HARDWARE_UI_PROPERTY,
false /* default */); false /* default */);
mPreference.setChecked(isEnabled); ((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(HARDWARE_UI_PROPERTY, Boolean.toString(false)); SystemProperties.set(HARDWARE_UI_PROPERTY, Boolean.toString(false));
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -21,7 +21,6 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -35,8 +34,6 @@ public class ForceMSAAPreferenceController extends DeveloperOptionsPreferenceCon
@VisibleForTesting @VisibleForTesting
static final String MSAA_PROPERTY = "debug.egl.force_msaa"; static final String MSAA_PROPERTY = "debug.egl.force_msaa";
private SwitchPreference mPreference;
public ForceMSAAPreferenceController(Context context) { public ForceMSAAPreferenceController(Context context) {
super(context); super(context);
} }
@@ -46,13 +43,6 @@ public class ForceMSAAPreferenceController extends DeveloperOptionsPreferenceCon
return FORCE_MSAA_KEY; return FORCE_MSAA_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -65,18 +55,13 @@ public class ForceMSAAPreferenceController extends DeveloperOptionsPreferenceCon
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(MSAA_PROPERTY, false /* default */); final boolean isEnabled = SystemProperties.getBoolean(MSAA_PROPERTY, false /* default */);
mPreference.setChecked(isEnabled); ((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(MSAA_PROPERTY, Boolean.toString(false)); SystemProperties.set(MSAA_PROPERTY, Boolean.toString(false));
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -22,15 +22,13 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class FreeformWindowsPreferenceController extends public class FreeformWindowsPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String ENABLE_FREEFORM_SUPPORT_KEY = "enable_freeform_support"; private static final String ENABLE_FREEFORM_SUPPORT_KEY = "enable_freeform_support";
@@ -41,8 +39,6 @@ public class FreeformWindowsPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final String USER_BUILD_TYPE = "user"; static final String USER_BUILD_TYPE = "user";
private SwitchPreference mPreference;
public FreeformWindowsPreferenceController(Context context) { public FreeformWindowsPreferenceController(Context context) {
super(context); super(context);
} }
@@ -57,13 +53,6 @@ public class FreeformWindowsPreferenceController extends
return ENABLE_FREEFORM_SUPPORT_KEY; return ENABLE_FREEFORM_SUPPORT_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -77,20 +66,15 @@ public class FreeformWindowsPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(), final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF); Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF); Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -0,0 +1,78 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development;
import android.content.Context;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
/**
* Base controller for Switch preference that maps to a specific value in Settings.Global.
*/
public abstract class GlobalSettingSwitchPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
private static final int SETTING_VALUE_OFF = 0;
private static final int SETTING_VALUE_ON = 1;
private final String mSettingsKey;
private final int mOn;
private final int mOff;
private final int mDefault;
public GlobalSettingSwitchPreferenceController(Context context, String globalSettingsKey) {
this(context, globalSettingsKey, SETTING_VALUE_ON, SETTING_VALUE_OFF, SETTING_VALUE_OFF);
}
/**
* Use different on/off/default vaules other than the standard 1/0/0.
*/
public GlobalSettingSwitchPreferenceController(Context context, String globalSettingsKey,
int valueOn, int valueOff, int valueDefault) {
super(context);
mSettingsKey = globalSettingsKey;
mOn = valueOn;
mOff = valueOff;
mDefault = valueDefault;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
Settings.Global.putInt(mContext.getContentResolver(), mSettingsKey, isEnabled ? mOn : mOff);
return true;
}
@Override
public void updateState(Preference preference) {
final int mode =
Settings.Global.getInt(mContext.getContentResolver(), mSettingsKey, mDefault);
((SwitchPreference) mPreference).setChecked(mode != mOff);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), mSettingsKey, mOff);
((SwitchPreference) mPreference).setChecked(false);
}
}

View File

@@ -20,21 +20,17 @@ import android.content.Context;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.ThreadedRenderer; import android.view.ThreadedRenderer;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker; import com.android.settingslib.development.SystemPropPoker;
public class GpuViewUpdatesPreferenceController extends public class GpuViewUpdatesPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String SHOW_HW_SCREEN_UPDATES_KEY = "show_hw_screen_updates"; private static final String SHOW_HW_SCREEN_UPDATES_KEY = "show_hw_screen_updates";
private SwitchPreference mPreference;
public GpuViewUpdatesPreferenceController(Context context) { public GpuViewUpdatesPreferenceController(Context context) {
super(context); super(context);
} }
@@ -44,13 +40,6 @@ public class GpuViewUpdatesPreferenceController extends
return SHOW_HW_SCREEN_UPDATES_KEY; return SHOW_HW_SCREEN_UPDATES_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -64,18 +53,13 @@ public class GpuViewUpdatesPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean( final boolean isEnabled = SystemProperties.getBoolean(
ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, false /* default */); ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, false /* default */);
mPreference.setChecked(isEnabled); ((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, null); SystemProperties.set(ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, null);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -20,21 +20,17 @@ import android.content.Context;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.ThreadedRenderer; import android.view.ThreadedRenderer;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker; import com.android.settingslib.development.SystemPropPoker;
public class HardwareLayersUpdatesPreferenceController extends public class HardwareLayersUpdatesPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String SHOW_HW_LAYERS_UPDATES_KEY = "show_hw_layers_updates"; private static final String SHOW_HW_LAYERS_UPDATES_KEY = "show_hw_layers_updates";
private SwitchPreference mPreference;
public HardwareLayersUpdatesPreferenceController(Context context) { public HardwareLayersUpdatesPreferenceController(Context context) {
super(context); super(context);
} }
@@ -44,13 +40,6 @@ public class HardwareLayersUpdatesPreferenceController extends
return SHOW_HW_LAYERS_UPDATES_KEY; return SHOW_HW_LAYERS_UPDATES_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -64,18 +53,13 @@ public class HardwareLayersUpdatesPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean( final boolean isEnabled = SystemProperties.getBoolean(
ThreadedRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY, false /* default */); ThreadedRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY, false /* default */);
mPreference.setChecked(isEnabled); ((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(ThreadedRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY, null); SystemProperties.set(ThreadedRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY, null);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

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

View File

@@ -22,7 +22,6 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.settings.R; import com.android.settings.R;
@@ -30,9 +29,8 @@ import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker; import com.android.settingslib.development.SystemPropPoker;
public class HdcpCheckingPreferenceController extends public class HdcpCheckingPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String HDCP_CHECKING_KEY = "hdcp_checking"; private static final String HDCP_CHECKING_KEY = "hdcp_checking";
@@ -43,7 +41,6 @@ public class HdcpCheckingPreferenceController extends
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public HdcpCheckingPreferenceController(Context context) { public HdcpCheckingPreferenceController(Context context) {
super(context); super(context);
@@ -62,37 +59,20 @@ public class HdcpCheckingPreferenceController extends
return HDCP_CHECKING_KEY; return HDCP_CHECKING_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString()); SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
updateHdcpValues(); updateHdcpValues((ListPreference) mPreference);
SystemPropPoker.getInstance().poke(); SystemPropPoker.getInstance().poke();
return true; return true;
} }
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
updateHdcpValues(); updateHdcpValues((ListPreference) mPreference);
} }
@Override private void updateHdcpValues(ListPreference preference) {
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
private void updateHdcpValues() {
final String currentValue = SystemProperties.get(HDCP_CHECKING_PROPERTY); final String currentValue = SystemProperties.get(HDCP_CHECKING_PROPERTY);
int index = 1; // Defaults to drm-only. Needs to match with R.array.hdcp_checking_values int index = 1; // Defaults to drm-only. Needs to match with R.array.hdcp_checking_values
for (int i = 0; i < mListValues.length; i++) { for (int i = 0; i < mListValues.length; i++) {
@@ -101,8 +81,8 @@ public class HdcpCheckingPreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); preference.setValue(mListValues[index]);
mPreference.setSummary(mListSummaries[index]); preference.setSummary(mListSummaries[index]);
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -39,7 +39,6 @@ public class KeepActivitiesPreferenceController extends DeveloperOptionsPreferen
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private IActivityManager mActivityManager; private IActivityManager mActivityManager;
private SwitchPreference mPreference;
public KeepActivitiesPreferenceController(Context context) { public KeepActivitiesPreferenceController(Context context) {
super(context); super(context);
@@ -54,7 +53,6 @@ public class KeepActivitiesPreferenceController extends DeveloperOptionsPreferen
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
mActivityManager = getActivityManager(); mActivityManager = getActivityManager();
} }
@@ -69,19 +67,14 @@ public class KeepActivitiesPreferenceController extends DeveloperOptionsPreferen
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(), final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.ALWAYS_FINISH_ACTIVITIES, SETTING_VALUE_OFF); Settings.Global.ALWAYS_FINISH_ACTIVITIES, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeImmediatelyDestroyActivitiesOptions(false); writeImmediatelyDestroyActivitiesOptions(false);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
private void writeImmediatelyDestroyActivitiesOptions(boolean isEnabled) { private void writeImmediatelyDestroyActivitiesOptions(boolean isEnabled) {

View File

@@ -23,14 +23,13 @@ import android.os.ServiceManager;
import android.os.UserManager; import android.os.UserManager;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class LocalBackupPasswordPreferenceController extends public class LocalBackupPasswordPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements PreferenceControllerMixin { implements PreferenceControllerMixin {
private static final String LOCAL_BACKUP_PASSWORD = "local_backup_password"; private static final String LOCAL_BACKUP_PASSWORD = "local_backup_password";

View File

@@ -12,9 +12,8 @@ import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.wrapper.PackageManagerWrapper; import com.android.settingslib.wrapper.PackageManagerWrapper;
public class LocalTerminalPreferenceController extends public class LocalTerminalPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String ENABLE_TERMINAL_KEY = "enable_terminal"; private static final String ENABLE_TERMINAL_KEY = "enable_terminal";
@@ -22,7 +21,6 @@ public class LocalTerminalPreferenceController extends
static final String TERMINAL_APP_PACKAGE = "com.android.terminal"; static final String TERMINAL_APP_PACKAGE = "com.android.terminal";
private PackageManagerWrapper mPackageManager; private PackageManagerWrapper mPackageManager;
private SwitchPreference mPreference;
private UserManager mUserManager; private UserManager mUserManager;
public LocalTerminalPreferenceController(Context context) { public LocalTerminalPreferenceController(Context context) {
@@ -45,7 +43,6 @@ public class LocalTerminalPreferenceController extends
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
mPackageManager = getPackageManagerWrapper(); mPackageManager = getPackageManagerWrapper();
if (isAvailable() && !isEnabled()) { if (isAvailable() && !isEnabled()) {
@@ -66,7 +63,7 @@ public class LocalTerminalPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isTerminalEnabled = mPackageManager.getApplicationEnabledSetting( final boolean isTerminalEnabled = mPackageManager.getApplicationEnabledSetting(
TERMINAL_APP_PACKAGE) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED; TERMINAL_APP_PACKAGE) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
mPreference.setChecked(isTerminalEnabled); ((SwitchPreference) mPreference).setChecked(isTerminalEnabled);
} }
@Override @Override
@@ -78,10 +75,10 @@ public class LocalTerminalPreferenceController extends
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
mPackageManager.setApplicationEnabledSetting(TERMINAL_APP_PACKAGE, mPackageManager.setApplicationEnabledSetting(TERMINAL_APP_PACKAGE,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0 /* flags */); PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0 /* flags */);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -18,20 +18,16 @@ package com.android.settings.development;
import android.content.Context; import android.content.Context;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.core.lifecycle.Lifecycle; import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.development.AbstractLogpersistPreferenceController; import com.android.settingslib.development.AbstractLogpersistPreferenceController;
public class LogPersistPreferenceController extends public class LogPersistPreferenceController extends AbstractLogpersistPreferenceController
AbstractLogpersistPreferenceController implements PreferenceControllerMixin { implements PreferenceControllerMixin {
private final DevelopmentSettingsDashboardFragment mFragment; private final DevelopmentSettingsDashboardFragment mFragment;
private ListPreference mPreference;
public LogPersistPreferenceController(Context context, public LogPersistPreferenceController(Context context,
DevelopmentSettingsDashboardFragment fragment, Lifecycle lifecycle) { DevelopmentSettingsDashboardFragment fragment, Lifecycle lifecycle) {
@@ -55,27 +51,15 @@ public class LogPersistPreferenceController extends
return false; return false;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
updateLogpersistValues(); updateLogpersistValues();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeLogpersistOption(null /* new value */, true); writeLogpersistOption(null /* new value */, true);
mPreference.setEnabled(false);
} }
public void onDisableLogPersistDialogConfirmed() { public void onDisableLogPersistDialogConfirmed() {

View File

@@ -17,9 +17,7 @@
package com.android.settings.development; package com.android.settings.development;
import android.content.Context; import android.content.Context;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.AbstractLogdSizePreferenceController; import com.android.settingslib.development.AbstractLogdSizePreferenceController;
@@ -27,32 +25,18 @@ import com.android.settingslib.development.AbstractLogdSizePreferenceController;
public class LogdSizePreferenceController extends AbstractLogdSizePreferenceController implements public class LogdSizePreferenceController extends AbstractLogdSizePreferenceController implements
Preference.OnPreferenceChangeListener, PreferenceControllerMixin { Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private ListPreference mPreference;
public LogdSizePreferenceController(Context context) { public LogdSizePreferenceController(Context context) {
super(context); super(context);
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
updateLogdSizeValues(); updateLogdSizeValues();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeLogdSizeOption(null /* new value */); writeLogdSizeOption(null /* new value */);
mPreference.setEnabled(false);
} }
} }

View File

@@ -34,7 +34,6 @@ public class MemoryUsagePreferenceController extends DeveloperOptionsPreferenceC
private static final String MEMORY_USAGE_KEY = "memory"; private static final String MEMORY_USAGE_KEY = "memory";
private Preference mPreference;
private ProcStatsData mProcStatsData; private ProcStatsData mProcStatsData;
public MemoryUsagePreferenceController(Context context) { public MemoryUsagePreferenceController(Context context) {
@@ -50,7 +49,6 @@ public class MemoryUsagePreferenceController extends DeveloperOptionsPreferenceC
public void displayPreference(PreferenceScreen screen) { public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen); super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
mProcStatsData = getProcStatsData(); mProcStatsData = getProcStatsData();
setDuration(); setDuration();
} }

View File

@@ -21,7 +21,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -37,8 +36,6 @@ public class MobileDataAlwaysOnPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public MobileDataAlwaysOnPreferenceController(Context context) { public MobileDataAlwaysOnPreferenceController(Context context) {
super(context); super(context);
} }
@@ -48,13 +45,6 @@ public class MobileDataAlwaysOnPreferenceController extends
return MOBILE_DATA_ALWAYS_ON; return MOBILE_DATA_ALWAYS_ON;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -68,19 +58,14 @@ public class MobileDataAlwaysOnPreferenceController extends
final int mobileDataAlwaysOnMode = Settings.Global.getInt(mContext.getContentResolver(), final int mobileDataAlwaysOnMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.MOBILE_DATA_ALWAYS_ON, SETTING_VALUE_ON); Settings.Global.MOBILE_DATA_ALWAYS_ON, SETTING_VALUE_ON);
mPreference.setChecked(mobileDataAlwaysOnMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(mobileDataAlwaysOnMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON, Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.MOBILE_DATA_ALWAYS_ON,
SETTING_VALUE_OFF); SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -27,7 +27,6 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.settings.R; import com.android.settings.R;
@@ -37,9 +36,8 @@ import com.android.settingslib.wrapper.PackageManagerWrapper;
import java.util.List; import java.util.List;
public class MockLocationAppPreferenceController extends public class MockLocationAppPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements PreferenceControllerMixin, implements PreferenceControllerMixin, OnActivityResultListener {
OnActivityResultListener {
private static final String MOCK_LOCATION_APP_KEY = "mock_location_app"; private static final String MOCK_LOCATION_APP_KEY = "mock_location_app";
private static final int[] MOCK_LOCATION_APP_OPS = new int[]{AppOpsManager.OP_MOCK_LOCATION}; private static final int[] MOCK_LOCATION_APP_OPS = new int[]{AppOpsManager.OP_MOCK_LOCATION};
@@ -47,7 +45,6 @@ public class MockLocationAppPreferenceController extends
private final DevelopmentSettingsDashboardFragment mFragment; private final DevelopmentSettingsDashboardFragment mFragment;
private final AppOpsManager mAppsOpsManager; private final AppOpsManager mAppsOpsManager;
private final PackageManagerWrapper mPackageManager; private final PackageManagerWrapper mPackageManager;
private Preference mPreference;
public MockLocationAppPreferenceController(Context context, public MockLocationAppPreferenceController(Context context,
DevelopmentSettingsDashboardFragment fragment) { DevelopmentSettingsDashboardFragment fragment) {
@@ -63,13 +60,6 @@ public class MockLocationAppPreferenceController extends
return MOCK_LOCATION_APP_KEY; return MOCK_LOCATION_APP_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean handlePreferenceTreeClick(Preference preference) { public boolean handlePreferenceTreeClick(Preference preference) {
if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) { if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
@@ -97,16 +87,6 @@ public class MockLocationAppPreferenceController extends
return true; return true;
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
private void updateMockLocation() { private void updateMockLocation() {
final String mockLocationApp = getCurrentMockLocationApp(); final String mockLocationApp = getCurrentMockLocationApp();

View File

@@ -22,7 +22,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -34,8 +33,6 @@ public class NotificationChannelWarningsPreferenceController extends
private static final String SHOW_NOTIFICATION_CHANNEL_WARNINGS_KEY = private static final String SHOW_NOTIFICATION_CHANNEL_WARNINGS_KEY =
"show_notification_channel_warnings"; "show_notification_channel_warnings";
private SwitchPreference mPreference;
@VisibleForTesting @VisibleForTesting
final static int SETTING_VALUE_ON = 1; final static int SETTING_VALUE_ON = 1;
@VisibleForTesting @VisibleForTesting
@@ -55,13 +52,6 @@ public class NotificationChannelWarningsPreferenceController extends
return SHOW_NOTIFICATION_CHANNEL_WARNINGS_KEY; return SHOW_NOTIFICATION_CHANNEL_WARNINGS_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -76,20 +66,15 @@ public class NotificationChannelWarningsPreferenceController extends
final int defaultWarningEnabled = isDebuggable() ? DEBUGGING_ENABLED : DEBUGGING_DISABLED; final int defaultWarningEnabled = isDebuggable() ? DEBUGGING_ENABLED : DEBUGGING_DISABLED;
final int mode = Settings.Global.getInt(mContext.getContentResolver(), final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, defaultWarningEnabled); Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, defaultWarningEnabled);
mPreference.setChecked(mode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, SETTING_VALUE_OFF); Settings.Global.SHOW_NOTIFICATION_CHANNEL_WARNINGS, SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -129,11 +129,6 @@ public class OemUnlockPreferenceController extends DeveloperOptionsPreferenceCon
handleDeveloperOptionsToggled(); handleDeveloperOptionsToggled();
} }
@Override
protected void onDeveloperOptionsSwitchDisabled() {
handleDeveloperOptionsToggled();
}
public void onOemUnlockConfirmed() { public void onOemUnlockConfirmed() {
mOemLockManager.setOemUnlockAllowedByUser(true); mOemLockManager.setOemUnlockAllowedByUser(true);
} }

View File

@@ -27,9 +27,8 @@ import com.android.settingslib.core.lifecycle.events.OnPause;
import com.android.settingslib.core.lifecycle.events.OnResume; import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class PictureColorModePreferenceController extends public class PictureColorModePreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements implements LifecycleObserver, OnResume, OnPause, PreferenceControllerMixin {
LifecycleObserver, OnResume, OnPause, PreferenceControllerMixin {
private static final String KEY_COLOR_MODE = "picture_color_mode"; private static final String KEY_COLOR_MODE = "picture_color_mode";
@@ -79,16 +78,6 @@ public class PictureColorModePreferenceController extends
mPreference.stopListening(); mPreference.stopListening();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
@VisibleForTesting @VisibleForTesting
boolean isWideColorGamut() { boolean isWideColorGamut() {
return mContext.getResources().getConfiguration().isScreenWideColorGamut(); return mContext.getResources().getConfiguration().isScreenWideColorGamut();

View File

@@ -21,7 +21,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -36,8 +35,6 @@ public class PointerLocationPreferenceController extends DeveloperOptionsPrefere
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public PointerLocationPreferenceController(Context context) { public PointerLocationPreferenceController(Context context) {
super(context); super(context);
} }
@@ -47,13 +44,6 @@ public class PointerLocationPreferenceController extends DeveloperOptionsPrefere
return POINTER_LOCATION_KEY; return POINTER_LOCATION_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -66,19 +56,14 @@ public class PointerLocationPreferenceController extends DeveloperOptionsPrefere
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int pointerLocationMode = Settings.System.getInt(mContext.getContentResolver(), final int pointerLocationMode = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.POINTER_LOCATION, SETTING_VALUE_OFF); Settings.System.POINTER_LOCATION, SETTING_VALUE_OFF);
mPreference.setChecked(pointerLocationMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(pointerLocationMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.System.putInt(mContext.getContentResolver(), Settings.System.POINTER_LOCATION, Settings.System.putInt(mContext.getContentResolver(), Settings.System.POINTER_LOCATION,
SETTING_VALUE_OFF); SETTING_VALUE_OFF);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.ThreadedRenderer; import android.view.ThreadedRenderer;
@@ -29,15 +28,13 @@ import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker; import com.android.settingslib.development.SystemPropPoker;
public class ProfileGpuRenderingPreferenceController extends public class ProfileGpuRenderingPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String TRACK_FRAME_TIME_KEY = "track_frame_time"; private static final String TRACK_FRAME_TIME_KEY = "track_frame_time";
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public ProfileGpuRenderingPreferenceController(Context context) { public ProfileGpuRenderingPreferenceController(Context context) {
super(context); super(context);
@@ -51,13 +48,6 @@ public class ProfileGpuRenderingPreferenceController extends
return TRACK_FRAME_TIME_KEY; return TRACK_FRAME_TIME_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
writeTrackFrameTimeOptions(newValue); writeTrackFrameTimeOptions(newValue);
@@ -70,16 +60,6 @@ public class ProfileGpuRenderingPreferenceController extends
updateTrackFrameTimeOptions(); updateTrackFrameTimeOptions();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
private void writeTrackFrameTimeOptions(Object newValue) { private void writeTrackFrameTimeOptions(Object newValue) {
SystemProperties.set(ThreadedRenderer.PROFILE_PROPERTY, SystemProperties.set(ThreadedRenderer.PROFILE_PROPERTY,
newValue == null ? "" : newValue.toString()); newValue == null ? "" : newValue.toString());
@@ -96,7 +76,8 @@ public class ProfileGpuRenderingPreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); final ListPreference listPreference = (ListPreference) mPreference;
mPreference.setSummary(mListSummaries[index]); listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
} }
} }

View File

@@ -21,14 +21,12 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class ResizableActivityPreferenceController extends public class ResizableActivityPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String FORCE_RESIZABLE_KEY = "force_resizable_activities"; private static final String FORCE_RESIZABLE_KEY = "force_resizable_activities";
@@ -37,8 +35,6 @@ public class ResizableActivityPreferenceController extends
@VisibleForTesting @VisibleForTesting
final static int SETTING_VALUE_OFF = 0; final static int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public ResizableActivityPreferenceController(Context context) { public ResizableActivityPreferenceController(Context context) {
super(context); super(context);
} }
@@ -48,13 +44,6 @@ public class ResizableActivityPreferenceController extends
return FORCE_RESIZABLE_KEY; return FORCE_RESIZABLE_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -68,19 +57,14 @@ public class ResizableActivityPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(), final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, SETTING_VALUE_OFF); Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, SETTING_VALUE_OFF); Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, SETTING_VALUE_OFF);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -22,7 +22,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.internal.app.LocalePicker; import com.android.internal.app.LocalePicker;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
@@ -38,8 +37,6 @@ public class RtlLayoutPreferenceController extends DeveloperOptionsPreferenceCon
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public RtlLayoutPreferenceController(Context context) { public RtlLayoutPreferenceController(Context context) {
super(context); super(context);
} }
@@ -49,13 +46,6 @@ public class RtlLayoutPreferenceController extends DeveloperOptionsPreferenceCon
return FORCE_RTL_LAYOUT_KEY; return FORCE_RTL_LAYOUT_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -68,20 +58,15 @@ public class RtlLayoutPreferenceController extends DeveloperOptionsPreferenceCon
public void updateState(Preference preference) { public void updateState(Preference preference) {
int rtlLayoutMode = Settings.Global.getInt(mContext.getContentResolver(), int rtlLayoutMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RTL, SETTING_VALUE_OFF); Settings.Global.DEVELOPMENT_FORCE_RTL, SETTING_VALUE_OFF);
mPreference.setChecked(rtlLayoutMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(rtlLayoutMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeToForceRtlLayoutSetting(false); writeToForceRtlLayoutSetting(false);
updateLocales(); updateLocales();
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -20,22 +20,19 @@ import android.content.Context;
import android.provider.Settings; import android.provider.Settings;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class SecondaryDisplayPreferenceController extends public class SecondaryDisplayPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices"; private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public SecondaryDisplayPreferenceController(Context context) { public SecondaryDisplayPreferenceController(Context context) {
super(context); super(context);
@@ -50,13 +47,6 @@ public class SecondaryDisplayPreferenceController extends
return OVERLAY_DISPLAY_DEVICES_KEY; return OVERLAY_DISPLAY_DEVICES_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
writeSecondaryDisplayDevicesOption(newValue.toString()); writeSecondaryDisplayDevicesOption(newValue.toString());
@@ -68,15 +58,10 @@ public class SecondaryDisplayPreferenceController extends
updateSecondaryDisplayDevicesOptions(); updateSecondaryDisplayDevicesOptions();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeSecondaryDisplayDevicesOption(null); writeSecondaryDisplayDevicesOption(null);
mPreference.setEnabled(false);
} }
private void updateSecondaryDisplayDevicesOptions() { private void updateSecondaryDisplayDevicesOptions() {
@@ -89,8 +74,9 @@ public class SecondaryDisplayPreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); final ListPreference listPreference = (ListPreference) mPreference;
mPreference.setSummary(mListSummaries[index]); listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
} }
private void writeSecondaryDisplayDevicesOption(String newValue) { private void writeSecondaryDisplayDevicesOption(String newValue) {

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development;
import android.content.Context;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
/**
* Base controller for Switch preference that maps to a specific value in Settings.Secure.
*/
public abstract class SecureSettingSwitchPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
private static final int SETTING_VALUE_OFF = 0;
private static final int SETTING_VALUE_ON = 1;
private final String mSettingsKey;
public SecureSettingSwitchPreferenceController(Context context, String secureSettingsKey) {
super(context);
mSettingsKey = secureSettingsKey;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
Settings.Secure.putInt(mContext.getContentResolver(), mSettingsKey,
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
return true;
}
@Override
public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(
mContext.getContentResolver(), mSettingsKey, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(), mSettingsKey, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
}
}

View File

@@ -27,24 +27,20 @@ import android.content.pm.PackageManager;
import android.provider.Settings; import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.wrapper.PackageManagerWrapper; import com.android.settingslib.wrapper.PackageManagerWrapper;
public class SelectDebugAppPreferenceController extends public class SelectDebugAppPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements PreferenceControllerMixin, implements PreferenceControllerMixin, OnActivityResultListener {
OnActivityResultListener {
private static final String DEBUG_APP_KEY = "debug_app"; private static final String DEBUG_APP_KEY = "debug_app";
private final DevelopmentSettingsDashboardFragment mFragment; private final DevelopmentSettingsDashboardFragment mFragment;
private final PackageManagerWrapper mPackageManager; private final PackageManagerWrapper mPackageManager;
private Preference mPreference;
public SelectDebugAppPreferenceController(Context context, public SelectDebugAppPreferenceController(Context context,
DevelopmentSettingsDashboardFragment fragment) { DevelopmentSettingsDashboardFragment fragment) {
super(context); super(context);
@@ -57,13 +53,6 @@ public class SelectDebugAppPreferenceController extends
return DEBUG_APP_KEY; return DEBUG_APP_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean handlePreferenceTreeClick(Preference preference) { public boolean handlePreferenceTreeClick(Preference preference) {
if (DEBUG_APP_KEY.equals(preference.getKey())) { if (DEBUG_APP_KEY.equals(preference.getKey())) {
@@ -91,14 +80,9 @@ public class SelectDebugAppPreferenceController extends
return true; return true;
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false); super.onDeveloperOptionsSwitchDisabled();
mPreference.setSummary(mContext.getResources().getString(R.string.debug_app_not_set)); mPreference.setSummary(mContext.getResources().getString(R.string.debug_app_not_set));
} }

View File

@@ -21,14 +21,12 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class ShowFirstCrashDialogPreferenceController extends public class ShowFirstCrashDialogPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String SHOW_FIRST_CRASH_DIALOG_KEY = "show_first_crash_dialog"; private static final String SHOW_FIRST_CRASH_DIALOG_KEY = "show_first_crash_dialog";
@@ -37,8 +35,6 @@ public class ShowFirstCrashDialogPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public ShowFirstCrashDialogPreferenceController(Context context) { public ShowFirstCrashDialogPreferenceController(Context context) {
super(context); super(context);
} }
@@ -56,13 +52,6 @@ public class ShowFirstCrashDialogPreferenceController extends
Settings.Global.SHOW_FIRST_CRASH_DIALOG, SETTING_VALUE_OFF) == SETTING_VALUE_OFF; Settings.Global.SHOW_FIRST_CRASH_DIALOG, SETTING_VALUE_OFF) == SETTING_VALUE_OFF;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -76,19 +65,14 @@ public class ShowFirstCrashDialogPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(mContext.getContentResolver(), final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, SETTING_VALUE_OFF); Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, SETTING_VALUE_OFF); Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.View; import android.view.View;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
@@ -32,8 +31,6 @@ public class ShowLayoutBoundsPreferenceController extends DeveloperOptionsPrefer
private static final String DEBUG_LAYOUT_KEY = "debug_layout"; private static final String DEBUG_LAYOUT_KEY = "debug_layout";
private SwitchPreference mPreference;
public ShowLayoutBoundsPreferenceController(Context context) { public ShowLayoutBoundsPreferenceController(Context context) {
super(context); super(context);
} }
@@ -43,13 +40,6 @@ public class ShowLayoutBoundsPreferenceController extends DeveloperOptionsPrefer
return DEBUG_LAYOUT_KEY; return DEBUG_LAYOUT_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -63,18 +53,13 @@ public class ShowLayoutBoundsPreferenceController extends DeveloperOptionsPrefer
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY, final boolean isEnabled = SystemProperties.getBoolean(View.DEBUG_LAYOUT_PROPERTY,
false /* default */); false /* default */);
mPreference.setChecked(isEnabled); ((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY, Boolean.toString(false)); SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY, Boolean.toString(false));
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -24,7 +24,6 @@ import android.os.ServiceManager;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; 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 static final String SURFACE_COMPOSER_INTERFACE_KEY = "android.ui.ISurfaceComposer";
private final IBinder mSurfaceFlinger; private final IBinder mSurfaceFlinger;
private SwitchPreference mPreference;
public ShowSurfaceUpdatesPreferenceController(Context context) { public ShowSurfaceUpdatesPreferenceController(Context context) {
super(context); super(context);
@@ -58,13 +56,6 @@ public class ShowSurfaceUpdatesPreferenceController extends DeveloperOptionsPref
return SHOW_SCREEN_UPDATES_KEY; return SHOW_SCREEN_UPDATES_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -77,20 +68,16 @@ public class ShowSurfaceUpdatesPreferenceController extends DeveloperOptionsPref
updateShowUpdatesSetting(); updateShowUpdatesSetting();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { 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 // 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 // side effect of turning on the preference that we wish to avoid
writeShowUpdatesSetting(false); writeShowUpdatesSetting(false);
mPreference.setChecked(false); preference.setChecked(false);
} }
mPreference.setEnabled(false);
} }
@VisibleForTesting @VisibleForTesting
@@ -105,7 +92,7 @@ public class ShowSurfaceUpdatesPreferenceController extends DeveloperOptionsPref
@SuppressWarnings("unused") final int showCpu = reply.readInt(); @SuppressWarnings("unused") final int showCpu = reply.readInt();
@SuppressWarnings("unused") final int enableGL = reply.readInt(); @SuppressWarnings("unused") final int enableGL = reply.readInt();
final int showUpdates = reply.readInt(); final int showUpdates = reply.readInt();
mPreference.setChecked(showUpdates != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(showUpdates != SETTING_VALUE_OFF);
reply.recycle(); reply.recycle();
data.recycle(); data.recycle();
} }

View File

@@ -21,7 +21,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -36,8 +35,6 @@ public class ShowTapsPreferenceController extends DeveloperOptionsPreferenceCont
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public ShowTapsPreferenceController(Context context) { public ShowTapsPreferenceController(Context context) {
super(context); super(context);
} }
@@ -47,13 +44,6 @@ public class ShowTapsPreferenceController extends DeveloperOptionsPreferenceCont
return SHOW_TOUCHES_KEY; return SHOW_TOUCHES_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -66,19 +56,14 @@ public class ShowTapsPreferenceController extends DeveloperOptionsPreferenceCont
public void updateState(Preference preference) { public void updateState(Preference preference) {
int showTapsMode = Settings.System.getInt(mContext.getContentResolver(), int showTapsMode = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.SHOW_TOUCHES, SETTING_VALUE_OFF); Settings.System.SHOW_TOUCHES, SETTING_VALUE_OFF);
mPreference.setChecked(showTapsMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(showTapsMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.System.putInt(mContext.getContentResolver(), Settings.System.SHOW_TOUCHES, Settings.System.putInt(mContext.getContentResolver(), Settings.System.SHOW_TOUCHES,
SETTING_VALUE_OFF); SETTING_VALUE_OFF);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -23,16 +23,14 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class SimulateColorSpacePreferenceController extends public class SimulateColorSpacePreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String SIMULATE_COLOR_SPACE = "simulate_color_space"; private static final String SIMULATE_COLOR_SPACE = "simulate_color_space";
@@ -41,8 +39,6 @@ public class SimulateColorSpacePreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_ON = 1; static final int SETTING_VALUE_ON = 1;
private ListPreference mPreference;
public SimulateColorSpacePreferenceController(Context context) { public SimulateColorSpacePreferenceController(Context context) {
super(context); super(context);
} }
@@ -52,13 +48,6 @@ public class SimulateColorSpacePreferenceController extends
return SIMULATE_COLOR_SPACE; return SIMULATE_COLOR_SPACE;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
writeSimulateColorSpace(newValue); writeSimulateColorSpace(newValue);
@@ -70,17 +59,12 @@ public class SimulateColorSpacePreferenceController extends
updateSimulateColorSpace(); updateSimulateColorSpace();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
public void onDeveloperOptionsDisabled() { public void onDeveloperOptionsDisabled() {
super.onDeveloperOptionsDisabled();
if (usingDevelopmentColorSpace()) { if (usingDevelopmentColorSpace()) {
writeSimulateColorSpace(-1); writeSimulateColorSpace(-1);
} }
mPreference.setEnabled(false);
} }
private void updateSimulateColorSpace() { private void updateSimulateColorSpace() {
@@ -88,22 +72,23 @@ public class SimulateColorSpacePreferenceController extends
final boolean enabled = Settings.Secure.getInt( final boolean enabled = Settings.Secure.getInt(
cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, SETTING_VALUE_OFF) cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, SETTING_VALUE_OFF)
!= SETTING_VALUE_OFF; != SETTING_VALUE_OFF;
final ListPreference listPreference = (ListPreference) mPreference;
if (enabled) { if (enabled) {
final String mode = Integer.toString(Settings.Secure.getInt( final String mode = Integer.toString(Settings.Secure.getInt(
cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER,
AccessibilityManager.DALTONIZER_DISABLED)); AccessibilityManager.DALTONIZER_DISABLED));
mPreference.setValue(mode); listPreference.setValue(mode);
final int index = mPreference.findIndexOfValue(mode); final int index = listPreference.findIndexOfValue(mode);
if (index < 0) { if (index < 0) {
final Resources res = mContext.getResources(); final Resources res = mContext.getResources();
// We're using a mode controlled by accessibility preferences. // We're using a mode controlled by accessibility preferences.
mPreference.setSummary(res.getString(R.string.daltonizer_type_overridden, listPreference.setSummary(res.getString(R.string.daltonizer_type_overridden,
res.getString(R.string.accessibility_display_daltonizer_preference_title))); res.getString(R.string.accessibility_display_daltonizer_preference_title)));
} else { } else {
mPreference.setSummary("%s"); listPreference.setSummary("%s");
} }
} else { } else {
mPreference.setValue( listPreference.setValue(
Integer.toString(AccessibilityManager.DALTONIZER_DISABLED)); Integer.toString(AccessibilityManager.DALTONIZER_DISABLED));
} }
} }
@@ -134,7 +119,7 @@ public class SimulateColorSpacePreferenceController extends
final String mode = Integer.toString(Settings.Secure.getInt( final String mode = Integer.toString(Settings.Secure.getInt(
cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER,
AccessibilityManager.DALTONIZER_DISABLED)); AccessibilityManager.DALTONIZER_DISABLED));
final int index = mPreference.findIndexOfValue(mode); final int index = ((ListPreference) mPreference).findIndexOfValue(mode);
if (index >= 0) { if (index >= 0) {
// We're using a mode controlled by developer preferences. // We're using a mode controlled by developer preferences.
return true; return true;

View File

@@ -37,9 +37,9 @@ import com.android.settingslib.core.lifecycle.events.OnResume;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class StayAwakePreferenceController extends DeveloperOptionsPreferenceController implements public class StayAwakePreferenceController extends DeveloperOptionsPreferenceController
Preference.OnPreferenceChangeListener, LifecycleObserver, implements Preference.OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause,
OnResume, OnPause, PreferenceControllerMixin { PreferenceControllerMixin {
private static final String TAG = "StayAwakeCtrl"; private static final String TAG = "StayAwakeCtrl";
private static final String PREFERENCE_KEY = "keep_screen_on"; private static final String PREFERENCE_KEY = "keep_screen_on";
@@ -115,17 +115,12 @@ public class StayAwakePreferenceController extends DeveloperOptionsPreferenceCon
mSettingsObserver.register(false /* unregister */); mSettingsObserver.register(false /* unregister */);
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, SETTING_VALUE_OFF); Settings.Global.STAY_ON_WHILE_PLUGGED_IN, SETTING_VALUE_OFF);
mPreference.setChecked(false); mPreference.setChecked(false);
mPreference.setEnabled(false);
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -24,7 +24,6 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.IWindowManager; import android.view.IWindowManager;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
@@ -43,8 +42,6 @@ public class StrictModePreferenceController extends DeveloperOptionsPreferenceCo
private final IWindowManager mWindowManager; private final IWindowManager mWindowManager;
private SwitchPreference mPreference;
public StrictModePreferenceController(Context context) { public StrictModePreferenceController(Context context) {
super(context); super(context);
@@ -57,13 +54,6 @@ public class StrictModePreferenceController extends DeveloperOptionsPreferenceCo
return STRICT_MODE_KEY; return STRICT_MODE_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -73,19 +63,14 @@ public class StrictModePreferenceController extends DeveloperOptionsPreferenceCo
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
mPreference.setChecked(isStrictModeEnabled()); ((SwitchPreference) mPreference).setChecked(isStrictModeEnabled());
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeStrictModeVisualOptions(false); writeStrictModeVisualOptions(false);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
private boolean isStrictModeEnabled() { private boolean isStrictModeEnabled() {

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.development;
import android.content.Context;
import android.provider.Settings;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
/**
* Base controller for Switch preference that maps to a specific value in Settings.System.
*/
public abstract class SystemSettingSwitchPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
private static final int SETTING_VALUE_OFF = 0;
private static final int SETTING_VALUE_ON = 1;
private final String mSettingsKey;
public SystemSettingSwitchPreferenceController(Context context, String systemSettingsKey) {
super(context);
mSettingsKey = systemSettingsKey;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
Settings.System.putInt(mContext.getContentResolver(), mSettingsKey,
isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
return true;
}
@Override
public void updateState(Preference preference) {
final int mode = Settings.System.getInt(
mContext.getContentResolver(), mSettingsKey, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.System.putInt(mContext.getContentResolver(), mSettingsKey, SETTING_VALUE_OFF);
((SwitchPreference) mPreference).setChecked(false);
}
}

View File

@@ -21,14 +21,12 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class TetheringHardwareAccelPreferenceController extends public class TetheringHardwareAccelPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String TETHERING_HARDWARE_OFFLOAD = "tethering_hardware_offload"; private static final String TETHERING_HARDWARE_OFFLOAD = "tethering_hardware_offload";
@@ -39,8 +37,6 @@ public class TetheringHardwareAccelPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 1; static final int SETTING_VALUE_OFF = 1;
private SwitchPreference mPreference;
public TetheringHardwareAccelPreferenceController(Context context) { public TetheringHardwareAccelPreferenceController(Context context) {
super(context); super(context);
} }
@@ -50,13 +46,6 @@ public class TetheringHardwareAccelPreferenceController extends
return TETHERING_HARDWARE_OFFLOAD; return TETHERING_HARDWARE_OFFLOAD;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -71,19 +60,14 @@ public class TetheringHardwareAccelPreferenceController extends
final int tetheringMode = Settings.Global.getInt( final int tetheringMode = Settings.Global.getInt(
mContext.getContentResolver(), mContext.getContentResolver(),
Settings.Global.TETHER_OFFLOAD_DISABLED, 0 /* default */); Settings.Global.TETHER_OFFLOAD_DISABLED, 0 /* default */);
mPreference.setChecked(tetheringMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(tetheringMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.TETHER_OFFLOAD_DISABLED, SETTING_VALUE_OFF); Settings.Global.TETHER_OFFLOAD_DISABLED, SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -22,7 +22,6 @@ import android.os.ServiceManager;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.IWindowManager; import android.view.IWindowManager;
import com.android.settings.R; import com.android.settings.R;
@@ -43,7 +42,6 @@ public class TransitionAnimationScalePreferenceController extends
private final IWindowManager mWindowManager; private final IWindowManager mWindowManager;
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public TransitionAnimationScalePreferenceController(Context context) { public TransitionAnimationScalePreferenceController(Context context) {
super(context); super(context);
@@ -61,13 +59,6 @@ public class TransitionAnimationScalePreferenceController extends
return TRANSITION_ANIMATION_SCALE_KEY; return TRANSITION_ANIMATION_SCALE_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
writeAnimationScaleOption(newValue); writeAnimationScaleOption(newValue);
@@ -79,15 +70,10 @@ public class TransitionAnimationScalePreferenceController extends
updateAnimationScaleValue(); updateAnimationScaleValue();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeAnimationScaleOption(null); writeAnimationScaleOption(null);
mPreference.setEnabled(false);
} }
private void writeAnimationScaleOption(Object newValue) { private void writeAnimationScaleOption(Object newValue) {
@@ -112,8 +98,9 @@ public class TransitionAnimationScalePreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); final ListPreference listPreference = (ListPreference) mPreference;
mPreference.setSummary(mListSummaries[index]); listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
} catch (RemoteException e) { } catch (RemoteException e) {
// intentional no-op // intentional no-op
} }

View File

@@ -21,7 +21,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -36,8 +35,6 @@ public class UsbAudioRoutingPreferenceController extends DeveloperOptionsPrefere
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public UsbAudioRoutingPreferenceController(Context context) { public UsbAudioRoutingPreferenceController(Context context) {
super(context); super(context);
} }
@@ -47,13 +44,6 @@ public class UsbAudioRoutingPreferenceController extends DeveloperOptionsPrefere
return USB_AUDIO_KEY; return USB_AUDIO_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -67,19 +57,14 @@ public class UsbAudioRoutingPreferenceController extends DeveloperOptionsPrefere
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int usbAudioRoutingMode = Settings.Secure.getInt(mContext.getContentResolver(), final int usbAudioRoutingMode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, SETTING_VALUE_OFF); Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, SETTING_VALUE_OFF);
mPreference.setChecked(usbAudioRoutingMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(usbAudioRoutingMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, SETTING_VALUE_OFF); Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED, SETTING_VALUE_OFF);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -24,7 +24,6 @@ import android.os.UserManager;
import android.provider.Settings; import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.RestrictedLockUtils; import com.android.settingslib.RestrictedLockUtils;
@@ -38,14 +37,12 @@ import java.util.List;
/** /**
* Controller to manage the state of "Verify apps over USB" toggle. * Controller to manage the state of "Verify apps over USB" toggle.
*/ */
public class VerifyAppsOverUsbPreferenceController extends public class VerifyAppsOverUsbPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, AdbOnChangeListener,
AdbOnChangeListener, PreferenceControllerMixin { PreferenceControllerMixin {
private static final String VERIFY_APPS_OVER_USB_KEY = "verify_apps_over_usb"; private static final String VERIFY_APPS_OVER_USB_KEY = "verify_apps_over_usb";
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive"; private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
private RestrictedSwitchPreference mPreference;
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_ON = 1; static final int SETTING_VALUE_ON = 1;
@VisibleForTesting @VisibleForTesting
@@ -87,12 +84,6 @@ public class VerifyAppsOverUsbPreferenceController extends
return VERIFY_APPS_OVER_USB_KEY; return VERIFY_APPS_OVER_USB_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -104,26 +95,28 @@ public class VerifyAppsOverUsbPreferenceController extends
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
final RestrictedSwitchPreference restrictedPreference =
(RestrictedSwitchPreference) preference;
if (!shouldBeEnabled()) { if (!shouldBeEnabled()) {
mPreference.setChecked(false); restrictedPreference.setChecked(false);
mPreference.setDisabledByAdmin(null); restrictedPreference.setDisabledByAdmin(null);
mPreference.setEnabled(false); restrictedPreference.setEnabled(false);
return; return;
} }
final EnforcedAdmin enforcingAdmin = mRestrictedLockUtils.checkIfRestrictionEnforced( final EnforcedAdmin enforcingAdmin = mRestrictedLockUtils.checkIfRestrictionEnforced(
mContext, UserManager.ENSURE_VERIFY_APPS, UserHandle.myUserId()); mContext, UserManager.ENSURE_VERIFY_APPS, UserHandle.myUserId());
if (enforcingAdmin != null) { if (enforcingAdmin != null) {
mPreference.setChecked(true); restrictedPreference.setChecked(true);
mPreference.setDisabledByAdmin(enforcingAdmin); restrictedPreference.setDisabledByAdmin(enforcingAdmin);
return; return;
} }
mPreference.setEnabled(true); restrictedPreference.setEnabled(true);
final boolean checked = Settings.Global.getInt(mContext.getContentResolver(), final boolean checked = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, SETTING_VALUE_ON) Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, SETTING_VALUE_ON)
!= SETTING_VALUE_OFF; != SETTING_VALUE_OFF;
mPreference.setChecked(checked); restrictedPreference.setChecked(checked);
} }
@Override @Override
@@ -135,15 +128,10 @@ public class VerifyAppsOverUsbPreferenceController extends
@Override @Override
protected void onDeveloperOptionsSwitchEnabled() { protected void onDeveloperOptionsSwitchEnabled() {
super.onDeveloperOptionsSwitchEnabled();
updateState(mPreference); updateState(mPreference);
} }
@Override
protected void onDeveloperOptionsSwitchDisabled() {
// intentional no-op
// We can rely on onAdbSettingChanged() to update this controller.
}
/** /**
* Checks whether the toggle should be enabled depending on whether verify apps over USB is * Checks whether the toggle should be enabled depending on whether verify apps over USB is
* possible currently. If ADB is disabled or if package verifier does not exist, the toggle * possible currently. If ADB is disabled or if package verifier does not exist, the toggle

View File

@@ -29,15 +29,14 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class WaitForDebuggerPreferenceController extends public class WaitForDebuggerPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin,
PreferenceControllerMixin, OnActivityResultListener { OnActivityResultListener {
private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger"; private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
@@ -46,8 +45,6 @@ public class WaitForDebuggerPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public WaitForDebuggerPreferenceController(Context context) { public WaitForDebuggerPreferenceController(Context context) {
super(context); super(context);
} }
@@ -57,13 +54,6 @@ public class WaitForDebuggerPreferenceController extends
return WAIT_FOR_DEBUGGER_KEY; return WAIT_FOR_DEBUGGER_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean debuggerEnabled = (Boolean) newValue; final boolean debuggerEnabled = (Boolean) newValue;
@@ -75,13 +65,8 @@ public class WaitForDebuggerPreferenceController extends
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
final String debugApp = Settings.Global.getString( updateState(mPreference, Settings.Global.getString(
mContext.getContentResolver(), Settings.Global.DEBUG_APP); mContext.getContentResolver(), Settings.Global.DEBUG_APP));
final boolean debuggerEnabled = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.WAIT_FOR_DEBUGGER, SETTING_VALUE_OFF) != SETTING_VALUE_OFF;
writeDebuggerAppOptions(debugApp, debuggerEnabled, true /* persistent */);
mPreference.setChecked(debuggerEnabled);
mPreference.setEnabled(!TextUtils.isEmpty(debugApp));
} }
@Override @Override
@@ -89,26 +74,25 @@ public class WaitForDebuggerPreferenceController extends
if (requestCode != REQUEST_CODE_DEBUG_APP || resultCode != Activity.RESULT_OK) { if (requestCode != REQUEST_CODE_DEBUG_APP || resultCode != Activity.RESULT_OK) {
return false; return false;
} }
final boolean debuggerEnabled = Settings.Global.getInt(mContext.getContentResolver(), updateState(mPreference, data.getAction());
Settings.Global.WAIT_FOR_DEBUGGER, SETTING_VALUE_OFF) != SETTING_VALUE_OFF;
final String debugApp = data.getAction();
writeDebuggerAppOptions(debugApp, debuggerEnabled, true /* persistent */);
mPreference.setChecked(debuggerEnabled);
mPreference.setEnabled(!TextUtils.isEmpty(debugApp));
return true; return true;
} }
@Override private void updateState(Preference preference, String debugApp) {
protected void onDeveloperOptionsSwitchEnabled() { final SwitchPreference switchPreference = (SwitchPreference) preference;
mPreference.setEnabled(true); final boolean debuggerEnabled = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.WAIT_FOR_DEBUGGER, SETTING_VALUE_OFF) != SETTING_VALUE_OFF;
writeDebuggerAppOptions(debugApp, debuggerEnabled, true /* persistent */);
switchPreference.setChecked(debuggerEnabled);
switchPreference.setEnabled(!TextUtils.isEmpty(debugApp));
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeDebuggerAppOptions(null /* package name */, writeDebuggerAppOptions(null /* package name */,
false /* waitForDebugger */, false /* persistent */); false /* waitForDebugger */, false /* persistent */);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
@VisibleForTesting @VisibleForTesting

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
@@ -31,8 +30,8 @@ import com.android.settingslib.applications.DefaultAppInfo;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.wrapper.PackageManagerWrapper; import com.android.settingslib.wrapper.PackageManagerWrapper;
public class WebViewAppPreferenceController extends public class WebViewAppPreferenceController extends DeveloperOptionsPreferenceController implements
DeveloperOptionsPreferenceController implements PreferenceControllerMixin { PreferenceControllerMixin {
private static final String TAG = "WebViewAppPrefCtrl"; private static final String TAG = "WebViewAppPrefCtrl";
private static final String WEBVIEW_APP_KEY = "select_webview_provider"; private static final String WEBVIEW_APP_KEY = "select_webview_provider";
@@ -40,8 +39,6 @@ public class WebViewAppPreferenceController extends
private final PackageManagerWrapper mPackageManager; private final PackageManagerWrapper mPackageManager;
private final WebViewUpdateServiceWrapper mWebViewUpdateServiceWrapper; private final WebViewUpdateServiceWrapper mWebViewUpdateServiceWrapper;
private Preference mPreference;
public WebViewAppPreferenceController(Context context) { public WebViewAppPreferenceController(Context context) {
super(context); super(context);
@@ -54,13 +51,6 @@ public class WebViewAppPreferenceController extends
return WEBVIEW_APP_KEY; return WEBVIEW_APP_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
}
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
final CharSequence defaultAppLabel = getDefaultAppLabel(); final CharSequence defaultAppLabel = getDefaultAppLabel();
@@ -72,16 +62,6 @@ public class WebViewAppPreferenceController extends
} }
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
@VisibleForTesting @VisibleForTesting
DefaultAppInfo getDefaultAppInfo() { DefaultAppInfo getDefaultAppInfo() {
final PackageInfo currentPackage = mWebViewUpdateServiceWrapper.getCurrentWebViewPackage(); final PackageInfo currentPackage = mWebViewUpdateServiceWrapper.getCurrentWebViewPackage();

View File

@@ -21,7 +21,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
@@ -39,8 +38,6 @@ public class WifiConnectedMacRandomizationPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public WifiConnectedMacRandomizationPreferenceController(Context context) { public WifiConnectedMacRandomizationPreferenceController(Context context) {
super(context); super(context);
} }
@@ -56,12 +53,6 @@ public class WifiConnectedMacRandomizationPreferenceController extends
return WIFI_CONNECTED_MAC_RANDOMIZATION_KEY; return WIFI_CONNECTED_MAC_RANDOMIZATION_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -75,19 +66,14 @@ public class WifiConnectedMacRandomizationPreferenceController extends
public void updateState(Preference preference) { public void updateState(Preference preference) {
final int enableMode = Settings.Global.getInt(mContext.getContentResolver(), final int enableMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_OFF); Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_OFF);
mPreference.setChecked(enableMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(enableMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_OFF); Settings.Global.WIFI_CONNECTED_MAC_RANDOMIZATION_ENABLED, SETTING_VALUE_OFF);
mPreference.setChecked(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setEnabled(false);
} }
} }

View File

@@ -21,7 +21,6 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -37,8 +36,6 @@ public class WifiDisplayCertificationPreferenceController extends
@VisibleForTesting @VisibleForTesting
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public WifiDisplayCertificationPreferenceController(Context context) { public WifiDisplayCertificationPreferenceController(Context context) {
super(context); super(context);
} }
@@ -48,13 +45,6 @@ public class WifiDisplayCertificationPreferenceController extends
return WIFI_DISPLAY_CERTIFICATION_KEY; return WIFI_DISPLAY_CERTIFICATION_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -69,19 +59,15 @@ public class WifiDisplayCertificationPreferenceController extends
final int wifiDisplayCertificationMode = Settings.Global.getInt( final int wifiDisplayCertificationMode = Settings.Global.getInt(
mContext.getContentResolver(), Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, mContext.getContentResolver(), Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON,
SETTING_VALUE_OFF); SETTING_VALUE_OFF);
mPreference.setChecked(wifiDisplayCertificationMode != SETTING_VALUE_OFF); ((SwitchPreference) mPreference).setChecked(
} wifiDisplayCertificationMode != SETTING_VALUE_OFF);
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
} }
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, SETTING_VALUE_OFF); Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -21,14 +21,12 @@ import android.net.wifi.WifiManager;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference; import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController; import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class WifiVerboseLoggingPreferenceController extends public class WifiVerboseLoggingPreferenceController extends DeveloperOptionsPreferenceController
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener, implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
PreferenceControllerMixin {
private static final String WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging"; private static final String WIFI_VERBOSE_LOGGING_KEY = "wifi_verbose_logging";
@@ -38,7 +36,6 @@ public class WifiVerboseLoggingPreferenceController extends
static final int SETTING_VALUE_OFF = 0; static final int SETTING_VALUE_OFF = 0;
private final WifiManager mWifiManager; private final WifiManager mWifiManager;
private SwitchPreference mPreference;
public WifiVerboseLoggingPreferenceController(Context context) { public WifiVerboseLoggingPreferenceController(Context context) {
super(context); super(context);
@@ -51,13 +48,6 @@ public class WifiVerboseLoggingPreferenceController extends
return WIFI_VERBOSE_LOGGING_KEY; return WIFI_VERBOSE_LOGGING_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue; final boolean isEnabled = (Boolean) newValue;
@@ -68,19 +58,14 @@ public class WifiVerboseLoggingPreferenceController extends
@Override @Override
public void updateState(Preference preference) { public void updateState(Preference preference) {
final boolean enabled = mWifiManager.getVerboseLoggingLevel() > 0; final boolean enabled = mWifiManager.getVerboseLoggingLevel() > 0;
mPreference.setChecked(enabled); ((SwitchPreference) mPreference).setChecked(enabled);
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
mWifiManager.enableVerboseLogging(SETTING_VALUE_OFF); mWifiManager.enableVerboseLogging(SETTING_VALUE_OFF);
mPreference.setEnabled(false); ((SwitchPreference) mPreference).setChecked(false);
mPreference.setChecked(false);
} }
} }

View File

@@ -22,7 +22,6 @@ import android.os.ServiceManager;
import android.support.annotation.VisibleForTesting; import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.IWindowManager; import android.view.IWindowManager;
import com.android.settings.R; import com.android.settings.R;
@@ -44,8 +43,6 @@ public class WindowAnimationScalePreferenceController extends
private final String[] mListValues; private final String[] mListValues;
private final String[] mListSummaries; private final String[] mListSummaries;
private ListPreference mPreference;
public WindowAnimationScalePreferenceController(Context context) { public WindowAnimationScalePreferenceController(Context context) {
super(context); super(context);
@@ -61,13 +58,6 @@ public class WindowAnimationScalePreferenceController extends
return WINDOW_ANIMATION_SCALE_KEY; return WINDOW_ANIMATION_SCALE_KEY;
} }
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override @Override
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
writeAnimationScaleOption(newValue); writeAnimationScaleOption(newValue);
@@ -79,15 +69,10 @@ public class WindowAnimationScalePreferenceController extends
updateAnimationScaleValue(); updateAnimationScaleValue();
} }
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override @Override
protected void onDeveloperOptionsSwitchDisabled() { protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeAnimationScaleOption(null); writeAnimationScaleOption(null);
mPreference.setEnabled(false);
} }
private void writeAnimationScaleOption(Object newValue) { private void writeAnimationScaleOption(Object newValue) {
@@ -111,8 +96,9 @@ public class WindowAnimationScalePreferenceController extends
break; break;
} }
} }
mPreference.setValue(mListValues[index]); final ListPreference listPreference = (ListPreference) mPreference;
mPreference.setSummary(mListSummaries[index]); listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
} catch (RemoteException e) { } catch (RemoteException e) {
// intentional no-op // intentional no-op
} }

View File

@@ -119,20 +119,6 @@ public class AbstractBluetoothA2dpPreferenceControllerTest {
verify(mController).updateState(mPreference); verify(mController).updateState(mPreference);
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
@Test
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsSwitchDisabled();
verify(mPreference).setEnabled(false);
}
static class AbstractBluetoothA2dpPreferenceControllerImpl extends static class AbstractBluetoothA2dpPreferenceControllerImpl extends
AbstractBluetoothA2dpPreferenceController { AbstractBluetoothA2dpPreferenceController {

View File

@@ -78,14 +78,6 @@ public class AdbPreferenceControllerTest {
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
when(mUserManager.isAdminUser()).thenReturn(true);
mController.onDeveloperOptionsEnabled();
verify(mPreference).setEnabled(true);
}
@Test @Test
public void onAdbDialogConfirmed_shouldEnableAdbSetting() { public void onAdbDialogConfirmed_shouldEnableAdbSetting() {
mController.onAdbDialogConfirmed(); mController.onAdbDialogConfirmed();

View File

@@ -114,11 +114,4 @@ public class AllowAppsOnExternalPreferenceControllerTest {
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -126,11 +126,4 @@ public class AnimatorDurationScalePreferenceControllerTest {
verify(mWindowManager).setAnimationScale(ANIMATOR_DURATION_SCALE_SELECTOR, DEFAULT_VALUE); verify(mWindowManager).setAnimationScale(ANIMATOR_DURATION_SCALE_SELECTOR, DEFAULT_VALUE);
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() throws RemoteException {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -113,11 +113,4 @@ public class AppsNotRespondingPreferenceControllerTest {
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -123,13 +123,6 @@ public class BackgroundProcessLimitPreferenceControllerTest {
verify(mPreference).setSummary(mListSummaries[0]); verify(mPreference).setSummary(mListSummaries[0]);
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
@Test @Test
public void onDeveloperOptionsSwitchDisabled_shouldDisableAndResetPreference() public void onDeveloperOptionsSwitchDisabled_shouldDisableAndResetPreference()
throws RemoteException { throws RemoteException {

View File

@@ -114,11 +114,4 @@ public class BluetoothAbsoluteVolumePreferenceControllerTest {
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -129,18 +129,4 @@ public class BluetoothAvrcpVersionPreferenceControllerTest {
verify(mPreference).setValue(mListValues[0]); verify(mPreference).setValue(mListValues[0]);
verify(mPreference).setSummary(mListSummaries[0]); verify(mPreference).setSummary(mListSummaries[0]);
} }
@Test
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsSwitchDisabled();
verify(mPreference).setEnabled(false);
}
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -114,16 +114,4 @@ public class BluetoothDelayReportsPreferenceControllerTest {
assertThat(mPreference.isEnabled()).isFalse(); assertThat(mPreference.isEnabled()).isFalse();
assertThat(mPreference.isChecked()).isFalse(); assertThat(mPreference.isChecked()).isFalse();
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
final boolean mode = SettingsShadowSystemProperties.getBoolean(
BLUETOOTH_ENABLE_AVDTP_DELAY_REPORTS_PROPERTY, false /* default */);
assertThat(mode).isFalse();
assertThat(mPreference.isEnabled()).isTrue();
assertThat(mPreference.isChecked()).isFalse();
}
} }

View File

@@ -113,11 +113,4 @@ public class BluetoothDeviceNoNamePreferenceControllerTest {
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -128,11 +128,4 @@ public class BluetoothInbandRingingPreferenceControllerTest {
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -107,11 +107,4 @@ public class BluetoothSnoopLogPreferenceControllerTest {
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -149,13 +149,6 @@ public class CameraLaserSensorPreferenceControllerTest {
Integer.toString(CameraLaserSensorPreferenceController.ENABLED))); Integer.toString(CameraLaserSensorPreferenceController.ENABLED)));
} }
@Test
public void onDeveloperOptionsSwitchEnabled_preferenceShouldBeEnabled() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
@Test @Test
public void onDeveloperOptionsSwitchDisabled_preferenceShouldBeEnabled() { public void onDeveloperOptionsSwitchDisabled_preferenceShouldBeEnabled() {
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();

View File

@@ -172,16 +172,6 @@ public class ClearAdbKeysPreferenceControllerTest {
verify(mPreference, never()).setEnabled(true); verify(mPreference, never()).setEnabled(true);
} }
@Test
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
SystemProperties.set(RO_ADB_SECURE_PROPERTY_KEY, Boolean.toString(true));
doReturn(true).when(mController).isAdminUser();
mController.displayPreference(mScreen);
mController.onDeveloperOptionsSwitchDisabled();
verify(mPreference).setEnabled(false);
}
@Test @Test
public void onClearAdbKeysConfirmed_shouldClearKeys() throws RemoteException { public void onClearAdbKeysConfirmed_shouldClearKeys() throws RemoteException {
mController.onClearAdbKeysConfirmed(); mController.onClearAdbKeysConfirmed();

View File

@@ -198,13 +198,6 @@ public class ConnectivityMonitorPreferenceControllerTest {
ConnectivityMonitorPreferenceController.DISABLED_STATUS)); ConnectivityMonitorPreferenceController.DISABLED_STATUS));
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
@Test @Test
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() { public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();

View File

@@ -109,13 +109,6 @@ public class CoolColorTemperaturePreferenceControllerTest {
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
verify(mPreference).setEnabled(true);
}
@Test @Test
@Config(qualifiers = "mcc999") @Config(qualifiers = "mcc999")
public void isAvailable_shouldBeFalse() { public void isAvailable_shouldBeFalse() {

View File

@@ -124,18 +124,4 @@ public class DebugGpuOverdrawPreferenceControllerTest {
verify(mPreference).setValue(mListValues[0]); verify(mPreference).setValue(mListValues[0]);
verify(mPreference).setSummary(mListSummaries[0]); verify(mPreference).setSummary(mListSummaries[0]);
} }
@Test
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsSwitchDisabled();
verify(mPreference).setEnabled(false);
}
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -127,18 +127,4 @@ public class DebugNonRectClipOperationsPreferenceControllerTest {
verify(mPreference).setValue(mListValues[0]); verify(mPreference).setValue(mListValues[0]);
verify(mPreference).setSummary(mListSummaries[0]); verify(mPreference).setSummary(mListSummaries[0]);
} }
@Test
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsSwitchDisabled();
verify(mPreference).setEnabled(false);
}
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -108,11 +108,4 @@ public class DebugViewAttributesPreferenceControllerTest {
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -110,11 +110,4 @@ public class DisableAutomaticUpdatesPreferenceControllerTest {
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@@ -28,6 +29,7 @@ import static org.mockito.Mockito.when;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.support.v7.preference.ListPreference; import android.support.v7.preference.ListPreference;
import android.support.v7.preference.PreferenceScreen;
import android.view.DisplayCutout; import android.view.DisplayCutout;
import com.android.settings.TestConfig; import com.android.settings.TestConfig;
@@ -125,19 +127,12 @@ public class EmulateDisplayCutoutPreferenceControllerTest {
verify(mPreference).setValueIndex(0); verify(mPreference).setValueIndex(0);
} }
@Test
public void onDeveloperOptionsSwitchEnabled() throws Exception {
mockCurrentOverlays();
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
verify(mOverlayManager, never()).setEnabledExclusiveInCategory(any(), anyInt());
}
@Test @Test
public void onDeveloperOptionsSwitchDisabled() throws Exception { public void onDeveloperOptionsSwitchDisabled() throws Exception {
mockCurrentOverlays(ONE_ENABLED, TWO_DISABLED); mockCurrentOverlays(ONE_ENABLED, TWO_DISABLED);
final PreferenceScreen screen = mock(PreferenceScreen.class);
when(screen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
mController.displayPreference(screen);
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();

View File

@@ -114,11 +114,4 @@ public class EnableGnssRawMeasFullTrackingPreferenceControllerTest {
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -114,11 +114,4 @@ public class EnableGpuDebugLayersPreferenceControllerTest {
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -117,11 +117,4 @@ public class ForceGpuRenderingPreferenceControllerTest {
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -112,15 +112,4 @@ public class ForceMSAAPreferenceControllerTest {
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
final boolean mode = SettingsShadowSystemProperties.getBoolean(
ForceMSAAPreferenceController.MSAA_PROPERTY, false /* default */);
assertThat(mode).isFalse();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -121,13 +121,6 @@ public class FreeformWindowsPreferenceControllerTest {
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
@Test @Test
public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() { public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
mController.onDeveloperOptionsSwitchDisabled(); mController.onDeveloperOptionsSwitchDisabled();

View File

@@ -113,15 +113,4 @@ public class GpuViewUpdatesPreferenceControllerTest {
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
final boolean mode = SettingsShadowSystemProperties.getBoolean(
ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, false /* default */);
assertThat(mode).isFalse();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -113,15 +113,4 @@ public class HardwareLayersUpdatesPreferenceControllerTest {
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false); verify(mPreference).setChecked(false);
} }
@Test
public void onDeveloperOptionsEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsEnabled();
final boolean mode = SettingsShadowSystemProperties.getBoolean(
ThreadedRenderer.DEBUG_SHOW_LAYERS_UPDATES_PROPERTY, false /* default */);
assertThat(mode).isFalse();
verify(mPreference).setEnabled(true);
}
} }

View File

@@ -127,11 +127,4 @@ public class HardwareOverlaysPreferenceControllerTest {
verify(mPreference, never()).setChecked(anyBoolean()); verify(mPreference, never()).setChecked(anyBoolean());
verify(mPreference).setEnabled(false); verify(mPreference).setEnabled(false);
} }
@Test
public void onDeveloperOptionsSwitchEnabled_shouldEnablePreference() {
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setEnabled(true);
}
} }

Some files were not shown because too many files have changed in this diff Show More