diff --git a/services/distributeddataservice/service/udmf/lifecycle/lifecycle_manager.cpp b/services/distributeddataservice/service/udmf/lifecycle/lifecycle_manager.cpp index cbfdca07a431b4edd55fba26efc3e70081f1d8dc..ce6f6609dd90cdc197c870545aab8d5b249ad368 100644 --- a/services/distributeddataservice/service/udmf/lifecycle/lifecycle_manager.cpp +++ b/services/distributeddataservice/service/udmf/lifecycle/lifecycle_manager.cpp @@ -23,6 +23,9 @@ namespace UDMF { using CleanAfterGet = LifeCyclePolicy; std::unordered_map> LifeCycleManager::intentionPolicy_ = { { UD_INTENTION_MAP.at(UD_INTENTION_DRAG), std::make_shared() }, + { UD_INTENTION_MAP.at(UD_INTENTION_PICKER), std::make_shared() }, + { UD_INTENTION_MAP.at(UD_INTENTION_RIGHT_CLICK), std::make_shared() }, + { UD_INTENTION_MAP.at(UD_INTENTION_SYSTEM_SHARE), std::make_shared() }, { UD_INTENTION_MAP.at(UD_INTENTION_DATA_HUB), std::make_shared() } }; diff --git a/services/distributeddataservice/service/udmf/lifecycle/lifecycle_policy.cpp b/services/distributeddataservice/service/udmf/lifecycle/lifecycle_policy.cpp index 095a95f65ddb346549999b6579cc3b8f6a73c412..1015aae5dce4603f43c4e87b305f4bdbe8d418bf 100644 --- a/services/distributeddataservice/service/udmf/lifecycle/lifecycle_policy.cpp +++ b/services/distributeddataservice/service/udmf/lifecycle/lifecycle_policy.cpp @@ -59,6 +59,12 @@ Status LifeCyclePolicy::OnTimeout(const std::string &intention) return E_DB_ERROR; } std::vector timeoutKeys; + Duration interval = INTERVAL; + if (intention == UD_INTENTION_MAP.at(UD_INTENTION_SYSTEM_SHARE) + ||intention == UD_INTENTION_MAP.at(UD_INTENTION_PICKER) + ||intention == UD_INTENTION_MAP.at(UD_INTENTION_RIGHT_CLICK)) { + interval = SYSTEM_SHARE_INTERVAL; + } auto status = GetTimeoutKeys(store, INTERVAL, timeoutKeys); if (status != E_OK) { ZLOGE("Timeout keys get failed"); diff --git a/services/distributeddataservice/service/udmf/lifecycle/lifecycle_policy.h b/services/distributeddataservice/service/udmf/lifecycle/lifecycle_policy.h index f7703e562be97760cb5218ca560c3afa4d2c8df4..d058b4fd0e944cbc19eb23126bf7f162229cff6d 100644 --- a/services/distributeddataservice/service/udmf/lifecycle/lifecycle_policy.h +++ b/services/distributeddataservice/service/udmf/lifecycle/lifecycle_policy.h @@ -23,6 +23,7 @@ class LifeCyclePolicy { public: using Duration = std::chrono::steady_clock::duration; static constexpr Duration INTERVAL = std::chrono::milliseconds(60 * 60 * 1000); + static constexpr Duration SYSTEM_SHARE_INTERVAL = std::chrono::milliseconds(24 * 60 * 60 * 1000); virtual ~LifeCyclePolicy() = default; virtual Status OnGot(const UnifiedKey &key); virtual Status OnStart(const std::string &intention); diff --git a/services/distributeddataservice/service/udmf/store/store_cache.cpp b/services/distributeddataservice/service/udmf/store/store_cache.cpp index 9bd6ae679bae31ba76641bfffa2aaaf18f483726..e72125a100e74eea6e6788cfa6f6e0ad76ad7dd5 100644 --- a/services/distributeddataservice/service/udmf/store/store_cache.cpp +++ b/services/distributeddataservice/service/udmf/store/store_cache.cpp @@ -46,6 +46,9 @@ std::shared_ptr StoreCache::GetStore(std::string intention) } if (intention == UD_INTENTION_MAP.at(UD_INTENTION_DRAG) + || intention == UD_INTENTION_MAP.at(UD_INTENTION_PICKER) + || intention == UD_INTENTION_MAP.at(UD_INTENTION_RIGHT_CLICK) + || intention == UD_INTENTION_MAP.at(UD_INTENTION_SYSTEM_SHARE) || intention == UD_INTENTION_MAP.at(UD_INTENTION_DATA_HUB)) { storePtr = std::make_shared(intention); if (!storePtr->Init()) { diff --git a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp index 42ef97a5d3a3385b69f5e8793a8b8eb184fc1e71..e88bdcf10bd4db6193175ad549b50d97cc50707b 100644 --- a/services/distributeddataservice/service/udmf/udmf_service_impl.cpp +++ b/services/distributeddataservice/service/udmf/udmf_service_impl.cpp @@ -224,7 +224,6 @@ int32_t UdmfServiceImpl::RetrieveData(const QueryOption &query, UnifiedData &uni ZLOGE("Get data incomplete,key:%{public}s", query.key.c_str()); return E_NOT_FOUND; } - CheckerManager::CheckInfo info; info.tokenId = query.tokenId; std::shared_ptr runtime = unifiedData.GetRuntime(); @@ -236,7 +235,6 @@ int32_t UdmfServiceImpl::RetrieveData(const QueryOption &query, UnifiedData &uni BizScene::GET_DATA, GetDataStage::VERIFY_PRIVILEGE, StageRes::FAILED, E_NO_PERMISSION); return E_NO_PERMISSION; } - if (key.intention == UD_INTENTION_MAP.at(UD_INTENTION_DRAG)) { int32_t ret = ProcessUri(query, unifiedData); if (ret != E_OK) { @@ -246,15 +244,15 @@ int32_t UdmfServiceImpl::RetrieveData(const QueryOption &query, UnifiedData &uni return E_NO_PERMISSION; } } - if (!IsReadAndKeep(runtime->privileges, query)) { - if (LifeCycleManager::GetInstance().OnGot(key) != E_OK) { - ZLOGE("Remove data failed:%{public}s", key.intention.c_str()); - return E_DB_ERROR; + if (key.intention != UD_INTENTION_MAP.at(UD_INTENTION_DATA_HUB)) { + if (!IsReadAndKeep(runtime->privileges, query)) { + if (LifeCycleManager::GetInstance().OnGot(key) != E_OK) { + ZLOGE("Remove data failed:%{public}s", key.intention.c_str()); + return E_DB_ERROR; + } } + privilegeCache_.erase(query.key); } - - privilegeCache_.erase(query.key); - PreProcessUtils::SetRemoteData(unifiedData); return E_OK; } @@ -387,6 +385,10 @@ int32_t UdmfServiceImpl::UpdateData(const QueryOption &query, UnifiedData &unifi ZLOGE("data or key is invalid,key=%{public}s", query.key.c_str()); return E_INVALID_PARAMETERS; } + if (key.intention != UD_INTENTION_MAP.at(UD_INTENTION_DATA_HUB)) { + ZLOGE("intention:%{public}s no permission", key.intention.c_str()); + return E_NO_PERMISSION; + } std::string bundleName; PreProcessUtils::GetHapBundleNameByToken(query.tokenId, bundleName); if (key.bundleName != bundleName && !HasDatahubPriviledge(bundleName)) { @@ -429,6 +431,11 @@ int32_t UdmfServiceImpl::UpdateData(const QueryOption &query, UnifiedData &unifi int32_t UdmfServiceImpl::DeleteData(const QueryOption &query, std::vector &unifiedDataSet) { ZLOGD("start"); + UnifiedKey key(query.key); + if (!key.IsValid()) { + ZLOGE("key is invalid,key=%{public}s", query.key.c_str()); + return E_INVALID_PARAMETERS; + } std::vector dataSet; std::shared_ptr store; auto status = QueryDataCommon(query, dataSet, store); @@ -440,6 +447,10 @@ int32_t UdmfServiceImpl::DeleteData(const QueryOption &query, std::vector runtime; std::vector deleteKeys; for (const auto &data : dataSet) { @@ -499,16 +510,16 @@ int32_t UdmfServiceImpl::AddPrivilege(const QueryOption &query, Privilege &privi if (!PreProcessUtils::GetNativeProcessNameByToken(query.tokenId, processName)) { return E_ERROR; } - + if (key.intention == UD_INTENTION_MAP.at(UD_INTENTION_DATA_HUB)) { + ZLOGE("intention:%{public}s no permission", key.intention.c_str()); + return E_NO_PERMISSION; + } if (key.intention == UD_INTENTION_MAP.at(UD_INTENTION_DRAG)) { if (find(DRAG_AUTHORIZED_PROCESSES, std::end(DRAG_AUTHORIZED_PROCESSES), processName) == std::end(DRAG_AUTHORIZED_PROCESSES)) { ZLOGE("Process:%{public}s lacks permission for intention:drag", processName.c_str()); return E_NO_PERMISSION; } - } else { - ZLOGE("Intention: %{public}s has no authorized processes", key.intention.c_str()); - return E_NO_PERMISSION; } auto store = StoreCache::GetInstance().GetStore(key.intention);