android/tester: Add AVRCP init - Success test case
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH v2 1/5 android/tester: Add AVRCP init - Success test case
From: Luiz Augusto von Dentz <[email protected]>
--- android/Makefile.am | 1 + android/tester-avrcp.c | 50 +++++++++++++++++++++++++++++++++++ android/tester-main.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ android/tester-main.h | 4 +++ 4 files changed, 127 insertions(+) create mode 100644 android/tester-avrcp.c
android/Makefile.am +1 -0
@@ -171,6 +171,7 @@ android_android_tester_SOURCES = emulator/btdev.h emulator/btdev.c \ android/tester-pan.c \ android/tester-hdp.c \ android/tester-a2dp.c \ + android/tester-avrcp.c \ android/tester-gatt.c \ android/tester-main.h android/tester-main.c
android/tester-avrcp.c new file +50 -0
50 lines not on this page · raw message
android/tester-main.c +72 -0
108 lines not on this page · raw message
android/tester-main.h +4 -0
@@ -50,6 +50,7 @@#include <hardware/bt_pan.h> #include <hardware/bt_hl.h> #include <hardware/bt_av.h> +#include <hardware/bt_rc.h> #include <hardware/bt_gatt.h> #include <hardware/bt_gatt_client.h> #include <hardware/bt_gatt_server.h>
@@ -321,6 +322,7 @@ struct test_data {const bthl_interface_t *if_hdp;const btav_interface_t *if_a2dp;struct audio_stream_out *if_stream; +const btrc_interface_t *if_avrcp;const btgatt_interface_t *if_gatt;const void *test_data;
@@ -443,6 +445,8 @@ struct queue *get_hdp_tests(void);void remove_hdp_tests (void );struct queue *get_a2dp_tests (void );void remove_a2dp_tests (void ); +struct queue *get_avrcp_tests (void ); +void remove_avrcp_tests (void );struct queue *get_gatt_tests (void );void remove_gatt_tests (void );
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v2 2/5 android/tester: Add AVRCP Connect - Success test case
From: Luiz Augusto von Dentz <[email protected]>
--- android/tester-avrcp.c | 209 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+)
android/tester-avrcp.c +209 -0
@@ -25,10 +25,219 @@static struct queue *list; +struct emu_cid_data { +uint16_t handle; +uint16_t cid; +}; + +static struct emu_cid_data sdp_data; +static struct emu_cid_data a2dp_data; +static struct emu_cid_data avrcp_data; + +static const uint8_t sdp_rsp_pdu[] = {0x07 ,/* PDU id */ +0x00 ,0x00 ,/* Transaction id */ +0x00 ,0x7f ,/* Response length */ +0x00 ,0x7c ,/* Attributes length */ +0x36 ,0x00 ,0x79 ,0x36 ,0x00 ,0x3b ,0x09 ,0x00 ,0x00 , +0x0a ,0x00 ,0x01 ,0x00 ,0x04 ,0x09 ,0x00 ,0x01 ,0x35 , +0x06 ,0x19 ,0x11 ,0x0e ,0x19 ,0x11 ,0x0f ,0x09 ,0x00 , +0x04 ,0x35 ,0x10 ,0x35 ,0x06 ,0x19 ,0x01 ,0x00 ,0x09 , +0x00 ,0x17 ,0x35 ,0x06 ,0x19 ,0x00 ,0x17 ,0x09 ,0x01 , +0x03 ,0x09 ,0x00 ,0x09 ,0x35 ,0x08 ,0x35 ,0x06 ,0x19 , +0x11 ,0x0e ,0x09 ,0x01 ,0x00 ,0x09 ,0x03 ,0x11 ,0x09 , +0x00 ,0x01 ,0x36 ,0x00 ,0x38 ,0x09 ,0x00 ,0x00 ,0x0a , +0x00 ,0x01 ,0x00 ,0x05 ,0x09 ,0x00 ,0x01 ,0x35 ,0x03 , +0x19 ,0x11 ,0x0c ,0x09 ,0x00 ,0x04 ,0x35 ,0x10 ,0x35 , +0x06 ,0x19 ,0x01 ,0x00 ,0x09 ,0x00 ,0x17 ,0x35 ,0x06 , +0x19 ,0x00 ,0x17 ,0x09 ,0x01 ,0x03 ,0x09 ,0x00 ,0x09 , +0x35 ,0x08 ,0x35 ,0x06 ,0x19 ,0x11 ,0x0e ,0x09 ,0x01 , +0x04 ,0x09 ,0x03 ,0x11 ,0x09 ,0x00 ,0x02 , +0x00 };/* no continuation */ +static const uint8_t req_dsc[] = {0x00 ,0x01 }; +static const uint8_t rsp_dsc[] = {0x02 ,0x01 ,0x04 ,0x08 }; +static const uint8_t req_get[] = {0x10 ,0x02 ,0x04 }; +static const uint8_t rsp_get[] = {0x12 ,0x02 ,0x01 ,0x00 ,0x07 ,0x06 ,0x00 , +0x00 ,0xff ,0xff ,0x02 ,0x40 }; +static const uint8_t req_cfg[] = {0x20 ,0x03 ,0x04 ,0x04 ,0x01 ,0x00 ,0x07 , +0x06 ,0x00 ,0x00 ,0x21 ,0x15 ,0x02 , +0x40 }; +static const uint8_t rsp_cfg[] = {0x22 ,0x03 }; +static const uint8_t req_open[] = {0x30 ,0x06 ,0x04 }; +static const uint8_t rsp_open[] = {0x32 ,0x06 }; +static const uint8_t req_close[] = {0x40 ,0x08 ,0x04 }; +static const uint8_t rsp_close[] = {0x42 ,0x08 }; +static const uint8_t req_start[] = {0x40 ,0x07 ,0x04 }; +static const uint8_t rsp_start[] = {0x42 ,0x07 }; +static const uint8_t req_suspend[] = {0x50 ,0x09 ,0x04 }; +static const uint8_t rsp_suspend[] = {0x52 ,0x09 }; + +static const struct pdu { +const uint8_t *req; +size_t req_len; +const uint8_t *rsp; +size_t rsp_len; +} pdus[] = { + { req_dsc,sizeof (req_dsc), rsp_dsc,sizeof (rsp_dsc) }, + { req_get,sizeof (req_get), rsp_get,sizeof (rsp_get) }, + { req_cfg,sizeof (req_cfg), rsp_cfg,sizeof (rsp_cfg) }, + { req_open,sizeof (req_open), rsp_open,sizeof (rsp_open) }, + { req_close,sizeof (req_close), rsp_close,sizeof (rsp_close) }, + { req_start,sizeof (req_start), rsp_start,sizeof (rsp_start) }, + { req_suspend,sizeof (req_suspend), rsp_suspend,sizeof (rsp_start) }, + { }, +}; + +static void print_avrcp (const char *str,void *user_data) +{ +tester_debug ("avrcp: %s" , str); +} + +static void avrcp_cid_hook_cb (const void *data,uint16_t len,void *user_data) +{ +util_hexdump ('>' , data, len, print_avrcp,NULL ); +} + +static void avrcp_connect_request_cb (uint16_t handle,uint16_t cid, +void *user_data) +{ +struct test_data *data =tester_get_data (); +struct bthost *bthost =hciemu_client_get_host (data->hciemu); +struct emu_cid_data *cid_data = user_data; + + cid_data->handle = handle; + cid_data->cid = cid; + +bthost_add_cid_hook (bthost, handle, cid, avrcp_cid_hook_cb, cid_data); +} + +static struct emu_set_l2cap_data avrcp_setup_data = { + .psm =23 , + .func = avrcp_connect_request_cb, + .user_data = &avrcp_data, +}; + +static void print_a2dp (const char *str,void *user_data) +{ +tester_debug ("a2dp: %s" , str); +} + +static void a2dp_cid_hook_cb (const void *data,uint16_t len,void *user_data) +{ +struct emu_cid_data *cid_data = user_data; +struct test_data *t_data =tester_get_data (); +struct bthost *bthost =hciemu_client_get_host (t_data->hciemu); +int i; + +util_hexdump ('>' , data, len, print_a2dp,NULL ); + +for (i =0 ; pdus[i].req; i++) { +if (pdus[i].req_len != len) +continue ; + +if (memcmp (pdus[i].req, data, len)) +continue ; + +util_hexdump ('<' , pdus[i].rsp, pdus[i].rsp_len, print_a2dp, +NULL ); + +bthost_send_cid (bthost, cid_data->handle, cid_data->cid, + pdus[i].rsp, pdus[i].rsp_len); + } +} + +static void a2dp_connect_request_cb (uint16_t handle,uint16_t cid, +void *user_data) +{ +struct test_data *data =tester_get_data (); +struct bthost *bthost =hciemu_client_get_host (data->hciemu); +struct emu_cid_data *cid_data = user_data; + +if (cid_data->handle) +return ; + + cid_data->handle = handle; + cid_data->cid = cid; + +bthost_add_cid_hook (bthost, handle, cid, a2dp_cid_hook_cb, cid_data); +} + +static struct emu_set_l2cap_data a2dp_setup_data = { + .psm =25 , + .func = a2dp_connect_request_cb, + .user_data = &a2dp_data, +}; + +static void sdp_cid_hook_cb (const void *data,uint16_t len,void *user_data) +{ +struct test_data *t_data =tester_get_data (); +struct bthost *bthost =hciemu_client_get_host (t_data->hciemu); +struct emu_cid_data *cid_data = user_data; + +bthost_send_cid (bthost, cid_data->handle, cid_data->cid, + sdp_rsp_pdu,sizeof (sdp_rsp_pdu)); +} +static void sdp_connect_request_cb (uint16_t handle,uint16_t cid, +void *user_data) +{ +struct test_data *data =tester_get_data (); +struct bthost *bthost =hciemu_client_get_host (data->hciemu); +struct emu_cid_data *cid_data = user_data; + + cid_data->handle = handle; + cid_data->cid = cid; + +bthost_add_cid_hook (bthost, handle, cid, sdp_cid_hook_cb, cid_data); +} + +static struct emu_set_l2cap_data sdp_setup_data = { + .psm =1 , + .func = sdp_connect_request_cb, + .user_data = &sdp_data, +}; + +static void avrcp_connect_action (void ) +{ +struct test_data *data =tester_get_data (); +const uint8_t *addr =hciemu_get_client_bdaddr (data->hciemu); + struct step *step = g_new0(struct step, 1); +bt_bdaddr_t bdaddr; + + sdp_data.handle =0 ; + sdp_data.cid =0 ; + + a2dp_data.handle =0 ; + a2dp_data.cid =0 ; + + avrcp_data.handle =0 ; + avrcp_data.cid =0 ; + +bdaddr2android ((const bdaddr_t *) addr, &bdaddr); + + step->action_status = data->if_a2dp->connect (&bdaddr); + +schedule_action_verification (step); +} +static struct test_case test_cases[] = {TEST_CASE_BREDRLE ("AVRCP Init" , ACTION_SUCCESS(dummy_action, NULL), ), +TEST_CASE_BREDRLE ("AVRCP Connect - Success" , +ACTION_SUCCESS (bluetooth_enable_action,NULL ), +CALLBACK_STATE (CB_BT_ADAPTER_STATE_CHANGED ,BT_STATE_ON ), +ACTION_SUCCESS (emu_setup_powered_remote_action,NULL ), +ACTION_SUCCESS (emu_set_ssp_mode_action,NULL ), +ACTION_SUCCESS (emu_add_l2cap_server_action, &sdp_setup_data), +ACTION_SUCCESS (emu_add_l2cap_server_action, &a2dp_setup_data), +ACTION_SUCCESS (emu_add_l2cap_server_action, &avrcp_setup_data), +ACTION_SUCCESS (avrcp_connect_action,NULL ), +CALLBACK_AV_CONN_STATE (CB_A2DP_CONN_STATE , +BTAV_CONNECTION_STATE_CONNECTING ), +CALLBACK_AV_CONN_STATE (CB_A2DP_CONN_STATE , +BTAV_CONNECTION_STATE_CONNECTED ), +ACTION_SUCCESS (bluetooth_disable_action,NULL ), + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF), + ), };struct queue *get_avrcp_tests (void )
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v2 3/5 android/tester: Add AVRCP Disconnect - Success test case
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/tester-avrcp.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
android/tester-avrcp.c +35 -0
@@ -218,6 +218,20 @@ static void avrcp_connect_action(void)schedule_action_verification (step); } +static void avrcp_disconnect_action (void ) +{ +struct test_data *data =tester_get_data (); +const uint8_t *addr =hciemu_get_client_bdaddr (data->hciemu); + struct step *step = g_new0(struct step, 1); +bt_bdaddr_t bdaddr; + +bdaddr2android ((const bdaddr_t *) addr, &bdaddr); + + step->action_status = data->if_a2dp->disconnect (&bdaddr); + +schedule_action_verification (step); +} +static struct test_case test_cases[] = { TEST_CASE_BREDRLE("AVRCP Init", ACTION_SUCCESS(dummy_action, NULL),
@@ -238,6 +252,27 @@ static struct test_case test_cases[] = {ACTION_SUCCESS (bluetooth_disable_action,NULL ),CALLBACK_STATE (CB_BT_ADAPTER_STATE_CHANGED ,BT_STATE_OFF ), ), +TEST_CASE_BREDRLE ("AVRCP Disconnect - Success" , +ACTION_SUCCESS (bluetooth_enable_action,NULL ), +CALLBACK_STATE (CB_BT_ADAPTER_STATE_CHANGED ,BT_STATE_ON ), +ACTION_SUCCESS (emu_setup_powered_remote_action,NULL ), +ACTION_SUCCESS (emu_set_ssp_mode_action,NULL ), +ACTION_SUCCESS (emu_add_l2cap_server_action, &sdp_setup_data), +ACTION_SUCCESS (emu_add_l2cap_server_action, &a2dp_setup_data), +ACTION_SUCCESS (emu_add_l2cap_server_action, &avrcp_setup_data), +ACTION_SUCCESS (avrcp_connect_action,NULL ), +CALLBACK_AV_CONN_STATE (CB_A2DP_CONN_STATE , +BTAV_CONNECTION_STATE_CONNECTING ), +CALLBACK_AV_CONN_STATE (CB_A2DP_CONN_STATE , +BTAV_CONNECTION_STATE_CONNECTED ), +ACTION_SUCCESS (avrcp_disconnect_action,NULL ), +CALLBACK_AV_CONN_STATE (CB_A2DP_CONN_STATE , +BTAV_CONNECTION_STATE_DISCONNECTING ), +CALLBACK_AV_CONN_STATE (CB_A2DP_CONN_STATE , +BTAV_CONNECTION_STATE_DISCONNECTED ), +ACTION_SUCCESS (bluetooth_disable_action,NULL ), + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF), + ), };struct queue *get_avrcp_tests (void )
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v2 4/5 lib/sdp: Split error handing for length and transaction id
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This split the handling of invalid PDU length and not matching transaction id adding proper debug logs.
--- lib/sdp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
lib/sdp.c +8 -3
@@ -4181,10 +4181,15 @@ int sdp_process(sdp_session_t *session) goto end; } -if (n ==0 || reqhdr->tid != rsphdr->tid || - (n != (int ) (ntohs (rsphdr->plen) +sizeof (sdp_pdu_hdr_t)))) { +if (reqhdr->tid != rsphdr->tid) { t->err =EPROTO ; -SDPERR ("Protocol error." ); +SDPERR ("Protocol error: transaction id does not match" ); + goto end; + } + +if (n != (int ) (ntohs (rsphdr->plen) +sizeof (sdp_pdu_hdr_t))) { + t->err =EPROTO ; +SDPERR ("Protocol error: invalid length" ); goto end; }
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH v2 5/5 emulator/bthost: Fix not matching cid data properly
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
When using bthost_add_l2cap_server the caller expect that both scid and dcid are the same since the callback only take one value.
--- emulator/bthost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
emulator/bthost.c +1 -1
@@ -1226,7 +1226,7 @@ static bool l2cap_conn_req(struct bthost *bthost, struct btconn *conn, cb_data =bthost_find_l2cap_cb_by_psm (bthost, psm);if (cb_data) - rsp.dcid =cpu_to_le16 (conn->next_cid++); + rsp.dcid = rsp.scid;else rsp.result =cpu_to_le16 (0x0002 );/* PSM Not Supported */
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerHi,
Quoted 226 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
--- android/Makefile.am | 1 + android/tester-avrcp.c | 50 +++++++++++++++++++++++++++++++++++ android/tester-main.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ android/tester-main.h | 4 +++ 4 files changed, 127 insertions(+) create mode 100644 android/tester-avrcp.candroid/Makefile.am +1
-0@@ -171,6 +171,7 @@ android_android_tester_SOURCES = emulator/btdev.h emulator/btdev.c \ android/tester-pan.c \ android/tester-hdp.c \ android/tester-a2dp.c \ + android/tester-avrcp.c \ android/tester-gatt.c \ android/tester-main.h android/tester-main.candroid/tester-avrcp.c new file +50
-0@@ -0,0 +1,50 @@ +/* +* Copyright (C) 2014 Intel Corporation +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +#include <stdbool.h> + +#include "emulator/bthost.h" +#include "src/shared/util.h" + +#include "tester-main.h" +#include "android/utils.h" + +static struct queue *list; + +static struct test_case test_cases[] = { +TEST_CASE_BREDRLE ("AVRCP Init" , + ACTION_SUCCESS(dummy_action, NULL), + ), +}; + +struct queue *get_avrcp_tests (void ) +{ +uint16_t i =0 ; + + list =queue_new (); + +for (; i <sizeof (test_cases) /sizeof (test_cases[0 ]); ++i) +if (!queue_push_tail (list, &test_cases[i])) +return NULL ; + +return list; +} + +void remove_avrcp_tests (void ) +{ +queue_destroy (list,NULL ); +}android/tester-main.c +72
-0@@ -1212,6 +1212,10 @@ static btav_callbacks_t bta2dp_callbacks = { .audio_state_cb = a2dp_audio_state_cb, }; +static btrc_callbacks_t btavrcp_callbacks = { + .size =sizeof (btavrcp_callbacks), +}; +static const btgatt_client_callbacks_t btgatt_client_callbacks = { .register_client_cb = gattc_register_client_cb, .scan_result_cb = gattc_scan_result_cb,@@ -1528,6 +1532,60 @@ static void setup_a2dp(const void *test_data)tester_setup_complete (); } +static void setup_avrcp (const void *test_data) +{ +struct test_data *data =tester_get_data (); +const bt_interface_t *if_bt; +bt_status_t status; +const void *a2dp, *avrcp; + +if (!setup_base (data)) { +tester_setup_failed (); +return ; + } + + if_bt = data->if_bluetooth; + + status = if_bt->init (&bt_callbacks); +if (status !=BT_STATUS_SUCCESS ) { + data->if_bluetooth =NULL ; +tester_setup_failed (); +return ; + } + + a2dp = if_bt->get_profile_interface (BT_PROFILE_ADVANCED_AUDIO_ID ); +if (!a2dp) { +tester_setup_failed (); +return ; + } + + data->if_a2dp = a2dp; + + status = data->if_a2dp->init (&bta2dp_callbacks); +if (status !=BT_STATUS_SUCCESS ) { + data->if_a2dp =NULL ; +tester_setup_failed (); +return ; + } + + avrcp = if_bt->get_profile_interface (BT_PROFILE_AV_RC_ID ); +if (!a2dp) { +tester_setup_failed (); +return ; + } + + data->if_avrcp = avrcp; + + status = data->if_avrcp->init (&btavrcp_callbacks); +if (status !=BT_STATUS_SUCCESS ) { + data->if_avrcp =NULL ; +tester_setup_failed (); +return ; + } + +tester_setup_complete (); +} +static void setup_gatt (const void *test_data) {struct test_data *data =tester_get_data ();@@ -1605,6 +1663,11 @@ static void teardown(const void *test_data) data->if_a2dp =NULL ; } +if (data->if_avrcp) { + data->if_avrcp->cleanup (); + data->if_avrcp =NULL ; + } +if (data->if_bluetooth) { data->if_bluetooth->cleanup (); data->if_bluetooth =NULL ;@@ -2125,6 +2188,7 @@ static void tester_testcases_cleanup(void)remove_hidhost_tests ();remove_gatt_tests ();remove_a2dp_tests (); +remove_avrcp_tests ();remove_hdp_tests ();remove_pan_tests (); }@@ -2171,6 +2235,13 @@ static void add_a2dp_tests(void *data, void *user_data)test (tc, setup_a2dp, generic_test_function, teardown); } +static void add_avrcp_tests (void *data,void *user_data) +{ +struct test_case *tc = data; + +test (tc, setup_avrcp, generic_test_function, teardown); +} +static void add_gatt_tests (void *data,void *user_data) {struct test_case *tc = data;@@ -2190,6 +2261,7 @@ int main(int argc, char *argv[])queue_foreach (get_pan_tests (), add_pan_tests,NULL );queue_foreach (get_hdp_tests (), add_hdp_tests,NULL );queue_foreach (get_a2dp_tests (), add_a2dp_tests,NULL ); +queue_foreach (get_avrcp_tests (), add_avrcp_tests,NULL );queue_foreach (get_gatt_tests (), add_gatt_tests,NULL );if (tester_run ())android/tester-main.h +4
-1@@ -50,6 +50,7 @@#include <hardware/bt_pan.h> #include <hardware/bt_hl.h> #include <hardware/bt_av.h> +#include <hardware/bt_rc.h> #include <hardware/bt_gatt.h> #include <hardware/bt_gatt_client.h> #include <hardware/bt_gatt_server.h> @@ -321,6 +322,7 @@ struct test_data {const bthl_interface_t *if_hdp;const btav_interface_t *if_a2dp;struct audio_stream_out *if_stream; +const btrc_interface_t *if_avrcp;const btgatt_interface_t *if_gatt;const void *test_data;@@ -443,6 +445,8 @@ struct queue *get_hdp_tests(void);void remove_hdp_tests (void );struct queue *get_a2dp_tests (void );void remove_a2dp_tests (void ); +struct queue *get_avrcp_tests (void ); +void remove_avrcp_tests (void );struct queue *get_gatt_tests (void );void remove_gatt_tests (void ); --
Quoted 1 line
1.9.3
Pushed.
Signature · 1 line
Luiz Augusto von Dentz