OSDN Git Service

GAP: Try to retrieve CoD from NVRAM if 0
authorHemant Gupta <hemantg@codeaurora.org>
Thu, 28 Nov 2013 07:37:10 +0000 (13:07 +0530)
committerMatthew Xie <mattx@google.com>
Tue, 6 May 2014 08:14:24 +0000 (01:14 -0700)
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

btif/src/btif_dm.c

index 753ce7a..a0ea0b0 100644 (file)
@@ -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__);