Skip to content

Commit 69e640e

Browse files
Amith YamasaniAndroid (Google) Code Review
authored andcommitted
Merge "Bring back the old-style Ring/Vibrate/Silent states when using volume keys." into ics-mr0
2 parents 2d280f7 + c696a53 commit 69e640e

File tree

9 files changed

+35
-12
lines changed

9 files changed

+35
-12
lines changed

core/java/android/view/VolumePanel.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ private void updateSlider(StreamControl sc) {
352352
sc.seekbarView.setProgress(mAudioManager.getLastAudibleStreamVolume(sc.streamType));
353353
final boolean muted = isMuted(sc.streamType);
354354
sc.icon.setImageResource(muted ? sc.iconMuteRes : sc.iconRes);
355+
if (sc.streamType == AudioManager.STREAM_RING && muted
356+
&& mAudioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER)) {
357+
sc.icon.setImageResource(R.drawable.ic_audio_ring_notif_vibrate);
358+
}
355359
sc.seekbarView.setEnabled(!muted);
356360
}
357361

@@ -695,8 +699,14 @@ public void onClick(View v) {
695699
expand();
696700
} else if (v.getTag() instanceof StreamControl) {
697701
StreamControl sc = (StreamControl) v.getTag();
698-
mAudioManager.setRingerMode(mAudioManager.isSilentMode()
699-
? AudioManager.RINGER_MODE_NORMAL : AudioManager.RINGER_MODE_SILENT);
702+
boolean vibeInSilent = Settings.System.getInt(mContext.getContentResolver(),
703+
System.VIBRATE_IN_SILENT, 1) == 1;
704+
int newMode = mAudioManager.isSilentMode()
705+
? AudioManager.RINGER_MODE_NORMAL
706+
: (vibeInSilent
707+
? AudioManager.RINGER_MODE_VIBRATE
708+
: AudioManager.RINGER_MODE_SILENT);
709+
mAudioManager.setRingerMode(newMode);
700710
// Expand the dialog if it hasn't been expanded yet.
701711
if (mShowCombinedVolumes && !isExpanded()) expand();
702712
}
1.28 KB
Loading
905 Bytes
Loading
1.8 KB
Loading

media/java/android/media/AudioService.java

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
package android.media;
1818

19+
import static android.media.AudioManager.RINGER_MODE_NORMAL;
20+
import static android.media.AudioManager.RINGER_MODE_SILENT;
21+
import static android.media.AudioManager.RINGER_MODE_VIBRATE;
22+
1923
import android.app.ActivityManagerNative;
2024
import android.app.KeyguardManager;
2125
import android.app.PendingIntent;
@@ -528,8 +532,8 @@ public void adjustStreamVolume(int streamType, int direction, int flags) {
528532
(!mVoiceCapable && streamType != AudioSystem.STREAM_VOICE_CALL &&
529533
streamType != AudioSystem.STREAM_BLUETOOTH_SCO) ||
530534
(mVoiceCapable && streamTypeAlias == AudioSystem.STREAM_RING)) {
531-
// do not vibrate if already in silent mode
532-
if (mRingerMode != AudioManager.RINGER_MODE_NORMAL) {
535+
// do not vibrate if already in vibrate mode
536+
if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
533537
flags &= ~AudioManager.FLAG_VIBRATE;
534538
}
535539
// Check if the ringer mode changes with this volume adjustment. If
@@ -1621,26 +1625,36 @@ private boolean checkForRingerModeChange(int oldIndex, int direction, int stream
16211625
boolean adjustVolumeIndex = true;
16221626
int newRingerMode = mRingerMode;
16231627
int uiIndex = (oldIndex + 5) / 10;
1628+
boolean vibeInSilent = System.getInt(mContentResolver, System.VIBRATE_IN_SILENT, 1) == 1;
16241629

1625-
if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
1630+
if (mRingerMode == RINGER_MODE_NORMAL) {
16261631
if ((direction == AudioManager.ADJUST_LOWER) && (uiIndex <= 1)) {
16271632
// enter silent mode if current index is the last audible one and not repeating a
16281633
// volume key down
1629-
if (mPrevVolDirection != AudioManager.ADJUST_LOWER) {
1634+
if (vibeInSilent || mPrevVolDirection != AudioManager.ADJUST_LOWER) {
16301635
// "silent mode", but which one?
1631-
newRingerMode = System.getInt(mContentResolver, System.VIBRATE_IN_SILENT, 1) == 1
1632-
? AudioManager.RINGER_MODE_VIBRATE
1633-
: AudioManager.RINGER_MODE_SILENT;
1636+
newRingerMode = vibeInSilent ? RINGER_MODE_VIBRATE : RINGER_MODE_SILENT;
16341637
}
16351638
if (uiIndex == 0 || (mPrevVolDirection == AudioManager.ADJUST_LOWER &&
16361639
mVoiceCapable && streamType == AudioSystem.STREAM_RING)) {
16371640
adjustVolumeIndex = false;
16381641
}
16391642
}
1643+
} else if (mRingerMode == RINGER_MODE_VIBRATE) {
1644+
if ((direction == AudioManager.ADJUST_LOWER)) {
1645+
// Set it to silent, if it wasn't a long-press
1646+
if (mPrevVolDirection != AudioManager.ADJUST_LOWER) {
1647+
newRingerMode = RINGER_MODE_SILENT;
1648+
}
1649+
} else if (direction == AudioManager.ADJUST_RAISE) {
1650+
newRingerMode = RINGER_MODE_NORMAL;
1651+
}
1652+
adjustVolumeIndex = false;
16401653
} else {
16411654
if (direction == AudioManager.ADJUST_RAISE) {
16421655
// exiting silent mode
1643-
newRingerMode = AudioManager.RINGER_MODE_NORMAL;
1656+
// If VIBRATE_IN_SILENT, then go into vibrate mode
1657+
newRingerMode = vibeInSilent ? RINGER_MODE_VIBRATE : RINGER_MODE_NORMAL;
16441658
}
16451659
adjustVolumeIndex = false;
16461660
}
40 Bytes
Loading
-42 Bytes
Loading
98 Bytes
Loading

policy/src/com/android/internal/policy/impl/GlobalActions.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ private AlertDialog createDialog() {
121121
R.string.global_action_silent_mode_off_status) {
122122

123123
void willCreate() {
124-
// XXX: FIXME: Add vibrate indicator when available
125124
mEnabledIconResId = (Settings.System.getInt(mContext.getContentResolver(),
126125
Settings.System.VIBRATE_IN_SILENT, 1) == 1)
127-
? R.drawable.ic_audio_vol_mute
126+
? R.drawable.ic_audio_ring_notif_vibrate
128127
: R.drawable.ic_audio_vol_mute;
129128
}
130129

0 commit comments

Comments
 (0)