diff options
author | Eric Laurent <elaurent@google.com> | 2012-10-01 19:39:04 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2012-10-02 11:46:30 -0700 |
commit | 002e9d382d2daa7ed41636463ecdbddbd4897aba (patch) | |
tree | 33146bb2642d01c1899ac629cda4e081cede2f6c /media/java | |
parent | 57e6203457cedbc6f4bf8a45635862a3eb717e9f (diff) | |
download | frameworks_base-002e9d382d2daa7ed41636463ecdbddbd4897aba.zip frameworks_base-002e9d382d2daa7ed41636463ecdbddbd4897aba.tar.gz frameworks_base-002e9d382d2daa7ed41636463ecdbddbd4897aba.tar.bz2 |
audio service: fix system volume settings
STREAM_SYSTEM stream volume is never persisted to settings as
it is always derived from another stream volume (STREAM_RING on phones
and STREAM_MUSIC on tablets). Therefore values stored in settings
are stale from previous releases and should be ignored.
Also fix a problem where a muted stream can be unmuted by
readAudioSettings() even if it is muted by ringer mode.
Bug 7216630.
Change-Id: If23561ddfbc704f89fd0a997faf1b50299a50c2e
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/AudioService.java | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index fdb6818..61418fb 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -1737,7 +1737,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished { streamState.readSettings(); // unmute stream that was muted but is not affect by mute anymore - if (streamState.muteCount() != 0 && !isStreamAffectedByMute(streamType)) { + if (streamState.muteCount() != 0 && !isStreamAffectedByMute(streamType) && + !isStreamMutedByRingerMode(streamType)) { int size = streamState.mDeathHandlers.size(); for (int i = 0; i < size; i++) { streamState.mDeathHandlers.get(i).mMuteCount = 1; @@ -2591,6 +2592,18 @@ public class AudioService extends IAudioService.Stub implements OnFinished { public synchronized void readSettings() { int remainingDevices = AudioSystem.DEVICE_OUT_ALL; + // do not read system stream volume from settings: this stream is always aliased + // to another stream type and its volume is never persisted. Values in settings can + // only be stale values + if ((mStreamType == AudioSystem.STREAM_SYSTEM) || + (mStreamType == AudioSystem.STREAM_SYSTEM_ENFORCED)) { + mLastAudibleIndex.put(AudioSystem.DEVICE_OUT_DEFAULT, + 10 * AudioManager.DEFAULT_STREAM_VOLUME[mStreamType]); + mIndex.put(AudioSystem.DEVICE_OUT_DEFAULT, + 10 * AudioManager.DEFAULT_STREAM_VOLUME[mStreamType]); + return; + } + for (int i = 0; remainingDevices != 0; i++) { int device = (1 << i); if ((device & remainingDevices) == 0) { @@ -2621,11 +2634,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished { // a last audible index of 0 should never be stored for ring and notification // streams on phones (voice capable devices). - // same for system stream on phones and tablets - if ((lastAudibleIndex == 0) && - ((mVoiceCapable && - (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_RING)) || - (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_SYSTEM))) { + if ((lastAudibleIndex == 0) && mVoiceCapable && + (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_RING)) { lastAudibleIndex = AudioManager.DEFAULT_STREAM_VOLUME[mStreamType]; // Correct the data base sendMsg(mAudioHandler, @@ -2639,11 +2649,9 @@ public class AudioService extends IAudioService.Stub implements OnFinished { mLastAudibleIndex.put(device, getValidIndex(10 * lastAudibleIndex)); // the initial index should never be 0 for ring and notification streams on phones // (voice capable devices) if not in silent or vibrate mode. - // same for system stream on phones and tablets if ((index == 0) && (mRingerMode == AudioManager.RINGER_MODE_NORMAL) && - ((mVoiceCapable && - (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_RING)) || - (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_SYSTEM))) { + mVoiceCapable && + (mStreamVolumeAlias[mStreamType] == AudioSystem.STREAM_RING)) { index = lastAudibleIndex; // Correct the data base sendMsg(mAudioHandler, |