Diff between a328efa7b6b31f5247dc72b1ebb7be1add492eb2 and ff2c83e54c36785c308d20970d92d507b7880fc3

Changed Files

File Additions Deletions Status
android/bluetooth.c +18 -8 modified

Full Patch

diff --git a/android/bluetooth.c b/android/bluetooth.c
index b6ef3e6..e32ddd6 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -95,6 +95,7 @@ struct device {
 	bdaddr_t bdaddr;
 	int bond_state;
 	char *name;
+	char *friendly_name;
 };
 
 struct browse_req {
@@ -2282,11 +2283,13 @@ static uint8_t get_device_service_rec(struct device *dev)
 
 static uint8_t get_device_friendly_name(struct device *dev)
 {
-	DBG("Not implemented");
+	if (!dev->friendly_name)
+		return HAL_STATUS_FAILED;
 
-	/* TODO */
+	send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_FRIENDLY_NAME,
+				strlen(dev->friendly_name), dev->friendly_name);
 
-	return HAL_STATUS_FAILED;
+	return HAL_STATUS_SUCCESS;
 }
 
 static uint8_t get_device_rssi(struct device *dev)
@@ -2377,13 +2380,20 @@ failed:
 								status);
 }
 
-static uint8_t set_device_friendly_name(struct device *dev)
+static uint8_t set_device_friendly_name(struct device *dev, const uint8_t *val,
+								uint16_t len)
 {
-	DBG("Not implemented");
+	DBG("");
 
-	/* TODO */
+	g_free(dev->friendly_name);
+	dev->friendly_name = g_strndup((const char *) val, len);
 
-	return HAL_STATUS_FAILED;
+	/* TODO store friendly name */
+
+	send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_FRIENDLY_NAME,
+				strlen(dev->friendly_name), dev->friendly_name);
+
+	return HAL_STATUS_SUCCESS;
 }
 
 static uint8_t set_device_version_info(struct device *dev)
@@ -2419,7 +2429,7 @@ static void handle_set_remote_device_prop_cmd(const void *buf, uint16_t len)
 
 	switch (cmd->type) {
 	case HAL_PROP_DEVICE_FRIENDLY_NAME:
-		status = set_device_friendly_name(l->data);
+		status = set_device_friendly_name(l->data, cmd->val, cmd->len);
 		break;
 	case HAL_PROP_DEVICE_VERSION_INFO:
 		status = set_device_version_info(l->data);