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

Commit 80ae7b56 authored by Henri Chataing's avatar Henri Chataing
Browse files

hearing_aid: Explicitly request encryption when creating audio channel

Bug: 309483354
Bug: 348505552
Test: m com.android.btservices
Test: manual
Flag: EXEMPT, minor bugfix
Change-Id: I7c74aa48c34bcedde2a6c4177b91e60bffa3a9b8
parent 3ddcd553
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -1100,7 +1100,17 @@ class HearingAidImpl : public HearingAid {
                             : BTM_SEC_SERVICE_HEARING_AID_RIGHT;
    uint16_t gap_handle = GAP_ConnOpen(
        "", service_id, false, &hearingDevice->address, psm, 514 /* MPS */,
        &cfg_info, nullptr, BTM_SEC_NONE /* TODO: request security ? */,
        &cfg_info, nullptr,
        /// b/309483354:
        /// Encryption needs to be explicitly requested at channel
        /// establishment even though validation is performed in this module
        /// because of re-connection logic present in the L2CAP module.
        /// The L2CAP will automatically reconnect the LE-ACL link on
        /// disconnection when there is a pending channel request,
        /// which invalidates all encryption checks performed here.
        com::android::bluetooth::flags::asha_asrc()
            ? BTM_SEC_IN_ENCRYPT | BTM_SEC_OUT_ENCRYPT
            : BTM_SEC_NONE,
        HearingAidImpl::GapCallbackStatic, BT_TRANSPORT_LE);

    if (gap_handle == GAP_INVALID_HANDLE) {