Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-bluetooth-bluez: Commit

external/bluetooth/bluez


Commit MetaInfo

Revision3be654144dfb099c42eee3af53c9f0c42bd17c9c (tree)
Time2015-12-10 16:42:42
AuthorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

android: fix building errors on Android 6.0

Change libhal to match the new HAL headers.

Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>

Change Summary

Incremental Difference

--- a/android/client/if-gatt.c
+++ b/android/client/if-gatt.c
@@ -783,6 +783,18 @@ static void gattc_batchscan_threshold_cb(int client_if)
783783 }
784784
785785 /* Track ADV VSE callback invoked when tracked device is found or lost */
786+#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0)
787+static void gattc_track_adv_event_cb(btgatt_track_adv_info_t *p_track_adv_info)
788+{
789+ char buf[MAX_ADDR_STR_LEN];
790+
791+ haltest_info("%s, client_if=%d, filt_index=%d, addr_type=%d, bda=%s"
792+ ", adv_state=%d", __func__, p_track_adv_info->client_if,
793+ p_track_adv_info->filt_index, p_track_adv_info->addr_type,
794+ bt_bdaddr_t2str(&p_track_adv_info->bd_addr, buf),
795+ p_track_adv_info->advertiser_state);
796+}
797+#else
786798 static void gattc_track_adv_event_cb(int client_if, int filt_index,
787799 int addr_type, bt_bdaddr_t* bda,
788800 int adv_state)
@@ -794,6 +806,7 @@ static void gattc_track_adv_event_cb(int client_if, int filt_index,
794806 addr_type, bt_bdaddr_t2str(bda, buf), adv_state);
795807 }
796808 #endif
809+#endif
797810
798811 static const btgatt_client_callbacks_t btgatt_client_callbacks = {
799812 .register_client_cb = gattc_register_client_cb,
@@ -1677,6 +1690,25 @@ static void scan_filter_param_setup_c(int argc, const char **argv,
16771690
16781691 static void scan_filter_param_setup_p(int argc, const char **argv)
16791692 {
1693+#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0)
1694+ btgatt_filt_param_setup_t filt_param;
1695+
1696+ RETURN_IF_NULL(if_gatt);
1697+ VERIFY_CLIENT_IF(2, filt_param.client_if);
1698+ VERIFY_ACTION(3, filt_param.action);
1699+ VERIFY_FILT_INDEX(4, filt_param.filt_index);
1700+ VERIFY_FEAT_SELN(5, filt_param.feat_seln);
1701+ VERIFY_LIST_LOGIC_TYPE(6, filt_param.list_logic_type);
1702+ VERIFY_FILT_LOGIC_TYPE(7, filt_param.filt_logic_type);
1703+ VERIFY_RSSI_HI_THR(8, filt_param.rssi_high_thres);
1704+ VERIFY_RSSI_LOW_THR(9, filt_param.rssi_low_thres);
1705+ VERIFY_DELY_MODE(10, filt_param.dely_mode);
1706+ VERIFY_FND_TIME(11, filt_param.found_timeout);
1707+ VERIFY_LOST_TIME(12, filt_param.lost_timeout);
1708+ VERIFY_FND_TIME_CNT(13, filt_param.found_timeout_cnt);
1709+
1710+ EXEC(if_gatt->client->scan_filter_param_setup, filt_param);
1711+#else
16801712 int client_if;
16811713 int action;
16821714 int filt_index;
@@ -1704,6 +1736,7 @@ static void scan_filter_param_setup_p(int argc, const char **argv)
17041736 filt_index, feat_seln, list_logic_type, filt_logic_type,
17051737 rssi_high_thres, rssi_low_thres, dely_mode, found_timeout,
17061738 lost_timeout, found_timeout_cnt);
1739+#endif
17071740 }
17081741
17091742 /* scan filter add remove */
@@ -1916,6 +1949,18 @@ static void conn_parameter_update_p(int argc, const char **argv)
19161949 /* set scan parameters */
19171950 static void set_scan_parameters_p(int argc, const char **argv)
19181951 {
1952+#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0)
1953+ int client_if;
1954+ int scan_interval;
1955+ int scan_window;
1956+
1957+ RETURN_IF_NULL(if_gatt);
1958+ VERIFY_CLIENT_IF(2, client_if);
1959+ VERIFY_SCAN_INTERVAL(3, scan_interval);
1960+ VERIFY_SCAN_WINDOW(4, scan_window);
1961+
1962+ EXEC(if_gatt->client->set_scan_parameters, client_if, scan_interval, scan_window);
1963+#else
19191964 int scan_interval;
19201965 int scan_window;
19211966
@@ -1924,6 +1969,7 @@ static void set_scan_parameters_p(int argc, const char **argv)
19241969 VERIFY_SCAN_WINDOW(3, scan_window);
19251970
19261971 EXEC(if_gatt->client->set_scan_parameters, scan_interval, scan_window);
1972+#endif
19271973 }
19281974
19291975 /* enable multi advertising */
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -249,7 +249,11 @@ static void handle_pin_request(void *buf, uint16_t len, int fd)
249249 DBG("");
250250
251251 if (bt_hal_cbacks->pin_request_cb)
252+#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0)
253+ bt_hal_cbacks->pin_request_cb(addr, name, ev->class_of_dev, false);
254+#else
252255 bt_hal_cbacks->pin_request_cb(addr, name, ev->class_of_dev);
256+#endif
253257 }
254258
255259 static void handle_ssp_request(void *buf, uint16_t len, int fd)
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -610,9 +610,21 @@ static void handle_batchscan_threshold(void *buf, uint16_t len, int fd)
610610
611611 static void handle_track_adv(void *buf, uint16_t len, int fd)
612612 {
613-#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
614613 struct hal_ev_gatt_client_track_adv *ev = buf;
615614
615+#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0)
616+ if (cbs->client->track_adv_event_cb) {
617+ btgatt_track_adv_info_t info_t = {
618+ .client_if = ev->client_if,
619+ .filt_index = ev->filetr_index,
620+ .advertiser_state = ev->state,
621+ .addr_type = ev->address_type,
622+ .bd_addr = *(bt_bdaddr_t *) ev->address,
623+ };
624+
625+ cbs->client->track_adv_event_cb(&info_t);
626+ }
627+#elif ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
616628 if (cbs->client->track_adv_event_cb)
617629 cbs->client->track_adv_event_cb(ev->client_if, ev->filetr_index,
618630 ev->address_type,
@@ -1341,6 +1353,20 @@ static bt_status_t test_command(int command, btgatt_test_params_t *params)
13411353 }
13421354
13431355 #if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
1356+#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0)
1357+static bt_status_t scan_filter_param_setup(btgatt_filt_param_setup_t filt_param)
1358+{
1359+ struct hal_cmd_gatt_client_scan_filter_setup *cmd;
1360+
1361+ if (!interface_ready())
1362+ return BT_STATUS_NOT_READY;
1363+
1364+ cmd = (struct hal_cmd_gatt_client_scan_filter_setup *)&filt_param;
1365+ return hal_ipc_cmd(HAL_SERVICE_ID_GATT,
1366+ HAL_OP_GATT_CLIENT_SCAN_FILTER_SETUP,
1367+ sizeof(*cmd), cmd, NULL, NULL, NULL);
1368+}
1369+#else
13441370 static bt_status_t scan_filter_param_setup(int client_if, int action,
13451371 int filt_index, int feat_seln,
13461372 int list_logic_type,
@@ -1374,6 +1400,7 @@ static bt_status_t scan_filter_param_setup(int client_if, int action,
13741400 HAL_OP_GATT_CLIENT_SCAN_FILTER_SETUP,
13751401 sizeof(cmd), &cmd, NULL, NULL, NULL);
13761402 }
1403+#endif
13771404
13781405 static bt_status_t scan_filter_add_remove(int client_if, int action,
13791406 int filt_type, int filt_index,
@@ -1491,7 +1518,12 @@ static bt_status_t conn_parameter_update(const bt_bdaddr_t *bd_addr,
14911518 sizeof(cmd), &cmd, NULL, NULL, NULL);
14921519 }
14931520
1521+#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0)
1522+static bt_status_t set_scan_parameters(int client_if, int scan_interval,
1523+ int scan_window)
1524+#else
14941525 static bt_status_t set_scan_parameters(int scan_interval, int scan_window)
1526+#endif
14951527 {
14961528 struct hal_cmd_gatt_client_set_scan_param cmd;
14971529
--- a/android/hal-utils.c
+++ b/android/hal-utils.c
@@ -314,8 +314,12 @@ static void local_le_feat2string(char *str, const bt_local_le_features_t *f)
314314 str += sprintf(str, "Num of offloaded scan filters: %u,\n",
315315 f->max_adv_filter_supported);
316316
317+#if ANDROID_VERSION >= PLATFORM_VER(6, 0, 0)
318+ scan_num = f->scan_result_storage_size;
319+#else
317320 scan_num = (f->scan_result_storage_size_hibyte << 8) +
318321 f->scan_result_storage_size_lobyte;
322+#endif
319323
320324 str += sprintf(str, "Num of offloaded scan results: %u,\n", scan_num);
321325
Show on old repository browser