diff --git a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp index 069609aba289fdbb03bf3515a72a5bad8c87551f..6285e557e4ca710adb93da1c3faed511bcd329e7 100644 --- a/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp +++ b/services/distributeddataservice/service/udmf/preprocess/preprocess_utils.cpp @@ -22,6 +22,7 @@ #include "udmf_radar_reporter.h" #include "accesstoken_kit.h" #include "device_manager_adapter.h" +#include "ipc_skeleton.h" #include "log_print.h" #include "udmf_radar_reporter.h" #include "udmf_utils.h" @@ -71,7 +72,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; } @@ -470,5 +471,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."); + 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 6d613007813bcf338963c5c1b332cd04960424a6..1532f4c49136116310619fbb39865319e80e42e6 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/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index 408c19a00c6143c33d875673174fab20f811e6ec..3147ce0ddebf909400bad65fd91589c01acb60a9 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -31,6 +31,9 @@ #include "log_print.h" #include "metadata/store_meta_data.h" #include "metadata/meta_data_manager.h" +<<<<<<< HEAD +#include "unified_data_helper.h" +======= #include "preprocess_utils.h" #include "reporter.h" #include "store_account_observer.h" @@ -39,6 +42,7 @@ #include "udmf_radar_reporter.h" #include "unified_data_helper.h" #include "utils/anonymous.h" +>>>>>>> 3774a93e96422fb5cf19ebbab238893176bb3494 namespace OHOS { namespace UDMF {