OSDN Git Service

HID: Fix the behavior of virtual_cable_unplug
authorHansong Zhang <hsz@google.com>
Tue, 17 Oct 2017 00:00:16 +0000 (17:00 -0700)
committerHansong Zhang <hsz@google.com>
Tue, 17 Oct 2017 00:40:38 +0000 (17:40 -0700)
The Bluetooth HID profile itself should not unbond other device; the
Bluetooth HID host and device should only disconnect the HID profile
when sending or receiving virtual_cable_unplug command.

Bug: 67866553
Test: Test with SL4A.
Change-Id: Ie378a7292309d2b11f53fcd82bca1cf42e64b0c0

btif/src/btif_hd.cc
btif/src/btif_hh.cc

index eb3dbbb..dd39bc7 100644 (file)
@@ -253,18 +253,8 @@ static void btif_hd_upstreams_evt(uint16_t event, char* p_param) {
     case BTA_HD_VC_UNPLUG_EVT:
       HAL_CBACK(bt_hd_callbacks, connection_state_cb,
                 (RawAddress*)&p_data->conn.bda, BTHD_CONN_STATE_DISCONNECTED);
-      if (bta_dm_check_if_only_hd_connected(p_data->conn.bda)) {
-        BTIF_TRACE_DEBUG("%s: Removing bonding as only HID profile connected",
-                         __func__);
-        BTA_DmRemoveDevice(p_data->conn.bda);
-      } else {
-        RawAddress* bd_addr = (RawAddress*)&p_data->conn.bda;
-        BTIF_TRACE_DEBUG(
-            "%s: Only removing HID data as some other profiles "
-            "connected",
-            __func__);
-        btif_hd_remove_device(*bd_addr);
-      }
+      LOG(INFO) << __func__ << ": Only removing HID data";
+      btif_hd_remove_device(p_data->conn.bda);
       HAL_CBACK(bt_hd_callbacks, vc_unplug_cb);
       break;
 
index 0e914d1..2f59858 100644 (file)
@@ -815,13 +815,6 @@ static void btif_hh_upstreams_evt(uint16_t event, char* p_param) {
         BTIF_TRACE_DEBUG("%s: uhid fd=%d local_vup=%d", __func__, p_dev->fd,
                          p_dev->local_vup);
         btif_hh_stop_vup_timer(&(p_dev->bd_addr));
-        /* If this is a locally initiated VUP, remove the bond as ACL got
-         *  disconnected while VUP being processed.
-         */
-        if (p_dev->local_vup) {
-          p_dev->local_vup = false;
-          BTA_DmRemoveDevice(p_dev->bd_addr);
-        }
 
         btif_hh_cb.status = (BTIF_HH_STATUS)BTIF_HH_DEV_DISCONNECTED;
         p_dev->dev_status = BTHH_CONN_STATE_DISCONNECTED;
@@ -1046,13 +1039,7 @@ static void btif_hh_upstreams_evt(uint16_t event, char* p_param) {
         HAL_CBACK(bt_hh_callbacks, connection_state_cb, &(p_dev->bd_addr),
                   p_dev->dev_status);
         BTIF_TRACE_DEBUG("%s---Removing HID bond", __func__);
-        /* If it is locally initiated VUP or remote device has its major COD as
-        Peripheral removed the bond.*/
-        if (p_dev->local_vup || check_cod_hid(&(p_dev->bd_addr))) {
-          p_dev->local_vup = false;
-          BTA_DmRemoveDevice(p_dev->bd_addr);
-        } else
-          btif_hh_remove_device(p_dev->bd_addr);
+        btif_hh_remove_device(p_dev->bd_addr);
         HAL_CBACK(bt_hh_callbacks, virtual_unplug_cb, &(p_dev->bd_addr),
                   (bthh_status_t)p_data->dev_status.status);
       }