Skip to content

Commit

Permalink
[JNI Example] call native in Java
Browse files Browse the repository at this point in the history
b/372559388
  • Loading branch information
haozheng-cobalt committed Jan 8, 2025
1 parent cbd0f25 commit 1ee96b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down
5 changes: 4 additions & 1 deletion starboard/android/shared/android_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1ee96b1

Please sign in to comment.