From 7212994a5ff637576847aec272eff3ef53e4444b Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 27 Mar 2025 01:17:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=92=8C=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/MicroPhoto.cpp | 21 ++++++++++++++++++--- app/src/main/cpp/PhoneDevice.cpp | 2 +- app/src/main/cpp/netcamera/YuShiCtrl.cpp | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) 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; }