#!/bin/bash # Pull recent Bluetooth / pairing / PBAP lines from LAB log buffers (no repro needed). set -euo pipefail LAB="${LAB_SERIAL:-11231JEC207477}" OUT_DIR="${1:-$(cd "$(dirname "$0")/.." && pwd)/.local-artifacts/lab-bt-logs}" STAMP=$(date -u +%Y%m%dT%H%M%SZ) mkdir -p "$OUT_DIR" adb -s "$LAB" shell true >/dev/null 2>&1 || { echo "LAB $LAB not visible to adb (USB or wireless debugging)." >&2 exit 1 } BASE="$OUT_DIR/${STAMP}-lab-bt" echo "LAB identity:" adb -s "$LAB" shell getprop ro.lineage.version ro.build.display.id 2>/dev/null | tr '\n' ' ' echo adb -s "$LAB" shell settings get global bluetooth_off_timeout >"${BASE}-bt-timeout.txt" adb -s "$LAB" logcat -d -v threadtime -t 80000 >"${BASE}-logcat-main.txt" adb -s "$LAB" logcat -b events -d -v threadtime -t 50000 >"${BASE}-logcat-events.txt" adb -s "$LAB" shell dumpsys bluetooth_manager >"${BASE}-dumpsys-bluetooth_manager.txt" adb -s "$LAB" shell dumpsys package com.android.bluetooth >"${BASE}-dumpsys-pkg-bluetooth.txt" grep -iE 'bluetooth|pbap|phonebook|pair|bond|BtAutoOff|PermissionController|READ_CONTACTS|READ_CALL_LOG' \ "${BASE}-logcat-main.txt" >"${BASE}-grep-main.txt" || true grep -iE 'bt_|bond|pair' "${BASE}-logcat-events.txt" >"${BASE}-grep-events.txt" || true echo "Wrote:" ls -la "${BASE}"-*