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

Commit 726acbdc authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

LE: Disable background connections if RPA offloading is not supported

If the local device does not support RPA offloading, background
connections to a resolvable random address will not work. Added callback
to indicate to the application writer that the requested operation is
not supported.

Bug: 16831527
Change-Id: I083d66b16704e997f52a40ea4daced3056b50ad5
parent 19125877
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -65,6 +65,9 @@
        BTIF_TRACE_DEBUG("%s", __FUNCTION__);\
    }

#define BLE_RESOLVE_ADDR_MSB                 0x40   /* bit7, bit6 is 01 to be resolvable random */
#define BLE_RESOLVE_ADDR_MASK                0xc0   /* bit 6, and bit7 */
#define BTM_BLE_IS_RESOLVE_BDA(x)           ((x[0] & BLE_RESOLVE_ADDR_MASK) == BLE_RESOLVE_ADDR_MSB)

typedef enum {
    BTIF_GATTC_REGISTER_APP = 1000,
@@ -1113,7 +1116,23 @@ static void btgattc_handle_event(uint16_t event, char* p_param)

            // Mark background connections
            if (!p_cb->is_direct)
            {
                // Check if RPA offloading is supported, otherwise, do not start
                // background connection, since it will not connect after address
                // changes
                if (BTM_BLE_IS_RESOLVE_BDA(p_cb->bd_addr.address))
                {
                    tBTM_BLE_VSC_CB vnd_capabilities;
                    BTM_BleGetVendorCapabilities(&vnd_capabilities);
                    if (!vnd_capabilities.rpa_offloading)
                    {
                        HAL_CBACK(bt_gatt_callbacks, client->open_cb, 0, BT_STATUS_UNSUPPORTED,
                                        p_cb->client_if, &p_cb->bd_addr);
                        return;
                    }
                }
                BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL);
            }

            switch(device_type)
            {