Diff between b5b655fca2416e039a46c0822356441d89b48477 and 1bd727b4770b18fe8460206682b211c8213c53e7

Changed Files

File Additions Deletions Status
android/handsfree.c +47 -1 modified

Full Patch

diff --git a/android/handsfree.c b/android/handsfree.c
index 84103e3..4103595 100644
--- a/android/handsfree.c
+++ b/android/handsfree.c
@@ -84,6 +84,7 @@ static struct {
 	bdaddr_t bdaddr;
 	uint8_t state;
 	uint32_t features;
+	bool indicators_enabled;
 	struct indicator inds[IND_COUNT];
 	struct hfp_gw *gw;
 } device;
@@ -142,7 +143,8 @@ static void at_command_handler(const char *command, void *user_data)
 {
 	hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
 
-	hfp_gw_disconnect(device.gw);
+	if (device.state != HAL_EV_HANDSFREE_CONNECTION_STATE_SLC_CONNECTED)
+		hfp_gw_disconnect(device.gw);
 }
 
 static void disconnect_watch(void *user_data)
@@ -152,6 +154,49 @@ static void disconnect_watch(void *user_data)
 	device_cleanup();
 }
 
+static void at_cmd_cmer(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
+							void *user_data)
+{
+	unsigned int val;
+
+	switch (type) {
+	case HFP_GW_CMD_TYPE_SET:
+		/* mode must be =3 */
+		if (!hfp_gw_result_get_number(result, &val) || val != 3)
+			break;
+
+		/* keyp is don't care */
+		if (!hfp_gw_result_get_number(result, &val))
+			break;
+
+		/* disp is don't care */
+		if (!hfp_gw_result_get_number(result, &val))
+			break;
+
+		/* ind must be 0 or 1 */
+		if (!hfp_gw_result_get_number(result, &val) || val > 1)
+			break;
+
+		if (hfp_gw_result_has_next(result))
+			break;
+
+		device.indicators_enabled = val;
+
+		/* TODO Check for 3-way calling support */
+		device_set_state(HAL_EV_HANDSFREE_CONNECTION_STATE_SLC_CONNECTED);
+
+		hfp_gw_send_result(device.gw, HFP_RESULT_OK);
+
+		return;
+	case HFP_GW_CMD_TYPE_TEST:
+	case HFP_GW_CMD_TYPE_READ:
+	case HFP_GW_CMD_TYPE_COMMAND:
+		break;
+	}
+
+	hfp_gw_send_result(device.gw, HFP_RESULT_ERROR);
+}
+
 static void at_cmd_cind(struct hfp_gw_result *result, enum hfp_gw_cmd_type type,
 							void *user_data)
 {
@@ -252,6 +297,7 @@ static void connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 
 	hfp_gw_register(device.gw, at_cmd_brsf, "+BRSF", NULL, NULL);
 	hfp_gw_register(device.gw, at_cmd_cind, "+CIND", NULL, NULL);
+	hfp_gw_register(device.gw, at_cmd_cmer, "+CMER", NULL, NULL);
 	device_set_state(HAL_EV_HANDSFREE_CONNECTION_STATE_CONNECTED);
 
 	return;