OSDN Git Service

Add respond track not selected interim when register notification
authortedwang <tedwang@google.com>
Wed, 16 May 2018 11:51:26 +0000 (19:51 +0800)
committerHansong Zhang <hsz@google.com>
Tue, 29 May 2018 23:31:14 +0000 (16:31 -0700)
Respond interim with Identifier 0xFFFFFFFFFFFFFFFF register
notification for EVENT_TRACK_CHANGE for pts test

Bug: 79378129
Test: PTS AVRCP/TG/NFY/BV-04-C
Change-Id: Ia861bf4682e9daf9c7c3842df9f95381171da574

conf/bt_stack.conf
internal_include/stack_config.h
main/stack_config.cc
profile/avrcp/Android.bp
profile/avrcp/device.cc
profile/avrcp/tests/avrcp_device_test.cc

index f1557b1..d1e7756 100644 (file)
@@ -50,6 +50,9 @@ TRC_HID_DEV=2
 # SMP Pair options (formatted as hex bytes) auth, io, ikey, rkey, ksize
 #PTS_SmpOptions=0xD,0x4,0xf,0xf,0x10
 
+# PTS AVRCP Test mode
+#PTS_AvrcpTest=true
+
 # SMP Certification Failure Cases
 # Set any of the following SMP error values (from smp_api_types.h)
 # to induce pairing failues for various PTS SMP test cases.
index 81396ab..d623fa4 100644 (file)
@@ -27,6 +27,7 @@ static const char STACK_CONFIG_MODULE[] = "stack_config_module";
 
 typedef struct {
   bool (*get_trace_config_enabled)(void);
+  bool (*get_pts_avrcp_test)(void);
   bool (*get_pts_secure_only_mode)(void);
   bool (*get_pts_conn_updates_disabled)(void);
   bool (*get_pts_crosskey_sdp_disable)(void);
index 6b937aa..0e56250 100644 (file)
@@ -27,6 +27,7 @@
 
 namespace {
 const char* TRACE_CONFIG_ENABLED_KEY = "TraceConf";
+const char* PTS_AVRCP_TEST = "PTS_AvrcpTest";
 const char* PTS_SECURE_ONLY_MODE = "PTS_SecurePairOnly";
 const char* PTS_LE_CONN_UPDATED_DISABLED = "PTS_DisableConnUpdates";
 const char* PTS_DISABLE_SDP_LE_PAIR = "PTS_DisableSDPOnLEPair";
@@ -77,6 +78,11 @@ static bool get_trace_config_enabled(void) {
                          TRACE_CONFIG_ENABLED_KEY, false);
 }
 
+static bool get_pts_avrcp_test(void) {
+  return config_get_bool(*config, CONFIG_DEFAULT_SECTION, PTS_AVRCP_TEST,
+                         false);
+}
+
 static bool get_pts_secure_only_mode(void) {
   return config_get_bool(*config, CONFIG_DEFAULT_SECTION, PTS_SECURE_ONLY_MODE,
                          false);
@@ -104,12 +110,10 @@ static int get_pts_smp_failure_case(void) {
 
 static config_t* get_all(void) { return config.get(); }
 
-const stack_config_t interface = {get_trace_config_enabled,
-                                  get_pts_secure_only_mode,
-                                  get_pts_conn_updates_disabled,
-                                  get_pts_crosskey_sdp_disable,
-                                  get_pts_smp_options,
-                                  get_pts_smp_failure_case,
-                                  get_all};
+const stack_config_t interface = {
+    get_trace_config_enabled,     get_pts_avrcp_test,
+    get_pts_secure_only_mode,     get_pts_conn_updates_disabled,
+    get_pts_crosskey_sdp_disable, get_pts_smp_options,
+    get_pts_smp_failure_case,     get_all};
 
 const stack_config_t* stack_config_get_interface(void) { return &interface; }
index b10a56d..1e27861 100644 (file)
@@ -4,6 +4,7 @@ cc_library_static {
     host_supported: true,
     include_dirs: [
         "system/bt",
+        "system/bt/btcore/include",
         "system/bt/internal_include",
         "system/bt/stack/include",
     ],
@@ -25,6 +26,7 @@ cc_test {
     host_supported: true,
     include_dirs: [
         "system/bt",
+        "system/bt/btcore/include",
         "system/bt/internal_include",
         "system/bt/stack/include",
     ],
index e1fb70b..3ab87dd 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "connection_handler.h"
 #include "device.h"
+#include "stack_config.h"
 
 namespace bluetooth {
 namespace avrcp {
@@ -362,6 +363,10 @@ void Device::TrackChangedNotificationResponse(uint8_t label, bool interim,
   if (curr_song_id == "") {
     DEVICE_LOG(WARNING) << "Empty media ID";
     uid = 0;
+    if (stack_config_get_interface()->get_pts_avrcp_test()) {
+      DEVICE_LOG(WARNING) << __func__ << ": pts test mode";
+      uid = 0xffffffffffffffff;
+    }
   }
 
   auto response = RegisterNotificationResponseBuilder::MakeTrackChangedBuilder(
index 63bd208..ead4643 100644 (file)
@@ -26,6 +26,7 @@
 #include "avrcp_packet.h"
 #include "avrcp_test_helper.h"
 #include "device.h"
+#include "stack_config.h"
 #include "tests/avrcp/avrcp_test_packets.h"
 #include "tests/packet_test_helper.h"
 
@@ -45,6 +46,12 @@ using ::testing::Mock;
 using ::testing::NiceMock;
 using ::testing::Return;
 
+bool get_pts_avrcp_test(void) { return false; }
+
+const stack_config_t interface = {
+    nullptr, get_pts_avrcp_test, nullptr, nullptr, nullptr, nullptr, nullptr,
+    nullptr};
+
 // TODO (apanicke): All the tests below are just basic positive unit tests.
 // Add more tests to increase code coverage.
 class AvrcpDeviceTest : public ::testing::Test {
@@ -1026,3 +1033,7 @@ TEST_F(AvrcpDeviceTest, getInvalidItemAttributesTest) {
 
 }  // namespace avrcp
 }  // namespace bluetooth
+
+const stack_config_t* stack_config_get_interface(void) {
+  return &bluetooth::avrcp::interface;
+}