From 1ee96b19cbe746defec40bc5a1958a3e960429c4 Mon Sep 17 00:00:00 2001 From: Hao Zheng Date: Tue, 7 Jan 2025 19:28:53 +0000 Subject: [PATCH] [JNI Example] call native in Java b/372559388 --- .../app/src/main/java/dev/cobalt/coat/StarboardBridge.java | 7 ++----- starboard/android/shared/android_main.cc | 5 ++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cobalt/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java b/cobalt/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java index 1c2ab30c339..2917b6e03e5 100644 --- a/cobalt/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java +++ b/cobalt/android/apk/app/src/main/java/dev/cobalt/coat/StarboardBridge.java @@ -131,13 +131,11 @@ public StarboardBridge( this.volumeStateReceiver = new VolumeStateReceiver(appContext); this.isAmatiDevice = appContext.getPackageManager().hasSystemFeature(AMATI_EXPERIENCE_FEATURE); - nativeApp = startNativeStarboard(); + nativeApp = StarboardBridgeJni.get().startNativeStarboard(); } private native boolean initJNI(); - private native long startNativeStarboard(); - private native void closeNativeStarboard(long nativeApp); @NativeMethods @@ -146,11 +144,10 @@ interface Natives { long currentMonotonicTime(); + long startNativeStarboard(); // TODO(cobalt, b/372559388): move below native methods to the Natives interface. // boolean initJNI(); - // long startNativeStarboard(); - // void closeNativeStarboard(long nativeApp); } diff --git a/starboard/android/shared/android_main.cc b/starboard/android/shared/android_main.cc index 1a42ab2c65e..17cbd5535c6 100644 --- a/starboard/android/shared/android_main.cc +++ b/starboard/android/shared/android_main.cc @@ -36,6 +36,9 @@ #include "starboard/crashpad_wrapper/wrapper.h" // nogncheck #endif +// Must come after all headers that specialize FromJniType() / ToJniType(). +#include "cobalt/android/jni_headers/StarboardBridge_jni.h" + namespace starboard { namespace android { namespace shared { @@ -279,7 +282,7 @@ extern "C" SB_EXPORT_PLATFORM void Java_dev_cobalt_coat_StarboardBridge_initJNI( } extern "C" SB_EXPORT_PLATFORM jlong -Java_dev_cobalt_coat_StarboardBridge_startNativeStarboard(JniEnvExt* env) { +JNI_StarboardBridge_StartNativeStarboard(JNIEnv* env) { #if SB_IS(EVERGREEN_COMPATIBLE) StarboardThreadLaunch(); #else