diff --git a/app/build.gradle b/app/build.gradle index 5fdec057..af9fd4c6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -40,7 +40,7 @@ android { // cppFlags '-std=c++17 -Wno-error=format-security' // arguments "-DANDROID_STL=c++_shared" arguments "-DNCNN_DISABLE_EXCEPTION=OFF", "-DTERM_CORE_ROOT=" + coreroot, "-DOpenCV_DIR=" + opencvsdk + "/sdk/native/jni", "-DHDRPLUS_ROOT=" + hdrplusroot, "-DNCNN_ROOT=" + ncnnroot - // abiFilters 'arm64-v8a', 'armeabi-v7a' + abiFilters 'arm64-v8a', 'armeabi-v7a' // setAbiFilters(['arm64-v8a']) } } diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 8032c26c..244f087b 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -694,19 +694,19 @@ bool CPhoneDevice::QuerySystemProperties(std::map& pro else if (it->first == PROP_MODEL) { __system_property_get("ro.product.model", value); - it->second = value; + it->second = std::string(value); } else if (it->first == PROP_BS_MANU) { __system_property_get("ro.product.manufacturer", value); - it->second = value; + it->second = std::string(value); } else if (it->first == PROP_VERSION) { // FOR Protocol snprintf(value, sizeof(value), "%u.%03u", (mVersionCode / 1000), (mVersionCode % 1000)); // __system_property_get("ro.build.version.release", value); - it->second = value; + it->second = std::string(value); } else if (it->first == (PROP_VERSION_ABBR)) { @@ -724,19 +724,19 @@ bool CPhoneDevice::QuerySystemProperties(std::map& pro else if (it->first == PROP_PROD_DATE) { __system_property_get("ro.build.date.utc", value); - it->second = value; + it->second = std::string(value); } else if (it->first == PROP_SN || it->first == PROP_BS_ID) { __system_property_get("ro.serialno", value); - it->second = value; + it->second = std::string(value); } else if (it->first == PROP_IMEI) { if (m_simcard.empty()) { __system_property_get("phone.imei", value); - it->second = value; + it->second = std::string(value); } else { @@ -756,9 +756,8 @@ bool CPhoneDevice::QuerySystemProperties(std::map& pro { fs::space_info si = fs::space("/data"); double fr = ((double)si.available * 100.0f) / ((double)si.capacity); - char buf[12] = { 0 }; - snprintf(buf, sizeof(buf), "%d%%", (int)fr); - it->second = buf; + snprintf(value, sizeof(value), "%d%%", (int)fr); + it->second = std::string(value); } else if (it->first == PROP_TOTAL_ROM) { @@ -774,9 +773,8 @@ bool CPhoneDevice::QuerySystemProperties(std::map& pro long fm = android_os_Process_getFreeMemory(); long tm = android_os_Process_getTotalMemory(); double fmp = ((double)fm * 100.0f) / ((double)tm); - char buf[12] = { 0 }; - snprintf(buf, sizeof(buf), "%d%%", (int)fmp); - it->second = buf; // Unit: M + snprintf(value, sizeof(value), "%d%%", (int)fmp); + it->second = std::string(value); // Unit: M } else if (it->first == PROP_TOTAL_MEMORY) { @@ -807,7 +805,7 @@ bool CPhoneDevice::QuerySystemProperties(std::map& pro continue; } snprintf(str, sizeof(str), "%.1f", (val / 1000.0)); - it->second = str; + it->second = std::string(str); break; } } @@ -821,9 +819,8 @@ bool CPhoneDevice::QuerySystemProperties(std::map& pro if (val > 0) { bv = val; - char str[32] = { 0 }; - snprintf(str, sizeof(str), "%.1f", val / 1000.0); - it->second = str; + snprintf(value, sizeof(value), "%.1f", val / 1000.0); + it->second = std::string(value); } else { @@ -865,7 +862,7 @@ bool CPhoneDevice::QuerySystemProperties(std::map& pro char str[32] = { 0 }; float batteryCurrent = STANDARD_CURRENT_64V / ((float)bv / 1000.0f / STANDARD_VOLTAGE_64V); snprintf(str, sizeof(str), "%d", (int)batteryCurrent); - it->second = str; + it->second = std::string(str); } } // __system_property_get("ro.telephony.default_network", value); @@ -1515,7 +1512,9 @@ void DrawOutlineText(cv::Ptr ft2, cv::Mat& mat, const std::st } } -bool CPhoneDevice::onBurstCapture(std::shared_ptr characteristics, std::vector >& results, uint32_t ldr, std::vector >& frames) +bool CPhoneDevice::onBurstCapture(std::shared_ptr characteristics, + std::vector >& results, + uint32_t ldr, std::vector >& frames) { time_t takingTime = time(NULL); if (mPhotoInfo.remedy != 0) @@ -1533,7 +1532,7 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr characteristi std::string path; path.swap(mPath); - std::string tmpPath = m_appPath + (APP_DIR_TMP DIR_SEP_STR) + std::to_string(photoInfo.photoId); + std::string tmpPath = m_appPath + std::string(APP_DIR_TMP DIR_SEP_STR) + std::to_string(photoInfo.photoId); acamera_metadata_enum_android_lens_facing_t facing = ACAMERA_LENS_FACING_FRONT; ACameraMetadata_const_entry e = { 0 }; @@ -1583,11 +1582,11 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr characteristi media_status_t status = AImage_getNumberOfPlanes(spImage.get(), &planeCount); AASSERT(status == AMEDIA_OK && planeCount == 1, "Error: getNumberOfPlanes() planeCount = %d", planeCount); - uint8_t *data = nullptr; - int len = 0; - mstatus = AImage_getPlaneData(spImage.get(), 0, &data, &len); + uint8_t *planeData = NULL; + int planeDataLen = 0; + mstatus = AImage_getPlaneData(spImage.get(), 0, &planeData, &planeDataLen); DngCreator dngCreator(characteristics.get(), result.get()); - dngCreator.writeInputBuffer(*it, data, len, width, height, 0); + dngCreator.writeInputBuffer(*it, planeData, planeDataLen, width, height, 0); } } else @@ -1617,7 +1616,7 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr characteristi } int32_t format; - media_status_t mstatus = AImage_getFormat(frame.get(), &format); + mstatus = AImage_getFormat(frame.get(), &format); if (format == AIMAGE_FORMAT_YUV_420_888) { @@ -1759,7 +1758,7 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr characteristi std::vector rawFilePaths; for (auto it = rawFiles.cbegin(); it != rawFiles.cend(); ++it) { - std::string dngFilePath = tmpPath + "-" + std::to_string(std::distance(rawFiles.cbegin(), it)) + ".dng"; + std::string dngFilePath = tmpPath + std::string("-") + std::to_string(std::distance(rawFiles.cbegin(), it)) + std::string(".dng"); #ifdef _DEBUG char log[256] = { 0 }; strcpy(log, dngFilePath.c_str()); @@ -1768,7 +1767,7 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr characteristi if (file) { if (!(*it).empty()) { - fwrite(&((*it)[0]), 1, (*it).size(), file); + fwrite((const void*)(&((*it)[0])), 1, (*it).size(), file); } fclose(file); rawFilePaths.push_back(dngFilePath); @@ -1781,7 +1780,7 @@ bool CPhoneDevice::onBurstCapture(std::shared_ptr characteristi XYLOG(XYLOG_SEVERITY_ERROR, "Finish HDR CH=%u IMGID=%u", (uint32_t)mPhotoInfo.channel, (uint32_t)mPhotoInfo.photoId); #ifdef NDEBUG - for (auto it = rawFilePaths.cbegin(); it != rawFiles.cend(); ++it) + for (auto it = rawFilePaths.cbegin(); it != rawFilePaths.cend(); ++it) { std::remove((*it).c_str()); } diff --git a/app/src/main/cpp/camera2/ndkcamera.cpp b/app/src/main/cpp/camera2/ndkcamera.cpp index 098ed6a1..2238be2c 100644 --- a/app/src/main/cpp/camera2/ndkcamera.cpp +++ b/app/src/main/cpp/camera2/ndkcamera.cpp @@ -1316,7 +1316,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque for (int idx = 1; idx < mCaptureRequests.size(); idx++) { - CopyPreviewRequest(mCaptureRequests[idx]->request, result); + // CopyPreviewRequest(mCaptureRequests[idx]->request, result); requests.push_back(mCaptureRequests[idx]->request); }