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

Commit 982eaede authored by Ganesh Ganapathi Batta's avatar Ganesh Ganapathi Batta Committed by Matthew Xie
Browse files

Removed COD check for unbond and UNPAIRED_EVT

PC supporting HID Device would not have Peripheral as
its MAJOR COD. So COD check for major peripheral device was removed
in case of UNBOND and while receiving UNPAIRED_EVT. Additonal checking
is done when virtual unplug evt is received to remove bonding only for
HID Devic with MAJOR COD as Peripheral or if its a locally initiated
VUP.

Change-Id: I5343919463e48babc9cd03e05ff92a3f93f6d26d
parent b4c0c5a4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -277,6 +277,7 @@ void bta_hh_co_open(UINT8 dev_handle, UINT8 sub_class, tBTA_HH_ATTR_MASK attr_ma
                p_dev->attr_mask  = attr_mask;
                p_dev->sub_class  = sub_class;
                p_dev->app_id     = app_id;
                p_dev->local_vup  = FALSE;

                btif_hh_cb.device_num++;
                // This is a new device,open the uhid driver now.
+1 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ typedef struct
    UINT8                         hh_keep_polling;
    BOOLEAN                       vup_timer_active;
    TIMER_LIST_ENT                vup_timer;
    BOOLEAN                       local_vup; // Indicated locally initiated VUP
} btif_hh_device_t;

/* Control block to maintain properties of devices */
+7 −30
Original line number Diff line number Diff line
@@ -443,16 +443,6 @@ static void btif_dm_cb_hid_remote_name(tBTM_REMOTE_DEV_NAME *p_remote_name)
    }
}

int remove_hid_bond(bt_bdaddr_t *bd_addr)
{
    /* For HID device, inorder to avoid the HID device from re-connecting again after unpairing,
         * we need to do virtual unplug
         */
    bdstr_t bdstr;
    BTIF_TRACE_DEBUG2("%s---Removing HID bond--%s", __FUNCTION__,bd2str((bt_bdaddr_t *)bd_addr, &bdstr));
    return btif_hh_virtual_unplug(bd_addr);

}
/*******************************************************************************
**
** Function         btif_dm_cb_create_bond
@@ -512,23 +502,13 @@ void btif_dm_cb_remove_bond(bt_bdaddr_t *bd_addr)
{
     bdstr_t bdstr;
     /*special handling for HID devices */
     if (check_cod_hid(bd_addr, COD_HID_MAJOR))
    {
     /*  VUP needs to be sent if its a HID Device. The HID HOST module will check if there
     is a valid hid connection with this bd_addr. If yes VUP will be issued.*/
#if (defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE))
        if(remove_hid_bond(bd_addr) != BTA_SUCCESS)
            BTA_DmRemoveDevice((UINT8 *)bd_addr->address);
    if (btif_hh_virtual_unplug(bd_addr) != BT_STATUS_SUCCESS)
#endif
    }
    else
    {
        if (BTA_DmRemoveDevice((UINT8 *)bd_addr->address) == BTA_SUCCESS)
    {
            BTIF_TRACE_DEBUG1("Successfully removed bonding with device: %s",
                                            bd2str((bt_bdaddr_t *)bd_addr, &bdstr));
        }
        else
            BTIF_TRACE_DEBUG1("Removed bonding with device failed: %s",
                                            bd2str((bt_bdaddr_t *)bd_addr, &bdstr));
         BTA_DmRemoveDevice((UINT8 *)bd_addr->address);
    }
}

@@ -1297,10 +1277,7 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param)

            /*special handling for HID devices */
            #if (defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE))
            if (check_cod_hid(&bd_addr, COD_HID_MAJOR))
            {
            btif_hh_remove_device(bd_addr);
            }
            #endif
            btif_storage_remove_bonded_device(&bd_addr);
            bond_state_changed(BT_STATUS_SUCCESS, &bd_addr, BT_BOND_STATE_NONE);
+15 −4
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@
#define COD_HID_KEYBOARD        0x0540
#define COD_HID_POINTING        0x0580
#define COD_HID_COMBO           0x05C0
#define COD_HID_MAJOR           0x0500

#define KEYSTATE_FILEPATH "/data/misc/bluedroid/bt_hh_ks" //keep this in sync with HID host jni

@@ -156,6 +157,7 @@ extern void bta_hh_co_send_hid_info(btif_hh_device_t *p_dev, char *dev_name, UIN
                                    int dscp_len, UINT8 *p_dscp);
extern BOOLEAN check_cod(const bt_bdaddr_t *remote_bdaddr, uint32_t cod);
extern void btif_dm_cb_remove_bond(bt_bdaddr_t *bd_addr);
extern BOOLEAN check_cod_hid(const bt_bdaddr_t *remote_bdaddr, uint32_t cod);
extern int  scru_ascii_2_hex(char *p_ascii, int len, UINT8 *p_hex);

/*****************************************************************************
@@ -602,6 +604,7 @@ bt_status_t btif_hh_virtual_unplug(bt_bdaddr_t *bd_addr)
        BTIF_TRACE_DEBUG1("%s Sending BTA_HH_CTRL_VIRTUAL_CABLE_UNPLUG", __FUNCTION__);
        /* start the timer */
        btif_hh_start_vup_timer(bd_addr);
        p_dev->local_vup = TRUE;
        BTA_HhSendCtrl(p_dev->dev_handle, BTA_HH_CTRL_VIRTUAL_CABLE_UNPLUG);
        return BT_STATUS_SUCCESS;
    }
@@ -1044,7 +1047,15 @@ static void btif_hh_upstreams_evt(UINT16 event, char* p_param)
                    BTIF_TRACE_DEBUG1("%s---Sending connection state change", __FUNCTION__);
                    HAL_CBACK(bt_hh_callbacks, connection_state_cb,&(p_dev->bd_addr), p_dev->dev_status);
                    BTIF_TRACE_DEBUG1("%s---Removing HID bond", __FUNCTION__);
                    /* 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), COD_HID_MAJOR))
                    {
                        p_dev->local_vup = FALSE;
                        BTA_DmRemoveDevice((UINT8 *)p_dev->bd_addr.address);
                    }
                    else
                        btif_hh_remove_device(p_dev->bd_addr);
                    HAL_CBACK(bt_hh_callbacks, virtual_unplug_cb,&(p_dev->bd_addr),
                                    p_data->dev_status.status);
                }