Diff between 5fb15cc547dd89e6cb1244e69004105a4c1c820c and aae8b515c5b769a99bfabad01b922f33399a761a

Changed Files

File Additions Deletions Status
android/hal-bluetooth.c +6 -1 modified
android/hal-msg.h +3 -0 modified
android/socket.c +27 -2 modified

Full Patch

diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 28289d3..e24f7d2 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -554,9 +554,14 @@ static int init(bt_callbacks_t *callbacks)
 	}
 
 	cmd.service_id = HAL_SERVICE_ID_SOCKET;
-	cmd.mode = HAL_MODE_DEFAULT;
 	cmd.max_clients = 1;
 
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+	cmd.mode = HAL_MODE_SOCKET_DYNAMIC_MAP;
+#else
+	cmd.mode = HAL_MODE_DEFAULT;
+#endif
+
 	status = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE,
 					sizeof(cmd), &cmd, NULL, NULL, NULL);
 	if (status != BT_STATUS_SUCCESS) {
diff --git a/android/hal-msg.h b/android/hal-msg.h
index 9d38a9f..88b0c52 100644
--- a/android/hal-msg.h
+++ b/android/hal-msg.h
@@ -267,6 +267,9 @@ struct hal_rsp_get_connection_state {
 
 /* Bluetooth Socket HAL api */
 
+#define HAL_MODE_SOCKET_DEFAULT		HAL_MODE_DEFAULT
+#define HAL_MODE_SOCKET_DYNAMIC_MAP	0x01
+
 #define HAL_SOCK_RFCOMM		0x01
 #define HAL_SOCK_SCO		0x02
 #define HAL_SOCK_L2CAP		0x03
diff --git a/android/socket.c b/android/socket.c
index 2b836e9..ec78dcd 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