Add default a2dp role setting logic for headless 97/202397/1 accepted/tizen/unified/20190330.030017 submit/tizen/20190329.002626
authorWootak Jung <wootak.jung@samsung.com>
Thu, 28 Mar 2019 04:53:30 +0000 (13:53 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 28 Mar 2019 04:53:30 +0000 (13:53 +0900)
Change-Id: I25f5fa87779790eb189d0ac6070a25d5cead09db

src/adapter.c
src/hcid.h
src/main.c
src/main_headless.conf

index 0cf6c10..de5bdee 100644 (file)
@@ -9961,7 +9961,12 @@ static void load_config(struct btd_adapter *adapter)
        /* Get A2DP Role */
        str = g_key_file_get_string(key_file, "General", "DefaultA2DPRole", &gerr);
        if (gerr || !str) {
-               adapter->a2dp_role = BLUETOOTH_A2DP_SOURCE_ROLE;
+               if (main_opts.default_a2dp_role_sink) {
+                       DBG("Default A2DP role is sink");
+                       adapter->a2dp_role = BLUETOOTH_A2DP_SINK_ROLE;
+               } else {
+                       adapter->a2dp_role = BLUETOOTH_A2DP_SOURCE_ROLE;
+               }
                g_error_free(gerr);
                gerr = NULL;
        } else {
index cbd11c1..c71a1e3 100755 (executable)
@@ -49,6 +49,7 @@ struct main_opts {
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        gboolean        le_privacy;
        char            *pin_code;
+       gboolean        default_a2dp_role_sink;
 #endif
 
        uint16_t        did_source;
index 17ddac1..bb52422 100755 (executable)
@@ -93,6 +93,7 @@ static const char *supported_options[] = {
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        "EnableLEPrivacy",
        "PinCode",
+       "DefaultA2DPRoleSink",
 #endif
        NULL
 };
@@ -418,6 +419,15 @@ static void parse_config(GKeyFile *config)
                main_opts.pin_code = g_strdup(str);
                g_free(str);
        }
+
+       boolean = g_key_file_get_boolean(config, "General", "DefaultA2DPRoleSink", &err);
+       if (err) {
+               DBG("%s", err->message);
+               g_clear_error(&err);
+       } else {
+               DBG("DefaultA2DPRoleSink=%s", boolean ? "true" : "false");
+               main_opts.default_a2dp_role_sink = boolean;
+       }
 #endif
        str = g_key_file_get_string(config, "GATT", "Cache", &err);
        if (err) {
@@ -447,6 +457,7 @@ static void init_defaults(void)
 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
        main_opts.le_privacy = FALSE;
        main_opts.pin_code = NULL;
+       main_opts.default_a2dp_role_sink = false;
 #endif
 
        if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2)
index 15b5fd1..ed3eada 100644 (file)
@@ -6,7 +6,11 @@
 
 # Default device class. Only the major and minor device class bits are
 # considered. Defaults to '0x000000'.
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+Class = 0x40414 # Audio/Video(Loudspeaker)
+#else
 #Class = 0x000100
+#endif
 
 # How long to stay in discoverable mode before going back to non-discoverable
 # The value is in seconds. Default is 180, i.e. 3 minutes.
 PinCode = 0000
 #endif
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+# Default A2DP role is sink in headless device.
+DefaultA2DPRoleSink = true
+#endif
+
 [GATT]
 # GATT attribute cache.
 # Possible values: