[PATCH] android/main: Call unregister for all registered services on exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

---
 android/main.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/android/main.c b/android/main.c
index 2879bbf..2a9348b 100644
--- a/android/main.c
+++ b/android/main.c
@@ -493,6 +493,38 @@ static void cleanup_hal_connection(void)
 	ipc_cleanup();
 }
 
+static void cleanup_services(void)
+{
+	int i;
+
+	DBG("");
+
+	for (i=HAL_SERVICE_ID_BLUETOOTH; i < HAL_SERVICE_ID_MAX; i++) {
+		if (!services[i])
+			continue;
+
+		switch (i) {
+		case HAL_SERVICE_ID_BLUETOOTH:
+			bt_bluetooth_unregister();
+			break;
+		case HAL_SERVICE_ID_SOCK:
+			bt_socket_unregister();
+			break;
+		case HAL_SERVICE_ID_HIDHOST:
+			bt_hid_unregister();
+			break;
+		case HAL_SERVICE_ID_A2DP:
+			bt_a2dp_unregister();
+			break;
+		case HAL_SERVICE_ID_PAN:
+			bt_pan_unregister();
+			break;
+		}
+
+		services[i] = false;
+	}
+}
+
 static bool set_capabilities(void)
 {
 #if defined(ANDROID)
@@ -598,6 +630,8 @@ int main(int argc, char *argv[])
 	if (bluetooth_start_timeout > 0)
 		g_source_remove(bluetooth_start_timeout);
 
+	cleanup_services();
+
 	cleanup_hal_connection();
 	stop_sdp_server();
 	bt_bluetooth_cleanup();
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux