summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2020-08-18 05:28:50 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2020-08-18 05:28:50 +0000
commite1a03c36619a2e1e4d824fc6028667f1e1e3bf39 (patch)
tree646611d0ffeaa7364e397d93348a12f53913333e
parent7d55904e6e4a52432375b33cbfcd5058067cafb2 (diff)
parent2efbc184af6b5120067307eb3dded126628c7e5a (diff)
Merge changes from topic "revert-12354482-fix_getDevicesForAttributes_internal-RKXYYKTJYZ"
* changes: Revert^2 "Revert "Fix mute issue when changing audio routes"" Reason for revert: SC blocking bug: 163642647 Revert "AudioService: fix internal use of getDevicesForAttributes()"
-rwxr-xr-xservices/core/java/com/android/server/audio/AudioService.java83
1 files changed, 20 insertions, 63 deletions
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index bf7c68a845c5..0a179e89f757 100755
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -1283,6 +1283,7 @@ public class AudioService extends IAudioService.Stub
}
if (isPlatformTelevision()) {
+ checkAddAllFixedVolumeDevices(AudioSystem.DEVICE_OUT_HDMI, caller);
synchronized (mHdmiClientLock) {
if (mHdmiManager != null && mHdmiPlaybackClient != null) {
updateHdmiCecSinkLocked(mHdmiCecSink | false);
@@ -1302,54 +1303,22 @@ public class AudioService extends IAudioService.Stub
}
}
- /**
- * Update volume states for the given device.
- *
- * This will initialize the volume index if no volume index is available.
- * If the device is the currently routed device, fixed/full volume policies will be applied.
- *
- * @param device a single audio device, ensure that this is not a devices bitmask
- * @param caller caller of this method
- */
- private void updateVolumeStatesForAudioDevice(int device, String caller) {
+ private void checkAddAllFixedVolumeDevices(int device, String caller) {
final int numStreamTypes = AudioSystem.getNumStreamTypes();
for (int streamType = 0; streamType < numStreamTypes; streamType++) {
- updateVolumeStates(device, streamType, caller);
- }
- }
-
- /**
- * Update volume states for the given device and given stream.
- *
- * This will initialize the volume index if no volume index is available.
- * If the device is the currently routed device, fixed/full volume policies will be applied.
- *
- * @param device a single audio device, ensure that this is not a devices bitmask
- * @param streamType streamType to be updated
- * @param caller caller of this method
- */
- private void updateVolumeStates(int device, int streamType, String caller) {
- if (!mStreamStates[streamType].hasIndexForDevice(device)) {
- // set the default value, if device is affected by a full/fix/abs volume rule, it
- // will taken into account in checkFixedVolumeDevices()
- mStreamStates[streamType].setIndex(
- mStreamStates[mStreamVolumeAlias[streamType]]
- .getIndex(AudioSystem.DEVICE_OUT_DEFAULT),
- device, caller, true /*hasModifyAudioSettings*/);
- }
-
- // Check if device to be updated is routed for the given audio stream
- List<AudioDeviceAttributes> devicesForAttributes = getDevicesForAttributesInt(
- new AudioAttributes.Builder().setInternalLegacyStreamType(streamType).build());
- for (AudioDeviceAttributes deviceAttributes : devicesForAttributes) {
- if (deviceAttributes.getType() == AudioDeviceInfo.convertInternalDeviceToDeviceType(
- device)) {
- mStreamStates[streamType].checkFixedVolumeDevices();
+ if (!mStreamStates[streamType].hasIndexForDevice(device)) {
+ // set the default value, if device is affected by a full/fix/abs volume rule, it
+ // will taken into account in checkFixedVolumeDevices()
+ mStreamStates[streamType].setIndex(
+ mStreamStates[mStreamVolumeAlias[streamType]]
+ .getIndex(AudioSystem.DEVICE_OUT_DEFAULT),
+ device, caller, true /*hasModifyAudioSettings*/);
+ }
+ mStreamStates[streamType].checkFixedVolumeDevices();
- // Unmute streams if required if device is full volume
- if (isStreamMute(streamType) && mFullVolumeDevices.contains(device)) {
- mStreamStates[streamType].mute(false);
- }
+ // Unmute streams if device is full volume
+ if (mFullVolumeDevices.contains(device)) {
+ mStreamStates[streamType].mute(false);
}
}
}
@@ -1899,13 +1868,8 @@ public class AudioService extends IAudioService.Stub
/** @see AudioManager#getDevicesForAttributes(AudioAttributes) */
public @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributes(
@NonNull AudioAttributes attributes) {
- enforceModifyAudioRoutingPermission();
- return getDevicesForAttributesInt(attributes);
- }
-
- protected @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributesInt(
- @NonNull AudioAttributes attributes) {
Objects.requireNonNull(attributes);
+ enforceModifyAudioRoutingPermission();
return AudioSystem.getDevicesForAttributes(attributes);
}
@@ -4952,15 +4916,7 @@ public class AudioService extends IAudioService.Stub
synchronized (VolumeStreamState.class) {
for (int stream = 0; stream < mStreamStates.length; stream++) {
if (stream != skipStream) {
- int devices = mStreamStates[stream].observeDevicesForStream_syncVSS(
- false /*checkOthers*/);
-
- Set<Integer> devicesSet = AudioSystem.generateAudioDeviceTypesSet(devices);
- for (Integer device : devicesSet) {
- // Update volume states for devices routed for the stream
- updateVolumeStates(device, stream,
- "AudioService#observeDevicesForStreams");
- }
+ mStreamStates[stream].observeDevicesForStream_syncVSS(false /*checkOthers*/);
}
}
}
@@ -5029,7 +4985,7 @@ public class AudioService extends IAudioService.Stub
+ Integer.toHexString(audioSystemDeviceOut) + " from:" + caller));
// make sure we have a volume entry for this device, and that volume is updated according
// to volume behavior
- updateVolumeStatesForAudioDevice(audioSystemDeviceOut, "setDeviceVolumeBehavior:" + caller);
+ checkAddAllFixedVolumeDevices(audioSystemDeviceOut, "setDeviceVolumeBehavior:" + caller);
}
/**
@@ -7251,9 +7207,10 @@ public class AudioService extends IAudioService.Stub
// HDMI output
removeAudioSystemDeviceOutFromFullVolumeDevices(AudioSystem.DEVICE_OUT_HDMI);
}
- updateVolumeStatesForAudioDevice(AudioSystem.DEVICE_OUT_HDMI,
- "HdmiPlaybackClient.DisplayStatusCallback");
}
+
+ checkAddAllFixedVolumeDevices(AudioSystem.DEVICE_OUT_HDMI,
+ "HdmiPlaybackClient.DisplayStatusCallback");
}
private class MyHdmiControlStatusChangeListenerCallback