Diff between 790e32b8da57755c9e97647310a0d7db6eb0c7fd and e3d377c0031923d0c72ecb883171441f8f3fd6b6

Changed Files

File Additions Deletions Status
android/client/haltest.c +7 -0 modified
android/client/if-bt.c +12 -3 modified
android/client/if-main.h +1 -0 modified

Full Patch

diff --git a/android/client/haltest.c b/android/client/haltest.c
index f9b0674..7fa15b5 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -34,6 +34,8 @@
 #include "pollhandler.h"
 #include "history.h"
 
+static void process_line(char *line_buffer);
+
 const struct interface *interfaces[] = {
 	&audio_if,
 	&sco_if,
@@ -173,6 +175,11 @@ static void help_p(int argc, const char **argv)
 /* quit/exit execution */
 static void quit_p(int argc, const char **argv)
 {
+	char cleanup_audio[] = "audio cleanup";
+
+	close_hw_bt_dev();
+	process_line(cleanup_audio);
+
 	exit(0);
 }
 
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 4f1a9d9..ce75834 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -23,6 +23,7 @@
 #include "../hal-msg.h"
 #include "../hal-utils.h"
 
+static hw_device_t *bt_device;
 const bt_interface_t *if_bluetooth;
 
 #define VERIFY_PROP_TYPE_ARG(n, typ) \
@@ -163,6 +164,15 @@ static void add_remote_device_from_props(int num_properties,
 	}
 }
 
+bool close_hw_bt_dev(void)
+{
+	if (!bt_device)
+		return false;
+
+	bt_device->close(bt_device);
+	return true;
+}
+
 static void adapter_state_changed_cb(bt_state_t state)
 {
 	haltest_info("%s: state=%s\n", __func__, bt_state_t2str(state));
@@ -403,7 +413,6 @@ static void init_p(int argc, const char **argv)
 {
 	int err;
 	const hw_module_t *module;
-	hw_device_t *device;
 
 	err = hw_get_module(BT_HARDWARE_MODULE_ID, &module);
 	if (err) {
@@ -411,14 +420,14 @@ static void init_p(int argc, const char **argv)
 		return;
 	}
 
-	err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
+	err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &bt_device);
 	if (err) {
 		haltest_error("module->methods->open returned %d\n", err);
 		return;
 	}
 
 	if_bluetooth =
-		    ((bluetooth_device_t *) device)->get_bluetooth_interface();
+		((bluetooth_device_t *) bt_device)->get_bluetooth_interface();
 	if (!if_bluetooth) {
 		haltest_error("get_bluetooth_interface returned NULL\n");
 		return;
diff --git a/android/client/if-main.h b/android/client/if-main.h
index 7fc8dad..d239bb2 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -156,6 +156,7 @@ const char *enum_devices(void *v, int i);
 const char *interface_name(void *v, int i);
 const char *command_name(void *v, int i);
 void add_remote_device(const bt_bdaddr_t *addr);
+bool close_hw_bt_dev(void);
 
 const struct interface *get_interface(const char *name);
 struct method *get_method(struct method *methods, const char *name);