ffi #jni_main R.5: retire legacy NativeActivity surface

Deletes the entire NativeActivity / native_app_glue / ALooper stack
that the previous Android entry path was built around:

  - `examples/99-android-egl-clear.sx` — the demo of the legacy path.
  - `library/modules/platform/android.sx` — `AndroidPlatform.init`,
    `run_frame_loop`, `sx_android_bootstrap`, `g_android_app`, plus
    the ALooper / AInputEvent / ANativeActivity / AConfiguration
    foreign decls that fed them. The JNI helpers (`sx_load_javavm_fn`,
    `sx_android_get_env`, `sx_query_safe_insets_jni`, the
    `ANATIVEACTIVITY_*` offsets) were tied to the ANativeActivity*
    delivered to `android_main` — they're stale now that the OS hands
    sx code a Java Activity directly via `onCreate(JNIEnv*, jobject)`.
  - `library/vendors/sx_android_jni/sx_android_jni.c` — the input-
    handler installer (`sx_android_install_input_handler`), which
    poked NDK app-pointer field offsets that no longer exist.

`library/modules/platform/android_jni.sx` (the `Activity`/`Window`/
`View`/`WindowInsets` `#jni_class` registry used for safe-insets
dispatch) survives — it's standalone declarative bindings useful from
any `#jni_main` onCreate body. Docstring updated to drop the
"imported from android.sx" framing.

131 host / 4 cross / zig build test all green. End-to-end smoke APK
still produces the expected JNI-mangled symbol +
SxApp-extends-Activity dex.

External consumers (chess) will need to migrate their entry from the
`AndroidPlatform.run_frame_loop` model to the `#jni_main` model
(Java-side Activity drives lifecycle; onSurfaceChanged / Choreographer
drive frames via JNI callbacks). That migration is downstream work.
This commit is contained in:
agra
2026-05-20 15:17:24 +03:00
parent 3300bfb0df
commit 619d524bac
5 changed files with 10 additions and 737 deletions

View File

@@ -1,34 +0,0 @@
// JNI helpers used by modules/platform/android.sx. Kept in the library
// so consumers don't need to vendor an identically-named copy. The sx
// compiler resolves `#source "vendors/..."` against the stdlib search
// paths in addition to the consumer's project root.
//
// The safe-insets JNI chain that used to live here was migrated to
// sx in Phase 1D of the FFI plan (see `library/modules/platform/
// android.sx::sx_query_safe_insets_jni` and the JavaVM helpers
// alongside it). What remains is the input-handler installer, which
// is a plain C struct-field assignment rather than JNI dispatch and
// has no sx equivalent yet.
#ifdef __ANDROID__
#include <android/input.h>
// Mirror of struct android_app (NDK 29 / arm64) up to the fields we touch.
// Avoids depending on the glue header in the sx library compile path.
struct sx_android_app_min {
void* userData;
void (*onAppCmd)(struct sx_android_app_min* app, int cmd);
int (*onInputEvent)(struct sx_android_app_min* app, AInputEvent* event);
// ...rest of struct ignored; we only assign onInputEvent.
};
// Install an sx-side handler as `app->onInputEvent`. native_app_glue's
// process_input loop calls this for every AInputEvent it pulls off the
// input queue. Returning 1 marks the event as consumed.
void sx_android_install_input_handler(void* app,
int (*handler)(void* app, void* event)) {
if (app == 0) return;
struct sx_android_app_min* a = (struct sx_android_app_min*)app;
a->onInputEvent = (int (*)(struct sx_android_app_min*, AInputEvent*))handler;
}
#endif