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

Commit e9f2d9f6 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 LEA output when ringing in vibration mode.
Use both Bluetooth LEA and phone default output when ringing in normal mode.

Change-Id: I6e3e4c8d7179b360631cba0db19b52d2f176a40c
Signed-off-by: default avatarchenxin20 <chenxin20@xiaomi.com>
parent 027e8a38
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -377,6 +377,8 @@ aidl2legacy_AudioPolicyForcedConfig_audio_policy_forced_cfg_t(media::AudioPolicy
            return AUDIO_POLICY_FORCE_ENCODED_SURROUND_ALWAYS;
        case media::AudioPolicyForcedConfig::ENCODED_SURROUND_MANUAL:
            return AUDIO_POLICY_FORCE_ENCODED_SURROUND_MANUAL;
        case media::AudioPolicyForcedConfig::BT_BLE:
            return AUDIO_POLICY_FORCE_BT_BLE;
    }
    return unexpected(BAD_VALUE);
}
@@ -416,6 +418,8 @@ legacy2aidl_audio_policy_forced_cfg_t_AudioPolicyForcedConfig(audio_policy_force
            return media::AudioPolicyForcedConfig::ENCODED_SURROUND_ALWAYS;
        case AUDIO_POLICY_FORCE_ENCODED_SURROUND_MANUAL:
            return media::AudioPolicyForcedConfig::ENCODED_SURROUND_MANUAL;
        case AUDIO_POLICY_FORCE_BT_BLE:
            return media::AudioPolicyForcedConfig::BT_BLE;
        case AUDIO_POLICY_FORCE_CFG_CNT:
            break;
    }
+1 −0
Original line number Diff line number Diff line
@@ -36,4 +36,5 @@ enum AudioPolicyForcedConfig {
    ENCODED_SURROUND_NEVER = 13,
    ENCODED_SURROUND_ALWAYS = 14,
    ENCODED_SURROUND_MANUAL = 15,
    BT_BLE = 16,
}
+36 −1
Original line number Diff line number Diff line
@@ -142,7 +142,8 @@ status_t Engine::setForceUse(audio_policy_force_use_t usage, audio_policy_forced
        }
        break;
    case AUDIO_POLICY_FORCE_FOR_VIBRATE_RINGING:
        if (config != AUDIO_POLICY_FORCE_BT_SCO && config != AUDIO_POLICY_FORCE_NONE) {
        if (config != AUDIO_POLICY_FORCE_BT_SCO && config != AUDIO_POLICY_FORCE_BT_BLE
                && config != AUDIO_POLICY_FORCE_NONE) {
            ALOGW("setForceUse() invalid config %d for VIBRATE_RINGING", config);
            return BAD_VALUE;
        }
@@ -355,6 +356,40 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy,
                }
            }
        }

        // if LEA headset is connected and we are told to use it, play ringtone over
        // speaker and BT LEA
        if (!availableOutputDevices.getDevicesFromTypes(getAudioDeviceOutAllBleSet()).isEmpty()) {
            DeviceVector devices2;
            devices2 = availableOutputDevices.getFirstDevicesFromTypes({
                    AUDIO_DEVICE_OUT_BLE_HEADSET, AUDIO_DEVICE_OUT_BLE_SPEAKER});
            // Use ONLY Bluetooth LEA output when ringing in vibration mode
            if (!((getForceUse(AUDIO_POLICY_FORCE_FOR_SYSTEM) == AUDIO_POLICY_FORCE_SYSTEM_ENFORCED)
                    && (strategy == STRATEGY_ENFORCED_AUDIBLE))) {
                if (getForceUse(AUDIO_POLICY_FORCE_FOR_VIBRATE_RINGING)
                        == AUDIO_POLICY_FORCE_BT_BLE) {
                    if (!devices2.isEmpty()) {
                        devices = devices2;
                        break;
                    }
                }
            }
            // Use both Bluetooth LEA and phone default output when ringing in normal mode
            if (audio_is_ble_out_device(getPreferredDeviceTypeForLegacyStrategy(
                    availableOutputDevices, STRATEGY_PHONE))) {
                if (strategy == STRATEGY_SONIFICATION) {
                    devices.replaceDevicesByType(
                            AUDIO_DEVICE_OUT_SPEAKER,
                            availableOutputDevices.getDevicesFromType(
                                    AUDIO_DEVICE_OUT_SPEAKER_SAFE));
                }
                if (!devices2.isEmpty()) {
                    devices.add(devices2);
                    break;
                }
            }
        }

        // The second device used for sonification is the same as the device used by media strategy
        FALLTHROUGH_INTENDED;