Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e57c38c authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioService: fix volume behavior for dock devices

In AudioService.getDeviceVolumeBehaviorInt(), prefer using the
internal device type determined by the AudioDeviceAttributes constructor
rather than converting back from the derived SDK type. This avoids
potential double conversions (internal > SDK > internal) that can yeld
to problems in case of non bijective mapping from internal to SDK types
In AudioDeviceInfo.

Bug: 237378890
Test: make
Change-Id: I8ba167e719d2b060edd0dfe6c549273132cb85d8
parent 858e21b5
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -6992,9 +6992,10 @@ public class AudioService extends IAudioService.Stub
    private @AudioManager.DeviceVolumeBehavior
    private @AudioManager.DeviceVolumeBehavior
            int getDeviceVolumeBehaviorInt(@NonNull AudioDeviceAttributes device) {
            int getDeviceVolumeBehaviorInt(@NonNull AudioDeviceAttributes device) {
        // translate Java device type to native device type (for the devices masks for full / fixed)
        // Get the internal type set by the AudioDeviceAttributes constructor which is always more
        final int audioSystemDeviceOut = AudioDeviceInfo.convertDeviceTypeToInternalDevice(
        // exact (avoids double conversions) than a conversion from SDK type via
                device.getType());
        // AudioDeviceInfo.convertDeviceTypeToInternalDevice()
        final int audioSystemDeviceOut = device.getInternalType();
        int setDeviceVolumeBehavior = retrieveStoredDeviceVolumeBehavior(audioSystemDeviceOut);
        int setDeviceVolumeBehavior = retrieveStoredDeviceVolumeBehavior(audioSystemDeviceOut);
        if (setDeviceVolumeBehavior != AudioManager.DEVICE_VOLUME_BEHAVIOR_UNSET) {
        if (setDeviceVolumeBehavior != AudioManager.DEVICE_VOLUME_BEHAVIOR_UNSET) {