summaryrefslogtreecommitdiff
path: root/android/socket.c
diff options
context:
space:
mode:
authorSzymon Janc <szymon.janc@tieto.com>2014-12-08 17:47:07 +0100
committerSzymon Janc <szymon.janc@tieto.com>2014-12-10 14:31:55 +0100
commitaae8b515c5b769a99bfabad01b922f33399a761a (patch)
tree23c623f4cf4070df99114de96f43646a86e2252d /android/socket.c
parent5fb15cc547dd89e6cb1244e69004105a4c1c820c (diff)
downloadbluez-aae8b515c5b769a99bfabad01b922f33399a761a.tar.gz
android/socket: Add support for dynamic MAP record
Android 5.0 uses service name (sic!) for defining instance ID and supported message types. Name passed is in format of "XXYYname" where XX is hex coded instance and YY is hex coded message types mask. This patch adds new mode for Socket HAL in which daemon tries to extract instance ID and message types from service name.
Diffstat (limited to 'android/socket.c')
-rw-r--r--android/socket.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/android/socket.c b/android/socket.c
index 2b836e922..ec78dcd7e 100644
--- a/android/socket.c
+++ b/android/socket.c
@@ -89,6 +89,8 @@ struct rfcomm_channel {
static bdaddr_t adapter_addr;
+static uint8_t hal_mode = HAL_MODE_SOCKET_DEFAULT;
+
static const uint8_t zero_uuid[16] = { 0 };
/* Simple list of RFCOMM connected sockets */
@@ -313,10 +315,31 @@ static sdp_record_t *create_mas_record(uint8_t chan, const char *svc_name)
{
sdp_list_t *seq;
sdp_profile_desc_t profile[1];
- uint8_t minst = DEFAULT_MAS_INSTANCE;
- uint8_t mtype = DEFAULT_MAS_MSG_TYPE;
+ uint8_t minst, mtype;
sdp_record_t *record;
uuid_t uuid;
+ int cnt, ret;
+
+ switch (hal_mode) {
+ case HAL_MODE_SOCKET_DYNAMIC_MAP:
+ /*
+ * Service name for MAP is passed as XXYYname
+ * XX - instance
+ * YY - message type
+ */
+ ret = sscanf(svc_name, "%02hhx%02hhx%n", &minst, &mtype, &cnt);
+ if (ret != 2 || cnt != 4)
+ return NULL;
+
+ svc_name += 4;
+ break;
+ case HAL_MODE_SOCKET_DEFAULT:
+ minst = DEFAULT_MAS_INSTANCE;
+ mtype = DEFAULT_MAS_MSG_TYPE;
+ break;
+ default:
+ return NULL;
+ }
sdp_uuid16_create(&uuid, MAP_MSE_SVCLASS_ID);
@@ -1147,6 +1170,8 @@ void bt_socket_register(struct ipc *ipc, const bdaddr_t *addr, uint8_t mode)
DBG("");
+ hal_mode = mode;
+
/*
* make sure channels assigned for profiles are reserved and not used
* for app services