Move APPLY_RAMPING_RINGER from Global to System

This configuration should be user-scoped.

Bug: 184165158
Test: AccessibilitySettingsTest
      RingVibrationPreferenceFragmentTest
      VibrateForCallsPreferenceControllerTest
      VibrateForCallsPreferenceFragmentTest
Change-Id: I7b8684fb1cf03d41872a700fd8732c76422e37c3
This commit is contained in:
Lais Andrade
2021-11-04 12:10:49 +00:00
parent 74a797efd8
commit 24b2d9e5a1
9 changed files with 38 additions and 38 deletions

View File

@@ -295,8 +295,8 @@ public class AccessibilitySettings extends DashboardFragment {
}
static boolean isRampingRingerEnabled(final Context context) {
return Settings.Global.getInt(
context.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0) == 1;
return Settings.System.getInt(
context.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, 0) == 1;
}
@VisibleForTesting

View File

@@ -47,7 +47,7 @@ public class RingVibrationPreferenceFragment extends VibrationPreferenceFragment
@Override
protected String getVibrationEnabledSetting() {
if (AccessibilitySettings.isRampingRingerEnabled(getContext())) {
return Settings.Global.APPLY_RAMPING_RINGER;
return Settings.System.APPLY_RAMPING_RINGER;
} else {
return Settings.System.VIBRATE_WHEN_RINGING;
}

View File

@@ -116,12 +116,12 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
// Update vibration enabled setting
final String vibrationEnabledSetting = getVibrationEnabledSetting();
final boolean wasEnabled = TextUtils.equals(
vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
vibrationEnabledSetting, Settings.System.APPLY_RAMPING_RINGER)
? true
: (Settings.System.getInt(
getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);
if (vibrationEnabled != wasEnabled) {
if (vibrationEnabledSetting.equals(Settings.Global.APPLY_RAMPING_RINGER)) {
if (vibrationEnabledSetting.equals(Settings.System.APPLY_RAMPING_RINGER)) {
Settings.Global.putInt(getContext().getContentResolver(),
vibrationEnabledSetting, 0);
} else {
@@ -212,7 +212,7 @@ public abstract class VibrationPreferenceFragment extends RadioButtonPickerFragm
getVibrationIntensitySetting(), getDefaultVibrationIntensity());
final String vibrationEnabledSetting = getVibrationEnabledSetting();
final boolean vibrationEnabled = TextUtils.equals(
vibrationEnabledSetting, Settings.Global.APPLY_RAMPING_RINGER)
vibrationEnabledSetting, Settings.System.APPLY_RAMPING_RINGER)
? true
: (Settings.System.getInt(
getContext().getContentResolver(), vibrationEnabledSetting, 1) == 1);

View File

@@ -51,9 +51,9 @@ public class VibrateForCallsPreferenceController extends BasePreferenceControlle
@Override
public CharSequence getSummary() {
if (Settings.Global.getInt(
if (Settings.System.getInt(
mContext.getContentResolver(),
Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
Settings.System.APPLY_RAMPING_RINGER, OFF) == ON) {
return mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer);
} else if (Settings.System.getInt(
mContext.getContentResolver(),

View File

@@ -78,18 +78,18 @@ public class VibrateForCallsPreferenceFragment extends RadioButtonPickerFragment
if (TextUtils.equals(key, KEY_ALWAYS_VIBRATE)) {
Settings.System.putInt(
getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, ON);
Settings.Global.putInt(
getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
Settings.System.putInt(
getContext().getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, OFF);
} else if (TextUtils.equals(key, KEY_RAMPING_RINGER)) {
Settings.System.putInt(
getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
Settings.Global.putInt(
getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, ON);
Settings.System.putInt(
getContext().getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, ON);
} else {
Settings.System.putInt(
getContext().getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING, OFF);
Settings.Global.putInt(
getContext().getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
Settings.System.putInt(
getContext().getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, OFF);
}
}
@@ -104,9 +104,9 @@ public class VibrateForCallsPreferenceFragment extends RadioButtonPickerFragment
@Override
protected String getDefaultKey() {
if (Settings.Global.getInt(
if (Settings.System.getInt(
getContext().getContentResolver(),
Settings.Global.APPLY_RAMPING_RINGER, OFF) == ON) {
Settings.System.APPLY_RAMPING_RINGER, OFF) == ON) {
return KEY_RAMPING_RINGER;
} else if (Settings.System.getInt(
getContext().getContentResolver(),

View File

@@ -146,16 +146,16 @@ public class AccessibilitySettingsTest {
@Test
@Config(shadows = {ShadowDeviceConfig.class})
public void isRampingRingerEnabled_settingsFlagOn_Enabled() {
Settings.Global.putInt(
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, ON);
Settings.System.putInt(
mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, ON);
assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isTrue();
}
@Test
@Config(shadows = {ShadowDeviceConfig.class})
public void isRampingRingerEnabled_settingsFlagOff_Disabled() {
Settings.Global.putInt(
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, OFF);
Settings.System.putInt(
mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, OFF);
assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
}

View File

@@ -50,17 +50,17 @@ public class RingVibrationPreferenceFragmentTest {
@Config(shadows = {ShadowDeviceConfig.class})
public void getVibrationEnabledSetting_rampingRingerEnabled_returnApplyRampingRinger() {
// Turn on both flags to enable ramping ringer.
Settings.Global.putInt(
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
Settings.System.putInt(
mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, 1 /* ON */);
assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
Settings.Global.APPLY_RAMPING_RINGER);
Settings.System.APPLY_RAMPING_RINGER);
}
@Test
public void getVibrationEnabledSetting_rampingRingerDisabled_returnVibrationWhenRinging() {
// Turn off Settings.Global.APPLY_RAMPING_RINGER to disable ramping ringer.
Settings.Global.putInt(
mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0 /* OFF */);
// Turn off Settings.System.APPLY_RAMPING_RINGER to disable ramping ringer.
Settings.System.putInt(
mContext.getContentResolver(), Settings.System.APPLY_RAMPING_RINGER, 0 /* OFF */);
assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
Settings.System.VIBRATE_WHEN_RINGING);
}

View File

@@ -94,7 +94,7 @@ public class VibrateForCallsPreferenceControllerTest {
@Test
public void getSummary_applyRampingRinger_rampingRingerSummary() {
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, ON);
assertThat(mController.getSummary()).isEqualTo(
mContext.getText(R.string.vibrate_when_ringing_option_ramping_ringer));
@@ -103,7 +103,7 @@ public class VibrateForCallsPreferenceControllerTest {
@Test
public void getSummary_enableVibrateWhenRinging_alwaysVibrateSummary() {
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF);
assertThat(mController.getSummary()).isEqualTo(
mContext.getText(R.string.vibrate_when_ringing_option_always_vibrate));
@@ -112,7 +112,7 @@ public class VibrateForCallsPreferenceControllerTest {
@Test
public void getSummary_notApplyRampingRingerDisableVibrateWhenRinging_neverVibrateSummary() {
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF);
assertThat(mController.getSummary()).isEqualTo(
mContext.getText(R.string.vibrate_when_ringing_option_never_vibrate));

View File

@@ -52,7 +52,7 @@ public class VibrateForCallsPreferenceFragmentTest {
@Test
public void getDefaultKey_applyRampingRinger_keyRampingRinger() {
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, ON);
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, ON);
assertThat(mFragment.getDefaultKey()).isEqualTo(
VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
@@ -61,7 +61,7 @@ public class VibrateForCallsPreferenceFragmentTest {
@Test
public void getDefaultKey_enableVibrateWhenRinging_keyAlwaysVibrate() {
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, ON);
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF);
assertThat(mFragment.getDefaultKey()).isEqualTo(
VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
@@ -70,7 +70,7 @@ public class VibrateForCallsPreferenceFragmentTest {
@Test
public void getDefaultKey_notApplyRampingRingerDisableVibrateWhenRinging_keyNeverVibrate() {
Settings.System.putInt(mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF);
Settings.Global.putInt(mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF);
Settings.System.putInt(mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF);
assertThat(mFragment.getDefaultKey()).isEqualTo(
VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
@@ -80,8 +80,8 @@ public class VibrateForCallsPreferenceFragmentTest {
public void setDefaultKey_keyRampingRinger_applyRampingRingerDisableVibrateWhenRinging() {
mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_RAMPING_RINGER);
assertThat(Settings.Global.getInt(
mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(ON);
assertThat(Settings.System.getInt(
mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF)).isEqualTo(ON);
assertThat(Settings.System.getInt(
mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
}
@@ -90,8 +90,8 @@ public class VibrateForCallsPreferenceFragmentTest {
public void setDefaultKey_keyAlwaysVibrate_notApplyRampingRingerEnableVibrateWhenRinging() {
mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_ALWAYS_VIBRATE);
assertThat(Settings.Global.getInt(
mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
assertThat(Settings.System.getInt(
mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
assertThat(Settings.System.getInt(
mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(ON);
}
@@ -100,8 +100,8 @@ public class VibrateForCallsPreferenceFragmentTest {
public void setDefaultKey_keyNeverVibrate_notApplyRampingRingerDisableVibrateWhenRinging() {
mFragment.setDefaultKey(VibrateForCallsPreferenceFragment.KEY_NEVER_VIBRATE);
assertThat(Settings.Global.getInt(
mContentResolver, Settings.Global.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
assertThat(Settings.System.getInt(
mContentResolver, Settings.System.APPLY_RAMPING_RINGER, OFF)).isEqualTo(OFF);
assertThat(Settings.System.getInt(
mContentResolver, Settings.System.VIBRATE_WHEN_RINGING, OFF)).isEqualTo(OFF);
}