ffi #jni_main R.1: manifest synthesis + default parent → android.app.Activity

When `Compilation.lowering_jni_main_decls` is non-empty, `createApk`
synthesises a manifest whose `<activity android:name>` points at the
user's `#jni_main` class (dotted form of the foreign path), sets
`android:hasCode="true"` so Android loads the bundled classes.dex, and
drops the `android.app.lib_name` meta-data (that's the NativeActivity-
specific autoload mechanism — Java-driven Activities load the .so via
`System.loadLibrary` from a Java static initializer slice R.3 will
emit). The legacy NativeActivity path stays as the fallback when no
`#jni_main` decl is present.

`jni_java_emit.zig`'s default superclass moves from
`android.app.NativeActivity` to `android.app.Activity` — the former
requires native_app_glue's `ANativeActivity_onCreate` to be in the .so,
which the next slice (R.2) will stop linking by default.

Verified end-to-end on the slice 2 smoke APK: `aapt2 dump xmltree`
shows `android:name="co.swipelab.sxjnimain.SxApp"` + `hasCode="true"`,
and `dexdump -l plain` confirms SxApp now extends `Landroid/app/Activity;`.
99-android-egl-clear's APK still uses the NativeActivity manifest as
before (legacy path intact for R.2-R.5).
This commit is contained in:
agra
2026-05-20 14:55:26 +03:00
parent 5648337749
commit 8ae4e0c653
3 changed files with 51 additions and 5 deletions

View File

@@ -50,7 +50,7 @@ test "rejects non-main decl" {
try std.testing.expectError(emit.EmitError.NotAJniMainClass, result);
}
test "void onCreate(Bundle) with #extends NativeActivity default" {
test "void onCreate(Bundle) with default Activity superclass" {
const a = std.testing.allocator;
var arena = std.heap.ArenaAllocator.init(a);
defer arena.deinit();
@@ -85,7 +85,7 @@ test "void onCreate(Bundle) with #extends NativeActivity default" {
const expected =
\\package co.swipelab.sx_runtime;
\\
\\public class SxNativeActivity extends android.app.NativeActivity {
\\public class SxNativeActivity extends android.app.Activity {
\\ @Override
\\ public void onCreate(android.os.Bundle b) {
\\ super.onCreate(b);