Diff between 19f8877af783231edda9de8d4b53c2da48d1b3cd and 5a1814ef0f42bac6ba402f083ce499085e18c759

Changed Files

File Additions Deletions Status
android/gatt.c +8 -6 modified
android/hal-gatt.c +13 -1 modified

Full Patch

diff --git a/android/gatt.c b/android/gatt.c
index b3dd6d3..5a531d9 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -1730,15 +1730,17 @@ static void handle_client_scan(const void *buf, uint16_t len)
 {
 	const struct hal_cmd_gatt_client_scan *cmd = buf;
 	uint8_t status;
-	void *registered;
 
 	DBG("new state %d", cmd->start);
 
-	registered = find_app_by_id(cmd->client_if);
-	if (!registered) {
-		error("gatt: Client not registered");
-		status = HAL_STATUS_FAILED;
-		goto reply;
+	if (cmd->client_if != 0) {
+		void *registered = find_app_by_id(cmd->client_if);
+
+		if (!registered) {
+			error("gatt: Client not registered");
+			status = HAL_STATUS_FAILED;
+			goto reply;
+		}
 	}
 
 	/* Turn off scan */
diff --git a/android/hal-gatt.c b/android/hal-gatt.c
index c563fe9..080852a 100644
--- a/android/hal-gatt.c
+++ b/android/hal-gatt.c
@@ -595,7 +595,7 @@ static bt_status_t unregister_client(int client_if)
 					sizeof(cmd), &cmd, NULL, NULL, NULL);
 }
 
-static bt_status_t scan(int client_if, bool start)
+static bt_status_t scan_real(int client_if, bool start)
 {
 	struct hal_cmd_gatt_client_scan cmd;
 
@@ -609,6 +609,18 @@ static bt_status_t scan(int client_if, bool start)
 					sizeof(cmd), &cmd, NULL, NULL, NULL);
 }
 
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+static bt_status_t scan(bool start)
+{
+	return scan_real(0, start);
+}
+#else
+static bt_status_t scan(int client_if, bool start)
+{
+	return scan_real(client_if, start);
+}
+#endif
+
 static bt_status_t connect(int client_if, const bt_bdaddr_t *bd_addr,
 								bool is_direct)
 {