Diff between 1dd3ac5875ee7756dd1b10e0ac50bf20e0ff011d and 658aa0968ded5ae05f20628a0c6a83acb9e708d4

Changed Files

File Additions Deletions Status
android/bluetooth.c +21 -24 modified

Full Patch

diff --git a/android/bluetooth.c b/android/bluetooth.c
index 784db64..b8dc354 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -3739,41 +3739,38 @@ static void handle_start_discovery_cmd(const void *buf, uint16_t len)
 {
 	uint8_t status;
 
-	/* Check if there is discovery with BREDR type */
-	if (adapter.cur_discovery_type & SCAN_TYPE_BREDR) {
-		status = HAL_STATUS_SUCCESS;
-		goto reply;
-	}
-
 	if (!(adapter.current_settings & MGMT_SETTING_POWERED)) {
 		status = HAL_STATUS_NOT_READY;
-		goto reply;
+		goto failed;
 	}
 
-	adapter.exp_discovery_type |= SCAN_TYPE_DUAL;
-
-	/* If there is no discovery ongoing, try to start discovery */
-	if (!adapter.cur_discovery_type) {
-		if (!start_discovery(adapter.exp_discovery_type))
+	switch (adapter.cur_discovery_type) {
+	case SCAN_TYPE_DUAL:
+	case SCAN_TYPE_BREDR:
+		break;
+	case SCAN_TYPE_NONE:
+		if (!start_discovery(SCAN_TYPE_DUAL)) {
 			status = HAL_STATUS_FAILED;
-		else
-			status = HAL_STATUS_SUCCESS;
+			goto failed;
+		}
 
-		goto reply;
-	}
+		break;
+	case SCAN_TYPE_LE:
+		if (get_adapter_discovering_type() == SCAN_TYPE_LE)
+			break;
 
-	/*
-	 * Stop discovery here. Once it is stop we will restart it
-	 * with exp_discovery_settings
-	 */
-	if (!stop_discovery(adapter.cur_discovery_type)) {
-		status = HAL_STATUS_FAILED;
-		goto reply;
+		if (!stop_discovery(SCAN_TYPE_LE)) {
+			status = HAL_STATUS_FAILED;
+			goto failed;
+		}
+
+		adapter.exp_discovery_type = SCAN_TYPE_DUAL;
+		break;
 	}
 
 	status = HAL_STATUS_SUCCESS;
 
-reply:
+failed:
 	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_BLUETOOTH, HAL_OP_START_DISCOVERY,
 									status);
 }