From 8f2db260d176db717c1410e9893fb1deaa7f37e7 Mon Sep 17 00:00:00 2001 From: Hemant Gupta <hemantg@codeaurora.org> Date: Tue, 19 Sep 2017 15:30:56 +0530 Subject: [PATCH] HID: Remove device from database in error case Usecase: 1) Pair and connect with remote hid device. 2) Disconnect with remote hid device. 3) Unpair DUT from remote hid device. 4) Send connect request from hid device by pressing any button. 5) Try to pair and connect DUT with remote hid device. Expected Result 1) Connection should fail after step 4 if remote device does not initaite pairing. 2) Connection should succeed with remote device and hid device should be added to paired list and hid operations should work properly. Observed Result HID operations from remote device starts working without device added to paired list and UI stucked at pairing. Root Cause: After step 4, device should be removed from database when incoming connection is rejected. Fix: Perform virtual unplug for device when connection request for hid is received from unpaired device. Test: Issue is not reproducible after stress testing with above change Bug: 68176469 Change-Id: I9bc72ccc7a849c0d6acf3230a75e1fe95949b3fe --- system/btif/src/btif_hh.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/system/btif/src/btif_hh.cc b/system/btif/src/btif_hh.cc index b2c1c6f3ff7..650923a3cb5 100644 --- a/system/btif/src/btif_hh.cc +++ b/system/btif/src/btif_hh.cc @@ -543,6 +543,14 @@ bt_status_t btif_hh_virtual_unplug(const RawAddress* bd_addr) { p_dev->local_vup = true; BTA_HhSendCtrl(p_dev->dev_handle, BTA_HH_CTRL_VIRTUAL_CABLE_UNPLUG); return BT_STATUS_SUCCESS; + } else if ((p_dev != NULL) && + (p_dev->dev_status == BTHH_CONN_STATE_CONNECTED)) { + BTIF_TRACE_ERROR("%s: Virtual unplug not suported, disconnecting device"); + /* start the timer */ + btif_hh_start_vup_timer(bd_addr); + p_dev->local_vup = true; + BTA_HhClose(p_dev->dev_handle); + return BT_STATUS_SUCCESS; } else { BTIF_TRACE_ERROR("%s: Error, device %s not opened, status = %d", __func__, bd_addr->ToString().c_str(), btif_hh_cb.status); -- GitLab