OSDN Git Service

Delete bt_snoop.log when snoop logging is disabled
authorAjay Panicker <apanicke@google.com>
Thu, 30 Mar 2017 17:33:19 +0000 (10:33 -0700)
committerAjay Panicker <apanicke@google.com>
Thu, 30 Mar 2017 17:37:56 +0000 (17:37 +0000)
This patch will immediatly delete the snoop log if Bluetooth is on. If Bluetooth
is off it will delete the log as soon as Bluetooth starts again.

Test: Turn off logging while Bluetooth is on and off
Bug: 36718948
Change-Id: Ib660cd442c93f1a34c948d51c5cffc38695558d5

hci/src/btsnoop.cc

index 38de5c3..9e181e3 100644 (file)
@@ -142,6 +142,11 @@ static void update_logging() {
   bool should_log = module_started && (logging_enabled_via_api ||
                                        stack_config->get_btsnoop_turned_on());
 
+  if (module_started && !should_log) {
+    LOG_INFO(LOG_TAG, "Deleting snoop log if it exists");
+    remove(stack_config->get_btsnoop_log_path());
+  }
+
   if (should_log == is_logging) return;
 
   is_logging = should_log;