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

Commit e8e24bcf authored by Hemant Gupta's avatar Hemant Gupta Committed by Jakub Pawlowski
Browse files

HID: Update state to disconnected in virtual unplug

Usecase:
1.Pair and connect DUT with Remote device
2.Disconnect Remote device from DUT (Settings menu)
3.Connect to Remote device from settings menu when Remote will not be
  advertising.
4.With in 30 secs of connect command, delete the stored link key and then pair
  and connect again to Remote device from settings menu
  (when RD is advertising).

Expected Result:
Remote device should connect successfully.

Observed Result:
Remote device is shown in paired devices(settings menu)but not connected.

Root cause:
When virtual unplug happens device state is not cleared properly. So next
time when we are trying to connect its going to connected state.

Fix:
Update the current device state to BTHH_CONN_STATE_CONNECTING to
BTIF_HH_DEV_DISCONNECTED when virtual unplug happens.

Test: Issue is not seen after above steps

Fixes: 74082929
Change-Id: I8a325987ff5eb0a8e4f8708fc7c76b8a9ade6ccf
parent 8b71db87
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ typedef struct {
  btif_hh_added_device_t added_devices[BTIF_HH_MAX_ADDED_DEV];
  btif_hh_device_t* p_curr_dev;
  bool service_dereg_active;
  RawAddress pending_conn_address;
} btif_hh_cb_t;

/*******************************************************************************
+9 −2
Original line number Diff line number Diff line
@@ -544,8 +544,13 @@ bt_status_t btif_hh_virtual_unplug(const RawAddress* bd_addr) {
    BTA_HhSendCtrl(p_dev->dev_handle, BTA_HH_CTRL_VIRTUAL_CABLE_UNPLUG);
    return BT_STATUS_SUCCESS;
  } else {
    BTIF_TRACE_ERROR("%s: Error, device %s not opened.", __func__,
                     bd_addr->ToString().c_str());
    BTIF_TRACE_ERROR("%s: Error, device %s not opened, status = %d", __func__,
                     bd_addr->ToString().c_str(), btif_hh_cb.status);
    if ((btif_hh_cb.pending_conn_address == *bd_addr) &&
       (btif_hh_cb.status == BTIF_HH_DEV_CONNECTING)) {
          btif_hh_cb.status = (BTIF_HH_STATUS)BTIF_HH_DEV_DISCONNECTED;
          btif_hh_cb.pending_conn_address = RawAddress::kEmpty;
    }
    return BT_STATUS_FAIL;
  }
}
@@ -600,6 +605,7 @@ bt_status_t btif_hh_connect(const RawAddress* bd_addr) {
   pagescan mode, we will do 2 retries to connect before giving up */
  tBTA_SEC sec_mask = BTUI_HH_SECURITY;
  btif_hh_cb.status = BTIF_HH_DEV_CONNECTING;
  btif_hh_cb.pending_conn_address = *bd_addr;
  BTA_HhOpen(*bd_addr, BTA_HH_PROTO_RPT_MODE, sec_mask);

  // TODO(jpawlowski); make cback accept const and remove tmp!
@@ -747,6 +753,7 @@ static void btif_hh_upstreams_evt(uint16_t event, char* p_param) {
    case BTA_HH_OPEN_EVT:
      BTIF_TRACE_WARNING("%s: BTA_HH_OPN_EVT: handle=%d, status =%d", __func__,
                         p_data->conn.handle, p_data->conn.status);
      btif_hh_cb.pending_conn_address = RawAddress::kEmpty;
      if (p_data->conn.status == BTA_HH_OK) {
        p_dev = btif_hh_find_connected_dev_by_handle(p_data->conn.handle);
        if (p_dev == NULL) {