Closes the Phase 1D migration for the safe-insets JNI chain. The C function and its `#foreign` declaration in `android.sx` are gone; all dispatch now goes through the sx-side `#jni_call` machinery plus the JavaVM helpers landed in 1.26. What's gone from `library/vendors/sx_android_jni/sx_android_jni.c`: - `#include <android/native_activity.h>` and `<jni.h>` (no longer needed without the JNI body). - `sx_android_query_safe_insets` — 55 lines of `(*env)->Foo` chain with manual `goto done` early-exit. Migrated to `library/modules/platform/android.sx::sx_query_safe_insets_jni` in 1.25 (15 lines of `#jni_call`). What stays: - `sx_android_install_input_handler` — non-JNI; struct-field assignment against `struct android_app`'s `onInputEvent` slot. No sx equivalent yet (would need to either land a `#android_app`- style intrinsic or hand-roll the offset, neither of which is Phase 1 scope). - `<android/input.h>` and the `struct sx_android_app_min` mirror needed by the input-handler installer. Net diff: -55 lines in the .c file, -1 line `#foreign` decl in android.sx. Phase 2 (declarative JNI imports) will revisit whether the .c file can be deleted entirely (the input-handler hop may move into a different shape). Verification: - zig build + zig test + run_examples + cross_compile all green. Notable: the previously-failing `ffi-objc-call-12-rect-u64-returns` also passes now — looks like the working-tree `#import c` work was tidied up alongside. - chess Android APK rebuilt + reinstalled + launched on Pixel device; safe-insets behavior unchanged (board top edge sits below the status bar correctly, all pieces in starting positions, no status-bar overlap).
35 lines
1.5 KiB
C
35 lines
1.5 KiB
C
// 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
|