Upgrade bluez5_37 :Merge the code from private
[platform/upstream/bluez.git] / android / tester-main.c
old mode 100644 (file)
new mode 100755 (executable)
index 2506548..3a55792
@@ -329,7 +329,7 @@ static void mgmt_debug(const char *str, void *user_data)
 static bool hciemu_post_encr_hook(const void *data, uint16_t len,
                                                        void *user_data)
 {
-       struct step *step = g_new0(struct step, 1);
+       struct step *step;
 
        /*
         * Expected data: status (1 octet) + conn. handle (2 octets) +
@@ -338,6 +338,8 @@ static bool hciemu_post_encr_hook(const void *data, uint16_t len,
        if (len < 4)
                return true;
 
+       step = g_new0(struct step, 1);
+
        step->callback = ((uint8_t *)data)[3] ? CB_EMU_ENCRYPTION_ENABLED :
                                                CB_EMU_ENCRYPTION_DISABLED;
 
@@ -2719,8 +2721,17 @@ void emu_setup_powered_remote_action(void)
        bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
 
        if ((data->hciemu_type == HCIEMU_TYPE_LE) ||
-                               (data->hciemu_type == HCIEMU_TYPE_BREDRLE))
-               bthost_set_adv_enable(bthost, 0x01, 0x02);
+                               (data->hciemu_type == HCIEMU_TYPE_BREDRLE)) {
+               uint8_t adv[4];
+
+               adv[0] = 0x02;  /* Field length */
+               adv[1] = 0x01;  /* Flags */
+               adv[2] = 0x02;  /* Flags value */
+               adv[3] = 0x00;  /* Field terminator */
+
+               bthost_set_adv_data(bthost, adv, sizeof(adv));
+               bthost_set_adv_enable(bthost, 0x01);
+       }
 
        if (data->hciemu_type != HCIEMU_TYPE_LE)
                bthost_write_scan_enable(bthost, 0x03);
@@ -2952,13 +2963,15 @@ void emu_add_rfcomm_server_action(void)
        struct step *current_data_step = queue_peek_head(data->steps);
        struct bt_action_data *rfcomm_data = current_data_step->set_data;
        struct bthost *bthost;
-       struct step *step = g_new0(struct step, 1);
+       struct step *step;
 
        if (!rfcomm_data) {
                tester_warn("Invalid l2cap_data params");
                return;
        }
 
+       step = g_new0(struct step, 1);
+
        bthost = hciemu_client_get_host(data->hciemu);
 
        bthost_add_rfcomm_server(bthost, rfcomm_data->channel,
@@ -3001,7 +3014,7 @@ void bluetooth_disable_action(void)
 void bt_set_property_action(void)
 {
        struct test_data *data = tester_get_data();
-       struct step *step = g_new0(struct step, 1);
+       struct step *step;
        struct step *current_data_step = queue_peek_head(data->steps);
        bt_property_t *prop;
 
@@ -3011,6 +3024,8 @@ void bt_set_property_action(void)
                return;
        }
 
+       step = g_new0(struct step, 1);
+
        prop = (bt_property_t *)current_data_step->set_data;
 
        step->action_status = data->if_bluetooth->set_adapter_property(prop);
@@ -3021,7 +3036,7 @@ void bt_set_property_action(void)
 void bt_get_property_action(void)
 {
        struct test_data *data = tester_get_data();
-       struct step *step = g_new0(struct step, 1);
+       struct step *step;
        struct step *current_data_step = queue_peek_head(data->steps);
        bt_property_t *prop;
 
@@ -3031,6 +3046,8 @@ void bt_get_property_action(void)
                return;
        }
 
+       step = g_new0(struct step, 1);
+
        prop = (bt_property_t *)current_data_step->set_data;
 
        step->action_status = data->if_bluetooth->get_adapter_property(
@@ -3063,7 +3080,7 @@ void bt_get_device_props_action(void)
 {
        struct test_data *data = tester_get_data();
        struct step *current_data_step = queue_peek_head(data->steps);
-       struct step *step = g_new0(struct step, 1);
+       struct step *step;
 
        if (!current_data_step->set_data) {
                tester_debug("bdaddr not defined");
@@ -3071,6 +3088,8 @@ void bt_get_device_props_action(void)
                return;
        }
 
+       step = g_new0(struct step, 1);
+
        step->action_status =
                data->if_bluetooth->get_remote_device_properties(
                                                current_data_step->set_data);
@@ -3083,7 +3102,7 @@ void bt_get_device_prop_action(void)
        struct test_data *data = tester_get_data();
        struct step *current_data_step = queue_peek_head(data->steps);
        struct bt_action_data *action_data = current_data_step->set_data;
-       struct step *step = g_new0(struct step, 1);
+       struct step *step;
 
        if (!action_data) {
                tester_warn("No arguments for 'get remote device prop' req.");
@@ -3091,6 +3110,8 @@ void bt_get_device_prop_action(void)
                return;
        }
 
+       step = g_new0(struct step, 1);
+
        step->action_status = data->if_bluetooth->get_remote_device_property(
                                                        action_data->addr,
                                                        action_data->prop_type);
@@ -3103,7 +3124,7 @@ void bt_set_device_prop_action(void)
        struct test_data *data = tester_get_data();
        struct step *current_data_step = queue_peek_head(data->steps);
        struct bt_action_data *action_data = current_data_step->set_data;
-       struct step *step = g_new0(struct step, 1);
+       struct step *step;
 
        if (!action_data) {
                tester_warn("No arguments for 'set remote device prop' req.");
@@ -3111,6 +3132,8 @@ void bt_set_device_prop_action(void)
                return;
        }
 
+       step = g_new0(struct step, 1);
+
        step->action_status = data->if_bluetooth->set_remote_device_property(
                                                        action_data->addr,
                                                        action_data->prop);
@@ -3123,7 +3146,7 @@ void bt_create_bond_action(void)
        struct test_data *data = tester_get_data();
        struct step *current_data_step = queue_peek_head(data->steps);
        struct bt_action_data *action_data = current_data_step->set_data;
-       struct step *step = g_new0(struct step, 1);
+       struct step *step;
 
        if (!action_data || !action_data->addr) {
                tester_warn("Bad arguments for 'create bond' req.");
@@ -3131,6 +3154,8 @@ void bt_create_bond_action(void)
                return;
        }
 
+       step = g_new0(struct step, 1);
+
        step->action_status =
                        data->if_bluetooth->create_bond(action_data->addr,
                                                action_data->transport_type ?
@@ -3145,7 +3170,7 @@ void bt_pin_reply_accept_action(void)
        struct test_data *data = tester_get_data();
        struct step *current_data_step = queue_peek_head(data->steps);
        struct bt_action_data *action_data = current_data_step->set_data;
-       struct step *step = g_new0(struct step, 1);
+       struct step *step;
 
        if (!action_data || !action_data->addr || !action_data->pin) {
                tester_warn("Bad arguments for 'pin reply' req.");
@@ -3153,6 +3178,8 @@ void bt_pin_reply_accept_action(void)
                return;
        }
 
+       step = g_new0(struct step, 1);
+
        step->action_status = data->if_bluetooth->pin_reply(action_data->addr,
                                                        TRUE,
                                                        action_data->pin_len,