Keep consistency between sound and accessibility settings.
Bug: 130741987
Test: Tested on device
Change-Id: Id6dd485c73f9453970b8d79929ffc04acb2c76c8
(cherry picked from commit 494071463b
)
This commit is contained in:
@@ -114,11 +114,20 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
|
||||
boolean vibrationEnabled = candidate.getIntensity() != Vibrator.VIBRATION_INTENSITY_OFF;
|
||||
if (hasVibrationEnabledSetting()) {
|
||||
// Update vibration enabled setting
|
||||
boolean wasEnabled = Settings.System.getInt(getContext().getContentResolver(),
|
||||
getVibrationEnabledSetting(), 1) == 1;
|
||||
final String vibrationEnabledSetting = getVibrationEnabledSetting();
|
||||
final boolean wasEnabled = TextUtils.equals(
|
||||
vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
|
||||
? true
|
||||
: (Settings.System.getInt(
|
||||
getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
|
||||
if (vibrationEnabled != wasEnabled) {
|
||||
Settings.System.putInt(getContext().getContentResolver(),
|
||||
getVibrationEnabledSetting(), vibrationEnabled ? 1 : 0);
|
||||
if (vibrationEnabledSetting.equals(Settings.Global.APPLY_RAMPING_RINGER)) {
|
||||
Settings.Global.putInt(getContext().getContentResolver(),
|
||||
vibrationEnabledSetting, 0);
|
||||
} else {
|
||||
Settings.System.putInt(getContext().getContentResolver(),
|
||||
vibrationEnabledSetting, vibrationEnabled ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// There are two conditions that need to change the intensity.
|
||||
@@ -196,8 +205,12 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
|
||||
protected String getDefaultKey() {
|
||||
int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
|
||||
getVibrationIntensitySetting(), getDefaultVibrationIntensity());
|
||||
final boolean vibrationEnabled = Settings.System.getInt(getContext().getContentResolver(),
|
||||
getVibrationEnabledSetting(), 1) == 1;
|
||||
final String vibrationEnabledSetting = getVibrationEnabledSetting();
|
||||
final boolean vibrationEnabled = TextUtils.equals(
|
||||
vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
|
||||
? true
|
||||
: (Settings.System.getInt(
|
||||
getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
|
||||
if (!vibrationEnabled) {
|
||||
vibrationIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
|
||||
}
|
||||
|
Reference in New Issue
Block a user