Merge "Fix issues 3425035 and 3423785." into honeycomb

This commit is contained in:
Eric Laurent
2011-02-04 14:06:40 -08:00
committed by Android (Google) Code Review
3 changed files with 46 additions and 4 deletions

View File

@@ -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();

View File

@@ -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;
@@ -262,6 +262,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;
@@ -682,6 +699,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.

View File

@@ -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