android: build.sh installs and syncs the game files when a phone is attached

After building the APK, android/build.sh now picks the attached device (ANDROID_SERIAL for several),
installs the APK (reinstalling on a signature mismatch), syncs the zh client into files/Client and, with
--launch, wakes the phone and starts the app. Without a device it only builds.

push-client.sh is now incremental (android/sync_client.py): the device keeps files/Client/.mt_sync
(size, mtime, path of what the last sync wrote), so later syncs send only new and changed files as one
tar streamed through `adb shell -T run-as` (no copy in /data/local/tmp) and delete the ones gone
locally. Only game resources are synced; settings and logs the app writes there are kept. --locale zh
rebuilds build/zh-locale/Client first when its inputs changed. android/adb_env.sh picks adb and falls
back to server port 5038 when :5037 cannot bind.

Verified against a fake adb device: first sync (1.4 GB, byte-identical), no-op resync, changed files,
deletions, locale switch, --full, the install/launch path and the no-device path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-30 16:36:21 +09:00
co-authored by Claude Opus 5.5
parent f9cd63713f
commit cd9e5b259d
10 changed files with 363 additions and 64 deletions
+10 -5
View File
@@ -23,7 +23,7 @@ returned by SDL's `SDL_GetBasePath`). `MT_PYTHON_STDLIB` can override the zip pa
## Android integration
`./android/build.sh [Debug|Release] [--install]` builds the arm64 APK
`./android/build.sh [Debug|Release] [--no-deploy] [--no-push] [--locale XX] [--full-push] [--launch]` builds the arm64 APK
(`android/app/build/outputs/apk/debug/app-debug.apk`, package
`org.metin2port.client`): it downloads SDL 3.4.16 (sha256-checked) into
`build/android/_deps`, builds `libSDL3.so`, cross-builds `libmain.so`
@@ -32,10 +32,15 @@ SDLActivity shell under `android/` (`MainActivity` passes the launch intent's
`args` extra as argv). `mt_native_android_assets` supplies `native.vert.spv`,
`native.frag.spv` and `python27.zip` as APK assets.
The 40250 `Client` directory is not packaged. `./android/push-client.sh` copies it
to the app's `files/Client` (`SDL_GetPrefPath`) with `run-as`, so it needs the
debug-signed APK installed first. Without arguments the app runs against the
in-process fake server; for a real server:
When a device is attached it then installs the APK and runs
`./android/push-client.sh --locale zh` (details in `docs/ANDROID-TESTING.md`).
The 40250 `Client` directory is not packaged. `./android/push-client.sh`
(`android/sync_client.py`) syncs it into the app's `files/Client` (`SDL_GetPrefPath`)
with `run-as`, sending only the files changed since the last sync, so it needs the
debug-signed APK installed first. A launcher start opens the login screen of the server in
`MainActivity.DEFAULT_ARGS`; explicit args without `--live-server` run the in-process fake
server. To pick the server:
```sh
adb shell am start -n org.metin2port.client/.MainActivity \