mirror of
git://f0xx.org/android_cast
synced 2026-07-29 03:38:52 +03:00
sync
This commit is contained in:
21
rebuild.sh
21
rebuild.sh
@@ -29,7 +29,8 @@ for arg in "$@"; do
|
||||
echo "Usage: $0 [--skip-tests] [--no-reconnect] [--java-home=PATH]"
|
||||
echo " Builds debug APK, runs unit tests (unless skipped), reconnects adb (mdns + HTTP"
|
||||
echo " :5039/adb.json + known IPs), installs on all adb devices, and launches the app."
|
||||
echo " Env: RECONNECT_KNOWN_DEVICES=yes|no (default yes), DEV_ADB_HTTP_PORT=5039"
|
||||
echo " Env: RECONNECT_KNOWN_DEVICES=yes|no, DEV_ADB_HTTP_PORT=5039, ADB_TCP_PROBE=yes"
|
||||
echo " ANDROID_CAST_JAVA_HOME=/path/to/jdk-21 (avoids JDK 25 warning)"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
@@ -70,6 +71,11 @@ if ! picked="$(pick_java_home)"; then
|
||||
fi
|
||||
export JAVA_HOME="$picked"
|
||||
|
||||
if [[ "${RECONNECT_KNOWN_DEVICES}" =~ [yY] ]]; then
|
||||
echo "==> Pre-build adb reconnect (HTTP :${DEV_ADB_HTTP_PORT:-5039}/adb.json)"
|
||||
adb_reconnect_all "pre-build" || true
|
||||
fi
|
||||
|
||||
# shellcheck source=scripts/android-ndk.sh
|
||||
source "$ROOT/scripts/android-ndk.sh"
|
||||
# shellcheck source=scripts/native-build-cache.sh
|
||||
@@ -124,15 +130,18 @@ if [[ ! -f "$APK" ]]; then
|
||||
fi
|
||||
|
||||
if [[ "${RECONNECT_KNOWN_DEVICES}" =~ [yY] ]]; then
|
||||
adb_reconnect_all || true
|
||||
adb_reconnect_all "post-build" || true
|
||||
fi
|
||||
|
||||
mapfile -t DEVICES < <(adb devices | awk 'NR > 1 && $2 == "device" { print $1 }')
|
||||
|
||||
if [[ ${#DEVICES[@]} -eq 0 ]]; then
|
||||
echo "ERROR: No adb devices in 'device' state after reconnect." >&2
|
||||
echo " Enable dev setting “ADB over Wi‑Fi keeper”, grant WRITE_SECURE_SETTINGS once via USB," >&2
|
||||
echo " pair wireless debugging once, then retry. Or: curl http://DEVICE:5039/adb.json" >&2
|
||||
echo " Empty curl = app/keeper not running on that device (install once via USB)." >&2
|
||||
echo " Check: scripts/adb-reconnect.sh adb_http_status 192.168.33.39" >&2
|
||||
for _hint_ip in 192.168.33.39 192.168.33.106 192.168.33.153 192.168.33.173; do
|
||||
adb_http_status "$_hint_ip" 2>/dev/null || true
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -140,12 +149,14 @@ echo "==> Installing to ${#DEVICES[@]} device(s): ${DEVICES[*]}"
|
||||
FAILED=0
|
||||
for serial in "${DEVICES[@]}"; do
|
||||
echo "--- $serial"
|
||||
adb_prepare_device_for_deploy "$serial"
|
||||
if adb -s "$serial" install -r "$APK"; then
|
||||
echo " Installed"
|
||||
adb_prepare_device_for_deploy "$serial"
|
||||
adb -s "$serial" shell am broadcast \
|
||||
-a com.foxx.androidcast.dev.REFRESH_ADB_WIFI \
|
||||
-n com.foxx.androidcast/.dev.DevAdbWifiReceiver >/dev/null 2>&1 || true
|
||||
if adb -s "$serial" shell am start -n "$LAUNCHER" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER; then
|
||||
if adb -s "$serial" shell am start -n "$LAUNCHER" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER --ez after_deploy true; then
|
||||
echo " Launched $LAUNCHER"
|
||||
else
|
||||
echo " WARN: launch failed (app may still be installed)" >&2
|
||||
|
||||
Reference in New Issue
Block a user