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

Commit f7a59a4a authored by chenxin20's avatar chenxin20
Browse files

audio: ble: change the ring of ble same as sco



change the ring of ble same as sco.
Use ONLY Bluetooth BLE output when ringing in vibration mode.
Use both Bluetooth BLE and phone default output when ringing in normal mode.

Change-Id: Ic79b53318aa5e16edc175545e6ab83d84ac03646
Signed-off-by: default avatarchenxin20 <chenxin20@xiaomi.com>
parent d660759c
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);