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

Commit e220d3b5 authored by David Brageul's avatar David Brageul Committed by Hongwei Wang
Browse files

Get volume indexes from Audio Policy Service



This patch reads min/max volume indexes from Audio Policy
Service.

Bug: 124767636
Test: dumpsys media.audio_policy
Change-Id: Ic473721a856c37e95104d2fc24f5f8ca942b5335
Signed-off-by: default avatarDavid Brageul <david.brageul@renault.com>
parent e6d280d6
Loading
Loading
Loading
Loading
+25 −0
Original line number Original line Diff line number Diff line
@@ -637,6 +637,26 @@ public class AudioService extends IAudioService.Stub
        sAudioVolumeGroups = new AudioVolumeGroups();
        sAudioVolumeGroups = new AudioVolumeGroups();


        // Initialize volume
        // Initialize volume
        // Priority 1 - Android Property
        // Priority 2 - Audio Policy Service
        // Priority 3 - Default Value
        if (sAudioProductStrategies.size() > 0) {
            int numStreamTypes = AudioSystem.getNumStreamTypes();

            for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
                AudioAttributes attr =
                        sAudioProductStrategies.getAudioAttributesForLegacyStreamType(streamType);
                int maxVolume = AudioSystem.getMaxVolumeIndexForAttributes(attr);
                if (maxVolume != -1) {
                    MAX_STREAM_VOLUME[streamType] = maxVolume;
                }
                int minVolume = AudioSystem.getMinVolumeIndexForAttributes(attr);
                if (minVolume != -1) {
                    MIN_STREAM_VOLUME[streamType] = minVolume;
                }
            }
        }

        int maxCallVolume = SystemProperties.getInt("ro.config.vc_call_vol_steps", -1);
        int maxCallVolume = SystemProperties.getInt("ro.config.vc_call_vol_steps", -1);
        if (maxCallVolume != -1) {
        if (maxCallVolume != -1) {
            MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = maxCallVolume;
            MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL] = maxCallVolume;
@@ -1465,6 +1485,11 @@ public class AudioService extends IAudioService.Stub
    }
    }


    private int rescaleIndex(int index, int srcStream, int dstStream) {
    private int rescaleIndex(int index, int srcStream, int dstStream) {
        int max = mStreamStates[srcStream].getMaxIndex();
        if (max == 0) {
            Log.e(TAG, "rescaleIndex : Max index should not be zero");
            return mStreamStates[srcStream].getMinIndex();
        }
        final int rescaled =
        final int rescaled =
                (index * mStreamStates[dstStream].getMaxIndex()
                (index * mStreamStates[dstStream].getMaxIndex()
                        + mStreamStates[srcStream].getMaxIndex() / 2)
                        + mStreamStates[srcStream].getMaxIndex() / 2)