From 6388002df2d690baeb71cb54ceefb18ce2d0025f Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 7 Apr 2025 21:21:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BD=91=E7=BB=9C=E6=8B=8D?= =?UTF-8?q?=E7=85=A7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index c23f8096..24989f19 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1451,9 +1451,7 @@ IDevice::timer_uid_t CPhoneDevice::RegisterTimer(unsigned int timerType, unsigne bool CPhoneDevice::UnregisterTimer(IDevice::timer_uid_t uid) { - timer_t timer = (timer_t)uid; - int res = timer_delete(timer); - + bool existed = false; m_devLocker.lock(); std::map::iterator it = mTimers.find(uid); if (it != mTimers.end()) @@ -1461,11 +1459,21 @@ bool CPhoneDevice::UnregisterTimer(IDevice::timer_uid_t uid) delete it->second; mTimers.erase(it); m_devLocker.unlock(); - return true; + existed = true; + } + else + { + m_devLocker.unlock(); } - m_devLocker.unlock(); - return false; + if (existed) + { + ALOGI("UnregisterTimer: %lld", uid); + timer_t timer = (timer_t)uid; + int res = timer_delete(timer); + } + + return existed; } uint64_t CPhoneDevice::RequestWakelock(uint64_t timeout) @@ -1693,6 +1701,7 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c // strcpy(netPhotoInfo.interface, "eth0"); std::vector img; + cv::Mat rgb; bool netCaptureResult = false; for (int idx = 0; idx < 64; idx++) @@ -1730,18 +1739,14 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c XYLOG(XYLOG_SEVERITY_INFO, "NetCapture Succeeded PHOTOID=%u Img Size=%u", localPhotoInfo.photoId, (uint32_t)img.size()); if(img.size() <= 1000) { - std::string hexStr; - const size_t maxBytes = 128; - for (size_t i = 0; i < std::min(img.size(), maxBytes); ++i) - { - char buf[3]; - snprintf(buf, sizeof(buf), "%02X", img[i]); - hexStr += buf; - hexStr += " "; - } + std::string hexStr = ByteArrayToString(&img[0], img.size()); XYLOG(XYLOG_SEVERITY_DEBUG,"Img Size<1000, img=%s", hexStr.c_str()); } - break; + rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR); + if (!rgb.empty()) + { + break; + } } std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } @@ -1749,11 +1754,6 @@ bool CPhoneDevice::TakePhotoWithNetCamera(IDevice::PHOTO_INFO& localPhotoInfo, c ethernetPowerCtrl.reset(); XYLOG(XYLOG_SEVERITY_DEBUG, "Ethernet Power OFF"); - cv::Mat rgb; - if (netCaptureResult && !img.empty()) - { - rgb = cv::imdecode(cv::Mat(img), cv::IMREAD_COLOR); - } if (!rgb.empty()) { time_t takingTime = ts; @@ -3723,7 +3723,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat mat) #endif textSize = ft2->getTextSize(it->text, fontSize, thickness, &baseline); - XYLOG(XYLOG_SEVERITY_DEBUG, "%s font Size=%d height: %d baseline=%d", it->text.c_str(), fontSize, textSize.height, baseline); + // XYLOG(XYLOG_SEVERITY_DEBUG, "%s font Size=%d height: %d baseline=%d", it->text.c_str(), fontSize, textSize.height, baseline); if (it->alignment == OSD_ALIGNMENT_TOP_LEFT) { @@ -4023,7 +4023,7 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vectorgetTextSize(it->text, fontSize, thickness, &baseline); - XYLOG(XYLOG_SEVERITY_DEBUG, "%s font Size=%d height: %d baseline=%d", it->text.c_str(), fontSize, textSize.height, baseline); + // XYLOG(XYLOG_SEVERITY_DEBUG, "%s font Size=%d height: %d baseline=%d", it->text.c_str(), fontSize, textSize.height, baseline); if (it->alignment == OSD_ALIGNMENT_TOP_LEFT) {