mirror of
git://f0xx.org/android_cast
synced 2026-07-29 04:18:09 +03:00
snap
This commit is contained in:
@@ -1,48 +1,68 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
|
||||
DEVICES_LIST="$(adb devices -l)"
|
||||
echo "${DEVICES_LIST}"
|
||||
|
||||
|
||||
filter_out() {
|
||||
local -n dev_string=${1}
|
||||
[[ ${dev_string} =~ List* ]] && dev_string=""
|
||||
return 0
|
||||
}
|
||||
|
||||
LOG_ROOT="log_capture/session_stats/"
|
||||
CLEAN_LOGS="no"
|
||||
|
||||
while true; do
|
||||
read -p "clean logs on device after fetch? [Y/n]" yn
|
||||
case $yn in
|
||||
[Y|Yes|y|yes]* )
|
||||
yn=""
|
||||
read -rp "clean logs on device after fetch? [Y/n] " yn
|
||||
yn="${yn,,}"
|
||||
case "${yn}" in
|
||||
y|yes)
|
||||
CLEAN_LOGS="yes"
|
||||
break
|
||||
;;
|
||||
[N|No|n|no]* )
|
||||
;;
|
||||
n|no)
|
||||
break
|
||||
;;
|
||||
;;
|
||||
"")
|
||||
CLEAN_LOGS="yes"
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "answer Y(es) or N(no) (short y/n or yes/no)"
|
||||
;;
|
||||
echo "answer Y(es) or N(o) (y/n or yes/no)"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "${DEVICES_LIST}" | while IFS= read -r DEV; do
|
||||
SERIAL="$(echo "${DEV}" | awk '{print $1}')"
|
||||
filter_out SERIAL
|
||||
[ -z "${SERIAL}" ] && continue
|
||||
# echo "Device: ${DEV}"
|
||||
# echo "Serial: ${SERIAL}"
|
||||
adb -s "${SERIAL}" shell run-as com.foxx.androidcast ls files/session_stats/
|
||||
echo "Known devices list:"
|
||||
echo "${DEVICES_LIST}"
|
||||
|
||||
while IFS= read -r DEV; do
|
||||
[[ -z "${DEV}" ]] && continue
|
||||
[[ "${DEV}" == List* ]] && continue
|
||||
|
||||
SERIAL="$(awk '{print $1}' <<<"${DEV}")"
|
||||
STATE="$(awk '{print $2}' <<<"${DEV}")"
|
||||
[[ "${STATE}" != "device" ]] && continue
|
||||
|
||||
LOG_PATH="${LOG_ROOT}/${SERIAL}/"
|
||||
echo "------------ dumping in ${LOG_PATH}"
|
||||
mkdir -p "${LOG_PATH}"
|
||||
for f in $(adb -s ${SERIAL} shell run-as com.foxx.androidcast ls files/session_stats/); do
|
||||
adb -s ${SERIAL} exec-out run-as com.foxx.androidcast cat "files/session_stats/$f" > "${LOG_PATH}/$f"
|
||||
[[ "no" != "${CLEAN_LOGS}" ]] && adb -s ${SERIAL} shell run-as com.foxx.androidcast rm -f "files/session_stats/$f"
|
||||
|
||||
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
|
||||
done
|
||||
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}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user