fix: stabilize device debugging and cloud deploy
This commit is contained in:
@@ -3,6 +3,7 @@ set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
DEFAULT_SERIAL="adb-A9TU024628000647-B0UNif._adb-tls-connect._tcp"
|
||||
TARGET_MODEL="FLC_AN00"
|
||||
DEFAULT_SDK_DIR="/opt/homebrew/share/android-commandlinetools"
|
||||
PACKAGE_NAME="site.hyzq.bossandroid"
|
||||
ACTIVITY_NAME=".MainActivity"
|
||||
@@ -30,7 +31,30 @@ Environment:
|
||||
EOF
|
||||
}
|
||||
|
||||
lookup_honor_serial() {
|
||||
adb devices -l | sed -nE "/model:${TARGET_MODEL}/ s/^(.*)[[:space:]]device .*/\\1/p" | head -n 1
|
||||
}
|
||||
|
||||
resolve_target_serial() {
|
||||
local requested state detected
|
||||
requested="${BOSS_ANDROID_SERIAL:-$DEFAULT_SERIAL}"
|
||||
state="$(adb -s "$requested" get-state 2>/dev/null || true)"
|
||||
if [[ "$state" == "device" ]]; then
|
||||
printf '%s' "$requested"
|
||||
return 0
|
||||
fi
|
||||
|
||||
detected="$(lookup_honor_serial)"
|
||||
if [[ -n "$detected" ]]; then
|
||||
printf '%s' "$detected"
|
||||
return 0
|
||||
fi
|
||||
|
||||
printf '%s' "$requested"
|
||||
}
|
||||
|
||||
ensure_connected() {
|
||||
TARGET_SERIAL="$(resolve_target_serial)"
|
||||
local state
|
||||
state="$(adb -s "$TARGET_SERIAL" get-state 2>/dev/null || true)"
|
||||
if [[ "$state" != "device" ]]; then
|
||||
@@ -64,7 +88,7 @@ command="${1:-}"
|
||||
|
||||
case "$command" in
|
||||
serial)
|
||||
echo "$TARGET_SERIAL"
|
||||
echo "$(resolve_target_serial)"
|
||||
;;
|
||||
status)
|
||||
ensure_connected
|
||||
|
||||
Reference in New Issue
Block a user