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;
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();
- 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 (mState.ringerModeInternal == RINGER_MODE_NORMAL) {
+ playTouchFeedback();
}
- if (effect != null) {
- vibrate(effect);
- }
+ return true;
}
private void onSetRingerModeW(int mode, boolean external) {
}
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);