summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2011-10-28 17:02:37 -0700
committerAmith Yamasani <yamasani@google.com>2011-10-28 18:40:43 -0700
commitc696a53d1fe4d61373c5dc64dd057d322da90c8f (patch)
tree52999422370ca84ef1fedf1490bd6cfa14c7a96d /media
parentfe9a2a5471616a3267b30013bce36b13a455c0cd (diff)
downloadframeworks_base-c696a53d1fe4d61373c5dc64dd057d322da90c8f.zip
frameworks_base-c696a53d1fe4d61373c5dc64dd057d322da90c8f.tar.gz
frameworks_base-c696a53d1fe4d61373c5dc64dd057d322da90c8f.tar.bz2
Bring back the old-style Ring/Vibrate/Silent states when using volume keys.
In order to completely mute the ringer (no vibrate), introduce an extra state beyond mute, which mutes the vibrator as well, if it was enabled. Bug: 5530217 Change-Id: Ib1f299ee6bbca56c1aa7e1100662591362d08307
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioService.java30
1 files changed, 22 insertions, 8 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java
index 1d20e24..25a3705 100644
--- a/media/java/android/media/AudioService.java
+++ b/media/java/android/media/AudioService.java
@@ -16,6 +16,10 @@
package android.media;
+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.ActivityManagerNative;
import android.app.KeyguardManager;
import android.app.PendingIntent;
@@ -528,8 +532,8 @@ public class AudioService extends IAudioService.Stub {
(!mVoiceCapable && streamType != AudioSystem.STREAM_VOICE_CALL &&
streamType != AudioSystem.STREAM_BLUETOOTH_SCO) ||
(mVoiceCapable && streamTypeAlias == AudioSystem.STREAM_RING)) {
- // do not vibrate if already in silent mode
- if (mRingerMode != AudioManager.RINGER_MODE_NORMAL) {
+ // do not vibrate if already in vibrate mode
+ if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
flags &= ~AudioManager.FLAG_VIBRATE;
}
// Check if the ringer mode changes with this volume adjustment. If
@@ -1621,26 +1625,36 @@ public class AudioService extends IAudioService.Stub {
boolean adjustVolumeIndex = true;
int newRingerMode = mRingerMode;
int uiIndex = (oldIndex + 5) / 10;
+ boolean vibeInSilent = System.getInt(mContentResolver, System.VIBRATE_IN_SILENT, 1) == 1;
- if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
+ if (mRingerMode == RINGER_MODE_NORMAL) {
if ((direction == AudioManager.ADJUST_LOWER) && (uiIndex <= 1)) {
// enter silent mode if current index is the last audible one and not repeating a
// volume key down
- if (mPrevVolDirection != AudioManager.ADJUST_LOWER) {
+ if (vibeInSilent || mPrevVolDirection != AudioManager.ADJUST_LOWER) {
// "silent mode", but which one?
- newRingerMode = System.getInt(mContentResolver, System.VIBRATE_IN_SILENT, 1) == 1
- ? AudioManager.RINGER_MODE_VIBRATE
- : AudioManager.RINGER_MODE_SILENT;
+ newRingerMode = vibeInSilent ? RINGER_MODE_VIBRATE : RINGER_MODE_SILENT;
}
if (uiIndex == 0 || (mPrevVolDirection == AudioManager.ADJUST_LOWER &&
mVoiceCapable && streamType == AudioSystem.STREAM_RING)) {
adjustVolumeIndex = false;
}
}
+ } else if (mRingerMode == RINGER_MODE_VIBRATE) {
+ if ((direction == AudioManager.ADJUST_LOWER)) {
+ // Set it to silent, if it wasn't a long-press
+ if (mPrevVolDirection != AudioManager.ADJUST_LOWER) {
+ newRingerMode = RINGER_MODE_SILENT;
+ }
+ } else if (direction == AudioManager.ADJUST_RAISE) {
+ newRingerMode = RINGER_MODE_NORMAL;
+ }
+ adjustVolumeIndex = false;
} else {
if (direction == AudioManager.ADJUST_RAISE) {
// exiting silent mode
- newRingerMode = AudioManager.RINGER_MODE_NORMAL;
+ // If VIBRATE_IN_SILENT, then go into vibrate mode
+ newRingerMode = vibeInSilent ? RINGER_MODE_VIBRATE : RINGER_MODE_NORMAL;
}
adjustVolumeIndex = false;
}