Merge "Don't allow changing master volume when muted" into ics-aah

This commit is contained in:
Mike Lockwood
2012-01-05 12:29:58 -08:00
committed by Android (Google) Code Review

View File

@@ -603,7 +603,6 @@ public class AudioService extends IAudioService.Stub {
float volume = AudioSystem.getMasterVolume();
if (volume >= 0.0) {
// get current master volume adjusted to 0 to 100
int oldVolume = getMasterVolume();
if (direction == AudioManager.ADJUST_RAISE) {
volume += MASTER_VOLUME_INCREMENT;
if (volume > 1.0f) volume = 1.0f;
@@ -611,11 +610,7 @@ public class AudioService extends IAudioService.Stub {
volume -= MASTER_VOLUME_INCREMENT;
if (volume < 0.0f) volume = 0.0f;
}
AudioSystem.setMasterVolume(volume);
// Post a persist master volume msg
sendMsg(mAudioHandler, MSG_PERSIST_MASTER_VOLUME, 0, SENDMSG_REPLACE,
Math.round(volume * (float)1000.0), 0, null, PERSIST_DELAY);
sendMasterVolumeUpdate(flags, oldVolume, getMasterVolume());
doSetMasterVolume(volume, flags);
}
}
@@ -765,7 +760,19 @@ public class AudioService extends IAudioService.Stub {
}
public void setMasterVolume(int volume, int flags) {
AudioSystem.setMasterVolume((float)volume / MAX_MASTER_VOLUME);
doSetMasterVolume((float)volume / MAX_MASTER_VOLUME, flags);
}
private void doSetMasterVolume(float volume, int flags) {
// don't allow changing master volume when muted
if (!AudioSystem.getMasterMute()) {
int oldVolume = getMasterVolume();
AudioSystem.setMasterVolume(volume);
// Post a persist master volume msg
sendMsg(mAudioHandler, MSG_PERSIST_MASTER_VOLUME, 0, SENDMSG_REPLACE,
Math.round(volume * (float)1000.0), 0, null, PERSIST_DELAY);
sendMasterVolumeUpdate(flags, oldVolume, getMasterVolume());
}
}
/** @see AudioManager#getStreamMaxVolume(int) */