From 5ad340ca9429b3e64eace20cd0639440f57096d5 Mon Sep 17 00:00:00 2001 From: caochuan Date: Tue, 26 Nov 2024 15:20:51 +0800 Subject: [PATCH] ptp1126 Signed-off-by: caochuan --- .../media_mtp/src/mtp_error_utils.cpp | 21 ++++++++++++++++--- .../src/mtp_medialibrary_manager.cpp | 5 +++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/frameworks/services/media_mtp/src/mtp_error_utils.cpp b/frameworks/services/media_mtp/src/mtp_error_utils.cpp index 8273fd162..65a0b1534 100755 --- a/frameworks/services/media_mtp/src/mtp_error_utils.cpp +++ b/frameworks/services/media_mtp/src/mtp_error_utils.cpp @@ -30,7 +30,12 @@ int32_t MtpErrorUtils::SolveGetHandlesError(const int32_t mediaError) { E_HAS_DB_ERROR, MTP_ERROR_STORE_NOT_AVAILABLE }, { E_NO_SUCH_FILE, MTP_ERROR_INVALID_OBJECTHANDLE }, }; - return getHandlesError.at(mediaError); + map::const_iterator iterator = getHandlesError.find(mediaError); + if (iterator != getHandlesError.end()) { + return getHandlesError.at(mediaError); + } else { + return MTP_ERROR_INVALID_OBJECTHANDLE; + } } int32_t MtpErrorUtils::SolveGetObjectInfoError(const int32_t mediaError) @@ -40,7 +45,12 @@ int32_t MtpErrorUtils::SolveGetObjectInfoError(const int32_t mediaError) { E_HAS_DB_ERROR, MTP_ERROR_STORE_NOT_AVAILABLE }, { E_NO_SUCH_FILE, MTP_ERROR_INVALID_OBJECTHANDLE }, }; - return getObjectInfoError.at(mediaError); + map::const_iterator iterator = getObjectInfoError.find(mediaError); + if (iterator != getObjectInfoError.end()) { + return getObjectInfoError.at(mediaError); + } else { + return MTP_ERROR_INVALID_OBJECTHANDLE; + } } int32_t MtpErrorUtils::SolveGetFdError(const int32_t mediaError) @@ -50,7 +60,12 @@ int32_t MtpErrorUtils::SolveGetFdError(const int32_t mediaError) { E_HAS_DB_ERROR, MTP_ERROR_STORE_NOT_AVAILABLE }, { E_HAS_FS_ERROR, MTP_ERROR_INVALID_OBJECTHANDLE }, }; - return getFdInfoError.at(mediaError); + map::const_iterator iterator = getFdInfoError.find(mediaError); + if (iterator != getFdInfoError.end()) { + return getFdInfoError.at(mediaError); + } else { + return MTP_ERROR_INVALID_OBJECTHANDLE; + } } int32_t MtpErrorUtils::SolveSendObjectInfoError(const int32_t mediaError) diff --git a/frameworks/services/media_mtp/src/mtp_medialibrary_manager.cpp b/frameworks/services/media_mtp/src/mtp_medialibrary_manager.cpp index a4ccfeb3d..0277aab2f 100644 --- a/frameworks/services/media_mtp/src/mtp_medialibrary_manager.cpp +++ b/frameworks/services/media_mtp/src/mtp_medialibrary_manager.cpp @@ -264,6 +264,9 @@ int32_t MtpMedialibraryManager::HaveMovingPhotesHandle(const shared_ptrGoToNextRow() == NativeRdb::E_OK) { int32_t id = GetInt32Val(MediaColumn::MEDIA_ID, resultSet); outHandles->push_back(id); + if (id < COMMON_PHOTOS_OFFSET) { + continue; + } int32_t subtype = GetInt32Val(PhotoColumn::PHOTO_SUBTYPE, resultSet); int32_t editTime = GetInt32Val(PhotoColumn::PHOTO_EDIT_TIME, resultSet); MEDIA_INFO_LOG("MtpMedialibraryManager::HaveMovingPhotesHandle subtype:%{public}d, editTime:%{public}d", @@ -791,6 +794,7 @@ int32_t MtpMedialibraryManager::SetObjectPropValue(const std::shared_ptr &context, int32_t fd) { + CHECK_AND_RETURN_RET_LOG(context != nullptr, MTP_ERROR_STORE_NOT_AVAILABLE, "context is nullptr"); MEDIA_INFO_LOG("CloseFd handle::%{public}u", context->handle); CHECK_AND_RETURN_RET_LOG(fd > 0, E_ERR, "wrong fd"); int errCode = close(fd); @@ -799,6 +803,7 @@ int32_t MtpMedialibraryManager::CloseFdForGet(const std::shared_ptr &context, int32_t fd) { + CHECK_AND_RETURN_RET_LOG(context != nullptr, MTP_ERROR_STORE_NOT_AVAILABLE, "context is nullptr"); MEDIA_INFO_LOG("CloseFd handle::%{public}u", context->handle); int32_t errCode = E_SUCCESS; CHECK_AND_RETURN_RET_LOG(fd > 0, E_ERR, "wrong fd"); -- Gitee