Android device verification: forced landscape, fullscreen, data layering
- Ava2Activity passes the "args" intent extra as the command line (build.sh forwards AVA2_ARGS); it also always requests sensor landscape. - app_loop sets SDL_HINT_ORIENTATIONS to landscape and creates the window fullscreen on Android/iOS (SDL requested FULL_USER for the resizable window, overriding the manifest; the status bar drew over the HUD). - push_assets.py: pack-manifest test-rundir now wins over assets/loose (~1000 differing files; half-size tree atlases broke SpeedTree UVs), pushes in batches of <=20k files, and chmods shell-owned files so the app can read them on Android 17. - PORT-PLAN: device verification results and outstanding gaps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6244b1d860
commit
8f96e7a143
+12
-2
@@ -25,6 +25,9 @@ APK compiles C++ as RelWithDebInfo; a Debug build is too slow to judge frame rat
|
||||
|
||||
Overrides: `ANDROID_HOME`, `ANDROID_NDK_HOME`, `JAVA_HOME`, `AVA2_SDK_ROOT`, `AVA2_SOURCE_DIR`
|
||||
(CMake source tree to build instead of this checkout), `ADB_SERIAL`.
|
||||
`AVA2_ARGS` passes client arguments to the launch (`Ava2Activity` reads the `args` intent
|
||||
extra), e.g. `AVA2_ARGS="--phase game --preview-data" android/build.sh`, or by hand:
|
||||
`adb shell "am start -n com.metin2.ava2/.Ava2Activity --es args '--phase game --preview-data'"`.
|
||||
|
||||
Android Studio can open this directory after `android/build.sh deps` has run once.
|
||||
|
||||
@@ -34,13 +37,20 @@ Android Studio can open this directory after `android/build.sh deps` has run onc
|
||||
android/push_assets.py # after android/build.sh, with the phone attached
|
||||
```
|
||||
|
||||
Stages `assets/loose` + `upstream/python-root` (scripts win) + `python27.zip` as hard links in
|
||||
Stages `assets/loose`, then `build/dev/test-rundir` (the pack-manifest root from
|
||||
`tools/make_test_rundir.py`; its pack files win), then `upstream/python-root` (scripts win) and
|
||||
`python27.zip` as hard links in
|
||||
`build/android-data/root` and sends them with `adb push --sync` to
|
||||
`/sdcard/Android/data/com.metin2.ava2/files`, where the client starts. The first push moves
|
||||
about 2.9 GB; later pushes only send changed files. The three `assets/loose` symlinks into the
|
||||
about 4 GB; later pushes only send changed files. The three `assets/loose` symlinks into the
|
||||
decoded pack_maker tree are remapped to `--pack-maker` (default `../AVA2/TEST/1. Client DEV/pack_maker`).
|
||||
Uninstalling the app deletes this directory.
|
||||
|
||||
On Android 17 (OnePlus PJZ110) the directories `adb push` creates are `shell`-owned with mode
|
||||
2770, so the app cannot enter them and the first model load dies with `posix_stat ... Permission
|
||||
denied`. push_assets.py therefore runs `chmod` over the pushed tree afterwards (directories 2777,
|
||||
files 666).
|
||||
|
||||
Running the desktop client inside `build/android-data/root` exercises the same flattened layout.
|
||||
|
||||
Logs: `adb logcat -s SDL SDL/APP AndroidRuntime DEBUG`.
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
android:hardwareAccelerated="true">
|
||||
|
||||
<activity
|
||||
android:name="org.libsdl.app.SDLActivity"
|
||||
android:name="com.metin2.ava2.Ava2Activity"
|
||||
android:label="@string/app_name"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:launchMode="singleInstance"
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.metin2.ava2;
|
||||
|
||||
import android.content.pm.ActivityInfo;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
/**
|
||||
* SDLActivity with command-line arguments for development runs:
|
||||
* {@code adb shell "am start -n com.metin2.ava2/.Ava2Activity --es args '--phase game --preview-data'"}.
|
||||
* A normal launch (no extra) passes none, as before.
|
||||
*/
|
||||
public class Ava2Activity extends SDLActivity {
|
||||
@Override
|
||||
protected String[] getArguments() {
|
||||
String args = getIntent() != null ? getIntent().getStringExtra("args") : null;
|
||||
if (args == null || args.trim().isEmpty()) return new String[0];
|
||||
return args.trim().split("\\s+");
|
||||
}
|
||||
|
||||
/**
|
||||
* The game is landscape-only. SDL re-requests an orientation whenever a window is created or
|
||||
* resized (FULL_USER for a resizable window without SDL_HINT_ORIENTATIONS), which would override
|
||||
* the manifest's sensorLandscape; keep both landscape directions regardless of the hint.
|
||||
*/
|
||||
@Override
|
||||
public void setOrientationBis(int w, int h, boolean resizable, String hint) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -96,7 +96,8 @@ ADB="$ANDROID_HOME/platform-tools/adb"; command -v adb >/dev/null && ADB="$(comm
|
||||
[[ -n "${ADB_SERIAL:-}" ]] && ADB="$ADB -s $ADB_SERIAL"
|
||||
if $ADB get-state >/dev/null 2>&1; then
|
||||
$ADB install -r -d "$APK"
|
||||
$ADB shell am start -n com.metin2.ava2/org.libsdl.app.SDLActivity
|
||||
# AVA2_ARGS: client arguments for this launch (Ava2Activity), e.g. "--phase game --preview-data".
|
||||
$ADB shell "am start -n com.metin2.ava2/.Ava2Activity${AVA2_ARGS:+ --es args '$AVA2_ARGS'}"
|
||||
echo "Launched. Logs: $ADB logcat -s SDL SDL/APP AVA2 DEBUG AndroidRuntime"
|
||||
else
|
||||
echo "No device attached; APK not installed."
|
||||
|
||||
+46
-10
@@ -4,8 +4,11 @@
|
||||
The APK holds code only; on Android the client runs in its external files directory
|
||||
(/sdcard/Android/data/com.metin2.ava2/files) and reads the flattened client root from there:
|
||||
|
||||
0. build/dev/test-rundir the pack-manifest client root (tools/make_test_rundir.py)
|
||||
1. assets/loose the client-root asset tree
|
||||
0. assets/loose the client-root asset tree
|
||||
1. build/dev/test-rundir the pack-manifest client root (tools/make_test_rundir.py): what
|
||||
the original client serves from its packs, so it wins over the
|
||||
~1000 older models/textures assets/loose holds (zone/b tree
|
||||
atlases at half size broke the SpeedTree UVs on the phone)
|
||||
2. upstream/python-root scripts; win over same-named asset files (case-insensitive)
|
||||
3. <pack_maker>/../svside loose client-root folder that is in no pack
|
||||
4. python27.zip the embedded interpreter's stdlib
|
||||
@@ -110,6 +113,23 @@ def walk(top, pack_maker, missing):
|
||||
yield child, path
|
||||
|
||||
|
||||
PUSH_BATCH = 20000
|
||||
|
||||
|
||||
def count_files(path):
|
||||
return sum(len(files) for _, _, files in os.walk(path))
|
||||
|
||||
|
||||
def push_batches(stage, rel):
|
||||
"""Yields stage-relative paths (directories or files) of at most PUSH_BATCH files each."""
|
||||
path = stage / rel
|
||||
if not path.is_dir() or count_files(path) <= PUSH_BATCH:
|
||||
yield rel
|
||||
return
|
||||
for entry in sorted(path.iterdir()):
|
||||
yield from push_batches(stage, rel / entry.name)
|
||||
|
||||
|
||||
def adb(serial, *args, **kwargs):
|
||||
command = ["adb"] + (["-s", serial] if serial else []) + list(args)
|
||||
return subprocess.run(command, check=True, **kwargs)
|
||||
@@ -136,9 +156,11 @@ def main():
|
||||
shutil.rmtree(args.stage)
|
||||
args.stage.mkdir(parents=True)
|
||||
stage, missing = Stage(args.stage, args.lowercase), []
|
||||
# Base layer: the pack-manifest client root the desktop tests run against. assets/loose alone
|
||||
# lacks the pack files (Dopador_manual/*, the switcher art...) game.py needs, and a failed window
|
||||
# load there ends the game phase.
|
||||
for rel, path in walk(ROOT / "assets/loose", args.pack_maker, missing):
|
||||
stage.add(rel, path)
|
||||
# The pack-manifest client root the desktop tests run against, over assets/loose: assets/loose
|
||||
# alone lacks the pack files (Dopador_manual/*, the switcher art...) game.py needs, and where
|
||||
# both have a file the pack version is the one the original client loads.
|
||||
if args.rundir.is_dir():
|
||||
for rel, path in walk(args.rundir, args.pack_maker, missing):
|
||||
if rel.name != RUNDIR_MARKER:
|
||||
@@ -146,9 +168,8 @@ def main():
|
||||
else:
|
||||
print(f"warning: {args.rundir} not found (tools/make_test_rundir.py); the game phase will miss "
|
||||
"pack files", file=sys.stderr)
|
||||
for top in (ROOT / "assets/loose", ROOT / "upstream/python-root"):
|
||||
for rel, path in walk(top, args.pack_maker, missing):
|
||||
stage.add(rel, path)
|
||||
for rel, path in walk(ROOT / "upstream/python-root", args.pack_maker, missing):
|
||||
stage.add(rel, path)
|
||||
# Loose client-root folders that are in neither assets/loose nor any pack (same as
|
||||
# tools/make_test_rundir.py); svsideoi.py, built by game.py, needs svside/*.jpg.
|
||||
for name in LOOSE_DIRS:
|
||||
@@ -167,8 +188,23 @@ def main():
|
||||
return
|
||||
|
||||
adb(args.serial, "shell", "mkdir", "-p", DEVICE_DIR)
|
||||
# Trailing "/." pushes the directory's contents rather than the directory itself.
|
||||
adb(args.serial, "push", "--sync", f"{args.stage}/.", DEVICE_DIR)
|
||||
# One `adb push --sync` over all ~98k files aborts in file_sync_client ("protocol fault: failed
|
||||
# to read stat response"), so push in batches of at most PUSH_BATCH files.
|
||||
for rel in push_batches(args.stage, Path()):
|
||||
source, target = args.stage / rel, f"{DEVICE_DIR}/{rel.as_posix()}" if rel.parts else DEVICE_DIR
|
||||
if source.is_dir():
|
||||
adb(args.serial, "shell", "mkdir", "-p", f"'{target}'")
|
||||
# Trailing "/." pushes the directory's contents rather than the directory itself.
|
||||
adb(args.serial, "push", "--sync", f"{source}/.", target)
|
||||
else:
|
||||
adb(args.serial, "push", "--sync", str(source), target)
|
||||
# Recent Android versions (seen on Android 17) leave what adb creates under Android/data owned
|
||||
# by `shell` with 2770 directories, which the app's uid cannot enter ("Permission denied" on
|
||||
# the first model load). Open up what adb created; files the app wrote itself (channel.inf,
|
||||
# the cfg files) and the files directory belong to the app and cannot be chmodded by shell.
|
||||
adb(args.serial, "shell",
|
||||
f"find '{DEVICE_DIR}' -mindepth 1 -user shell -type d ! -perm -005 -exec chmod 2777 {{}} + ; "
|
||||
f"find '{DEVICE_DIR}' -user shell -type f ! -perm -004 -exec chmod 666 {{}} +")
|
||||
print(f"pushed to {DEVICE_DIR}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user