mirror of
https://gitee.com/openharmony/distributeddatamgr_datamgr_service
synced 2024-11-27 00:51:12 +00:00
f
Signed-off-by: hanlu <hanlu1@huawei.com>
This commit is contained in:
parent
31d8f89cb8
commit
31e0148bdc
@ -20,6 +20,9 @@
|
||||
},
|
||||
{
|
||||
"lib": "libudmf_server.z.so"
|
||||
},
|
||||
{
|
||||
"lib": "libdata_share_service.z.so"
|
||||
}
|
||||
],
|
||||
"bundleChecker": {
|
||||
|
@ -108,6 +108,7 @@ ohos_shared_library("distributeddataservice") {
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/uninstaller:distributeddata_uninstaller_static",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service:distributeddatasvc",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service/directory:distributeddata_directory",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
@ -13,6 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "feature_stub_impl.h"
|
||||
|
||||
#include "bootstrap.h"
|
||||
#include "ipc_skeleton.h"
|
||||
namespace OHOS::DistributedData {
|
||||
FeatureStubImpl::FeatureStubImpl(std::shared_ptr<FeatureSystem::Feature> feature)
|
||||
: featureImpl_(std::move(feature))
|
||||
@ -38,7 +41,8 @@ int32_t FeatureStubImpl::OnInitialize(std::shared_ptr<ExecutorPool> executor)
|
||||
return -1;
|
||||
}
|
||||
featureImpl_->OnExecutor(std::move(executor));
|
||||
return featureImpl_->OnInitialize();
|
||||
return featureImpl_->OnInitialize(
|
||||
{ Bootstrap::GetInstance().GetProcessLabel(), static_cast<uint32_t>(IPCSkeleton::GetSelfTokenID()) });
|
||||
}
|
||||
|
||||
int32_t FeatureStubImpl::OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName)
|
||||
|
@ -55,7 +55,7 @@ FeatureSystem::Feature::~Feature()
|
||||
{
|
||||
}
|
||||
|
||||
int32_t FeatureSystem::Feature::OnInitialize()
|
||||
int32_t FeatureSystem::Feature::OnInitialize(const BinderInfo &binderInfo)
|
||||
{
|
||||
return E_OK;
|
||||
}
|
||||
|
@ -36,9 +36,13 @@ public:
|
||||
};
|
||||
class API_EXPORT Feature {
|
||||
public:
|
||||
struct BinderInfo {
|
||||
std::string bundleName;
|
||||
uint32_t localTokenId;
|
||||
};
|
||||
virtual ~Feature();
|
||||
virtual int OnRemoteRequest(uint32_t code, OHOS::MessageParcel &data, OHOS::MessageParcel &reply) = 0;
|
||||
virtual int32_t OnInitialize();
|
||||
virtual int32_t OnInitialize(const BinderInfo &binderInfo);
|
||||
virtual int32_t OnExecutor(std::shared_ptr<ExecutorPool> executors);
|
||||
virtual int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &bundleName);
|
||||
virtual int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index, uint32_t tokenId);
|
||||
|
@ -25,10 +25,6 @@ config("module_public_config") {
|
||||
"cloud",
|
||||
"config/include",
|
||||
"crypto/include",
|
||||
"data_share",
|
||||
"data_share/strategies",
|
||||
"data_share/common",
|
||||
"data_share/data",
|
||||
"directory/include",
|
||||
"kvdb",
|
||||
"matrix/include",
|
||||
@ -72,42 +68,6 @@ ohos_shared_library("distributeddatasvc") {
|
||||
"config/src/model/network_config.cpp",
|
||||
"config/src/model/protocol_config.cpp",
|
||||
"crypto/src/crypto_manager.cpp",
|
||||
"data_share/common/bundle_mgr_proxy.cpp",
|
||||
"data_share/common/db_delegate.cpp",
|
||||
"data_share/common/div_strategy.cpp",
|
||||
"data_share/common/kv_delegate.cpp",
|
||||
"data_share/common/rdb_delegate.cpp",
|
||||
"data_share/common/scheduler_manager.cpp",
|
||||
"data_share/common/seq_strategy.cpp",
|
||||
"data_share/common/template_manager.cpp",
|
||||
"data_share/common/uri_utils.cpp",
|
||||
"data_share/data/json_formatter.cpp",
|
||||
"data_share/data/published_data.cpp",
|
||||
"data_share/data/resultset_json_formatter.cpp",
|
||||
"data_share/data/template_data.cpp",
|
||||
"data_share/data_share_obs_proxy.cpp",
|
||||
"data_share/data_share_service_impl.cpp",
|
||||
"data_share/data_share_service_stub.cpp",
|
||||
"data_share/data_share_types_util.cpp",
|
||||
"data_share/strategies/data_proxy/load_config_from_data_proxy_node_strategy.cpp",
|
||||
"data_share/strategies/data_share/load_config_from_data_share_bundle_info_strategy.cpp",
|
||||
"data_share/strategies/delete_strategy.cpp",
|
||||
"data_share/strategies/general/check_is_data_proxy_strategy.cpp",
|
||||
"data_share/strategies/general/check_is_single_app_strategy.cpp",
|
||||
"data_share/strategies/general/connect_extension_strategy.cpp",
|
||||
"data_share/strategies/general/empty_strategy.cpp",
|
||||
"data_share/strategies/general/load_config_common_strategy.cpp",
|
||||
"data_share/strategies/general/load_config_data_info_strategy.cpp",
|
||||
"data_share/strategies/general/load_config_from_bundle_info_strategy.cpp",
|
||||
"data_share/strategies/general/permission_strategy.cpp",
|
||||
"data_share/strategies/general/process_single_app_user_cross_strategy.cpp",
|
||||
"data_share/strategies/get_data_strategy.cpp",
|
||||
"data_share/strategies/insert_strategy.cpp",
|
||||
"data_share/strategies/publish_strategy.cpp",
|
||||
"data_share/strategies/query_strategy.cpp",
|
||||
"data_share/strategies/subscribe_strategy.cpp",
|
||||
"data_share/strategies/update_strategy.cpp",
|
||||
"directory/src/directory_manager.cpp",
|
||||
"kvdb/auth_delegate.cpp",
|
||||
"kvdb/executor_factory.cpp",
|
||||
"kvdb/kvdb_exporter.cpp",
|
||||
@ -147,7 +107,7 @@ ohos_shared_library("distributeddatasvc") {
|
||||
deps = [
|
||||
"${kv_store_distributeddb_path}:distributeddb",
|
||||
"${relational_store_path}/interfaces/inner_api/cloud_data:cloud_data_inner",
|
||||
"data_share/gaussdb_rd:gaussdb_rd",
|
||||
"directory:distributeddata_directory",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk",
|
||||
@ -160,10 +120,7 @@ ohos_shared_library("distributeddatasvc") {
|
||||
"ability_runtime:dataobs_manager",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"data_share:datashare_common",
|
||||
"device_auth:deviceauth_sdk",
|
||||
"device_manager:devicemanagersdk",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
@ -171,10 +128,6 @@ ohos_shared_library("distributeddatasvc") {
|
||||
"ipc:ipc_core",
|
||||
"kv_store:distributeddata_inner",
|
||||
"relational_store:native_rdb",
|
||||
"relational_store:rdb_bms_adapter",
|
||||
"relational_store:rdb_data_share_adapter",
|
||||
"resource_management:global_resmgr",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
subsystem_name = "distributeddatamgr"
|
||||
|
||||
|
110
services/distributeddataservice/service/data_share/BUILD.gn
Normal file
110
services/distributeddataservice/service/data_share/BUILD.gn
Normal file
@ -0,0 +1,110 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos_var.gni")
|
||||
import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni")
|
||||
config("module_public_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
".",
|
||||
"strategies",
|
||||
"common",
|
||||
"data",
|
||||
"../directory/include",
|
||||
"//third_party/json/single_include",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework/include",
|
||||
"${datashare_path}/frameworks/native/common/include",
|
||||
"${datashare_path}/interfaces/inner_api/common/include",
|
||||
"${datashare_path}/interfaces/inner_api/consumer/include",
|
||||
]
|
||||
}
|
||||
group("build_module") {
|
||||
deps = [ ":data_share_service" ]
|
||||
}
|
||||
ohos_shared_library("data_share_service") {
|
||||
sources = [
|
||||
"common/bundle_mgr_proxy.cpp",
|
||||
"common/db_delegate.cpp",
|
||||
"common/div_strategy.cpp",
|
||||
"common/kv_delegate.cpp",
|
||||
"common/rdb_delegate.cpp",
|
||||
"common/scheduler_manager.cpp",
|
||||
"common/seq_strategy.cpp",
|
||||
"common/template_manager.cpp",
|
||||
"common/uri_utils.cpp",
|
||||
"data/json_formatter.cpp",
|
||||
"data/published_data.cpp",
|
||||
"data/resultset_json_formatter.cpp",
|
||||
"data/template_data.cpp",
|
||||
"data_share_obs_proxy.cpp",
|
||||
"data_share_service_impl.cpp",
|
||||
"data_share_service_stub.cpp",
|
||||
"data_share_types_util.cpp",
|
||||
"strategies/data_proxy/load_config_from_data_proxy_node_strategy.cpp",
|
||||
"strategies/data_share/load_config_from_data_share_bundle_info_strategy.cpp",
|
||||
"strategies/delete_strategy.cpp",
|
||||
"strategies/general/check_is_data_proxy_strategy.cpp",
|
||||
"strategies/general/check_is_single_app_strategy.cpp",
|
||||
"strategies/general/connect_extension_strategy.cpp",
|
||||
"strategies/general/empty_strategy.cpp",
|
||||
"strategies/general/load_config_common_strategy.cpp",
|
||||
"strategies/general/load_config_data_info_strategy.cpp",
|
||||
"strategies/general/load_config_from_bundle_info_strategy.cpp",
|
||||
"strategies/general/permission_strategy.cpp",
|
||||
"strategies/general/process_single_app_user_cross_strategy.cpp",
|
||||
"strategies/get_data_strategy.cpp",
|
||||
"strategies/insert_strategy.cpp",
|
||||
"strategies/publish_strategy.cpp",
|
||||
"strategies/query_strategy.cpp",
|
||||
"strategies/subscribe_strategy.cpp",
|
||||
"strategies/update_strategy.cpp",
|
||||
]
|
||||
cflags = [ "-Wno-multichar" ]
|
||||
|
||||
cflags_cc = [ "-fvisibility=hidden" ]
|
||||
|
||||
configs = [ ":module_public_config" ]
|
||||
|
||||
deps = [
|
||||
"gaussdb_rd:gaussdb_rd",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service/directory:distributeddata_directory",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:dataobs_manager",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"data_share:datashare_common",
|
||||
"device_manager:devicemanagersdk",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_rdb",
|
||||
"relational_store:rdb_bms_adapter",
|
||||
"relational_store:rdb_data_share_adapter",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
subsystem_name = "distributeddatamgr"
|
||||
|
||||
part_name = "datamgr_service"
|
||||
}
|
@ -15,7 +15,7 @@
|
||||
#define LOG_TAG "RdbAdaptor"
|
||||
#include "rdb_delegate.h"
|
||||
|
||||
#include "data/resultset_json_formatter.h"
|
||||
#include "resultset_json_formatter.h"
|
||||
#include "log_print.h"
|
||||
#include "rdb_utils.h"
|
||||
#include "scheduler_manager.h"
|
||||
|
@ -294,7 +294,7 @@ int RdbSubscriberManager::Notify(
|
||||
changeNode.data_.emplace_back(DistributedData::Serializable::Marshall(formatter));
|
||||
}
|
||||
|
||||
ZLOGI("emit, size %{public}d %{private}s", val.size(), changeNode.uri_.c_str());
|
||||
ZLOGI("emit, size %{public}ul %{private}s", val.size(), changeNode.uri_.c_str());
|
||||
for (auto &callback : val) {
|
||||
if (callback.enabled && callback.observer != nullptr) {
|
||||
callback.observer->OnChangeFromRdb(changeNode);
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "account/account_delegate.h"
|
||||
#include "bootstrap.h"
|
||||
#include "dataobs_mgr_client.h"
|
||||
#include "datashare_errno.h"
|
||||
#include "datashare_template.h"
|
||||
@ -334,26 +333,22 @@ enum DataShareKvStoreType : int32_t {
|
||||
DISTRIBUTED_TYPE_BUTT
|
||||
};
|
||||
|
||||
int32_t DataShareServiceImpl::OnInitialize()
|
||||
int32_t DataShareServiceImpl::OnInitialize(const BinderInfo &binderInfo)
|
||||
{
|
||||
auto token = IPCSkeleton::GetCallingTokenID();
|
||||
auto type = OHOS::Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(token);
|
||||
if (type != OHOS::Security::AccessToken::TOKEN_NATIVE && type != OHOS::Security::AccessToken::TOKEN_SHELL) {
|
||||
return EOK;
|
||||
}
|
||||
binderInfo_ = binderInfo;
|
||||
const std::string accountId = DistributedKv::AccountDelegate::GetInstance()->GetCurrentAccountId();
|
||||
const auto userId = DistributedKv::AccountDelegate::GetInstance()->GetUserByToken(token);
|
||||
const auto userId = DistributedKv::AccountDelegate::GetInstance()->GetUserByToken(binderInfo.localTokenId);
|
||||
DistributedData::StoreMetaData saveMeta;
|
||||
saveMeta.appType = "default";
|
||||
saveMeta.storeId = "data_share_data_";
|
||||
saveMeta.isAutoSync = false;
|
||||
saveMeta.isBackup = false;
|
||||
saveMeta.isEncrypt = false;
|
||||
saveMeta.bundleName = DistributedData::Bootstrap::GetInstance().GetProcessLabel();
|
||||
saveMeta.appId = DistributedData::Bootstrap::GetInstance().GetProcessLabel();
|
||||
saveMeta.bundleName = binderInfo.bundleName;
|
||||
saveMeta.appId = binderInfo.bundleName;
|
||||
saveMeta.user = std::to_string(userId);
|
||||
saveMeta.account = accountId;
|
||||
saveMeta.tokenId = token;
|
||||
saveMeta.tokenId = binderInfo.localTokenId;
|
||||
saveMeta.securityLevel = DistributedKv::SecurityLevel::S1;
|
||||
saveMeta.area = 1;
|
||||
saveMeta.uid = IPCSkeleton::GetCallingUid();
|
||||
@ -377,8 +372,8 @@ int32_t DataShareServiceImpl::OnUserChange(uint32_t code, const std::string &use
|
||||
saveMeta.isAutoSync = false;
|
||||
saveMeta.isBackup = false;
|
||||
saveMeta.isEncrypt = false;
|
||||
saveMeta.bundleName = DistributedData::Bootstrap::GetInstance().GetProcessLabel();
|
||||
saveMeta.appId = DistributedData::Bootstrap::GetInstance().GetProcessLabel();
|
||||
saveMeta.bundleName = binderInfo_.bundleName;
|
||||
saveMeta.appId = binderInfo_.bundleName;
|
||||
saveMeta.user = user;
|
||||
saveMeta.account = account;
|
||||
saveMeta.tokenId = token;
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
const int64_t subscriberId) override;
|
||||
std::vector<OperationResult> DisablePubSubs(const std::vector<std::string> &uris,
|
||||
const int64_t subscriberId) override;
|
||||
int32_t OnInitialize() override;
|
||||
int32_t OnInitialize(const BinderInfo &binderInfo) override;
|
||||
int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account) override;
|
||||
|
||||
private:
|
||||
@ -71,6 +71,7 @@ private:
|
||||
static Factory factory_;
|
||||
static constexpr int32_t ERROR = -1;
|
||||
PublishStrategy publishStrategy_;
|
||||
BinderInfo binderInfo_;
|
||||
};
|
||||
} // namespace OHOS::DataShare
|
||||
#endif
|
||||
|
52
services/distributeddataservice/service/directory/BUILD.gn
Normal file
52
services/distributeddataservice/service/directory/BUILD.gn
Normal file
@ -0,0 +1,52 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos_var.gni")
|
||||
import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni")
|
||||
|
||||
config("module_public_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework/include",
|
||||
]
|
||||
}
|
||||
|
||||
group("build_module") {
|
||||
deps = [ ":distributeddata_directory" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("distributeddata_directory") {
|
||||
sources = [ "src/directory_manager.cpp" ]
|
||||
cflags = [ "-Wno-multichar" ]
|
||||
|
||||
cflags_cc = [ "-fvisibility=hidden" ]
|
||||
|
||||
configs = [ ":module_public_config" ]
|
||||
|
||||
deps = [
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static",
|
||||
"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
subsystem_name = "distributeddatamgr"
|
||||
part_name = "datamgr_service"
|
||||
}
|
@ -71,7 +71,7 @@ int32_t ObjectServiceImpl::ObjectStoreSave(const std::string &bundleName, const
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t ObjectServiceImpl::OnInitialize()
|
||||
int32_t ObjectServiceImpl::OnInitialize(const BinderInfo &binderInfo)
|
||||
{
|
||||
ZLOGI("Initialize");
|
||||
auto localDeviceId = DmAdapter::GetInstance().GetLocalDevice().uuid;
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
void Clear();
|
||||
int32_t ResolveAutoLaunch(const std::string &identifier, DistributedDB::AutoLaunchParam ¶m) override;
|
||||
int32_t OnAppExit(pid_t uid, pid_t pid, uint32_t tokenId, const std::string &appId) override;
|
||||
int32_t OnInitialize() override;
|
||||
int32_t OnInitialize(const BinderInfo &binderInfo) override;
|
||||
int32_t OnExecutor(std::shared_ptr<ExecutorPool> executors) override;
|
||||
int32_t OnUserChange(uint32_t code, const std::string &user, const std::string &account) override;
|
||||
int32_t OnAppUninstall(const std::string &bundleName, int32_t user, int32_t index, uint32_t tokenId) override;
|
||||
|
Loading…
Reference in New Issue
Block a user