Skip to content

Commit

Permalink
mobile: Create a JNI binding for Runtime::runtimeFeatureEnabled (#36011)
Browse files Browse the repository at this point in the history
This PR allows us to have a runtime guard check in the Android code.

Risk Level: low
Testing: n/a
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: mobile

Signed-off-by: Fredy Wijaya <[email protected]>
  • Loading branch information
fredyw authored Sep 7, 2024
1 parent 18cbe86 commit d3b3ef8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,9 @@ public static native long createBootstrap(
* href="https://c-ares.org/docs/ares_library_init_android.html">ares_library_init_android</a>.
*/
public static native void initCares(ConnectivityManager connectivityManager);

/**
* Returns true if the runtime feature is enabled.
*/
public static native boolean isRuntimeFeatureEnabled(String featureName);
}
8 changes: 8 additions & 0 deletions mobile/library/jni/jni_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ extern "C" JNIEXPORT void JNICALL Java_io_envoyproxy_envoymobile_engine_JniLibra
#endif
}

extern "C" JNIEXPORT jboolean JNICALL
Java_io_envoyproxy_envoymobile_engine_JniLibrary_runtimeFeatureEnabled(JNIEnv* env, jclass,
jstring feature_name) {
Envoy::JNI::JniHelper jni_helper(env);
return Envoy::Runtime::runtimeFeatureEnabled(
Envoy::JNI::javaStringToCppString(jni_helper, feature_name));
}

extern "C" JNIEXPORT jint JNICALL Java_io_envoyproxy_envoymobile_engine_JniLibrary_recordCounterInc(
JNIEnv* env,
jclass, // class
Expand Down

0 comments on commit d3b3ef8

Please sign in to comment.