Skip to content

Commit

Permalink
HCI logs
Browse files Browse the repository at this point in the history
  • Loading branch information
aBozowski committed Oct 23, 2023
1 parent a856bf6 commit 29d8969
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
32 changes: 22 additions & 10 deletions src/tools/interop/idt/capture/platform/android/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29d8969

Please sign in to comment.