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

Commit 813b460e authored by Subramanian Srinivasan's avatar Subramanian Srinivasan Committed by Jakub Pawlowski
Browse files

Fixes setting of service uuid mask during BLE APCF scan

Fixes setting of incorrect service uuid mask bytes in vendor
specific command when service uuid mask length is less than
the length of service uuid APCF filter.
eg:ServiceUuid:12131215-0000-1000-8000-00805F9B34FB
SvcMaskUuid:0000FFFF-0000-1000-8000-00805F9B34FB
In the above eg, user is trying to apply 32 bit service uuid
mask on 32 bit service uuid. But the stack treats the
service uuid mask as 16 bits and inserts garbage values for
the first 16 bits of service uuid mask in the VS command
since the MSB bits of the mask are zeroes. This change fixes
the scenario where service uuid mask length is less than
service uuid length.

Change-Id: Ie1aece1162b1ba7f4b7a3e9eea7eb5a074f85d62
parent 9b0b2da3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@

void btif_to_bta_uuid(tBT_UUID *p_dest, const bt_uuid_t *p_src);
void btif_to_bta_response(tBTA_GATTS_RSP *p_dest, btgatt_response_t* p_src);
void btif_to_bta_uuid_mask(tBTA_DM_BLE_PF_COND_MASK *p_mask, const bt_uuid_t *p_src);
void btif_to_bta_uuid_mask(tBTA_DM_BLE_PF_COND_MASK *p_mask, const bt_uuid_t *p_src, const bt_uuid_t *svc_uuid);

void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src);

+1 −1
Original line number Diff line number Diff line
@@ -938,7 +938,7 @@ bt_status_t btif_gattc_scan_filter_add_remove(

      if (p_uuid_mask != NULL) {
        tBTA_DM_BLE_PF_COND_MASK *uuid_mask = new tBTA_DM_BLE_PF_COND_MASK;
        btif_to_bta_uuid_mask(uuid_mask, p_uuid_mask);
        btif_to_bta_uuid_mask(uuid_mask, p_uuid_mask, p_uuid);
        return do_in_jni_thread(Bind(&btif_gattc_scan_filter_add_srvc_uuid,
                                     bt_uuid, base::Owned(uuid_mask), action,
                                     filt_type, filt_index, client_if));
+7 −6
Original line number Diff line number Diff line
@@ -118,20 +118,21 @@ void btif_to_bta_response(tBTA_GATTS_RSP *p_dest, btgatt_response_t* p_src)
    memcpy(p_dest->attr_value.value, p_src->attr_value.value, GATT_MAX_ATTR_LEN);
}

void btif_to_bta_uuid_mask(tBTA_DM_BLE_PF_COND_MASK *p_mask, const bt_uuid_t *p_src)
void btif_to_bta_uuid_mask(tBTA_DM_BLE_PF_COND_MASK *p_mask, const bt_uuid_t *uuid_mask, const bt_uuid_t *svc_uuid)
{
    char *p_byte = (char*)p_src;
    char *p_byte = (char*)uuid_mask;
    int uuid_len = uuidType(svc_uuid->uu);
    int i = 0;

    switch (uuidType(p_src->uu))
    switch (uuid_len)
    {
        case LEN_UUID_16:
            p_mask->uuid16_mask = (p_src->uu[13] << 8) + p_src->uu[12];
            p_mask->uuid16_mask = (uuid_mask->uu[13] << 8) + uuid_mask->uu[12];
            break;

        case LEN_UUID_32:
            p_mask->uuid32_mask = (p_src->uu[13] <<  8) + p_src->uu[12];
            p_mask->uuid32_mask += (p_src->uu[15] << 24) + (p_src->uu[14] << 16);
            p_mask->uuid32_mask = (uuid_mask->uu[13] <<  8) + uuid_mask->uu[12];
            p_mask->uuid32_mask += (uuid_mask->uu[15] << 24) + (uuid_mask->uu[14] << 16);
            break;

        case LEN_UUID_128: