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

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

Merge "Revert "When ringer changes to vibrate, phone vibrates" Fixes: 79773317...

Merge "Revert "When ringer changes to vibrate, phone vibrates" Fixes: 79773317 Bug: 78665512" into pi-dev
parents c82ab5e7 efd8e08d
Loading
Loading
Loading
Loading
+3 −22
Original line number Diff line number Diff line
@@ -17,8 +17,6 @@
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;
@@ -583,28 +581,11 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
        mState.ringerModeInternal = rm;
        Events.writeEvent(mContext, Events.EVENT_INTERNAL_RINGER_MODE_CHANGED, rm);

        provideFeedback(mState.ringerModeInternal);
        return true;
    }

    private void provideFeedback(int newRingerMode) {
        VibrationEffect effect = null;
        switch (newRingerMode) {
            case RINGER_MODE_NORMAL:
                scheduleTouchFeedback();
        if (mState.ringerModeInternal == RINGER_MODE_NORMAL) {
            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);
        }

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

    private void onSetRingerModeW(int mode, boolean external) {
+20 −0
Original line number Diff line number Diff line
@@ -446,12 +446,32 @@ 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);