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

Commit 3f726ee8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Enable touch feedback vibrations on silent mode." into tm-dev am: 22a1c4c3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16978549

Change-Id: Ieca810fdb487ecd9f12c01cd30c772ca3054d9c8
parents 44b59098 22a1c4c3
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -347,24 +347,19 @@ final class VibrationSettings {
     * Return {@code true} if the device should vibrate for current ringer mode.
     *
     * <p>This checks the current {@link AudioManager#getRingerModeInternal()} against user settings
     * for touch and ringtone usages only. All other usages are allowed by this method.
     * for ringtone usage only. All other usages are allowed by this method.
     */
    @GuardedBy("mLock")
    private boolean shouldVibrateForRingerModeLocked(@VibrationAttributes.Usage int usageHint) {
        if (usageHint != USAGE_RINGTONE) {
            // Only ringtone vibrations are disabled when phone is on silent mode.
            return true;
        }
        // If audio manager was not loaded yet then assume most restrictive mode.
        int ringerMode = (mAudioManager == null)
                ? AudioManager.RINGER_MODE_SILENT
                : mAudioManager.getRingerModeInternal();

        switch (usageHint) {
            case USAGE_TOUCH:
            case USAGE_RINGTONE:
                // Touch feedback and ringtone disabled when phone is on silent mode.
        return ringerMode != AudioManager.RINGER_MODE_SILENT;
            default:
                // All other usages ignore ringer mode settings.
                return true;
        }
    }

    /** Updates all vibration settings and triggers registered listeners. */
+2 −2
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ public class VibrationSettingsTest {
    }

    @Test
    public void shouldIgnoreVibration_withRingerModeSilent_ignoresRingtoneAndTouch() {
    public void shouldIgnoreVibration_withRingerModeSilent_ignoresRingtoneOnly() {
        // Vibrating settings on are overruled by ringer mode.
        setUserSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED, 1);
        setUserSetting(Settings.System.VIBRATE_WHEN_RINGING, 1);
@@ -293,7 +293,7 @@ public class VibrationSettingsTest {
        setRingerMode(AudioManager.RINGER_MODE_SILENT);

        for (int usage : ALL_USAGES) {
            if (usage == USAGE_RINGTONE || usage == USAGE_TOUCH) {
            if (usage == USAGE_RINGTONE) {
                assertVibrationIgnoredForUsage(usage, Vibration.Status.IGNORED_FOR_RINGER_MODE);
            } else {
                assertVibrationNotIgnoredForUsage(usage);