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

Commit 87b96013 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

HID: Fix the behavior of virtual_cable_unplug

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
parent 29498f57
Loading
Loading
Loading
Loading
+2 −12
Original line number Diff line number Diff line
@@ -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;

+1 −14
Original line number Diff line number Diff line
@@ -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,12 +1039,6 @@ 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);
        HAL_CBACK(bt_hh_callbacks, virtual_unplug_cb, &(p_dev->bd_addr),
                  (bthh_status_t)p_data->dev_status.status);