Files
TEESimulator-RS/module/diag.sh
T
Enginex0 d0139003a6 feat(logging): per-UID NDJSON on external storage
Move debug diagnostics off /data/local/tmp/teesim to
/data/media/0/TEESimulator (visible at /sdcard/TEESimulator), so users
can pull them without a root explorer. The logging code runs in the
keystore SELinux domain, so a debug-only media_rw_data_file grant plus
a debug-only diag.sh fragment gate the plane: diag.sh's presence is the
signal service.sh (setup) and action.sh (export) test. customize.sh
extracts diag.sh on debug installs or sweeps the dir on release, since
the release keystore domain cannot remove it itself.

Replace the per-call .bin parcel dumps (a fresh undecodable file per
generateKey) with one NDJSON record per event on the UID's own file,
carrying decoded fields plus the raw parcel as base64 for the offline
parsers. computeIfAbsent makes per-UID writer creation atomic.
2026-06-25 02:31:35 +01:00

21 lines
707 B
Bash

#!/system/bin/sh
# Debug-only diagnostic plane. Shipped solely in debug ZIPs; its presence is the gate that
# service.sh (setup) and action.sh (export) test before touching external storage.
DIAG_DIR=/data/media/0/TEESimulator
diag_setup() {
mkdir -p "$DIAG_DIR"
chmod 0777 "$DIAG_DIR"
chcon u:object_r:media_rw_data_file:s0 "$DIAG_DIR" 2>/dev/null
}
diag_export() {
_ts=$(date +%Y%m%d-%H%M%S)
_dest=/sdcard/Download/teesim-logs-$_ts
mkdir -p "$_dest"
cp -f "$DIAG_DIR"/teesim-uid-* "$_dest"/ 2>/dev/null
cp -f /data/adb/tricky_store/logs/certgen.log* "$_dest"/ 2>/dev/null
logcat -d -s TEESimulator > "$_dest/logcat.txt" 2>/dev/null
echo " ✅ Saved to $_dest"
}