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}")
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
## 现状
|
||||
|
||||
- `android/build.sh` 可以编出 arm64 调试 APK(SDL3 + FreeType 自动编译,16 KB 页对齐),连接手机时自动安装启动;真机运行尚未验证。
|
||||
- `android/push_assets.py` 把资源(`assets/loose` + python-root + `python27.zip`)推送到应用外部存储目录,客户端启动时切换到该目录。
|
||||
- `android/push_assets.py` 把资源(`assets/loose`,其上叠加按打包清单生成的 `build/dev/test-rundir`,同名文件以 pack 版本为准;再叠加 python-root 和 `python27.zip`)推送到应用外部存储目录,客户端启动时切换到该目录。
|
||||
- 游戏资源为 2.8 GB、约 5 万个散文件(`assets/loose`),17 个源文件中 120 多处通过 `std::filesystem` / `ifstream` 直接读文件,无法读取 APK 内置资源。
|
||||
- 平台层已实现(`src/app/platform/`):资源根目录与配置目录;前后台切换(进后台时保存配置、暂停声音、取消输入、停止渲染,网络照常收发;Android 设 `SDL_ANDROID_BLOCK_ON_PAUSE=0`);安全区域按逻辑分辨率换算后放进触摸布局,HUD 用 `touch.GetSafeArea()` 内缩。低内存事件目前只记日志;均未真机验证。
|
||||
- 触摸分流已实现(`src/app/input/touch_router.*`,见下文 `input/`):移动端或 `--touch` / `AVA2_TOUCH=1` 时关闭 SDL 触摸转鼠标,每个手指分到界面、攻击键、左下浮动摇杆或镜头(单指拖动转向、双指缩放、轻点=点地移动)。Python 模块 `touch` 供 HUD 设置攻击键位置并读取摇杆状态;`ui_mobile_joystick` / `ui_mobile_combat` 改为只做显示(`not_pick`)。多指同时操作尚未在真机验证。
|
||||
|
||||
@@ -1495,3 +1495,55 @@ Outstanding:
|
||||
- A button's zero-size TextLine sits at the button's exact centre pixel,
|
||||
and IsIn is inclusive, as in the original. Only that one pixel misses
|
||||
the button.
|
||||
|
||||
### 2026-10-13 Android device verification
|
||||
|
||||
Device: OnePlus PJZ110 (Android 17), 2376x1080 at density 3.00, giving a 1320x600 logical UI.
|
||||
Safe area insets: 117/67/50/53.
|
||||
|
||||
Changes:
|
||||
- `Ava2Activity` (extends SDLActivity) passes the `args` intent extra as the command line,
|
||||
so a dev run can start in `--phase game --preview-data`. `android/build.sh` forwards
|
||||
`AVA2_ARGS`.
|
||||
- Startup crash: directories created by `adb push` were owned by `shell` with mode 2770,
|
||||
so the app uid could not stat `ymir work/pc/...gr2`. The uncaught std::filesystem
|
||||
exception ended main. `push_assets.py` now chmods what shell owns after the push. It
|
||||
skips files the app wrote itself (channel.inf, the cfg files), which shell cannot chmod.
|
||||
- Forced landscape: the window is resizable and had no `SDL_HINT_ORIENTATIONS`, so SDL
|
||||
requested FULL_USER. That overrode the manifest's `sensorLandscape`, and the game
|
||||
rendered letterboxed in portrait. Fixes:
|
||||
- app_loop sets the hint to `LandscapeLeft LandscapeRight` on Android and iOS.
|
||||
- `Ava2Activity.setOrientationBis` always requests SENSOR_LANDSCAPE.
|
||||
- Verified with the system rotation locked to portrait.
|
||||
- The mobile window is `SDL_WINDOW_FULLSCREEN` (immersive). Before this, the status bar
|
||||
drew over the HUD. Verified.
|
||||
- Wrong trees on the phone: about 1000 files exist in both `assets/loose` and the
|
||||
pack-manifest test-rundir with different content. Examples are the zone/b tree atlases
|
||||
(at half size), monster2/npc_pet models and pc effects. `assets/loose` was layered on
|
||||
top, which broke the SpeedTree UVs into flat green cards. The desktop client showed the
|
||||
same result in `build/android-data/root`. Fix: `push_assets.py` now stages
|
||||
`assets/loose` first and lets test-rundir (what the original client serves from its
|
||||
packs) win.
|
||||
- One `adb push --sync` over all ~98k files aborts in file_sync_client ("failed to read
|
||||
stat response"). push_assets.py now pushes batches of at most 20,000 files.
|
||||
|
||||
Verified on the device:
|
||||
- Game phase renders correctly on Vulkan.
|
||||
- Joystick moves the player.
|
||||
- The inventory opens from the HUD and closes with its X.
|
||||
- Login phase shows the server list.
|
||||
- 60 fps steady on the 60 Hz panel (SurfaceFlinger latency: 0 frames over 25 ms), with
|
||||
SoC sensors around 41 °C.
|
||||
|
||||
Environment notes:
|
||||
- A root-owned adb server on :5037 claims the phone, and launchd respawns it. Use the SDK
|
||||
adb (34.0.4) against it: a different client version restarts that server mid-push.
|
||||
|
||||
Outstanding:
|
||||
- Item gestures on the device: the preview inventory is empty, so pick/drag/double-tap/
|
||||
long-press were checked only in `ava2.inventory_touch`.
|
||||
- Real-server login: no isolated AVA2 server or account is available. The listed
|
||||
servers are not to be used.
|
||||
- A missing or unreadable model should fail that load, not throw out of main.
|
||||
- The `--preview-data` camera starts inside the tree canopy, so the player is hidden.
|
||||
- Thermals over a long session not yet measured.
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"""Copy the client root into the iOS app's Documents directory (development builds).
|
||||
|
||||
The .app holds code only; on iOS the client runs in its Documents directory and reads the same
|
||||
flattened client root as Android (test-rundir + assets/loose + upstream/python-root + python27.zip).
|
||||
flattened client root as Android (assets/loose + test-rundir + upstream/python-root + python27.zip).
|
||||
The tree is staged by android/push_assets.py --stage-only --lowercase into build/ios-data/root (all
|
||||
names ASCII lower-case: iOS file systems are case-sensitive and the client opens lower-cased
|
||||
paths), then:
|
||||
|
||||
@@ -377,6 +377,9 @@ ava2::app::AppLoop::Frame RunClient(ava2::app::AppLoop* loop, int argc, char** a
|
||||
bool mobile_ui = false;
|
||||
float phone_w = 0.0f, phone_h = 0.0f, phone_density = 1.0f;
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_IOS)
|
||||
// The game is landscape-only. Without this hint SDL requests FULL_USER for a resizable window
|
||||
// on Android, overriding the manifest's sensorLandscape (the HUD then letterboxes in portrait).
|
||||
SDL_SetHint(SDL_HINT_ORIENTATIONS, "LandscapeLeft LandscapeRight");
|
||||
mobile_ui = ava2::platform::QueryDisplay(&phone_w, &phone_h, &phone_density);
|
||||
#endif
|
||||
if (!phone_spec.empty()) {
|
||||
@@ -398,9 +401,14 @@ ava2::app::AppLoop::Frame RunClient(ava2::app::AppLoop* loop, int argc, char** a
|
||||
screen_width = int(ava2::CPythonSystem::Instance().GetWidth());
|
||||
screen_height = int(ava2::CPythonSystem::Instance().GetHeight());
|
||||
}
|
||||
#endif
|
||||
SDL_WindowFlags window_flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||
#if defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_IOS)
|
||||
// Immersive: hide the status and navigation bars, which otherwise draw over the HUD.
|
||||
window_flags |= SDL_WINDOW_FULLSCREEN;
|
||||
#endif
|
||||
std::unique_ptr<SDL_Window, decltype(&SDL_DestroyWindow)> window(
|
||||
SDL_CreateWindow("AVA2 — Metin2 Client", screen_width, screen_height, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY),
|
||||
SDL_CreateWindow("AVA2 — Metin2 Client", screen_width, screen_height, window_flags),
|
||||
SDL_DestroyWindow
|
||||
);
|
||||
if (!window) throw std::runtime_error(SDL_GetError());
|
||||
|
||||
Reference in New Issue
Block a user