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
@@ -352,6 +352,10 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
||||
sc.seekbarView.setProgress(mAudioManager.getLastAudibleStreamVolume(sc.streamType));
|
||||
final boolean muted = isMuted(sc.streamType);
|
||||
sc.icon.setImageResource(muted ? sc.iconMuteRes : sc.iconRes);
|
||||
if (sc.streamType == AudioManager.STREAM_RING && muted
|
||||
&& mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) {
|
||||
sc.icon.setImageResource(R.drawable.ic_audio_ring_notif_vibrate);
|
||||
}
|
||||
sc.seekbarView.setEnabled(!muted);
|
||||
}
|
||||
|
||||
@@ -695,8 +699,14 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie
|
||||
expand();
|
||||
} else if (v.getTag() instanceof StreamControl) {
|
||||
StreamControl sc = (StreamControl) v.getTag();
|
||||
mAudioManager.setRingerMode(mAudioManager.isSilentMode()
|
||||
? AudioManager.RINGER_MODE_NORMAL : AudioManager.RINGER_MODE_SILENT);
|
||||
boolean vibeInSilent = Settings.System.getInt(mContext.getContentResolver(),
|
||||
System.VIBRATE_IN_SILENT, 1) == 1;
|
||||
int newMode = mAudioManager.isSilentMode()
|
||||
? AudioManager.RINGER_MODE_NORMAL
|
||||
: (vibeInSilent
|
||||
? AudioManager.RINGER_MODE_VIBRATE
|
||||
: AudioManager.RINGER_MODE_SILENT);
|
||||
mAudioManager.setRingerMode(newMode);
|
||||
// Expand the dialog if it hasn't been expanded yet.
|
||||
if (mShowCombinedVolumes && !isExpanded()) expand();
|
||||
}
|
||||
|
||||
BIN
core/res/res/drawable-hdpi/ic_audio_ring_notif_vibrate.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
core/res/res/drawable-mdpi/ic_audio_ring_notif_vibrate.png
Normal file
|
After Width: | Height: | Size: 905 B |
BIN
core/res/res/drawable-xhdpi/ic_audio_ring_notif_vibrate.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
@@ -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;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 872 B After Width: | Height: | Size: 912 B |
|
Before Width: | Height: | Size: 640 B After Width: | Height: | Size: 598 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -121,10 +121,9 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
|
||||
R.string.global_action_silent_mode_off_status) {
|
||||
|
||||
void willCreate() {
|
||||
// XXX: FIXME: Add vibrate indicator when available
|
||||
mEnabledIconResId = (Settings.System.getInt(mContext.getContentResolver(),
|
||||
Settings.System.VIBRATE_IN_SILENT, 1) == 1)
|
||||
? R.drawable.ic_audio_vol_mute
|
||||
? R.drawable.ic_audio_ring_notif_vibrate
|
||||
: R.drawable.ic_audio_vol_mute;
|
||||
}
|
||||
|
||||
|
||||