summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2016-11-03 16:27:40 -0700
committer Eric Laurent <elaurent@google.com> 2016-12-07 18:56:19 +0000
commit825a5ea380d277d201a017d743cf10725266b64c (patch)
treec1e68cf4d60a0e1111db134d71d0e70144e9acc4
parent987f4e53e412fbf540ae8f05ae7b5eca9bfc8c7e (diff)
AudioService: fix mismatch in device volume index for alias streams
Fix VolumeStreamState.setIndex() to force device volume index update on an alias stream when no specific device volume exists on the VolumeStreamState of this alias stream. This prevents asymetric behaviors of setDeviceVolume() and setAllVolumes() causing some stream types to be muted and not unmuted if no specific device volume index exist. Test: make Test: wipe device, setup wizard, place call and check nofication volume Bug: 32626244 Change-Id: Idd170aa9f295b0a9533a589e1891a04c05ab2f2f (cherry picked from commit 3fb608e4f38df2781461ee601156258c90b6c472)
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java38
1 files changed, 23 insertions, 15 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index a9277cedd4fd..c70a87c36d22 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -4035,21 +4035,23 @@ public class AudioService extends IAudioService.Stub {
mIndexMap.put(device, index);
changed = oldIndex != index;
- if (changed) {
- // Apply change to all streams using this one as alias
- // if changing volume of current device, also change volume of current
- // device on aliased stream
- boolean currentDevice = (device == getDeviceForStream(mStreamType));
- int numStreamTypes = AudioSystem.getNumStreamTypes();
- for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
- if (streamType != mStreamType &&
- mStreamVolumeAlias[streamType] == mStreamType) {
- int scaledIndex = rescaleIndex(index, mStreamType, streamType);
- mStreamStates[streamType].setIndex(scaledIndex, device, caller);
- if (currentDevice) {
- mStreamStates[streamType].setIndex(scaledIndex,
- getDeviceForStream(streamType), caller);
- }
+ // Apply change to all streams using this one as alias if:
+ // - the index actually changed OR
+ // - there is no volume index stored for this device on alias stream.
+ // If changing volume of current device, also change volume of current
+ // device on aliased stream
+ final boolean currentDevice = (device == getDeviceForStream(mStreamType));
+ final int numStreamTypes = AudioSystem.getNumStreamTypes();
+ for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
+ final VolumeStreamState aliasStreamState = mStreamStates[streamType];
+ if (streamType != mStreamType &&
+ mStreamVolumeAlias[streamType] == mStreamType &&
+ (changed || !aliasStreamState.hasIndexForDevice(device))) {
+ final int scaledIndex = rescaleIndex(index, mStreamType, streamType);
+ aliasStreamState.setIndex(scaledIndex, device, caller);
+ if (currentDevice) {
+ aliasStreamState.setIndex(scaledIndex,
+ getDeviceForStream(streamType), caller);
}
}
}
@@ -4086,6 +4088,12 @@ public class AudioService extends IAudioService.Stub {
}
}
+ public boolean hasIndexForDevice(int device) {
+ synchronized (VolumeStreamState.class) {
+ return (mIndexMap.get(device, -1) != -1);
+ }
+ }
+
public int getMaxIndex() {
return mIndexMax;
}