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

Commit 66030b6b authored by Satya Calloji's avatar Satya Calloji Committed by Andre Eisenbach
Browse files

Fix GATT connection failure after BT reset

Handles the address type incorrect value storage issue
and removes usage of DMT supported flag which was based
on legacy code

Bug: 20912064
Change-Id: I5bd20dc9cd0997ac3dbd4b346cc0513f1809f241
parent eac9ba65
Loading
Loading
Loading
Loading
+0 −29
Original line number Diff line number Diff line
@@ -349,33 +349,4 @@ bt_status_t btif_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr,
bt_status_t btif_storage_get_remote_version(const bt_bdaddr_t *remote_bd_addr,
                                  bt_remote_version_t *p_ver);

/*******************************************************************************
**
** Function         btif_storage_set_dmt_support_type
**
** Description      Sets DMT support status for a remote device
**
** Returns          BT_STATUS_SUCCESS if config update is successful
**                  BT_STATUS_FAIL otherwise
**
*******************************************************************************/

bt_status_t btif_storage_set_dmt_support_type(const bt_bdaddr_t *remote_bd_addr,
                                                   BOOLEAN dmt_supported);



/*******************************************************************************
**
** Function         btif_storage_is_dmt_supported_device
**
** Description      checks if a device supports Dual mode topology
**
** Returns         TRUE if remote supports DMT else FALSE
**
*******************************************************************************/

BOOLEAN btif_storage_is_dmt_supported_device(const bt_bdaddr_t *remote_bd_addr);


#endif /* BTIF_STORAGE_H */
+5 −7
Original line number Diff line number Diff line
@@ -1380,12 +1380,6 @@ static void btif_dm_search_devices_evt (UINT16 event, char *p_param)
                ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote device (inquiry)", status);
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
                status = btif_storage_set_remote_addr_type(&bdaddr, addr_type);
                if (( dev_type == BT_DEVICE_TYPE_DUMO)&&
                   (p_search_data->inq_res.flag & BTA_BLE_DMT_CONTROLLER_SPT) &&
                   (p_search_data->inq_res.flag & BTA_BLE_DMT_HOST_SPT))
                 {
                    btif_storage_set_dmt_support_type (&bdaddr, TRUE);
                 }
                ASSERTC(status == BT_STATUS_SUCCESS, "failed to save remote addr type (inquiry)", status);
#endif
                /* Callback to notify upper layer of device */
@@ -2890,7 +2884,11 @@ static void btif_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
    {
        status = BT_STATUS_SUCCESS;
        state = BT_BOND_STATE_BONDED;

        int addr_type;
        bt_bdaddr_t bdaddr;
        bdcpy(bdaddr.address, p_auth_cmpl->bd_addr);
        if (btif_storage_get_remote_addr_type(&bdaddr, &addr_type) != BT_STATUS_SUCCESS)
            btif_storage_set_remote_addr_type(&bdaddr, p_auth_cmpl->addr_type);
        btif_dm_save_ble_bonding_keys();
        BTA_GATTC_Refresh(bd_addr.address);
        btif_dm_get_remote_services(&bd_addr);
+1 −9
Original line number Diff line number Diff line
@@ -639,13 +639,6 @@ static void btif_gattc_upstreams_evt(uint16_t event, char* p_param)
               }
            }

            if (( p_btif_cb->device_type == BT_DEVICE_TYPE_DUMO)&&
               (p_btif_cb->flag & BTA_BLE_DMT_CONTROLLER_SPT) &&
               (p_btif_cb->flag & BTA_BLE_DMT_HOST_SPT))
             {
                btif_storage_set_dmt_support_type (&(p_btif_cb->bd_addr), TRUE);
             }

             dev_type =  p_btif_cb->device_type;
             BTIF_STORAGE_FILL_PROPERTY(&properties,
                        BT_PROPERTY_TYPE_OF_DEVICE, sizeof(dev_type), &dev_type);
@@ -1219,8 +1212,7 @@ static void btgattc_handle_event(uint16_t event, char* p_param)
                    break;

                case BT_DEVICE_TYPE_DUMO:
                    if ((p_cb->transport == GATT_TRANSPORT_LE) &&
                        (btif_storage_is_dmt_supported_device(&(p_cb->bd_addr)) == TRUE))
                    if (p_cb->transport == GATT_TRANSPORT_LE)
                        transport = BTA_GATT_TRANSPORT_LE;
                    else
                        transport = BTA_GATT_TRANSPORT_BR_EDR;
+1 −2
Original line number Diff line number Diff line
@@ -413,8 +413,7 @@ static void btgatts_handle_event(uint16_t event, char* p_param)
                    break;

                case BT_DEVICE_TYPE_DUMO:
                    if ((p_cb->transport == GATT_TRANSPORT_LE) &&
                        (btif_storage_is_dmt_supported_device(&(p_cb->bd_addr)) == TRUE))
                    if (p_cb->transport == GATT_TRANSPORT_LE)
                        transport = BTA_GATT_TRANSPORT_LE;
                    else
                        transport = BTA_GATT_TRANSPORT_BR_EDR;
+0 −64
Original line number Diff line number Diff line
@@ -1651,67 +1651,3 @@ BOOLEAN btif_storage_is_fixed_pin_zeros_keyboard(bt_bdaddr_t *remote_bd_addr)

}
/*******************************************************************************
**
** Function         btif_storage_set_dmt_support_type
**
** Description      Sets DMT support status for a remote device
**
** Returns          BT_STATUS_SUCCESS if config update is successful
**                  BT_STATUS_FAIL otherwise
**
*******************************************************************************/

bt_status_t btif_storage_set_dmt_support_type(const bt_bdaddr_t *remote_bd_addr,
                                                   BOOLEAN dmt_supported)
{
    int ret;
    bdstr_t bdstr = {0};
    if(remote_bd_addr)
    {
        bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
    }
    else
    {
        BTIF_TRACE_ERROR("%s  NULL BD Address", __FUNCTION__);
        return BT_STATUS_FAIL;
    }

   ret = btif_config_set_int(bdstr,"DMTSupported", (int)dmt_supported);
   return ret ? BT_STATUS_SUCCESS:BT_STATUS_FAIL;

}

/*******************************************************************************
**
** Function         btif_storage_is_dmt_supported_device
**
** Description      checks if a device supports Dual mode topology
**
** Returns         TRUE if remote address is valid and supports DMT else FALSE
**
*******************************************************************************/

BOOLEAN btif_storage_is_dmt_supported_device(const bt_bdaddr_t *remote_bd_addr)
{
    int    dmt_supported = 0;
    bdstr_t bdstr = {0};
    if(remote_bd_addr)
        bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));

    if(remote_bd_addr)
    {
        bdaddr_to_string(remote_bd_addr, bdstr, sizeof(bdstr));
    }
    else
    {
        BTIF_TRACE_ERROR("%s  NULL BD Address", __FUNCTION__);
        return FALSE;
    }

    btif_config_get_int(bdstr,"DMTSupported", &dmt_supported);

    return dmt_supported == 1 ? TRUE:FALSE;
}