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

Commit a31fe061 authored by Vlad Popa's avatar Vlad Popa
Browse files

During ring mode set STREAM_VOICE_CALL as bluetooth context

Usually the ringtone is played over SCO and it would make sense to let
in this case STREAM_VOICE_CALL drive the absolute volume. This fixes
when Talkback is announcing the caller ID over VC by having a consistent
volume.

Also improved logging for better debugging

Test: manual
Flag: EXEMPT bugfix
Bug: 388561285
Change-Id: Iee1da97290b44eedb0acd753b5a0b9ddb9e9c614
parent 705beb0e
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -5274,6 +5274,7 @@ public class AudioService extends IAudioService.Stub
        switch (mode) {
            case AudioSystem.MODE_IN_COMMUNICATION:
            case AudioSystem.MODE_IN_CALL:
            case AudioSystem.MODE_RINGTONE:
                // TODO(b/382704431): remove to allow STREAM_VOICE_CALL to drive abs volume
                //  over A2DP
                if (getDeviceForStream(AudioSystem.STREAM_VOICE_CALL)
@@ -5588,10 +5589,12 @@ public class AudioService extends IAudioService.Stub
                AudioSystem.DEVICE_OUT_ALL_A2DP_SET);
        absVolumeDeviceTypes.addAll(mAbsVolumeMultiModeCaseDevices);
        absVolumeDeviceTypes.add(AudioSystem.DEVICE_OUT_BLE_BROADCAST);
        absVolumeDeviceTypes.addAll(AudioSystem.DEVICE_OUT_ALL_SCO_SET);
        final Set<AudioDeviceAttributes> absVolumeDevices =
                AudioSystem.intersectionAudioDeviceTypes(absVolumeDeviceTypes, devices);
        if (absVolumeDevices.isEmpty()) {
            Slog.v(TAG, "No absolute volume devices");
            return;
        }
        if (absVolumeDevices.size() > 1) {
@@ -5746,8 +5749,13 @@ public class AudioService extends IAudioService.Stub
                if (unifyAbsoluteVolumeManagement()) {
                    volInfoBuilder.setMuted(muted);
                }
                final VolumeInfo dispatchVolumeInfo = volInfoBuilder.build();
                sVolumeLogger.enqueue(new VolumeEvent(VolumeEvent.VOL_SET_ABS_VOL,
                        dispatchVolumeInfo.getStreamType(), dispatchVolumeInfo.getVolumeIndex(),
                        deviceInfo.mDevice.getInternalType(), muted));
                deviceInfo.mCallback.dispatchDeviceVolumeChanged(deviceInfo.mDevice,
                        volInfoBuilder.build());
                        dispatchVolumeInfo);
            } catch (RemoteException e) {
                Log.w(TAG, "Couldn't dispatch absolute volume behavior volume change");
            }
+31 −0
Original line number Diff line number Diff line
@@ -278,6 +278,7 @@ public class AudioServiceEvents {
        static final int VOL_ADJUST_GROUP_VOL = 11;
        static final int VOL_MASTER_MUTE = 12;
        static final int VOL_ABS_DEVICE_ENABLED_ERROR = 13;
        static final int VOL_SET_ABS_VOL = 14;

        final int mOp;
        final int mStream;
@@ -343,6 +344,19 @@ public class AudioServiceEvents {
            logMetricEvent();
        }

        /** used for VOL_SET_ABS_VOL */
        VolumeEvent(int op, int stream, int index, int device, boolean muted) {
            mOp = op;
            mVal1 = index;
            // unused
            mVal2 = device;
            mVal3 = muted ? 1 : 0;
            mStream = stream;
            mCaller = null;
            mGroupName = null;
            logMetricEvent();
        }

        /** used for VOL_VOICE_ACTIVITY_CONTEXTUAL_VOLUME */
        VolumeEvent(int op, boolean voiceActive, int stream, int index, int device) {
            mOp = op;
@@ -502,6 +516,16 @@ public class AudioServiceEvents {
                            .set(MediaMetrics.Property.INDEX, mVal1)
                            .record();
                    return;
                case VOL_SET_ABS_VOL:
                    new MediaMetrics.Item(mMetricsId)
                            .set(MediaMetrics.Property.EVENT, "setAbsoluteVolume")
                            .set(MediaMetrics.Property.STREAM_TYPE,
                                    AudioSystem.streamToString(mStream))
                            .set(MediaMetrics.Property.INDEX, mVal3 == 1 ? 0 : mVal1)
                            .set(MediaMetrics.Property.DEVICE,
                                    AudioSystem.getOutputDeviceName(mVal2))
                            .record();
                    return;
                case VOL_VOICE_ACTIVITY_CONTEXTUAL_VOLUME:
                    new MediaMetrics.Item(mMetricsId)
                            .set(MediaMetrics.Property.EVENT, "voiceActivityContextualVolume")
@@ -593,6 +617,13 @@ public class AudioServiceEvents {
                    return new StringBuilder("setAvrcpVolume:")
                            .append(" index:").append(mVal1)
                            .toString();
                case VOL_SET_ABS_VOL:
                    return new StringBuilder("setAbsoluteVolume:")
                            .append(" stream:").append(AudioSystem.streamToString(mStream))
                            .append(" index:").append(mVal1)
                            .append(" muted:").append(mVal3 == 1 ? "true" : "false")
                            .append(" device:").append(AudioSystem.getOutputDeviceName(mVal2))
                            .toString();
                case VOL_ADJUST_VOL_UID:
                    return new StringBuilder("adjustStreamVolumeForUid(stream:")
                            .append(AudioSystem.streamToString(mStream))