From: Hemant Gupta Date: Thu, 28 Nov 2013 07:37:10 +0000 (+0530) Subject: GAP: Try to retrieve CoD from NVRAM if 0 X-Git-Tag: android-x86-7.1-r1~1806 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=dda369e3a6b39c7df25072fc880fbd4903553f5c;p=android-x86%2Fsystem-bt.git GAP: Try to retrieve CoD from NVRAM if 0 This patch tries to retreive CoD from NVRAM if CoD is 0. This is because in scenarios when airplane mode on/off, inquiry is not performed again on devices shown in Available devices List of UI, so CoD is 0 during SSP information as database of stack is not properly updated since inquiry is not performed again. Without this patch it was observed because of wrong CoD info device icon for HID mouse was changed to Joystick and device is not shown in Paired List. Also some extra debug logs are added in code for better debugging. Change-Id: I14858ccee04728cb4b9cd60d397b79fa6494b842 --- diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c index 753ce7a84..a0ea0b0aa 100644 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -283,6 +283,7 @@ BOOLEAN check_cod(const bt_bdaddr_t *remote_bdaddr, uint32_t cod) sizeof(uint32_t), &remote_cod); if (btif_storage_get_remote_device_property((bt_bdaddr_t *)remote_bdaddr, &prop_name) == BT_STATUS_SUCCESS) { + BTIF_TRACE_ERROR2("%s: remote_cod = 0x%06x", __FUNCTION__, remote_cod); if ((remote_cod & 0x7ff) == cod) return TRUE; } @@ -301,6 +302,7 @@ BOOLEAN check_cod_hid(const bt_bdaddr_t *remote_bdaddr, uint32_t cod) if (btif_storage_get_remote_device_property((bt_bdaddr_t *)remote_bdaddr, &prop_name) == BT_STATUS_SUCCESS) { + BTIF_TRACE_DEBUG2("%s: remote_cod = 0x%06x", __FUNCTION__, remote_cod); if ((remote_cod & 0x700) == cod) return TRUE; } @@ -415,9 +417,18 @@ static void btif_update_remote_properties(BD_ADDR bd_addr, BD_NAME bd_name, /* class of device */ cod = devclass2uint(dev_class); + BTIF_TRACE_DEBUG2("%s():cod is 0x%06x", __FUNCTION__, cod); if ( cod == 0) { - BTIF_TRACE_DEBUG1("%s():cod is 0, set as unclassified", __FUNCTION__); - cod = COD_UNCLASSIFIED; + /* Try to retrieve cod from storage */ + BTIF_TRACE_DEBUG1("%s():cod is 0, checking cod from storage", __FUNCTION__); + BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], + BT_PROPERTY_CLASS_OF_DEVICE, sizeof(cod), &cod); + status = btif_storage_get_remote_device_property(&bdaddr, &properties[num_properties]); + BTIF_TRACE_DEBUG2("%s():cod retreived from storage is 0x%06x", __FUNCTION__, cod); + if ( cod == 0) { + BTIF_TRACE_DEBUG1("%s():cod is again 0, set as unclassified", __FUNCTION__); + cod = COD_UNCLASSIFIED; + } } BTIF_STORAGE_FILL_PROPERTY(&properties[num_properties], @@ -887,7 +898,10 @@ static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) case HCI_ERR_UNIT_KEY_USED: case HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED: case HCI_ERR_INSUFFCIENT_SECURITY: - BTIF_TRACE_DEBUG1(" %s() Authentication fail ", __FUNCTION__); + case HCI_ERR_PEER_USER: + case HCI_ERR_UNSPECIFIED: + BTIF_TRACE_DEBUG2(" %s() Authentication fail reason %d", + __FUNCTION__, p_auth_cmpl->fail_reason); if (pairing_cb.autopair_attempts == 1) { BTIF_TRACE_DEBUG1("%s(): Adding device to blacklist ", __FUNCTION__);