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

Commit b19192ec authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

AudioService: fix internal use of getDevicesForAttributes()

No permission check required for internal use of
getDevicesForAttributes()

Bug: 163447106
Test: atest android.media.cts.AudioManagerTest
Change-Id: I864e42e69e57d9c9c3ef090e97d2d0b98a459ff7
parent 668745be
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1338,7 +1338,7 @@ public class AudioService extends IAudioService.Stub
        }

        // Check if device to be updated is routed for the given audio stream
        List<AudioDeviceAttributes> devicesForAttributes = getDevicesForAttributes(
        List<AudioDeviceAttributes> devicesForAttributes = getDevicesForAttributesInt(
                new AudioAttributes.Builder().setInternalLegacyStreamType(streamType).build());
        for (AudioDeviceAttributes deviceAttributes : devicesForAttributes) {
            if (deviceAttributes.getType() == AudioDeviceInfo.convertInternalDeviceToDeviceType(
@@ -1884,8 +1884,13 @@ public class AudioService extends IAudioService.Stub
    /** @see AudioManager#getDevicesForAttributes(AudioAttributes) */
    public @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributes(
            @NonNull AudioAttributes attributes) {
        Objects.requireNonNull(attributes);
        enforceModifyAudioRoutingPermission();
        return getDevicesForAttributesInt(attributes);
    }

    protected @NonNull ArrayList<AudioDeviceAttributes> getDevicesForAttributesInt(
            @NonNull AudioAttributes attributes) {
        Objects.requireNonNull(attributes);
        return AudioSystem.getDevicesForAttributes(attributes);
    }