OSDN Git Service

Revert "When ringer changes to vibrate, phone vibrates"
authorBeverly Tai <beverlyt@google.com>
Tue, 15 May 2018 23:49:05 +0000 (23:49 +0000)
committerBeverly Tai <beverlyt@google.com>
Tue, 15 May 2018 23:49:05 +0000 (23:49 +0000)
Fixes: 79773317
Bug: 78665512

This reverts commit d253f98c0e2357307e5ae352d26e077ed7259b9b.

Reason for revert: b/79773317

Change-Id: I6f3eebd64b94436748986422906006686351cc4b

packages/SystemUI/src/com/android/systemui/volume/VolumeDialogControllerImpl.java
packages/SystemUI/src/com/android/systemui/volume/VolumeDialogImpl.java

index b360edc..a97effd 100644 (file)
@@ -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();
-                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) {
index 2cff00c..6b322c7 100644 (file)
@@ -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);