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

Commit b1e9e2f4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "audio: ble: change the ring of ble same as sco" into main

parents a5a22663 f7a59a4a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1636,7 +1636,8 @@ public class AudioSystem
    /** @hide */ public static final int FORCE_ENCODED_SURROUND_NEVER = 13;
    /** @hide */ public static final int FORCE_ENCODED_SURROUND_ALWAYS = 14;
    /** @hide */ public static final int FORCE_ENCODED_SURROUND_MANUAL = 15;
    /** @hide */ public static final int NUM_FORCE_CONFIG = 16;
    /** @hide */ public static final int FORCE_BT_BLE = 16;
    /** @hide */ public static final int NUM_FORCE_CONFIG = 17;
    /** @hide */ public static final int FORCE_DEFAULT = FORCE_NONE;

    /** @hide */
@@ -1658,6 +1659,7 @@ public class AudioSystem
            case FORCE_ENCODED_SURROUND_NEVER: return "FORCE_ENCODED_SURROUND_NEVER";
            case FORCE_ENCODED_SURROUND_ALWAYS: return "FORCE_ENCODED_SURROUND_ALWAYS";
            case FORCE_ENCODED_SURROUND_MANUAL: return "FORCE_ENCODED_SURROUND_MANUAL";
            case FORCE_BT_BLE: return "FORCE_BT_BLE";
            default: return "unknown config (" + config + ")" ;
        }
    }
+8 −0
Original line number Diff line number Diff line
@@ -787,6 +787,14 @@ public class AudioDeviceBroker {
        return isDeviceActiveForCommunication(AudioDeviceInfo.TYPE_BLUETOOTH_SCO);
    }

    /*package*/ boolean isBluetoothBleHeadsetActive() {
        return isDeviceActiveForCommunication(AudioDeviceInfo.TYPE_BLE_HEADSET);
    }

    /*package*/ boolean isBluetoothBleSpeakerActive() {
        return isDeviceActiveForCommunication(AudioDeviceInfo.TYPE_BLE_SPEAKER);
    }

    /*package*/ boolean isDeviceConnected(@NonNull AudioDeviceAttributes device) {
        synchronized (mDeviceStateLock) {
            return mDeviceInventory.isDeviceConnected(device);
+12 −3
Original line number Diff line number Diff line
@@ -5665,16 +5665,25 @@ public class AudioService extends IAudioService.Stub
                || ringerMode == AudioManager.RINGER_MODE_SILENT;
        final boolean shouldRingSco = ringerMode == AudioManager.RINGER_MODE_VIBRATE
                && mDeviceBroker.isBluetoothScoActive();
        // Ask audio policy engine to force use Bluetooth SCO channel if needed
        final boolean shouldRingBle = ringerMode == AudioManager.RINGER_MODE_VIBRATE
                && (mDeviceBroker.isBluetoothBleHeadsetActive()
                || mDeviceBroker.isBluetoothBleSpeakerActive());
        // Ask audio policy engine to force use Bluetooth SCO/BLE channel if needed
        final String eventSource = "muteRingerModeStreams() from u/pid:" + Binder.getCallingUid()
                + "/" + Binder.getCallingPid();
        int forceUse = AudioSystem.FORCE_NONE;
        if (shouldRingSco) {
            forceUse = AudioSystem.FORCE_BT_SCO;
        } else if (shouldRingBle) {
            forceUse = AudioSystem.FORCE_BT_BLE;
        }
        sendMsg(mAudioHandler, MSG_SET_FORCE_USE, SENDMSG_QUEUE, AudioSystem.FOR_VIBRATE_RINGING,
                shouldRingSco ? AudioSystem.FORCE_BT_SCO : AudioSystem.FORCE_NONE, eventSource, 0);
                forceUse, eventSource, 0);
        for (int streamType = numStreamTypes - 1; streamType >= 0; streamType--) {
            final boolean isMuted = isStreamMutedByRingerOrZenMode(streamType);
            final boolean muteAllowedBySco =
                    !(shouldRingSco && streamType == AudioSystem.STREAM_RING);
                    !((shouldRingSco || shouldRingBle) && streamType == AudioSystem.STREAM_RING);
            final boolean shouldZenMute = isStreamAffectedByCurrentZen(streamType);
            final boolean shouldMute = shouldZenMute || (ringerModeMute
                    && isStreamAffectedByRingerMode(streamType) && muteAllowedBySco);