#include "bt_common.h"
#include "bt_types.h"
+#include "log/log.h"
#include "l2cdefs.h"
#include "l2c_api.h"
#include "osi/include/osi.h"
+
+extern fixed_queue_t *btu_general_alarm_queue;
+
static UINT8 find_conn_by_cid (UINT16 cid);
static void hidh_conn_retry (UINT8 dhandle);
psm, l2cap_cid);
}
+void hidh_process_repage_timer_timeout(void *data)
+{
+ uint8_t dhandle = PTR_TO_UINT(data);
+ hidh_try_repage(dhandle);
+}
+
/*******************************************************************************
**
-** Function hidh_proc_repage_timeout
+** Function hidh_try_repage
**
-** Description This function handles timeout (to page device).
+** Description This function processes timeout (to page device).
**
** Returns void
**
*******************************************************************************/
-void hidh_proc_repage_timeout(timer_entry_t *p_te)
+void hidh_try_repage(UINT8 dhandle)
{
tHID_HOST_DEV_CTB *device;
- UINT8 dhandle = PTR_TO_UINT(p_te->param);
hidh_conn_initiate(dhandle);
(hh_cb.devices[dhandle].attr_mask & HID_NORMALLY_CONNECTABLE))
{
hh_cb.devices[dhandle].conn_tries = 0;
- hh_cb.devices[dhandle].conn.timer_entry.param = UINT_TO_PTR(dhandle);
- btu_start_timer (&(hh_cb.devices[dhandle].conn.timer_entry), BTU_TTYPE_HID_HOST_REPAGE_TO, HID_HOST_REPAGE_WIN);
+ period_ms_t interval_ms = HID_HOST_REPAGE_WIN * 1000;
+ alarm_set_on_queue(hh_cb.devices[dhandle].conn.process_repage_timer,
+ interval_ms, hidh_process_repage_timer_timeout,
+ UINT_TO_PTR(dhandle), btu_general_alarm_queue);
hh_cb.callback( dhandle, hh_cb.devices[dhandle].addr, HID_HDEV_EVT_CLOSE, disc_res, NULL);
}
else
if (p_hcon == NULL)
{
HIDH_TRACE_WARNING ("HID-Host Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid);
- osi_freebuf (p_msg);
+ osi_free(p_msg);
return;
}
+ if (p_msg->len < 1)
+ {
+ HIDH_TRACE_WARNING ("HID-Host Rcvd L2CAP data, invalid length");
+ osi_free(p_msg);
+ android_errorWriteLog(0x534e4554, "80493272");
+ return;
+ }
ttype = HID_GET_TRANS_FROM_HDR(*p_data);
param = HID_GET_PARAM_FROM_HDR(*p_data);
{
case HID_TRANS_HANDSHAKE:
hh_cb.callback(dhandle, hh_cb.devices[dhandle].addr, HID_HDEV_EVT_HANDSHAKE, param, NULL);
- osi_freebuf (p_msg);
+ osi_free(p_msg);
break;
case HID_TRANS_CONTROL:
default:
break;
}
- osi_freebuf (p_msg);
+ osi_free(p_msg);
break;
break;
default:
- osi_freebuf (p_msg);
+ osi_free(p_msg);
break;
}
-
}
/*******************************************************************************
if (!BTM_IsAclConnectionUp(hh_cb.devices[dhandle].addr, BT_TRANSPORT_BR_EDR))
{
- if (buf)
- osi_freebuf ((void *)buf);
- return( HID_ERR_NO_CONNECTION );
+ osi_free(buf);
+ return HID_ERR_NO_CONNECTION;
}
if (p_hcon->conn_flags & HID_CONN_FLAGS_CONGESTED)
{
- if (buf)
- osi_freebuf ((void *)buf);
- return( HID_ERR_CONGESTED );
+ osi_free(buf);
+ return HID_ERR_CONGESTED;
}
switch( trans_type )
{
if ( buf == NULL || blank_datc )
{
- p_buf = (BT_HDR *)osi_getbuf(buf_size);
- if (p_buf == NULL)
- return (HID_ERR_NO_RESOURCES);
+ p_buf = (BT_HDR *)osi_malloc(buf_size);
p_buf->offset = L2CAP_MIN_OFFSET;
seg_req = FALSE;
}
else if ( (buf->len > (p_hcon->rem_mtu_size - 1)))
{
- p_buf = (BT_HDR *)osi_getbuf(buf_size);
- if (p_buf == NULL)
- return (HID_ERR_NO_RESOURCES);
+ p_buf = (BT_HDR *)osi_malloc(buf_size);
p_buf->offset = L2CAP_MIN_OFFSET;
seg_req = TRUE;
tHID_HOST_DEV_CTB *p_dev = &hh_cb.devices[dhandle];
p_dev->conn.conn_state = HID_CONN_STATE_UNUSED;
- p_dev->conn.timer_entry.param = UINT_TO_PTR(dhandle);
#if (HID_HOST_REPAGE_WIN > 0)
- btu_start_timer (&(p_dev->conn.timer_entry), BTU_TTYPE_HID_HOST_REPAGE_TO, HID_HOST_REPAGE_WIN);
+ period_ms_t interval_ms = HID_HOST_REPAGE_WIN * 1000;
+ alarm_set_on_queue(p_dev->conn.process_repage_timer,
+ interval_ms, hidh_process_repage_timer_timeout,
+ UINT_TO_PTR(dhandle), btu_general_alarm_queue);
#else
- hidh_proc_repage_timeout( &(p_dev->conn.timer_entry) );
+ hidh_process_repage_process(dhandle);
#endif
}