1
0
mirror of git://f0xx.org/android_cast synced 2026-07-29 05:58:14 +03:00
This commit is contained in:
Anton Afanasyeu
2026-05-21 12:00:57 +02:00
parent e2d51fbb27
commit 55d588afa4
8 changed files with 99 additions and 33 deletions

View File

@@ -5,11 +5,37 @@ DEVICES_LIST="$(adb devices -l)"
echo "${DEVICES_LIST}"
LOG_ROOT="log_capture/session_stats/"
CRASH_ROOT="log_capture/crash_reports/"
CLEAN_LOGS="no"
pull_dir() {
local serial="$1"
local remote_subdir="$2"
local local_base="$3"
local local_path="${local_base}/${serial}/${remote_subdir}/"
mapfile -t FILES < <(adb -s "${serial}" shell run-as com.foxx.androidcast ls "files/${remote_subdir}/" </dev/null \
| tr -d '\r' | grep -v '^$' || true)
if ((${#FILES[@]} == 0)); then
echo " (no files in files/${remote_subdir}/ on ${serial})"
return 0
fi
mkdir -p "${local_path}"
for f in "${FILES[@]}"; do
adb -s "${serial}" exec-out run-as com.foxx.androidcast cat "files/${remote_subdir}/${f}" </dev/null \
> "${local_path}/${f}"
if [[ "${CLEAN_LOGS}" == "yes" ]]; then
adb -s "${serial}" shell run-as com.foxx.androidcast rm -f "files/${remote_subdir}/${f}" </dev/null
fi
done
echo " pulled ${#FILES[@]} file(s) -> ${local_path}"
}
while true; do
yn=""
read -rp "clean logs on device after fetch? [Y/n] " yn
read -rp "clean logs on device after fetch? [y/N] " yn
yn="${yn,,}"
case "${yn}" in
y|yes)
@@ -20,7 +46,7 @@ while true; do
break
;;
"")
CLEAN_LOGS="yes"
CLEAN_LOGS="no"
break
;;
*)
@@ -40,29 +66,20 @@ while IFS= read -r DEV; do
STATE="$(awk '{print $2}' <<<"${DEV}")"
[[ "${STATE}" != "device" ]] && continue
LOG_PATH="${LOG_ROOT}/${SERIAL}/"
echo "------------ dumping in ${LOG_PATH}"
mkdir -p "${LOG_PATH}"
mapfile -t FILES < <(adb -s "${SERIAL}" shell run-as com.foxx.androidcast ls files/session_stats/ </dev/null \
| tr -d '\r' | grep -v '^$' || true)
if ((${#FILES[@]} == 0)); then
echo " (no session_stats files on ${SERIAL})"
continue
fi
for f in "${FILES[@]}"; do
adb -s "${SERIAL}" exec-out run-as com.foxx.androidcast cat "files/session_stats/${f}" </dev/null \
> "${LOG_PATH}/${f}"
if [[ "${CLEAN_LOGS}" == "yes" ]]; then
adb -s "${SERIAL}" shell run-as com.foxx.androidcast rm -f "files/session_stats/${f}" </dev/null
fi
done
echo "------------ ${SERIAL}"
echo "session_stats:"
pull_dir "${SERIAL}" "session_stats" "${LOG_ROOT}"
echo "crash_reports/pending:"
pull_dir "${SERIAL}" "crash_reports/pending" "${CRASH_ROOT}"
echo "crash_reports/native (stubs):"
pull_dir "${SERIAL}" "crash_reports/native" "${CRASH_ROOT}"
done <<<"${DEVICES_LIST}"
echo "showing all the logs in ${LOG_ROOT} folder and derivatives:"
ls -a ${LOG_ROOT}/*/*
echo "run './gradlew :session-studio:run' to analyze logs; find the latest logs in ${LOG_ROOT}"
echo ""
echo "Session stats: ${LOG_ROOT}"
[[ -d "${LOG_ROOT}" ]] && find "${LOG_ROOT}" -type f 2>/dev/null | sort || true
echo ""
echo "Crash reports: ${CRASH_ROOT}"
[[ -d "${CRASH_ROOT}" ]] && find "${CRASH_ROOT}" -type f 2>/dev/null | sort || true
echo ""
echo "run './gradlew :session-studio:run' to analyze session logs"