From b98224fe56ead2b92f0cc41fe24e4c77d1188dff Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期一, 30 十二月 2019 18:11:25 +0800 Subject: [PATCH] 修改speaker --- lib/src/main/cpp/native-lib.h | 2 +- lib/src/main/cpp/native-lib.cpp | 38 +++----------------------------------- lib/src/main/java/com/anyun/exam/lib/RemoteService.java | 6 ++++++ 3 files changed, 10 insertions(+), 36 deletions(-) diff --git a/lib/src/main/cpp/native-lib.cpp b/lib/src/main/cpp/native-lib.cpp index 85f60cf..b910b1b 100644 --- a/lib/src/main/cpp/native-lib.cpp +++ b/lib/src/main/cpp/native-lib.cpp @@ -326,7 +326,7 @@ void TextOsd(int type, const char *text) { - JNIEnv *env; +/* JNIEnv *env; bool ready_in_java_env = false; if (sg_jvm->GetEnv((void **)&env, JNI_VERSION_1_6) != JNI_OK) { @@ -351,7 +351,7 @@ if (sg_jvm->DetachCurrentThread() != JNI_OK) { LOGE("%s: DetachCurrentThread() failed", __FUNCTION__); } - } + }*/ } void DrawScreen(const Polygon *map, const Polygon *car) @@ -412,44 +412,12 @@ DEBUG("DisplayText: %s", string); } -void CCL(int who) -{ - JNIEnv *env; - bool ready_in_java_env = false; - static int c[2] = {0}; - - if (sg_jvm->GetEnv((void **)&env, JNI_VERSION_1_6) != JNI_OK) { - // Attach涓荤嚎绋� - if (sg_jvm->AttachCurrentThread(&env, NULL) != JNI_OK) { - LOGE("%s: AttachCurrentThread() failed", __FUNCTION__); - return; - } - } else { - ready_in_java_env = true; - } - - jclass cls = env->GetObjectClass(sg_obj); - jmethodID fun = env->GetMethodID(cls, "CCL", "(II)V"); - - env->CallVoidMethod(sg_obj, fun, c[who], who); - - c[who] = !c[who]; - - env->DeleteLocalRef(cls); - - if (!ready_in_java_env) { - //Detach涓荤嚎绋� - if (sg_jvm->DetachCurrentThread() != JNI_OK) { - LOGE("%s: DetachCurrentThread() failed", __FUNCTION__); - } - } -} - extern "C" JNIEXPORT void JNICALL Java_com_anyun_exam_lib_RemoteService_startNative(JNIEnv *env, jobject thiz) { // TODO: implement startNative() // 淇濆瓨鍏ㄥ眬JVM浠ヤ究鍦ㄥ瓙绾跨▼涓娇鐢� + DEBUG("鍚姩Native"); env->GetJavaVM(&sg_jvm); // 涓嶈兘鐩存帴璧嬪��(g_obj = ojb) sg_obj = env->NewGlobalRef(thiz); diff --git a/lib/src/main/cpp/native-lib.h b/lib/src/main/cpp/native-lib.h index 578dbf9..2144b1c 100644 --- a/lib/src/main/cpp/native-lib.h +++ b/lib/src/main/cpp/native-lib.h @@ -22,7 +22,7 @@ void TextSpeak(const char *text); void TextOsd(int type, const char *text); void DrawScreen(const Polygon *map, const Polygon *car); -void CCL(int who); + void DisplayText(const char *string); #endif //RTKBASESTATION_NATIVE_LIB_H diff --git a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java index 57565de..af461da 100644 --- a/lib/src/main/java/com/anyun/exam/lib/RemoteService.java +++ b/lib/src/main/java/com/anyun/exam/lib/RemoteService.java @@ -162,6 +162,12 @@ return sharedPreferences.getInt(key, 0); } + public void TextSpeak(String text) { +/* if (speaker != null) { + speaker.speak(text); + }*/ + } + // Used to load the 'native-lib' library on application startup. static { System.loadLibrary("native-lib"); -- Gitblit v1.8.0