WebRTC: Finish setting up for the migration to JNI Zero's DEFINE_JNI() JNI Zero is launching a new feature that requires all .cc files to add a macro call DEFINE_JNI(JavaClassName). This CL does two things: 1. Add DEFINE_JNI() to two files in the examples directory. I missed these two files in my previous CL https://webrtc-review.googlesource.com/c/src/+/489720 2. Stop using @JniType in NativeTestWebrtc.java. This is the only usage of @JniType in WebRTC, and stop using @JniType in WebRTC would make the migration a lot easier. To be clear, the @JniType syntax is still fully supported, and you can feel free to use it once we finish the migration. But for the purpose of this migration, getting rid of the only usage of it would make the migration a lot easier, hence we converted it to an equivalent, but more verbose, syntax. Bug: chromium:481689330 Change-Id: Ia2a67c12580f449ab05289216ff09fabbda0c7e5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/490900 Commit-Queue: Martin Kong <martinkong@google.com> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#48226}
diff --git a/examples/androidnativeapi/jni/android_call_client.cc b/examples/androidnativeapi/jni/android_call_client.cc index b81d159..8933f87 100644 --- a/examples/androidnativeapi/jni/android_call_client.cc +++ b/examples/androidnativeapi/jni/android_call_client.cc
@@ -307,3 +307,5 @@ } } // namespace webrtc_examples + +DEFINE_JNI(CallClient)
diff --git a/examples/androidvoip/jni/android_voip_client.cc b/examples/androidvoip/jni/android_voip_client.cc index 53489da..5854e76 100644 --- a/examples/androidvoip/jni/android_voip_client.cc +++ b/examples/androidvoip/jni/android_voip_client.cc
@@ -566,3 +566,5 @@ } } // namespace webrtc_examples + +DEFINE_JNI(VoipClient)
diff --git a/test/android/native_test_launcher.cc b/test/android/native_test_launcher.cc index 9f79341..3407e99 100644 --- a/test/android/native_test_launcher.cc +++ b/test/android/native_test_launcher.cc
@@ -60,11 +60,19 @@ } // namespace -static void JNI_NativeTestWebrtc_RunTests(JNIEnv* env, - std::string& command_line_flags, - std::string& command_line_file_path, - std::string& stdout_file_path, - std::string& test_data_dir) { +static void JNI_NativeTestWebrtc_RunTests( + JNIEnv* env, + const jni_zero::JavaRef<jstring>& jcommand_line_flags, + const jni_zero::JavaRef<jstring>& jcommand_line_file_path, + const jni_zero::JavaRef<jstring>& jstdout_file_path, + const jni_zero::JavaRef<jstring>& jtest_data_dir) { + std::string command_line_flags = + jcommand_line_flags.ConvertTo<std::string>(env); + std::string command_line_file_path = + jcommand_line_file_path.ConvertTo<std::string>(env); + std::string stdout_file_path = jstdout_file_path.ConvertTo<std::string>(env); + std::string test_data_dir = jtest_data_dir.ConvertTo<std::string>(env); + AndroidLog( ANDROID_LOG_INFO, "Entering JNI_NativeTestWebrtc_RunTests with command_line_flags=%s, "
diff --git a/test/android/org/webrtc/native_test/NativeTestWebrtc.java b/test/android/org/webrtc/native_test/NativeTestWebrtc.java index 60cb538..4486052 100644 --- a/test/android/org/webrtc/native_test/NativeTestWebrtc.java +++ b/test/android/org/webrtc/native_test/NativeTestWebrtc.java
@@ -203,9 +203,9 @@ @NativeMethods interface Natives { void runTests( - @JniType("std::string") String commandLineFlags, - @JniType("std::string") String commandLineFilePath, - @JniType("std::string") String stdoutFilePath, - @JniType("std::string") String testDataDir); + String commandLineFlags, + String commandLineFilePath, + String stdoutFilePath, + String testDataDir); } }