Merge "Apply only RING_VIBRATION_INTENSITY to ringtone vibrations" into tm-dev
diff --git a/src/com/android/settings/accessibility/RingVibrationPreferenceConfig.java b/src/com/android/settings/accessibility/RingVibrationPreferenceConfig.java
index f4ec747..bce9260 100644
--- a/src/com/android/settings/accessibility/RingVibrationPreferenceConfig.java
+++ b/src/com/android/settings/accessibility/RingVibrationPreferenceConfig.java
@@ -42,21 +42,6 @@
}
@Override
- public int readIntensity() {
- final int vibrateWhenRinging = Settings.System.getInt(mContentResolver,
- Settings.System.VIBRATE_WHEN_RINGING, ON);
-
- if ((vibrateWhenRinging == OFF)
- && !mAudioManager.isRampingRingerEnabled()) {
- // VIBRATE_WHEN_RINGING is deprecated but should still be applied if the user has
- // turned it off and has not enabled the ramping ringer (old three-state setting).
- return Vibrator.VIBRATION_INTENSITY_OFF;
- }
-
- return super.readIntensity();
- }
-
- @Override
public boolean updateIntensity(int intensity) {
final boolean success = super.updateIntensity(intensity);
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java
index 2bffaf4..fa3f3bf 100644
--- a/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java
@@ -121,22 +121,22 @@
}
@Test
- public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() {
+ public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayRingIntensity() {
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
mController.updateState(mPreference);
- assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+ assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_HIGH);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
Vibrator.VIBRATION_INTENSITY_MEDIUM);
mController.updateState(mPreference);
- assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+ assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_MEDIUM);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
mController.updateState(mPreference);
- assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+ assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java
index 08ad1cd..865c290 100644
--- a/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java
@@ -116,22 +116,24 @@
}
@Test
- public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() {
+ public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldIgnoreAndUseIntensity() {
+ // VIBRATE_WHEN_RINGING is deprecated and should have no effect on the ring vibration
+ // setting. The ramping ringer is also independent now, instead of a 3-state setting.
when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
mController.updateState(mPreference);
- assertThat(mPreference.isChecked()).isFalse();
+ assertThat(mPreference.isChecked()).isTrue();
updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
Vibrator.VIBRATION_INTENSITY_MEDIUM);
mController.updateState(mPreference);
- assertThat(mPreference.isChecked()).isFalse();
+ assertThat(mPreference.isChecked()).isTrue();
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
mController.updateState(mPreference);
- assertThat(mPreference.isChecked()).isFalse();
+ assertThat(mPreference.isChecked()).isTrue();
updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
mController.updateState(mPreference);