From 29d8969c363146f8e10c5b6ba550c7f6b01c9500 Mon Sep 17 00:00:00 2001 From: bozowski Date: Mon, 23 Oct 2023 11:12:26 -0700 Subject: [PATCH] HCI logs --- .../capture/platform/android/capabilities.py | 32 +++++++++++++------ .../platform/android/streams/pcap/pcap.py | 4 +-- .../platform/android/streams/screen/screen.py | 3 +- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/tools/interop/idt/capture/platform/android/capabilities.py b/src/tools/interop/idt/capture/platform/android/capabilities.py index ef54ef513287e1..066a18a3e6c326 100644 --- a/src/tools/interop/idt/capture/platform/android/capabilities.py +++ b/src/tools/interop/idt/capture/platform/android/capabilities.py @@ -15,22 +15,34 @@ class Capabilities: def __init__(self, platform: "Android"): self.logger = logger self.platform = platform - self.has_tcpdump = False - self.has_root = False - self.is_64 = False + self.c_has_tcpdump = False + self.c_has_root = False + self.c_is_64 = False + self.c_hci_snoop_enabled = False + + def __repr__(self): + s = "Detected capabilities:\n" + for item in [x for x in dir(self) if x.startswith("c_")]: + s += f"{item}: {getattr(self, item)}\n" + return s def check_capabilities(self): self.logger.info("Checking if device has root") - self.has_root = self.platform.run_adb_command( + self.c_has_root = self.platform.run_adb_command( "shell which su", capture_output=True).finished_success() - if self.has_root: + if self.c_has_root: self.logger.warning("adb root!") Bash("adb root", sync=True).start_command() self.logger.info("Checking if device has tcpdump") - self.has_tcpdump = self.platform.run_adb_command( + self.c_has_tcpdump = self.platform.run_adb_command( "shell which tcpdump", capture_output=True).finished_success() self.logger.info("Checking device CPU arch") - cpu_arch_return = self.platform.run_adb_command( - "shell cat /proc/cpuinfo | grep rch", capture_output=True) - cpu_arch_output = cpu_arch_return.get_captured_output() - self.is_64 = cpu_arch_return.finished_success() and "8" in cpu_arch_output + self.c_is_64 = "8" in self.platform.run_adb_command("shell cat /proc/cpuinfo | grep rch", + capture_output=True).get_captured_output() + self.logger.info("Attempting to enable HCI snoop logs") + self.platform.run_adb_command("shell setprop persist.bluetooth.btsnooplogmode full").start_command() + self.platform.run_adb_command("shell svc bluetooth disable").start_command() + self.platform.run_adb_command("shell svc bluetooth enable").start_command() + self.c_hci_snoop_enabled = "full" in self.platform.run_adb_command("getprop persist.bluetooth.btsnooplogmode", + capture_output=True).get_captured_output() + self.logger.info(self) diff --git a/src/tools/interop/idt/capture/platform/android/streams/pcap/pcap.py b/src/tools/interop/idt/capture/platform/android/streams/pcap/pcap.py index 7a22d5b023ca63..b68004737b6650 100644 --- a/src/tools/interop/idt/capture/platform/android/streams/pcap/pcap.py +++ b/src/tools/interop/idt/capture/platform/android/streams/pcap/pcap.py @@ -39,7 +39,7 @@ def __init__(self, platform: "Android"): self.platform = platform self.pcap_artifact = create_standard_log_name("android_tcpdump", "cap", parent=platform.artifact_dir) self.pcap_phone_out_path = f"/sdcard/Movies/{os.path.basename(self.pcap_artifact)}" - self.pcap_phone_bin_location = "tcpdump" if platform.capabilities.has_tcpdump else "/sdcard/Movies/tcpdump" + self.pcap_phone_bin_location = "tcpdump" if platform.capabilities.c_has_tcpdump else "/sdcard/Movies/tcpdump" self.pcap_command = f"shell {self.pcap_phone_bin_location} -w {self.pcap_phone_out_path}" self.pcap_proc = platform.get_adb_background_command(self.pcap_command) self.pcap_pull = False @@ -54,7 +54,7 @@ async def pull_packet_capture(self) -> None: self.pcap_pull = False async def start(self): - if self.platform.capabilities.has_tcpdump: + if self.platform.capabilities.c_has_tcpdump: self.logger.info("tcpdump already available; using!") self.pcap_proc.start_command() self.pcap_pull = True diff --git a/src/tools/interop/idt/capture/platform/android/streams/screen/screen.py b/src/tools/interop/idt/capture/platform/android/streams/screen/screen.py index 058835ea243c8d..a8e593d8665b08 100644 --- a/src/tools/interop/idt/capture/platform/android/streams/screen/screen.py +++ b/src/tools/interop/idt/capture/platform/android/streams/screen/screen.py @@ -55,12 +55,11 @@ async def prepare_screen_recording(self) -> None: try: async with asyncio.timeout_at(asyncio.get_running_loop().time() + 20.0): screen_on = self.check_screen() - self.logger.error("Please turn the screen on so screen recording can start!") while not screen_on: await asyncio.sleep(2) screen_on = self.check_screen() if not screen_on: - self.logger.error("Screen is still not on for recording!") + self.logger.error("Please turn the screen on so screen recording can start!") except TimeoutError: self.logger.error("Screen recording timeout") return