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

Commit fd165bb5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "When ringer changes to vibrate, phone vibrates" into pi-dev

parents 0a381595 d253f98c
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.systemui.volume;

import static android.media.AudioManager.RINGER_MODE_NORMAL;
import static android.media.AudioManager.RINGER_MODE_SILENT;
import static android.media.AudioManager.RINGER_MODE_VIBRATE;

import android.app.NotificationManager;
import android.content.BroadcastReceiver;
@@ -581,11 +583,28 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
        mState.ringerModeInternal = rm;
        Events.writeEvent(mContext, Events.EVENT_INTERNAL_RINGER_MODE_CHANGED, rm);

        if (mState.ringerModeInternal == RINGER_MODE_NORMAL) {
        provideFeedback(mState.ringerModeInternal);
        return true;
    }

    private void provideFeedback(int newRingerMode) {
        VibrationEffect effect = null;
        switch (newRingerMode) {
            case RINGER_MODE_NORMAL:
                scheduleTouchFeedback();
                playTouchFeedback();
                break;
            case RINGER_MODE_SILENT:
                effect = VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
                break;
            case RINGER_MODE_VIBRATE:
            default:
                effect = VibrationEffect.get(VibrationEffect.EFFECT_DOUBLE_CLICK);
        }

        return true;
        if (effect != null) {
            vibrate(effect);
        }
    }

    private void onSetRingerModeW(int mode, boolean external) {
+0 −20
Original line number Diff line number Diff line
@@ -446,32 +446,12 @@ public class VolumeDialogImpl implements VolumeDialog {
            }
            Events.writeEvent(mContext, Events.EVENT_RINGER_TOGGLE, newRingerMode);
            updateRingerH();
            provideTouchFeedbackH(newRingerMode);
            mController.setRingerMode(newRingerMode, false);
            maybeShowToastH(newRingerMode);
        });
        updateRingerH();
    }


    private void provideTouchFeedbackH(int newRingerMode) {
        VibrationEffect effect = null;
        switch (newRingerMode) {
            case RINGER_MODE_NORMAL:
                mController.scheduleTouchFeedback();
                break;
            case RINGER_MODE_SILENT:
                effect = VibrationEffect.get(VibrationEffect.EFFECT_CLICK);
                break;
            case RINGER_MODE_VIBRATE:
            default:
                effect = VibrationEffect.get(VibrationEffect.EFFECT_DOUBLE_CLICK);
        }
        if (effect != null) {
            mController.vibrate(effect);
        }
    }

    private void maybeShowToastH(int newRingerMode) {
        int seenToastCount = Prefs.getInt(mContext, Prefs.Key.SEEN_RINGER_GUIDANCE_COUNT, 0);