Keep consistency between sound and accessibility settings.
Bug: 130741987 Test: Tested on device Change-Id: Id6dd485c73f9453970b8d79929ffc04acb2c76c8
This commit is contained in:
@@ -40,15 +40,17 @@ public abstract class VibrationIntensityPreferenceController extends BasePrefere
|
||||
private final SettingObserver mSettingsContentObserver;
|
||||
private final String mSettingKey;
|
||||
private final String mEnabledKey;
|
||||
private final boolean mSupportRampingRinger;
|
||||
|
||||
private Preference mPreference;
|
||||
|
||||
public VibrationIntensityPreferenceController(Context context, String prefkey,
|
||||
String settingKey, String enabledKey) {
|
||||
String settingKey, String enabledKey, boolean supportRampingRinger) {
|
||||
super(context, prefkey);
|
||||
mVibrator = mContext.getSystemService(Vibrator.class);
|
||||
mSettingKey = settingKey;
|
||||
mEnabledKey = enabledKey;
|
||||
mSupportRampingRinger= supportRampingRinger;
|
||||
mSettingsContentObserver = new SettingObserver(settingKey) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
@@ -57,6 +59,11 @@ public abstract class VibrationIntensityPreferenceController extends BasePrefere
|
||||
};
|
||||
}
|
||||
|
||||
public VibrationIntensityPreferenceController(Context context, String prefkey,
|
||||
String settingKey, String enabledKey) {
|
||||
this(context, prefkey, settingKey, enabledKey, /* supportRampingRinger= */ false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
mContext.getContentResolver().registerContentObserver(
|
||||
@@ -80,10 +87,11 @@ public abstract class VibrationIntensityPreferenceController extends BasePrefere
|
||||
public CharSequence getSummary() {
|
||||
final int intensity = Settings.System.getInt(mContext.getContentResolver(),
|
||||
mSettingKey, getDefaultIntensity());
|
||||
final boolean enabled = Settings.System.getInt(mContext.getContentResolver(),
|
||||
mEnabledKey, 1) == 1;
|
||||
final boolean enabled = (Settings.System.getInt(mContext.getContentResolver(),
|
||||
mEnabledKey, 1) == 1) ||
|
||||
(mSupportRampingRinger && AccessibilitySettings.isRampingRingerEnabled(mContext));
|
||||
return getIntensityString(mContext, enabled ? intensity : Vibrator.VIBRATION_INTENSITY_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
public static CharSequence getIntensityString(Context context, int intensity) {
|
||||
final boolean supportsMultipleIntensities = context.getResources().getBoolean(
|
||||
|
Reference in New Issue
Block a user