Files
sx/library/modules/platform/android_jni.sx
agra 619d524bac 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.
2026-05-20 15:17:24 +03:00

32 lines
1.4 KiB
Plaintext

// Declarative JNI class bindings for the standard Android system-bar
// inset chain (`Activity.getWindow → Window.getDecorView → View
// .getRootWindowInsets → WindowInsets.getSystemWindowInset{Top,Left,
// Bottom,Right}`). Intended to be imported under a named namespace
// (e.g. `Jni :: #import "library/modules/platform/android_jni.sx"`) so
// the bare class names don't pollute the top-level namespace —
// `View` in particular collides with `modules/ui/view.sx`'s protocol.
// Inside the namespace these are referenced as `Jni.Activity`,
// `Jni.Window`, etc. The compiler registers the decls both qualified
// and bare in `foreign_class_map`, so cross-class refs in method
// signatures (`getWindow :: (self: *Self) -> *Window`) still resolve
// against the bare name within the namespace.
WindowInsets :: #foreign #jni_class("android/view/WindowInsets") {
getSystemWindowInsetTop :: (self: *Self) -> s32;
getSystemWindowInsetLeft :: (self: *Self) -> s32;
getSystemWindowInsetBottom :: (self: *Self) -> s32;
getSystemWindowInsetRight :: (self: *Self) -> s32;
}
View :: #foreign #jni_class("android/view/View") {
getRootWindowInsets :: (self: *Self) -> *WindowInsets;
}
Window :: #foreign #jni_class("android/view/Window") {
getDecorView :: (self: *Self) -> *View;
}
Activity :: #foreign #jni_class("android/app/Activity") {
getWindow :: (self: *Self) -> *Window;
}