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;
}
@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}.
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -16,14 +16,12 @@
package com.android.settings.development;
import android.content.ComponentName;
import android.content.Context;
import android.os.UserManager;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -40,7 +38,6 @@ public class BugReportInPowerPreferenceController extends
static int SETTING_VALUE_OFF = 0;
private final UserManager mUserManager;
private SwitchPreference mPreference;
public BugReportInPowerPreferenceController(Context context) {
super(context);
@@ -57,13 +54,6 @@ public class BugReportInPowerPreferenceController extends
return KEY_BUGREPORT_IN_POWER;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(KEY_BUGREPORT_IN_POWER);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -77,18 +67,14 @@ public class BugReportInPowerPreferenceController extends
public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Global.BUGREPORT_IN_POWER_MENU, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
// no-op because this preference can never be disabled
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(),
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.
*/
package com.android.settings.development;
import android.content.Context;
import android.os.SystemProperties;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting;
@@ -29,9 +27,8 @@ import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class CameraLaserSensorPreferenceController extends
DeveloperOptionsPreferenceController implements
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
public class CameraLaserSensorPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String KEY_CAMERA_LASER_SENSOR_SWITCH = "camera_laser_sensor_switch";
@VisibleForTesting
@@ -49,8 +46,6 @@ public class CameraLaserSensorPreferenceController extends
@VisibleForTesting
static final String USER_BUILD = "user";
private SwitchPreference mPreference;
public CameraLaserSensorPreferenceController(Context context) {
super(context);
}
@@ -65,13 +60,6 @@ public class CameraLaserSensorPreferenceController extends
return KEY_CAMERA_LASER_SENSOR_SWITCH;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -83,19 +71,14 @@ public class CameraLaserSensorPreferenceController extends
@Override
public void updateState(Preference preference) {
final boolean enabled = isLaserSensorEnabled();
mPreference.setChecked(enabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
((SwitchPreference) mPreference).setChecked(enabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(PROPERTY_CAMERA_LASER_SENSOR, Integer.toString(DISABLED));
mPreference.setChecked(false);
mPreference.setEnabled(false);
((SwitchPreference) mPreference).setChecked(false);
}
private boolean isLaserSensorEnabled() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.os.SystemProperties;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import android.view.ThreadedRenderer;
@@ -37,7 +36,6 @@ public class DebugNonRectClipOperationsPreferenceController extends
private final String[] mListValues;
private final String[] mListSummaries;
private ListPreference mPreference;
public DebugNonRectClipOperationsPreferenceController(Context context) {
super(context);
@@ -51,13 +49,6 @@ public class DebugNonRectClipOperationsPreferenceController extends
return SHOW_NON_RECTANGULAR_CLIP_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
writeShowNonRectClipOptions(newValue);
@@ -70,16 +61,6 @@ public class DebugNonRectClipOperationsPreferenceController extends
updateShowNonRectClipOptions();
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
private void writeShowNonRectClipOptions(Object newValue) {
SystemProperties.set(ThreadedRenderer.DEBUG_SHOW_NON_RECTANGULAR_CLIP_PROPERTY,
newValue == null ? "" : newValue.toString());
@@ -97,7 +78,8 @@ public class DebugNonRectClipOperationsPreferenceController extends
break;
}
}
mPreference.setValue(mListValues[index]);
mPreference.setSummary(mListSummaries[index]);
final ListPreference listPreference = (ListPreference) mPreference;
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.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -37,8 +36,6 @@ public class DebugViewAttributesPreferenceController extends
@VisibleForTesting
static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public DebugViewAttributesPreferenceController(Context context) {
super(context);
}
@@ -48,13 +45,6 @@ public class DebugViewAttributesPreferenceController extends
return DEBUG_VIEW_ATTRIBUTES_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean showViewAttr = (Boolean) newValue;
@@ -68,19 +58,14 @@ public class DebugViewAttributesPreferenceController extends
public void updateState(Preference preference) {
final int debugViewAttrMode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEBUG_VIEW_ATTRIBUTES, 0 /* default */);
mPreference.setChecked(debugViewAttrMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
((SwitchPreference) mPreference).setChecked(debugViewAttrMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEBUG_VIEW_ATTRIBUTES, SETTING_VALUE_OFF);
mPreference.setChecked(false);
mPreference.setEnabled(false);
((SwitchPreference) mPreference).setChecked(false);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -22,15 +22,13 @@ import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class FreeformWindowsPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
public class FreeformWindowsPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String ENABLE_FREEFORM_SUPPORT_KEY = "enable_freeform_support";
@@ -41,8 +39,6 @@ public class FreeformWindowsPreferenceController extends
@VisibleForTesting
static final String USER_BUILD_TYPE = "user";
private SwitchPreference mPreference;
public FreeformWindowsPreferenceController(Context context) {
super(context);
}
@@ -57,13 +53,6 @@ public class FreeformWindowsPreferenceController extends
return ENABLE_FREEFORM_SUPPORT_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -77,20 +66,15 @@ public class FreeformWindowsPreferenceController extends
public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, SETTING_VALUE_OFF);
mPreference.setEnabled(false);
mPreference.setChecked(false);
((SwitchPreference) mPreference).setChecked(false);
}
@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.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.ThreadedRenderer;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.development.SystemPropPoker;
public class GpuViewUpdatesPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
public class GpuViewUpdatesPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String SHOW_HW_SCREEN_UPDATES_KEY = "show_hw_screen_updates";
private SwitchPreference mPreference;
public GpuViewUpdatesPreferenceController(Context context) {
super(context);
}
@@ -44,13 +40,6 @@ public class GpuViewUpdatesPreferenceController extends
return SHOW_HW_SCREEN_UPDATES_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -64,18 +53,13 @@ public class GpuViewUpdatesPreferenceController extends
public void updateState(Preference preference) {
final boolean isEnabled = SystemProperties.getBoolean(
ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, false /* default */);
mPreference.setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
((SwitchPreference) mPreference).setChecked(isEnabled);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
SystemProperties.set(ThreadedRenderer.DEBUG_DIRTY_REGIONS_PROPERTY, null);
mPreference.setEnabled(false);
mPreference.setChecked(false);
((SwitchPreference) mPreference).setChecked(false);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -23,14 +23,13 @@ import android.os.ServiceManager;
import android.os.UserManager;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class LocalBackupPasswordPreferenceController extends
DeveloperOptionsPreferenceController implements PreferenceControllerMixin {
public class LocalBackupPasswordPreferenceController extends DeveloperOptionsPreferenceController
implements PreferenceControllerMixin {
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.wrapper.PackageManagerWrapper;
public class LocalTerminalPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
public class LocalTerminalPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
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";
private PackageManagerWrapper mPackageManager;
private SwitchPreference mPreference;
private UserManager mUserManager;
public LocalTerminalPreferenceController(Context context) {
@@ -45,7 +43,6 @@ public class LocalTerminalPreferenceController extends
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
mPackageManager = getPackageManagerWrapper();
if (isAvailable() && !isEnabled()) {
@@ -66,7 +63,7 @@ public class LocalTerminalPreferenceController extends
public void updateState(Preference preference) {
final boolean isTerminalEnabled = mPackageManager.getApplicationEnabledSetting(
TERMINAL_APP_PACKAGE) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
mPreference.setChecked(isTerminalEnabled);
((SwitchPreference) mPreference).setChecked(isTerminalEnabled);
}
@Override
@@ -78,10 +75,10 @@ public class LocalTerminalPreferenceController extends
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
mPackageManager.setApplicationEnabledSetting(TERMINAL_APP_PACKAGE,
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0 /* flags */);
mPreference.setEnabled(false);
mPreference.setChecked(false);
((SwitchPreference) mPreference).setChecked(false);
}
@VisibleForTesting

View File

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

View File

@@ -17,9 +17,7 @@
package com.android.settings.development;
import android.content.Context;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.AbstractLogdSizePreferenceController;
@@ -27,32 +25,18 @@ import com.android.settingslib.development.AbstractLogdSizePreferenceController;
public class LogdSizePreferenceController extends AbstractLogdSizePreferenceController implements
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private ListPreference mPreference;
public LogdSizePreferenceController(Context context) {
super(context);
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override
public void updateState(Preference preference) {
updateLogdSizeValues();
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
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 Preference mPreference;
private ProcStatsData mProcStatsData;
public MemoryUsagePreferenceController(Context context) {
@@ -50,7 +49,6 @@ public class MemoryUsagePreferenceController extends DeveloperOptionsPreferenceC
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
mProcStatsData = getProcStatsData();
setDuration();
}

View File

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

View File

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

View File

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

View File

@@ -129,11 +129,6 @@ public class OemUnlockPreferenceController extends DeveloperOptionsPreferenceCon
handleDeveloperOptionsToggled();
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
handleDeveloperOptionsToggled();
}
public void onOemUnlockConfirmed() {
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.development.DeveloperOptionsPreferenceController;
public class PictureColorModePreferenceController extends
DeveloperOptionsPreferenceController implements
LifecycleObserver, OnResume, OnPause, PreferenceControllerMixin {
public class PictureColorModePreferenceController extends DeveloperOptionsPreferenceController
implements LifecycleObserver, OnResume, OnPause, PreferenceControllerMixin {
private static final String KEY_COLOR_MODE = "picture_color_mode";
@@ -78,16 +77,6 @@ public class PictureColorModePreferenceController extends
}
mPreference.stopListening();
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
@VisibleForTesting
boolean isWideColorGamut() {

View File

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

View File

@@ -20,7 +20,6 @@ import android.content.Context;
import android.os.SystemProperties;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
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.SystemPropPoker;
public class ProfileGpuRenderingPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
public class ProfileGpuRenderingPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String TRACK_FRAME_TIME_KEY = "track_frame_time";
private final String[] mListValues;
private final String[] mListSummaries;
private ListPreference mPreference;
public ProfileGpuRenderingPreferenceController(Context context) {
super(context);
@@ -51,13 +48,6 @@ public class ProfileGpuRenderingPreferenceController extends
return TRACK_FRAME_TIME_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
writeTrackFrameTimeOptions(newValue);
@@ -70,16 +60,6 @@ public class ProfileGpuRenderingPreferenceController extends
updateTrackFrameTimeOptions();
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
}
private void writeTrackFrameTimeOptions(Object newValue) {
SystemProperties.set(ThreadedRenderer.PROFILE_PROPERTY,
newValue == null ? "" : newValue.toString());
@@ -96,7 +76,8 @@ public class ProfileGpuRenderingPreferenceController extends
break;
}
}
mPreference.setValue(mListValues[index]);
mPreference.setSummary(mListSummaries[index]);
final ListPreference listPreference = (ListPreference) mPreference;
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.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class ResizableActivityPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
public class ResizableActivityPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String FORCE_RESIZABLE_KEY = "force_resizable_activities";
@@ -37,8 +35,6 @@ public class ResizableActivityPreferenceController extends
@VisibleForTesting
final static int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public ResizableActivityPreferenceController(Context context) {
super(context);
}
@@ -48,13 +44,6 @@ public class ResizableActivityPreferenceController extends
return FORCE_RESIZABLE_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -68,19 +57,14 @@ public class ResizableActivityPreferenceController extends
public void updateState(Preference preference) {
final int mode = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, SETTING_VALUE_OFF);
mPreference.setChecked(false);
mPreference.setEnabled(false);
((SwitchPreference) mPreference).setChecked(false);
}
}

View File

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

View File

@@ -20,22 +20,19 @@ import android.content.Context;
import android.provider.Settings;
import android.support.v7.preference.ListPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class SecondaryDisplayPreferenceController extends
DeveloperOptionsPreferenceController implements
Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
public class SecondaryDisplayPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
private final String[] mListValues;
private final String[] mListSummaries;
private ListPreference mPreference;
public SecondaryDisplayPreferenceController(Context context) {
super(context);
@@ -50,13 +47,6 @@ public class SecondaryDisplayPreferenceController extends
return OVERLAY_DISPLAY_DEVICES_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
writeSecondaryDisplayDevicesOption(newValue.toString());
@@ -68,15 +58,10 @@ public class SecondaryDisplayPreferenceController extends
updateSecondaryDisplayDevicesOptions();
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeSecondaryDisplayDevicesOption(null);
mPreference.setEnabled(false);
}
private void updateSecondaryDisplayDevicesOptions() {
@@ -89,8 +74,9 @@ public class SecondaryDisplayPreferenceController extends
break;
}
}
mPreference.setValue(mListValues[index]);
mPreference.setSummary(mListSummaries[index]);
final ListPreference listPreference = (ListPreference) mPreference;
listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
}
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.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.settingslib.wrapper.PackageManagerWrapper;
public class SelectDebugAppPreferenceController extends
DeveloperOptionsPreferenceController implements PreferenceControllerMixin,
OnActivityResultListener {
public class SelectDebugAppPreferenceController extends DeveloperOptionsPreferenceController
implements PreferenceControllerMixin, OnActivityResultListener {
private static final String DEBUG_APP_KEY = "debug_app";
private final DevelopmentSettingsDashboardFragment mFragment;
private final PackageManagerWrapper mPackageManager;
private Preference mPreference;
public SelectDebugAppPreferenceController(Context context,
DevelopmentSettingsDashboardFragment fragment) {
super(context);
@@ -57,13 +53,6 @@ public class SelectDebugAppPreferenceController extends
return DEBUG_APP_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = screen.findPreference(getPreferenceKey());
}
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
if (DEBUG_APP_KEY.equals(preference.getKey())) {
@@ -91,14 +80,9 @@ public class SelectDebugAppPreferenceController extends
return true;
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
mPreference.setEnabled(false);
super.onDeveloperOptionsSwitchDisabled();
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.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class ShowFirstCrashDialogPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
public class ShowFirstCrashDialogPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String SHOW_FIRST_CRASH_DIALOG_KEY = "show_first_crash_dialog";
@@ -37,8 +35,6 @@ public class ShowFirstCrashDialogPreferenceController extends
@VisibleForTesting
static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public ShowFirstCrashDialogPreferenceController(Context context) {
super(context);
}
@@ -56,13 +52,6 @@ public class ShowFirstCrashDialogPreferenceController extends
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
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -76,19 +65,14 @@ public class ShowFirstCrashDialogPreferenceController extends
public void updateState(Preference preference) {
final int mode = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, SETTING_VALUE_OFF);
mPreference.setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.SHOW_FIRST_CRASH_DIALOG_DEV_OPTION, SETTING_VALUE_OFF);
mPreference.setEnabled(false);
mPreference.setChecked(false);
((SwitchPreference) mPreference).setChecked(false);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -24,7 +24,6 @@ import android.os.SystemProperties;
import android.support.annotation.VisibleForTesting;
import android.support.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.view.IWindowManager;
import com.android.settings.core.PreferenceControllerMixin;
@@ -43,8 +42,6 @@ public class StrictModePreferenceController extends DeveloperOptionsPreferenceCo
private final IWindowManager mWindowManager;
private SwitchPreference mPreference;
public StrictModePreferenceController(Context context) {
super(context);
@@ -57,13 +54,6 @@ public class StrictModePreferenceController extends DeveloperOptionsPreferenceCo
return STRICT_MODE_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -73,19 +63,14 @@ public class StrictModePreferenceController extends DeveloperOptionsPreferenceCo
@Override
public void updateState(Preference preference) {
mPreference.setChecked(isStrictModeEnabled());
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
((SwitchPreference) mPreference).setChecked(isStrictModeEnabled());
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeStrictModeVisualOptions(false);
mPreference.setEnabled(false);
mPreference.setChecked(false);
((SwitchPreference) mPreference).setChecked(false);
}
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.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class TetheringHardwareAccelPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
public class TetheringHardwareAccelPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String TETHERING_HARDWARE_OFFLOAD = "tethering_hardware_offload";
@@ -39,8 +37,6 @@ public class TetheringHardwareAccelPreferenceController extends
@VisibleForTesting
static final int SETTING_VALUE_OFF = 1;
private SwitchPreference mPreference;
public TetheringHardwareAccelPreferenceController(Context context) {
super(context);
}
@@ -50,13 +46,6 @@ public class TetheringHardwareAccelPreferenceController extends
return TETHERING_HARDWARE_OFFLOAD;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -71,19 +60,14 @@ public class TetheringHardwareAccelPreferenceController extends
final int tetheringMode = Settings.Global.getInt(
mContext.getContentResolver(),
Settings.Global.TETHER_OFFLOAD_DISABLED, 0 /* default */);
mPreference.setChecked(tetheringMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
((SwitchPreference) mPreference).setChecked(tetheringMode != SETTING_VALUE_OFF);
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.TETHER_OFFLOAD_DISABLED, SETTING_VALUE_OFF);
mPreference.setEnabled(false);
mPreference.setChecked(false);
((SwitchPreference) mPreference).setChecked(false);
}
}

View File

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

View File

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

View File

@@ -24,7 +24,6 @@ import android.os.UserManager;
import android.provider.Settings;
import android.support.annotation.VisibleForTesting;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.RestrictedLockUtils;
@@ -38,14 +37,12 @@ import java.util.List;
/**
* Controller to manage the state of "Verify apps over USB" toggle.
*/
public class VerifyAppsOverUsbPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
AdbOnChangeListener, PreferenceControllerMixin {
public class VerifyAppsOverUsbPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, AdbOnChangeListener,
PreferenceControllerMixin {
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 RestrictedSwitchPreference mPreference;
@VisibleForTesting
static final int SETTING_VALUE_ON = 1;
@VisibleForTesting
@@ -87,12 +84,6 @@ public class VerifyAppsOverUsbPreferenceController extends
return VERIFY_APPS_OVER_USB_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
@@ -104,26 +95,28 @@ public class VerifyAppsOverUsbPreferenceController extends
@Override
public void updateState(Preference preference) {
final RestrictedSwitchPreference restrictedPreference =
(RestrictedSwitchPreference) preference;
if (!shouldBeEnabled()) {
mPreference.setChecked(false);
mPreference.setDisabledByAdmin(null);
mPreference.setEnabled(false);
restrictedPreference.setChecked(false);
restrictedPreference.setDisabledByAdmin(null);
restrictedPreference.setEnabled(false);
return;
}
final EnforcedAdmin enforcingAdmin = mRestrictedLockUtils.checkIfRestrictionEnforced(
mContext, UserManager.ENSURE_VERIFY_APPS, UserHandle.myUserId());
if (enforcingAdmin != null) {
mPreference.setChecked(true);
mPreference.setDisabledByAdmin(enforcingAdmin);
restrictedPreference.setChecked(true);
restrictedPreference.setDisabledByAdmin(enforcingAdmin);
return;
}
mPreference.setEnabled(true);
restrictedPreference.setEnabled(true);
final boolean checked = Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, SETTING_VALUE_ON)
!= SETTING_VALUE_OFF;
mPreference.setChecked(checked);
restrictedPreference.setChecked(checked);
}
@Override
@@ -135,15 +128,10 @@ public class VerifyAppsOverUsbPreferenceController extends
@Override
protected void onDeveloperOptionsSwitchEnabled() {
super.onDeveloperOptionsSwitchEnabled();
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
* 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.v14.preference.SwitchPreference;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.text.TextUtils;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class WaitForDebuggerPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin, OnActivityResultListener {
public class WaitForDebuggerPreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin,
OnActivityResultListener {
private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
@@ -46,8 +45,6 @@ public class WaitForDebuggerPreferenceController extends
@VisibleForTesting
static final int SETTING_VALUE_OFF = 0;
private SwitchPreference mPreference;
public WaitForDebuggerPreferenceController(Context context) {
super(context);
}
@@ -57,13 +54,6 @@ public class WaitForDebuggerPreferenceController extends
return WAIT_FOR_DEBUGGER_KEY;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
mPreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean debuggerEnabled = (Boolean) newValue;
@@ -75,13 +65,8 @@ public class WaitForDebuggerPreferenceController extends
@Override
public void updateState(Preference preference) {
final String debugApp = Settings.Global.getString(
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));
updateState(mPreference, Settings.Global.getString(
mContext.getContentResolver(), Settings.Global.DEBUG_APP));
}
@Override
@@ -89,26 +74,25 @@ public class WaitForDebuggerPreferenceController extends
if (requestCode != REQUEST_CODE_DEBUG_APP || resultCode != Activity.RESULT_OK) {
return false;
}
final boolean debuggerEnabled = Settings.Global.getInt(mContext.getContentResolver(),
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));
updateState(mPreference, data.getAction());
return true;
}
@Override
protected void onDeveloperOptionsSwitchEnabled() {
mPreference.setEnabled(true);
private void updateState(Preference preference, String debugApp) {
final SwitchPreference switchPreference = (SwitchPreference) preference;
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
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
writeDebuggerAppOptions(null /* package name */,
false /* waitForDebugger */, false /* persistent */);
mPreference.setChecked(false);
mPreference.setEnabled(false);
((SwitchPreference) mPreference).setChecked(false);
}
@VisibleForTesting

View File

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

View File

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

View File

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

View File

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

View File

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