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

Commit adc81000 authored by François Gaffie's avatar François Gaffie Committed by Eric Laurent
Browse files

fixup '[IMPR] AudioManager: add adjustAttributesVolume API'

Bug: 237409207
Bug: 260298113
Test: atest AudioManagerTest#testAdjustVolumeGroupVolume
Change-Id: I0a2b90d1ecc2d14b484e12e5da5edf2bf5aefbe2
Merged-In: I0a2b90d1ecc2d14b484e12e5da5edf2bf5aefbe2
parent 31bb5135
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -3759,7 +3759,9 @@ public class AudioService extends IAudioService.Stub
                throw new IllegalArgumentException("No volume group for id " + groupId);
            }
            VolumeGroupState vgs = sVolumeGroupStates.get(groupId);
            return vgs.isMuted() ? vgs.getMinIndex() : vgs.getVolumeIndex();
            // Return 0 when muted, not min index since for e.g. Voice Call, it has a non zero
            // min but it mutable on permission condition.
            return vgs.isMuted() ? 0 : vgs.getVolumeIndex();
        }
    }
@@ -3871,6 +3873,7 @@ public class AudioService extends IAudioService.Stub
        }
        VolumeGroupState vgs = sVolumeGroupStates.get(groupId);
        // For compatibility reason, use stream API if group linked to a valid stream
        boolean fallbackOnStream = false;
        for (int stream : vgs.getLegacyStreamTypes()) {
            try {
                ensureValidStreamType(stream);
@@ -3879,13 +3882,20 @@ public class AudioService extends IAudioService.Stub
                        + "), do not change associated stream volume");
                continue;
            }
            // Call only for the first valid stream, legacy API will propagate to aliased streams.
            // Note: Group and Stream does not share same convention, 0 is mute for stream,
            // min index is acting as mute for Groups
            if (vgs.isVssMuteBijective(stream)) {
                adjustStreamVolume(stream, direction, flags, callingPackage);
                if (isMuteAdjust(direction)) {
                    // will be propagated to all aliased streams
                    return;
                }
                fallbackOnStream = true;
            }
        }
        if (fallbackOnStream) {
            // Handled by at least one stream, will be propagated to group, bailing out.
            return;
        }
        sVolumeLogger.log(new VolumeEvent(VolumeEvent.VOL_ADJUST_GROUP_VOL, vgs.name(),
                direction, flags, callingPackage));
@@ -5096,7 +5106,7 @@ public class AudioService extends IAudioService.Stub
    }
    private void setRingerMode(int ringerMode, String caller, boolean external) {
        if (mUseFixedVolume || mIsSingleVolume) {
        if (mUseFixedVolume || mIsSingleVolume || mUseVolumeGroupAliases) {
            return;
        }
        if (caller == null || caller.length() == 0) {
@@ -7587,7 +7597,13 @@ public class AudioService extends IAudioService.Stub
            synchronized (VolumeStreamState.class) {
                int device = getDeviceForVolume();
                int previousIndex = getIndex(device);
                if (isMuteAdjust(direction) && !isMutable()) {
                    // Non mutable volume group
                    if (DEBUG_VOL) {
                        Log.d(TAG, "invalid mute on unmutable volume group " + name());
                    }
                    return;
                }
                switch (direction) {
                    case AudioManager.ADJUST_TOGGLE_MUTE: {
                        // Note: If muted by volume 0, unmute will restore volume 0.