Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24b2d9e5 authored by Lais Andrade's avatar Lais Andrade
Browse files

Move APPLY_RAMPING_RINGER from Global to System

This configuration should be user-scoped.

Bug: 184165158
Test: AccessibilitySettingsTest
      RingVibrationPreferenceFragmentTest
      VibrateForCallsPreferenceControllerTest
      VibrateForCallsPreferenceFragmentTest
Change-Id: I7b8684fb1cf03d41872a700fd8732c76422e37c3
parent 74a797ef
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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;
        }
+3 −3
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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(),
+8 −8
Original line number Diff line number Diff line
@@ -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(),
Loading