From 3e5de8f4231b67b364b7e53cfad113f2764997e3 Mon Sep 17 00:00:00 2001 From: zph Date: Thu, 17 Apr 2025 09:36:48 +0800 Subject: [PATCH] update Signed-off-by: zph --- .../permission/uri_permission_manager.cpp | 2 +- .../udmf/preprocess/preprocess_utils.cpp | 20 +++++++++++++++++-- .../udmf/preprocess/preprocess_utils.h | 1 + .../service/udmf/store/runtime_store.cpp | 4 ++++ .../service/udmf/udmf_service_impl.cpp | 14 +++++-------- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/services/distributeddataservice/service/udmf/permission/uri_permission_manager.cpp b/services/distributeddataservice/service/udmf/permission/uri_permission_manager.cpp index e9eb42a70..042325f49 100644 --- a/services/distributeddataservice/service/udmf/permission/uri_permission_manager.cpp +++ b/services/distributeddataservice/service/udmf/permission/uri_permission_manager.cpp @@ -22,7 +22,7 @@ namespace OHOS { namespace UDMF { -constexpr const std::uint32_t GRANT_URI_PERMISSION_MAX_SIZE = 500; +constexpr const std::uint32_t GRANT_URI_PERMISSION_MAX_SIZE = 10000; UriPermissionManager &UriPermissionManager::GetInstance() { static UriPermissionManager instance; diff --git a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp index 069609aba..0cf277aa7 100644 --- a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp +++ b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp @@ -71,7 +71,7 @@ int32_t PreProcessUtils::RuntimeDataImputation(UnifiedData &data, CustomOption & runtime.deviceId = GetLocalDeviceId(); runtime.recordTotalNum = static_cast(data.GetRecords().size()); runtime.tokenId = option.tokenId; - runtime.sdkVersion = data.GetSdkVersion(); + runtime.sdkVersion = GetSdkVersionByToken(option.tokenId); data.SetRuntime(runtime); return E_OK; } @@ -424,7 +424,7 @@ bool PreProcessUtils::GetDetailsFromUData(const UnifiedData &data, UDDetails &de { auto records = data.GetRecords(); if (records.size() != TEMP_UDATA_RECORD_SIZE) { - ZLOGE("Records size error.size:%{public}zu", records.size()); + ZLOGI("Records size:%{public}zu", records.size()); return false; } if (records[0] == nullptr) { @@ -470,5 +470,21 @@ Status PreProcessUtils::GetSummaryFromDetails(const UDDetails &details, Summary } return E_OK; } + +std::string PreProcessUtils::GetSdkVersionByToken(uint32_t tokenId) +{ + if (Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(tokenId) != + Security::AccessToken::ATokenTypeEnum::TOKEN_HAP) { + ZLOGE("Caller is not application, tokenid is %{public}u", tokenId); + return ""; + } + Security::AccessToken::HapTokenInfo hapTokenInfo; + auto ret = Security::AccessToken::AccessTokenKit::GetHapTokenInfo(tokenId, hapTokenInfo); + if (ret != 0) { + ZLOGE("GetHapTokenInfo fail, tokenid is %{public}u, ret is %{public}d.", tokenId, ret); + return ""; + } + return std::to_string(hapTokenInfo.apiVersion); +} } // namespace UDMF } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.h b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.h index 6d6130078..1532f4c49 100644 --- a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.h +++ b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.h @@ -46,6 +46,7 @@ private: static bool CheckUriAuthorization(const std::vector& uris, uint32_t tokenId); static int32_t GetDfsUrisFromLocal(const std::vector &uris, int32_t userId, UnifiedData &data); static bool IsFileType(std::shared_ptr record); + static std::string GetSdkVersionByToken(uint32_t tokenId); }; } // namespace UDMF } // namespace OHOS diff --git a/services/distributeddataservice/service/udmf/store/runtime_store.cpp b/services/distributeddataservice/service/udmf/store/runtime_store.cpp index 9b7bfd49e..28ccfb432 100644 --- a/services/distributeddataservice/service/udmf/store/runtime_store.cpp +++ b/services/distributeddataservice/service/udmf/store/runtime_store.cpp @@ -199,6 +199,10 @@ Status RuntimeStore::GetRuntime(const std::string &key, Runtime &runtime) UpdateTime(); Value value; auto res = kvStore_->Get({key.begin(), key.end()}, value); + if (res == NOT_FOUND) { + ZLOGW("Runtime not found, key: %{public}s", key.c_str()); + return E_NOT_FOUND; + } if (res != OK || value.empty()) { ZLOGE("Get failed, key: %{public}s, status:%{public}d", key.c_str(), res); return E_DB_ERROR; diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index 2d0cdacbc..ade32eb62 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -571,19 +571,15 @@ int32_t UdmfServiceImpl::IsRemoteData(const QueryOption &query, bool &result) return E_DB_ERROR; } - UnifiedData unifiedData; - if (store->Get(query.key, unifiedData) != E_OK) { - ZLOGE("Store get unifiedData failed:%{public}s", key.intention.c_str()); - return E_DB_ERROR; - } - std::shared_ptr runtime = unifiedData.GetRuntime(); - if (runtime == nullptr) { - ZLOGE("Store get runtime failed, key: %{public}s.", query.key.c_str()); + Runtime runtime; + auto res = store->GetRuntime(query.key, runtime); + if (res != E_OK) { + ZLOGE("Get runtime failed, res:%{public}d, key:%{public}s.", res, query.key.c_str()); return E_DB_ERROR; } std::string localDeviceId = PreProcessUtils::GetLocalDeviceId(); - if (localDeviceId != runtime->deviceId) { + if (localDeviceId != runtime.deviceId) { result = true; } return E_OK; -- Gitee