diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index 1103db69..abcfd73f 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -171,10 +171,26 @@ void Runner::RequestCapture(CTerminal* pTerminal, unsigned int channel, unsigned pTerminal->RequestCapture(channel, preset, type, scheduleTime); } +#include +#include + +#if 0 +void sighandler(int sig) { + __android_log_print(ANDROID_LOG_ERROR, "NativeCrash", "Caught signal %d", sig); + + exit(1); +} +#endif + jint JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEnv* env = NULL; jint result = -1; + + // 在 JNI_OnLoad 或其他初始化函数中注册 +#if 0 + signal(SIGSEGV, sighandler); +#endif #if defined(JNI_VERSION_1_6) if (result==-1 && vm->GetEnv((void**)&env, JNI_VERSION_1_6) == JNI_OK) @@ -983,9 +999,8 @@ Java_com_xypower_mpapp_MicroPhotoService_infoLog( return; } - const char *msgStr = env->GetStringUTFChars(msg, 0); - XYLOG(XYLOG_SEVERITY_INFO, msgStr); - env->ReleaseStringUTFChars(msg, msgStr); + std::string str = jstring2string(env, msg); + XYLOG(XYLOG_SEVERITY_INFO, str.c_str()); } extern "C" JNIEXPORT jboolean JNICALL diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index a0486d9d..a8775892 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1846,7 +1846,7 @@ bool CPhoneDevice::TakeVideoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c { TakePhotoCb(0, localPhotoInfo, "", 0); XYLOG(XYLOG_SEVERITY_ERROR, "Failed to TP on NET Camera CH=%u PR=%X PHOTOID=%u URL=%s", (uint32_t)localPhotoInfo.channel, (uint32_t)localPhotoInfo.preset, - localPhotoInfo.photoId, ip, streamingUrl.c_str()); + localPhotoInfo.photoId, ip.c_str(), streamingUrl.c_str()); } // Notify to take next photo // TakePhotoCb(1, localPhotoInfo, "", takingTime); diff --git a/app/src/main/cpp/netcamera/YuShiCtrl.cpp b/app/src/main/cpp/netcamera/YuShiCtrl.cpp index 93bd2bdb..1943300d 100644 --- a/app/src/main/cpp/netcamera/YuShiCtrl.cpp +++ b/app/src/main/cpp/netcamera/YuShiCtrl.cpp @@ -62,7 +62,7 @@ void YuShiCtrl::EnableOsd(bool enable, uint8_t channel) std::istringstream s(jsonString); if (!Json::parseFromStream(reader, s, &root, &errors)) { - XYLOG(XYLOG_SEVERITY_ERROR,"Failed to parse JSON:%s", errors); + XYLOG(XYLOG_SEVERITY_ERROR, "Failed to parse JSON:%s", errors.c_str()); return; }