diff options
| author | 2011-02-04 14:06:40 -0800 | |
|---|---|---|
| committer | 2011-02-04 14:06:40 -0800 | |
| commit | 2e96f15d8c6608c6bcb49c73fe13078a57245b28 (patch) | |
| tree | 0756a78966dcd45357ef04f51860a34af0286177 | |
| parent | a324a5810c84596d3a4f67f81a725a0c98dfc30f (diff) | |
| parent | 402f7f29634a9f68e7929be828a927a3e2f5efe9 (diff) | |
Merge "Fix issues 3425035 and 3423785." into honeycomb
| -rw-r--r-- | core/java/android/view/VolumePanel.java | 2 | ||||
| -rw-r--r-- | media/java/android/media/AudioManager.java | 34 | ||||
| -rw-r--r-- | media/java/android/media/AudioService.java | 14 |
3 files changed, 46 insertions, 4 deletions
diff --git a/core/java/android/view/VolumePanel.java b/core/java/android/view/VolumePanel.java index 2aa94dc65c44..3bab29fcc27f 100644 --- a/core/java/android/view/VolumePanel.java +++ b/core/java/android/view/VolumePanel.java @@ -190,6 +190,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie mDialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { mActiveStreamType = -1; + mAudioManager.forceVolumeControlStream(mActiveStreamType); } }); // Change some window properties @@ -483,6 +484,7 @@ public class VolumePanel extends Handler implements OnSeekBarChangeListener, Vie } if (!mDialog.isShowing()) { + mAudioManager.forceVolumeControlStream(streamType); mDialog.setContentView(mView); // Showing dialog - use collapsed state collapse(); diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index 051a0fc21760..5a59ef6ac809 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -48,7 +48,7 @@ public class AudioManager { private final Context mContext; private final Handler mHandler; private long mVolumeKeyUpTime; - + private int mVolumeControlStream = -1; private static String TAG = "AudioManager"; private static boolean DEBUG = false; private static boolean localLOGV = DEBUG || android.util.Config.LOGV; @@ -263,6 +263,13 @@ public class AudioManager { public static final int FLAG_VIBRATE = 1 << 4; /** + * forces use of specified stream + * @hide + */ + public static final int FLAG_FORCE_STREAM = 1 << 5; + + + /** * Ringer mode that will be silent and will not vibrate. (This overrides the * vibrate setting.) * @@ -392,12 +399,17 @@ public class AudioManager { * Adjust the volume in on key down since it is more * responsive to the user. */ + int flags = FLAG_SHOW_UI | FLAG_VIBRATE; + if (mVolumeControlStream != -1) { + stream = mVolumeControlStream; + flags |= FLAG_FORCE_STREAM; + } adjustSuggestedStreamVolume( keyCode == KeyEvent.KEYCODE_VOLUME_UP ? ADJUST_RAISE : ADJUST_LOWER, stream, - FLAG_SHOW_UI | FLAG_VIBRATE); + flags); break; case KeyEvent.KEYCODE_VOLUME_MUTE: // TODO: Actually handle MUTE. @@ -416,10 +428,15 @@ public class AudioManager { * Play a sound. This is done on key up since we don't want the * sound to play when a user holds down volume down to mute. */ + int flags = FLAG_PLAY_SOUND; + if (mVolumeControlStream != -1) { + stream = mVolumeControlStream; + flags |= FLAG_FORCE_STREAM; + } adjustSuggestedStreamVolume( ADJUST_SAME, stream, - FLAG_PLAY_SOUND); + flags); mVolumeKeyUpTime = SystemClock.uptimeMillis(); break; @@ -683,6 +700,17 @@ public class AudioManager { } /** + * forces the stream controlled by hard volume keys + * specifying streamType == -1 releases control to the + * logic. + * + * @hide + */ + public void forceVolumeControlStream(int streamType) { + mVolumeControlStream = streamType; + } + + /** * Returns whether a particular type should vibrate according to user * settings and the current ringer mode. * <p> diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index e18220ac0f4b..ba6f5489bd12 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -417,6 +417,9 @@ public class AudioService extends IAudioService.Stub { (1 << AudioSystem.STREAM_SYSTEM)|(1 << AudioSystem.STREAM_SYSTEM_ENFORCED)| (1 << AudioSystem.STREAM_MUSIC))); + if (!mVoiceCapable) { + mRingerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC); + } mMuteAffectedStreams = System.getInt(cr, System.MUTE_STREAMS_AFFECTED, ((1 << AudioSystem.STREAM_MUSIC)|(1 << AudioSystem.STREAM_RING)|(1 << AudioSystem.STREAM_SYSTEM))); @@ -461,7 +464,12 @@ public class AudioService extends IAudioService.Stub { /** @see AudioManager#adjustVolume(int, int, int) */ public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) { - int streamType = getActiveStreamType(suggestedStreamType); + int streamType; + if ((flags & AudioManager.FLAG_FORCE_STREAM) != 0) { + streamType = suggestedStreamType; + } else { + streamType = getActiveStreamType(suggestedStreamType); + } // Don't play sound on other streams if (streamType != AudioSystem.STREAM_RING && (flags & AudioManager.FLAG_PLAY_SOUND) != 0) { @@ -2025,6 +2033,10 @@ public class AudioService extends IAudioService.Stub { int ringerModeAffectedStreams = Settings.System.getInt(mContentResolver, Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); + if (!mVoiceCapable) { + ringerModeAffectedStreams |= (1 << AudioSystem.STREAM_MUSIC); + } + if (ringerModeAffectedStreams != mRingerModeAffectedStreams) { /* * Ensure all stream types that should be affected by ringer mode |