From 683b1595260e638d1d3c6cc0d6543a72f6d6f925 Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期二, 12 一月 2021 14:36:42 +0800 Subject: [PATCH] 扣分码标准化 --- lib/src/main/cpp/native-lib.cpp | 32 +++++++++++--------------------- 1 files changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/src/main/cpp/native-lib.cpp b/lib/src/main/cpp/native-lib.cpp index f0d0390..49d9e4e 100644 --- a/lib/src/main/cpp/native-lib.cpp +++ b/lib/src/main/cpp/native-lib.cpp @@ -35,8 +35,6 @@ static int ttsSeq = 1; -static void SendBootIndicate(union sigval sig); - static std::map<int, void (*)(int)> TTSCallBack; int DESEncrypt(const uint8_t *key, int key_length, @@ -173,25 +171,26 @@ } } -void SendMsgToMainProc(int cmd, const char *value) +int SendMsgToMainProc(int cmd, const char *value) { JNIEnv *env; bool ready_in_java_env = false; + int ret; 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; + return -3; } } else { ready_in_java_env = true; } jclass cls = env->GetObjectClass(sg_obj); - jmethodID fun = env->GetMethodID(cls, "SendMsgToMainProc", "(ILjava/lang/String;)V"); + jmethodID fun = env->GetMethodID(cls, "SendMsgToMainProc", "(ILjava/lang/String;)I"); - env->CallVoidMethod(sg_obj, fun, cmd, value != NULL ? env->NewStringUTF(value) : NULL); + ret = env->CallIntMethod(sg_obj, fun, cmd, value != NULL ? env->NewStringUTF(value) : NULL); env->DeleteLocalRef(cls); @@ -201,6 +200,8 @@ LOGE("%s: DetachCurrentThread() failed", __FUNCTION__); } } + + return ret; } static int GetTtsSeq(void) @@ -384,7 +385,7 @@ extern "C" JNIEXPORT void JNICALL -Java_com_anyun_exam_lib_RemoteService_startNative(JNIEnv *env, jobject thiz) { +Java_com_anyun_exam_lib_RemoteService_startNative(JNIEnv *env, jobject thiz, jboolean ayDevice) { // TODO: implement startNative() // 淇濆瓨鍏ㄥ眬JVM浠ヤ究鍦ㄥ瓙绾跨▼涓娇鐢� DEBUG("鍚姩Native"); @@ -395,28 +396,17 @@ srand(time(NULL)); AppTimer_Init(); - ConfigMCU(); + ConfigMCU(ayDevice); DriverTestInit(); - ConfigRTKModule(); + ConfigRTKModule(ayDevice); MA_Init(); - InitPlatform(phone, RTK_PLATFORM_IP, RTK_PLATFORM_PORT); - AppTimer_add(SendBootIndicate, D_SEC(1)); + InitPlatform(ayDevice, phone, RTK_PLATFORM_IP, RTK_PLATFORM_PORT); InitVirtualDevice(VIRTUAL_RTK_IP, VIRTUAL_RTK_PORT); pthread_mutex_init(&tts_mutex, NULL); -} -static void SendBootIndicate(union sigval sig) { - static int n = 0; - AppTimer_delete(SendBootIndicate); MA_NdkStart(); - - n++; - - if (n < 3) { - AppTimer_add(SendBootIndicate, D_SEC(1)); - } } extern "C" -- Gitblit v1.8.0