From cb557ae2d67b54186de337b1ddffb93429a7c795 Mon Sep 17 00:00:00 2001 From: heppen Date: Tue, 1 Aug 2023 16:37:10 +0800 Subject: [PATCH] remove useless dependency --- bundle.json | 2 - .../distributeddataservice/adapter/BUILD.gn | 4 +- .../adapter/account/BUILD.gn | 6 +- .../account/src/account_delegate_impl.cpp | 29 +--- .../account/src/account_delegate_impl.h | 15 +- .../adapter/account/test/BUILD.gn | 6 +- .../adapter/autils/BUILD.gn | 2 +- .../adapter/broadcaster/BUILD.gn | 8 +- .../adapter/communicator/BUILD.gn | 3 +- .../adapter/dfx/BUILD.gn | 6 +- .../adapter/dfx/src/hiview_adapter.cpp | 132 ++++++++---------- .../adapter/dfx/src/hiview_adapter.h | 2 +- .../adapter/dfx/test/BUILD.gn | 8 +- .../adapter/permission/BUILD.gn | 2 +- .../permission/src/permission_validator.cpp | 23 +-- services/distributeddataservice/app/BUILD.gn | 44 ++++-- .../app/src/checker/BUILD.gn | 10 +- .../app/src/checker/bundle_checker.cpp | 59 ++++---- .../app/src/checker/system_checker.cpp | 10 +- .../app/src/kvstore_data_service.cpp | 70 +--------- .../app/src/kvstore_data_service.h | 5 +- .../app/src/kvstore_meta_manager.cpp | 7 +- .../app/src/security/security.cpp | 48 ++++++- .../app/src/security/security.h | 2 + .../app/src/security/sensitive.cpp | 2 +- .../route_head_handler_impl.cpp | 4 +- .../src/session_manager/upgrade_manager.cpp | 11 +- .../distributeddataservice/app/test/BUILD.gn | 42 +++--- .../distributeddataservice/framework/BUILD.gn | 3 +- .../framework/checker/checker_manager.cpp | 22 +-- .../framework/test/BUILD.gn | 4 +- .../distributeddataservice/service/BUILD.gn | 34 ++--- .../directory/src/directory_manager.cpp | 20 +-- .../service/kvdb/kvdb_service_impl.cpp | 16 +-- .../service/kvdb/kvstore_sync_manager.cpp | 4 +- .../service/kvdb/user_delegate.cpp | 4 +- .../permission/src/permit_delegate.cpp | 6 +- .../service/rdb/rdb_result_set_stub.h | 50 +++---- .../service/rdb/rdb_service_impl.cpp | 1 - .../service/rdb/rdb_service_stub.h | 20 +-- .../service/rdb/rdb_syncer.cpp | 16 +-- .../service/rdb/rdb_syncer.h | 12 +- .../service/test/BUILD.gn | 8 +- 43 files changed, 349 insertions(+), 433 deletions(-) diff --git a/bundle.json b/bundle.json index 79367b7..824abb3 100644 --- a/bundle.json +++ b/bundle.json @@ -66,10 +66,8 @@ "dsoftbus", "jsoncpp", "hitrace_native", - "access_token", "huks", "ability_base", - "ability_runtime", "hiviewdfx_hilog_native", "hisysevent_native", "device_auth", diff --git a/services/distributeddataservice/adapter/BUILD.gn b/services/distributeddataservice/adapter/BUILD.gn index 8f2232a..1a77c98 100644 --- a/services/distributeddataservice/adapter/BUILD.gn +++ b/services/distributeddataservice/adapter/BUILD.gn @@ -31,6 +31,7 @@ config("distributeddata_adapter_public_config") { "include/communicator", "include/autils", "include/utils", + "include/broadcaster", "include", "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata/include/", "//foundation/distributeddatamgr/kv_store/frameworks/common", @@ -51,9 +52,6 @@ ohos_shared_library("distributeddata_adapter") { external_deps = [ "c_utils:utils", - "hisysevent_native:libhisysevent", - "hitrace_native:hitrace_meter", - "hitrace_native:libhitracechain", "hiviewdfx_hilog_native:libhilog", ] diff --git a/services/distributeddataservice/adapter/account/BUILD.gn b/services/distributeddataservice/adapter/account/BUILD.gn index bf53ea5..9bdc63c 100755 --- a/services/distributeddataservice/adapter/account/BUILD.gn +++ b/services/distributeddataservice/adapter/account/BUILD.gn @@ -40,9 +40,9 @@ ohos_static_library("distributeddata_account_static") { configs = [ "//build/config/compiler:exceptions" ] external_deps = [ - "ability_base:want", + # "ability_base:want", "c_utils:utils", - "common_event_service:cesfwk_innerkits", + # "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", ] @@ -50,7 +50,7 @@ ohos_static_library("distributeddata_account_static") { sources += [ "src/account_delegate_normal_impl.cpp" ] cflags_cc += [ "-DOS_ACCOUNT_PART_IS_ENABLED" ] external_deps += [ - "access_token:libaccesstoken_sdk", + #"access_token:libaccesstoken_sdk", "os_account:libaccountkits", "os_account:os_account_innerkits", ] diff --git a/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp b/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp index d05bdc1..1c2ebaa 100644 --- a/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp +++ b/services/distributeddataservice/adapter/account/src/account_delegate_impl.cpp @@ -24,35 +24,8 @@ namespace OHOS { namespace DistributedKv { -using namespace OHOS::EventFwk; -using namespace OHOS::AAFwk; -using namespace OHOS::DistributedData; - -EventSubscriber::EventSubscriber(const CommonEventSubscribeInfo &info) : CommonEventSubscriber(info) {} - -void EventSubscriber::OnReceiveEvent(const CommonEventData &event) -{ - const auto want = event.GetWant(); - AccountEventInfo accountEventInfo {}; - std::string action = want.GetAction(); - ZLOGI("Want Action is %s", action.c_str()); - - if (action == CommonEventSupport::COMMON_EVENT_USER_REMOVED) { - accountEventInfo.status = AccountStatus::DEVICE_ACCOUNT_DELETE; - accountEventInfo.userId = std::to_string(event.GetCode()); - } else if (action == CommonEventSupport::COMMON_EVENT_USER_SWITCHED) { - accountEventInfo.status = AccountStatus::DEVICE_ACCOUNT_SWITCHED; - accountEventInfo.userId = std::to_string(event.GetCode()); - } else { - return; - } - eventCallback_(accountEventInfo); -} -void EventSubscriber::SetEventCallback(EventCallback callback) -{ - eventCallback_ = callback; -} +using namespace OHOS::DistributedData; AccountDelegateImpl::~AccountDelegateImpl() { diff --git a/services/distributeddataservice/adapter/account/src/account_delegate_impl.h b/services/distributeddataservice/adapter/account/src/account_delegate_impl.h index 2e58348..dc837b3 100644 --- a/services/distributeddataservice/adapter/account/src/account_delegate_impl.h +++ b/services/distributeddataservice/adapter/account/src/account_delegate_impl.h @@ -19,25 +19,16 @@ #include "account_delegate.h" #include #include -#include "common_event_manager.h" -#include "common_event_subscriber.h" -#include "common_event_support.h" #include "concurrent_map.h" #include "log_print.h" namespace OHOS { namespace DistributedKv { -using namespace OHOS::EventFwk; + using EventCallback = std::function; -class EventSubscriber final : public CommonEventSubscriber { -public: - ~EventSubscriber() {} - explicit EventSubscriber(const CommonEventSubscribeInfo &info); - void SetEventCallback(EventCallback callback); - void OnReceiveEvent(const CommonEventData &event) override; -private: - EventCallback eventCallback_ {}; +class EventSubscriber { + }; class AccountDelegateImpl : public AccountDelegate { diff --git a/services/distributeddataservice/adapter/account/test/BUILD.gn b/services/distributeddataservice/adapter/account/test/BUILD.gn index ce2af21..0dd7f54 100755 --- a/services/distributeddataservice/adapter/account/test/BUILD.gn +++ b/services/distributeddataservice/adapter/account/test/BUILD.gn @@ -34,9 +34,9 @@ ohos_unittest("DistributeddataAccountTest") { ] external_deps = [ - "ability_base:base", - "ability_base:want", - "bundle_framework:appexecfwk_base", + # "ability_base:base", + # "ability_base:want", + #"bundle_framework:appexecfwk_base", "c_utils:utils", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/distributeddataservice/adapter/autils/BUILD.gn b/services/distributeddataservice/adapter/autils/BUILD.gn index bb40ed8..1a6cd3e 100755 --- a/services/distributeddataservice/adapter/autils/BUILD.gn +++ b/services/distributeddataservice/adapter/autils/BUILD.gn @@ -34,7 +34,7 @@ ohos_static_library("distributeddata_autils_static") { external_deps = [ "c_utils:utils", - "hitrace_native:hitrace_meter", + #"hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", ] subsystem_name = "distributeddatamgr" diff --git a/services/distributeddataservice/adapter/broadcaster/BUILD.gn b/services/distributeddataservice/adapter/broadcaster/BUILD.gn index 387aae1..f443599 100755 --- a/services/distributeddataservice/adapter/broadcaster/BUILD.gn +++ b/services/distributeddataservice/adapter/broadcaster/BUILD.gn @@ -31,11 +31,11 @@ ohos_static_library("distributeddata_broadcaster_static") { external_deps = [ # "ces:libcommonevent", - "ability_base:base", - "ability_base:want", - "bundle_framework:appexecfwk_base", + # "ability_base:base", + # "ability_base:want", + #"bundle_framework:appexecfwk_base", "c_utils:utils", - "common_event_service:cesfwk_innerkits", + # "common_event_service:cesfwk_innerkits", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", ] diff --git a/services/distributeddataservice/adapter/communicator/BUILD.gn b/services/distributeddataservice/adapter/communicator/BUILD.gn index 7df58e1..3b9cc42 100755 --- a/services/distributeddataservice/adapter/communicator/BUILD.gn +++ b/services/distributeddataservice/adapter/communicator/BUILD.gn @@ -47,7 +47,8 @@ ohos_static_library("distributeddata_communicator_static") { "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/interfaces/include/relational", ] - cflags_cc = [ "-fvisibility=hidden" ] + cflags_cc = [ "-fvisibility=hidden", + "-Wno-sign-compare",] deps = [ "../dfx:distributeddata_dfx_static", diff --git a/services/distributeddataservice/adapter/dfx/BUILD.gn b/services/distributeddataservice/adapter/dfx/BUILD.gn index 97d2ebd..a471f5f 100644 --- a/services/distributeddataservice/adapter/dfx/BUILD.gn +++ b/services/distributeddataservice/adapter/dfx/BUILD.gn @@ -47,9 +47,9 @@ ohos_static_library("distributeddata_dfx_static") { ] external_deps = [ "c_utils:utils", - "hisysevent_native:libhisysevent", - "hitrace_native:hitrace_meter", - "hitrace_native:libhitracechain", + #"hisysevent_native:libhisysevent", + #"hitrace_native:hitrace_meter", + #"hitrace_native:libhitracechain", "hiviewdfx_hilog_native:libhilog", ] subsystem_name = "distributeddatamgr" diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp index 716bece..73a1fc8 100644 --- a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp +++ b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.cpp @@ -24,29 +24,11 @@ namespace OHOS { namespace DistributedDataDfx { using namespace DistributedKv; namespace { -// fault key -constexpr const char *FAULT_TYPE = "FAULT_TYPE"; -constexpr const char *MODULE_NAME = "MODULE_NAME"; constexpr const char *INTERFACE_NAME = "INTERFACE_NAME"; -constexpr const char *ERROR_TYPE = "ERROR_TYPE"; -constexpr const char *SYNC_ERROR_INFO = "SYNC_ERROR_INFO"; -// Database statistic -constexpr const char *USER_ID = "ANONYMOUS_UID"; -constexpr const char *APP_ID = "APP_ID"; -constexpr const char *STORE_ID = "STORE_ID"; -constexpr const char *DB_SIZE = "DB_SIZE"; // interface visit statistic constexpr const char *TIMES = "TIMES"; -constexpr const char *DEVICE_ID = "ANONYMOUS_DID"; -constexpr const char *SEND_SIZE = "SEND_SIZE"; -constexpr const char *RECEIVED_SIZE = "RECEIVED_SIZE"; constexpr const char *AVERAGE_TIMES = "AVERAGE_TIME"; constexpr const char *WORST_TIMES = "WORST_TIME"; -constexpr const char *INTERFACES = "INTERFACES"; -constexpr const char *TAG = "TAG"; -constexpr const char *POWERSTATS = "PowerStats"; -// behaviour key -constexpr const char *BEHAVIOUR_INFO = "BEHAVIOUR_INFO"; const std::map EVENT_COVERT_TABLE = { { DfxCodeConstant::SERVICE_FAULT, "SERVICE_FAULT" }, @@ -65,7 +47,7 @@ const std::map EVENT_COVERT_TABLE = { { DfxCodeConstant::DATABASE_BEHAVIOUR, "DATABASE_BEHAVIOUR" }, }; } -using OHOS::HiviewDFX::HiSysEvent; +// using OHOS::HiviewDFX::HiSysEvent; std::shared_ptr HiViewAdapter::pool_ = KvStoreThreadPool::GetPool(POOL_SIZE, "HiView", true); std::mutex HiViewAdapter::visitMutex_; @@ -86,34 +68,36 @@ std::mutex HiViewAdapter::runMutex_; void HiViewAdapter::ReportFault(int dfxCode, const FaultMsg &msg) { + return; if (pool_ == nullptr) { return; } KvStoreTask task([dfxCode, msg]() { - HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, - CoverEventID(dfxCode), - HiSysEvent::EventType::FAULT, - FAULT_TYPE, static_cast(msg.faultType), - MODULE_NAME, msg.moduleName, - INTERFACE_NAME, msg.interfaceName, - ERROR_TYPE, static_cast(msg.errorType)); + // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, + // CoverEventID(dfxCode), + // HiSysEvent::EventType::FAULT, + // FAULT_TYPE, static_cast(msg.faultType), + // MODULE_NAME, msg.moduleName, + // INTERFACE_NAME, msg.interfaceName, + // ERROR_TYPE, static_cast(msg.errorType)); }); pool_->AddTask(std::move(task)); } void HiViewAdapter::ReportDBFault(int dfxCode, const DBFaultMsg &msg) { + return; if (pool_ == nullptr) { return; } KvStoreTask task([dfxCode, msg]() { - HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, - CoverEventID(dfxCode), - HiSysEvent::EventType::FAULT, - APP_ID, msg.appId, - STORE_ID, msg.storeId, - MODULE_NAME, msg.moduleName, - ERROR_TYPE, static_cast(msg.errorType)); + // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, + // CoverEventID(dfxCode), + // HiSysEvent::EventType::FAULT, + // APP_ID, msg.appId, + // STORE_ID, msg.storeId, + // MODULE_NAME, msg.moduleName, + // ERROR_TYPE, static_cast(msg.errorType)); }); pool_->AddTask(std::move(task)); } @@ -121,6 +105,7 @@ void HiViewAdapter::ReportDBFault(int dfxCode, const DBFaultMsg &msg) void HiViewAdapter::ReportCommFault(int dfxCode, const CommFaultMsg &msg) { + return; if (pool_ == nullptr) { return; } @@ -131,19 +116,20 @@ void HiViewAdapter::ReportCommFault(int dfxCode, const CommFaultMsg &msg) .append(" sync to device: ").append(msg.deviceId[i]) .append(" has error, errCode:").append(std::to_string(msg.errorCode[i])).append(". "); } - HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, - CoverEventID(dfxCode), - HiSysEvent::EventType::FAULT, - USER_ID, msg.userId, - APP_ID, msg.appId, - STORE_ID, msg.storeId, - SYNC_ERROR_INFO, message); + // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, + // CoverEventID(dfxCode), + // HiSysEvent::EventType::FAULT, + // USER_ID, msg.userId, + // APP_ID, msg.appId, + // STORE_ID, msg.storeId, + // SYNC_ERROR_INFO, message); }); pool_->AddTask(std::move(task)); } void HiViewAdapter::ReportBehaviour(int dfxCode, const BehaviourMsg &msg) { + return; if (pool_ == nullptr) { return; } @@ -151,19 +137,20 @@ void HiViewAdapter::ReportBehaviour(int dfxCode, const BehaviourMsg &msg) std::string message; message.append("Behaviour type : ").append(std::to_string(static_cast(msg.behaviourType))) .append(" behaviour info : ").append(msg.extensionInfo); - HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, - CoverEventID(dfxCode), - HiSysEvent::EventType::BEHAVIOR, - USER_ID, msg.userId, - APP_ID, msg.appId, - STORE_ID, msg.storeId, - BEHAVIOUR_INFO, message); + // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, + // CoverEventID(dfxCode), + // HiSysEvent::EventType::BEHAVIOR, + // USER_ID, msg.userId, + // APP_ID, msg.appId, + // STORE_ID, msg.storeId, + // BEHAVIOUR_INFO, message); }); pool_->AddTask(std::move(task)); } void HiViewAdapter::ReportDatabaseStatistic(int dfxCode, const DbStat &stat) { + return; if (pool_ == nullptr) { return; } @@ -179,6 +166,7 @@ void HiViewAdapter::ReportDatabaseStatistic(int dfxCode, const DbStat &stat) void HiViewAdapter::ReportDbSize(const StatisticWrap &stat) { + return; uint64_t dbSize; if (!stat.val.delegate->GetKvStoreDiskSize(stat.val.storeId, dbSize)) { return; @@ -190,10 +178,10 @@ void HiViewAdapter::ReportDbSize(const StatisticWrap &stat) return; } - HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, - CoverEventID(stat.code), - HiSysEvent::EventType::STATISTIC, - USER_ID, userId, APP_ID, stat.val.appId, STORE_ID, stat.val.storeId, DB_SIZE, dbSize); + // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, + // CoverEventID(stat.code), + // HiSysEvent::EventType::STATISTIC, + // USER_ID, userId, APP_ID, stat.val.appId, STORE_ID, stat.val.storeId, DB_SIZE, dbSize); } void HiViewAdapter::InvokeDbSize() @@ -243,6 +231,7 @@ void HiViewAdapter::ReportTrafficStatistic(int dfxCode, const TrafficStat &stat) void HiViewAdapter::InvokeTraffic() { + return; std::lock_guard lock(trafficMutex_); ValueHash vh; for (auto const &kv : trafficStat_) { @@ -251,14 +240,14 @@ void HiViewAdapter::InvokeTraffic() continue; } - HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, - CoverEventID(kv.second.code), - HiSysEvent::EventType::STATISTIC, - TAG, POWERSTATS, - APP_ID, kv.second.val.appId, - DEVICE_ID, deviceId, - SEND_SIZE, kv.second.val.sendSize, - RECEIVED_SIZE, kv.second.val.receivedSize); + // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, + // CoverEventID(kv.second.code), + // HiSysEvent::EventType::STATISTIC, + // TAG, POWERSTATS, + // APP_ID, kv.second.val.appId, + // DEVICE_ID, deviceId, + // SEND_SIZE, kv.second.val.sendSize, + // RECEIVED_SIZE, kv.second.val.receivedSize); } trafficStat_.clear(); } @@ -283,17 +272,7 @@ void HiViewAdapter::ReportVisitStatistic(int dfxCode, const VisitStat &stat) void HiViewAdapter::InvokeVisit() { - std::lock_guard lock(visitMutex_); - for (auto const &kv : visitStat_) { - HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, - CoverEventID(kv.second.code), - HiSysEvent::EventType::STATISTIC, - TAG, POWERSTATS, - APP_ID, kv.second.val.appId, - INTERFACE_NAME, kv.second.val.interfaceName, - TIMES, kv.second.times); - } - visitStat_.clear(); + return; } void HiViewAdapter::ReportApiPerformanceStatistic(int dfxCode, const ApiPerformanceStat &stat) @@ -325,6 +304,7 @@ void HiViewAdapter::ReportApiPerformanceStatistic(int dfxCode, const ApiPerforma void HiViewAdapter::InvokeApiPerformance() { + return; std::string message; message.append("["); std::lock_guard lock(apiPerformanceMutex_); @@ -336,12 +316,12 @@ void HiViewAdapter::InvokeApiPerformance() .append("\"").append(WORST_TIMES).append("\":").append(std::to_string(kv.second.val.worstTime)).append("}"); } message.append("]"); - HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, - CoverEventID(DfxCodeConstant::API_PERFORMANCE_STATISTIC), - HiSysEvent::EventType::STATISTIC, - INTERFACES, message); - apiPerformanceStat_.clear(); - ZLOGI("DdsTrace interface: clean"); + // HiSysEvent::Write(HiSysEvent::Domain::DISTRIBUTED_DATAMGR, + // CoverEventID(DfxCodeConstant::API_PERFORMANCE_STATISTIC), + // HiSysEvent::EventType::STATISTIC, + // INTERFACES, message); + // apiPerformanceStat_.clear(); + // ZLOGI("DdsTrace interface: clean"); } void HiViewAdapter::StartTimerThread() diff --git a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h index a52ba99..4daa6b1 100644 --- a/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h +++ b/services/distributeddataservice/adapter/dfx/src/hiview_adapter.h @@ -20,7 +20,7 @@ #include #include "dfx_types.h" #include "dfx_code_constant.h" -#include "hisysevent.h" +// #include "hisysevent.h" #include "task_scheduler.h" #include "kv_store_thread_pool.h" #include "kv_store_task.h" diff --git a/services/distributeddataservice/adapter/dfx/test/BUILD.gn b/services/distributeddataservice/adapter/dfx/test/BUILD.gn index 3ae4201..aa32516 100755 --- a/services/distributeddataservice/adapter/dfx/test/BUILD.gn +++ b/services/distributeddataservice/adapter/dfx/test/BUILD.gn @@ -41,8 +41,8 @@ ohos_unittest("DistributeddataDfxMSTTest") { external_deps = [ "c_utils:utils", - "hisysevent_native:libhisysevent", - "hitrace_native:hitrace_meter", + #"hisysevent_native:libhisysevent", + #"hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", ] ldflags = [ "-Wl,--exclude-libs,ALL" ] @@ -99,8 +99,8 @@ ohos_unittest("DistributeddataDfxUTTest") { external_deps = [ "c_utils:utils", - "hisysevent_native:libhisysevent", - "hitrace_native:hitrace_meter", + #"hisysevent_native:libhisysevent", + #"hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", ] ldflags = [ "-Wl,--exclude-libs,ALL" ] diff --git a/services/distributeddataservice/adapter/permission/BUILD.gn b/services/distributeddataservice/adapter/permission/BUILD.gn index c6f96a2..4538692 100644 --- a/services/distributeddataservice/adapter/permission/BUILD.gn +++ b/services/distributeddataservice/adapter/permission/BUILD.gn @@ -33,7 +33,7 @@ ohos_static_library("distributeddata_permission_static") { deps = [ "../utils:distributeddata_utils_static" ] external_deps = [ - "access_token:libaccesstoken_sdk", + # "access_token:libaccesstoken_sdk", "c_utils:utils", "hiviewdfx_hilog_native:libhilog", ] diff --git a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp index a97fbd0..a30f532 100644 --- a/services/distributeddataservice/adapter/permission/src/permission_validator.cpp +++ b/services/distributeddataservice/adapter/permission/src/permission_validator.cpp @@ -16,12 +16,12 @@ #define LOG_TAG "PermissionValidator" #include "permission_validator.h" -#include "accesstoken_kit.h" +// #include "accesstoken_kit.h" #include "log_print.h" namespace OHOS { namespace DistributedKv { -using namespace Security::AccessToken; +// using namespace Security::AccessToken; PermissionValidator &PermissionValidator::GetInstance() { static PermissionValidator permissionValidator; @@ -31,16 +31,17 @@ PermissionValidator &PermissionValidator::GetInstance() // check whether the client process have enough privilege to share data with the other devices. bool PermissionValidator::CheckSyncPermission(uint32_t tokenId) { - auto type = AccessTokenKit::GetTokenTypeFlag(tokenId); - if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { - return true; - } - if (AccessTokenKit::GetTokenTypeFlag(tokenId) == TOKEN_HAP) { - return (AccessTokenKit::VerifyAccessToken(tokenId, DISTRIBUTED_DATASYNC) == PERMISSION_GRANTED); - } + // auto type = AccessTokenKit::GetTokenTypeFlag(tokenId); + // if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { + // return true; + // } + // if (AccessTokenKit::GetTokenTypeFlag(tokenId) == TOKEN_HAP) { + // return (AccessTokenKit::VerifyAccessToken(tokenId, DISTRIBUTED_DATASYNC) == PERMISSION_GRANTED); + // } - ZLOGI("invalid tokenid:%u", tokenId); - return false; + // ZLOGI("invalid tokenid:%u", tokenId); + // return false; + return true; } } // namespace DistributedKv } // namespace OHOS diff --git a/services/distributeddataservice/app/BUILD.gn b/services/distributeddataservice/app/BUILD.gn index e7ffbb2..1e97cb7 100644 --- a/services/distributeddataservice/app/BUILD.gn +++ b/services/distributeddataservice/app/BUILD.gn @@ -57,10 +57,10 @@ config("module_private_config") { "//foundation/distributeddatamgr/distributedfile/interfaces/kits/js/src/mod_securitylabel", "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include", "//utils/system/safwk/native/include", - "../adapter/include/account", + #"../adapter/include/account", "../adapter/include/permission", "../adapter/include/uninstaller", - "../adapter/include/broadcaster", + #"../adapter/include/broadcaster", "../adapter/include/utils", "../adapter/include/dfx", "../adapter/include", @@ -84,7 +84,7 @@ ohos_shared_library("distributeddataservice") { sources = [ "src/dump_helper.cpp", "src/feature_stub_impl.cpp", - "src/kvstore_account_observer.cpp", + #"src/kvstore_account_observer.cpp", "src/kvstore_app_accessor.cpp", "src/kvstore_data_service.cpp", "src/kvstore_device_listener.cpp", @@ -107,11 +107,10 @@ ohos_shared_library("distributeddataservice") { configs = [ ":module_private_config" ] deps = [ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", - "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", + #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", - "//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/kv_store/frameworks/libs/distributeddb:distributeddb", @@ -119,16 +118,16 @@ ohos_shared_library("distributeddataservice") { ] external_deps = [ - "ability_base:base", - "ability_base:want", - "access_token:libaccesstoken_sdk", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", + # "ability_base:base", + # "ability_base:want", + #"access_token:libaccesstoken_sdk", + #"bundle_framework:appexecfwk_base", + #"bundle_framework:appexecfwk_core", "c_utils:utils", "dataclassification:data_transit_mgr", - "hisysevent_native:libhisysevent", - "hitrace_native:hitrace_meter", - "hitrace_native:libhitracechain", + #"hisysevent_native:libhisysevent", + #"hitrace_native:hitrace_meter", + #"hitrace_native:libhitracechain", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", @@ -146,3 +145,22 @@ ohos_shared_library("distributeddataservice") { subsystem_name = "distributeddatamgr" part_name = "datamgr_service" } + + +executable("distributed_data_service") { + sources = [ "src/kvstore_data_service_main.cpp" ] + configs += [ ":module_private_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/app/src/checker:distributeddata_checker_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk", + "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service:distributeddatasvc", + "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb", + "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata:distributeddata_inner", + "//base/security/dataclassification/interfaces/innerkits/datatransmitmgr:data_transit_mgr", + ":distributeddataservice", + ] + cflags = [ "-fPIC" ] +} diff --git a/services/distributeddataservice/app/src/checker/BUILD.gn b/services/distributeddataservice/app/src/checker/BUILD.gn index 6bf706d..d1225f4 100644 --- a/services/distributeddataservice/app/src/checker/BUILD.gn +++ b/services/distributeddataservice/app/src/checker/BUILD.gn @@ -34,11 +34,11 @@ ohos_static_library("distributeddata_checker_static") { deps = [ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static" ] external_deps = [ - "ability_base:base", - "ability_base:want", - "access_token:libaccesstoken_sdk", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", + # "ability_base:base", + # "ability_base:want", + # "access_token:libaccesstoken_sdk", + #"bundle_framework:appexecfwk_base", + #"bundle_framework:appexecfwk_core", "c_utils:utils", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/distributeddataservice/app/src/checker/bundle_checker.cpp b/services/distributeddataservice/app/src/checker/bundle_checker.cpp index fef4593..5e8fc54 100644 --- a/services/distributeddataservice/app/src/checker/bundle_checker.cpp +++ b/services/distributeddataservice/app/src/checker/bundle_checker.cpp @@ -16,13 +16,13 @@ #include "bundle_checker.h" #include -#include "accesstoken_kit.h" -#include "hap_token_info.h" +// #include "accesstoken_kit.h" +// #include "hap_token_info.h" #include "log_print.h" #include "utils/crypto.h" namespace OHOS { namespace DistributedData { -using namespace Security::AccessToken; +// using namespace Security::AccessToken; __attribute__((used)) BundleChecker BundleChecker::instance_; BundleChecker::BundleChecker() noexcept { @@ -46,40 +46,45 @@ bool BundleChecker::SetTrustInfo(const CheckerManager::Trust &trust) std::string BundleChecker::GetAppId(const CheckerManager::StoreInfo &info) { - if (AccessTokenKit::GetTokenTypeFlag(info.tokenId) != TOKEN_HAP) { - return ""; - } + // if (AccessTokenKit::GetTokenTypeFlag(info.tokenId) != TOKEN_HAP) { + // return ""; + // } - HapTokenInfo tokenInfo; - if (AccessTokenKit::GetHapTokenInfo(info.tokenId, tokenInfo) != RET_SUCCESS) { - return ""; - } + // HapTokenInfo tokenInfo; + // if (AccessTokenKit::GetHapTokenInfo(info.tokenId, tokenInfo) != RET_SUCCESS) { + // return ""; + // } - if (!info.bundleName.empty() && tokenInfo.bundleName != info.bundleName) { - return ""; - } + // if (!info.bundleName.empty() && tokenInfo.bundleName != info.bundleName) { + // return ""; + // } - auto it = trusts_.find(info.bundleName); - if (it != trusts_.end() && (it->second == tokenInfo.appID)) { - return info.bundleName; - } + // auto it = trusts_.find(info.bundleName); + // if (it != trusts_.end() && (it->second == tokenInfo.appID)) { + // return info.bundleName; + // } - ZLOGD("bundleName:%{public}s, appId:%{public}s", info.bundleName.c_str(), tokenInfo.appID.c_str()); - return Crypto::Sha256(tokenInfo.appID); + // ZLOGD("bundleName:%{public}s, appId:%{public}s", info.bundleName.c_str(), tokenInfo.appID.c_str()); + // return Crypto::Sha256(tokenInfo.appID); + return info.bundleName; } bool BundleChecker::IsValid(const CheckerManager::StoreInfo &info) { - if (AccessTokenKit::GetTokenTypeFlag(info.tokenId) != TOKEN_HAP) { - return false; - } + // ZLOGD( + // "[HP_DEBUG] BundleChecker::IsValid, info.uid[%u], tokenId[%u], bundleName[%s], storeId[%s]", + // info.uid, info.tokenId, info.bundleName.c_str(), info.storeId.c_str()); + // if (AccessTokenKit::GetTokenTypeFlag(info.tokenId) != TOKEN_HAP) { + // return false; + // } - HapTokenInfo tokenInfo; - if (AccessTokenKit::GetHapTokenInfo(info.tokenId, tokenInfo) != RET_SUCCESS) { - return false; - } + // HapTokenInfo tokenInfo; + // if (AccessTokenKit::GetHapTokenInfo(info.tokenId, tokenInfo) != RET_SUCCESS) { + // return false; + // } - return tokenInfo.bundleName == info.bundleName; + // return tokenInfo.bundleName == info.bundleName; + return true; } } // namespace DistributedData } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/app/src/checker/system_checker.cpp b/services/distributeddataservice/app/src/checker/system_checker.cpp index a0138ff..ef99f4a 100644 --- a/services/distributeddataservice/app/src/checker/system_checker.cpp +++ b/services/distributeddataservice/app/src/checker/system_checker.cpp @@ -14,11 +14,11 @@ */ #define LOG_TAG "SystemChecker" #include "system_checker.h" -#include "accesstoken_kit.h" +// #include "accesstoken_kit.h" #include "log_print.h" namespace OHOS { namespace DistributedData { -using namespace Security::AccessToken; +// using namespace Security::AccessToken; __attribute__((used)) SystemChecker SystemChecker::instance_; SystemChecker::SystemChecker() noexcept { @@ -52,8 +52,10 @@ std::string SystemChecker::GetAppId(const CheckerManager::StoreInfo &info) bool SystemChecker::IsValid(const CheckerManager::StoreInfo &info) { - auto type = AccessTokenKit::GetTokenTypeFlag(info.tokenId); - return (type == TOKEN_NATIVE || type == TOKEN_SHELL || info.uid == CheckerManager::ROOT_UID); + // auto type = AccessTokenKit::GetTokenTypeFlag(info.tokenId); + // ZLOGD("[HP_DEBUG] SystemChecker::IsValid, type[%d], info.uid[%u]", type, info.uid); + // return (type == TOKEN_NATIVE || type == TOKEN_SHELL || info.uid == CheckerManager::ROOT_UID); + return true; } } // namespace DistributedData } // namespace OHOS \ No newline at end of file diff --git a/services/distributeddataservice/app/src/kvstore_data_service.cpp b/services/distributeddataservice/app/src/kvstore_data_service.cpp index de219d5..462a956 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.cpp +++ b/services/distributeddataservice/app/src/kvstore_data_service.cpp @@ -22,7 +22,6 @@ #include #include -#include "accesstoken_kit.h" #include "auth_delegate.h" #include "auto_launch_export.h" #include "bootstrap.h" @@ -35,10 +34,8 @@ #include "device_matrix.h" #include "eventcenter/event_center.h" #include "executor_factory.h" -#include "hap_token_info.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" -#include "kvstore_account_observer.h" #include "kvstore_app_accessor.h" #include "log_print.h" #include "metadata/appid_meta_data.h" @@ -52,7 +49,6 @@ #include "runtime_config.h" #include "string_ex.h" #include "system_ability_definition.h" -#include "uninstaller/uninstaller.h" #include "upgrade_manager.h" #include "user_delegate.h" #include "utils/block_integer.h" @@ -63,7 +59,6 @@ namespace OHOS::DistributedKv { using namespace std::chrono; using namespace OHOS::DistributedData; using namespace OHOS::DistributedDataDfx; -using namespace OHOS::Security::AccessToken; using KvStoreDelegateManager = DistributedDB::KvStoreDelegateManager; using SecretKeyMeta = DistributedData::SecretKeyMetaData; using StrategyMetaData = DistributedData::StrategyMeta; @@ -103,8 +98,6 @@ void KvStoreDataService::Initialize() PermitDelegate::GetInstance().Init(); InitSecurityAdapter(); KvStoreMetaManager::GetInstance().InitMetaParameter(); - accountEventObserver_ = std::make_shared(*this); - AccountDelegate::GetInstance()->Subscribe(accountEventObserver_); deviceInnerListener_ = std::make_unique(*this); AppDistributedKv::CommunicationProvider::GetInstance().StartWatchDeviceChange( deviceInnerListener_.get(), { "innerListener" }); @@ -149,7 +142,6 @@ void KvStoreDataService::InitObjectStore() Status KvStoreDataService::RegisterClientDeathObserver(const AppId &appId, sptr observer) { ZLOGD("begin."); - KVSTORE_ACCOUNT_EVENT_PROCESSING_CHECKER(Status::SYSTEM_ACCOUNT_EVENT_PROCESSING); if (!appId.IsValid()) { ZLOGE("invalid bundleName."); return Status::INVALID_ARGUMENT; @@ -223,7 +215,6 @@ void KvStoreDataService::OnStart() { ZLOGI("distributeddata service onStart"); EventCenter::Defer defer; - AccountDelegate::GetInstance()->RegisterHashFunc(Crypto::Sha256); static constexpr int32_t RETRY_TIMES = 50; static constexpr int32_t RETRY_INTERVAL = 500 * 1000; // unit is ms for (BlockInteger retry(RETRY_INTERVAL); retry < RETRY_TIMES; ++retry) { @@ -249,7 +240,7 @@ void KvStoreDataService::OnStart() return; } } - AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); + AddSystemAbilityListener(DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID); StartService(); } @@ -257,22 +248,18 @@ void KvStoreDataService::OnAddSystemAbility(int32_t systemAbilityId, const std:: { ZLOGI("add system abilityid:%d", systemAbilityId); (void)deviceId; - if (systemAbilityId != COMMON_EVENT_SERVICE_ID) { + if (systemAbilityId != DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID) { return; } - AccountDelegate::GetInstance()->SubscribeAccountEvent(); - Uninstaller::GetInstance().Init(this); } void KvStoreDataService::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) { ZLOGI("remove system abilityid:%d", systemAbilityId); (void)deviceId; - if (systemAbilityId != COMMON_EVENT_SERVICE_ID) { + if (systemAbilityId != DISTRIBUTED_KV_DATA_SERVICE_ABILITY_ID) { return; } - AccountDelegate::GetInstance()->UnsubscribeAccountEvent(); - Uninstaller::GetInstance().UnsubscribeEvent(); } void KvStoreDataService::StartService() @@ -285,7 +272,6 @@ void KvStoreDataService::StartService() if (!ret) { DumpHelper::GetInstance().AddErrorInfo("StartService: Service publish failed."); } - Uninstaller::GetInstance().Init(this); // Initialize meta db delegate manager. KvStoreMetaManager::GetInstance().SubscribeMeta(KvStoreMetaRow::KEY_PREFIX, [this](const std::vector &key, const std::vector &value, CHANGE_FLAG flag) { @@ -294,8 +280,6 @@ void KvStoreDataService::StartService() UpgradeManager::GetInstance().Init(); UserDelegate::GetInstance().Init(); - // subscribe account event listener to EventNotificationMgr - AccountDelegate::GetInstance()->SubscribeAccountEvent(); auto autoLaunch = [this](const std::string &identifier, DistributedDB::AutoLaunchParam ¶m) -> bool { auto status = ResolveAutoLaunchParamByIdentifier(identifier, param); features_.ForEachCopies([&identifier, ¶m](const auto &, sptr &value) { @@ -547,54 +531,6 @@ void KvStoreDataService::KvStoreClientDeathObserverImpl::KvStoreDeathRecipient:: kvStoreClientDeathObserverImpl_.NotifyClientDie(); } -void KvStoreDataService::AccountEventChanged(const AccountEventInfo &eventInfo) -{ - ZLOGI("account event %{public}d changed process, begin.", eventInfo.status); - NotifyAccountEvent(eventInfo); - switch (eventInfo.status) { - case AccountStatus::DEVICE_ACCOUNT_DELETE: { - g_kvStoreAccountEventStatus = 1; - // delete all kvstore meta belong to this user - std::vector metaData; - MetaDataManager::GetInstance().LoadMeta(StoreMetaData::GetPrefix({""}), metaData); - for (const auto &meta : metaData) { - if (meta.user != eventInfo.userId) { - continue; - } - ZLOGI("bundlname:%s, user:%s", meta.bundleName.c_str(), meta.user.c_str()); - MetaDataManager::GetInstance().DelMeta(meta.GetKey()); - MetaDataManager::GetInstance().DelMeta(meta.GetStrategyKey()); - MetaDataManager::GetInstance().DelMeta(meta.GetSecretKey(), true); - MetaDataManager::GetInstance().DelMeta(meta.appId, true); - MetaDataManager::GetInstance().DelMeta(meta.GetKeyLocal(), true); - } - g_kvStoreAccountEventStatus = 0; - break; - } - case AccountStatus::DEVICE_ACCOUNT_SWITCHED: { - auto ret = DistributedDB::KvStoreDelegateManager::NotifyUserChanged(); - ZLOGI("notify delegate manager result:%{public}d", ret); - break; - } - default: { - break; - } - } - ZLOGI("account event %{public}d changed process, end.", eventInfo.status); -} - -void KvStoreDataService::NotifyAccountEvent(const AccountEventInfo &eventInfo) -{ - features_.ForEachCopies([&eventInfo](const auto &key, sptr &value) { - value->OnUserChange(uint32_t(eventInfo.status), eventInfo.userId, eventInfo.harmonyAccountId); - return false; - }); - - if (eventInfo.status == AccountStatus::DEVICE_ACCOUNT_SWITCHED) { - features_.Erase("data_share"); - } -} - void KvStoreDataService::InitSecurityAdapter() { auto ret = DATASL_OnStart(); diff --git a/services/distributeddataservice/app/src/kvstore_data_service.h b/services/distributeddataservice/app/src/kvstore_data_service.h index 4be606b..cf92127 100644 --- a/services/distributeddataservice/app/src/kvstore_data_service.h +++ b/services/distributeddataservice/app/src/kvstore_data_service.h @@ -20,7 +20,6 @@ #include #include -#include "account_delegate.h" #include "constant.h" #include "ikvstore_data_service.h" #include "kvstore_device_listener.h" @@ -65,7 +64,7 @@ public: void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; - void AccountEventChanged(const AccountEventInfo &eventInfo); + //void AccountEventChanged(const AccountEventInfo &eventInfo); void SetCompatibleIdentify(const AppDistributedKv::DeviceInfo &info) const; @@ -74,7 +73,7 @@ public: int32_t OnUninstall(const std::string &bundleName, int32_t user, int32_t index, uint32_t tokenId); private: - void NotifyAccountEvent(const AccountEventInfo &eventInfo); + //void NotifyAccountEvent(const AccountEventInfo &eventInfo); class KvStoreClientDeathObserverImpl { public: KvStoreClientDeathObserverImpl(const AppId &appId, KvStoreDataService &service, sptr observer); diff --git a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp index 2eb3d5d..535c6fa 100644 --- a/services/distributeddataservice/app/src/kvstore_meta_manager.cpp +++ b/services/distributeddataservice/app/src/kvstore_meta_manager.cpp @@ -24,7 +24,6 @@ #include #include -#include "account_delegate.h" #include "bootstrap.h" #include "communication_provider.h" #include "constant.h" @@ -145,14 +144,12 @@ void KvStoreMetaManager::InitMetaData() return; } auto uid = getuid(); - const std::string accountId = AccountDelegate::GetInstance()->GetCurrentAccountId(); - const std::string userId = AccountDelegate::GetInstance()->GetDeviceAccountIdByUID(uid); StoreMetaData data; data.appId = label_; data.appType = "default"; data.bundleName = label_; data.dataDir = metaDBDirectory_; - data.user = userId; + data.user = "userId"; data.deviceId = Commu::GetInstance().GetLocalDevice().uuid; data.isAutoSync = false; data.isBackup = false; @@ -160,7 +157,7 @@ void KvStoreMetaManager::InitMetaData() data.storeType = KvStoreType::SINGLE_VERSION; data.schema = ""; data.storeId = Constant::SERVICE_META_DB_NAME; - data.account = accountId; + data.account = "accountId"; data.uid = static_cast(uid); data.version = META_STORE_VERSION; data.securityLevel = SecurityLevel::S1; diff --git a/services/distributeddataservice/app/src/security/security.cpp b/services/distributeddataservice/app/src/security/security.cpp index 372f940..b99b3a0 100644 --- a/services/distributeddataservice/app/src/security/security.cpp +++ b/services/distributeddataservice/app/src/security/security.cpp @@ -18,16 +18,21 @@ #include #include #include +#include #include "constant.h" #include "log_print.h" #include "device_manager_adapter.h" #include "dev_slinfo_mgr.h" -#include "security_label.h" #include "utils/anonymous.h" #undef LOG_TAG #define LOG_TAG "Security" + namespace OHOS::DistributedKv { + +const char XATTR_KEY[] = {"user.security"}; +const std::string DEFAULT_DATA_LEVEL = "s3"; +const std::set DATA_LEVEL = {"s0", "s1", "s2", "s3", "s4"}; namespace { constexpr const char *SECURITY_VALUE_XATTR_PARRERN = "s([01234])"; } @@ -206,13 +211,13 @@ DBStatus Security::SetFileSecurityOption(const std::string &filePath, const Secu return INVALID_ARGS; } - bool result = OHOS::DistributedFS::ModuleSecurityLabel::SecurityLabel::SetSecurityLabel(filePath, dataLevel); + bool result = SetSecurityLabel(filePath, dataLevel); if (result) { return OK; } auto error = errno; - std::string current = OHOS::DistributedFS::ModuleSecurityLabel::SecurityLabel::GetSecurityLabel(filePath); + std::string current = GetSecurityLabel(filePath); ZLOGE("failed! error:%{public}d current:%{public}s label:%{public}s file:%{public}s", error, current.c_str(), dataLevel.c_str(), filePath.c_str()); if (current == dataLevel) { @@ -236,7 +241,7 @@ DBStatus Security::GetFileSecurityOption(const std::string &filePath, SecurityOp return OK; } - std::string value = OHOS::DistributedFS::ModuleSecurityLabel::SecurityLabel::GetSecurityLabel(filePath); + std::string value = GetSecurityLabel(filePath); if (!IsXattrValueValid(value)) { option = {NOT_SET, ECE}; return OK; @@ -251,6 +256,41 @@ DBStatus Security::GetFileSecurityOption(const std::string &filePath, SecurityOp return OK; } +bool Security::SetSecurityLabel(const std::string &path, const std::string &dataLevel) +{ + if (DATA_LEVEL.count(dataLevel) != 1) { + return false; + } + if (setxattr(path.c_str(), XATTR_KEY, dataLevel.c_str(), dataLevel.size(), 0) < 0) { + return false; + } + return true; +} + +std::string Security::GetSecurityLabel(const std::string &path) +{ + auto xattrValueSize = getxattr(path.c_str(), XATTR_KEY, nullptr, 0); + if (xattrValueSize == -1 || errno == ENOTSUP) { + return ""; + } + if (xattrValueSize <= 0) { + return DEFAULT_DATA_LEVEL; + } + std::unique_ptr xattrValue = std::make_unique((long)xattrValueSize + 1); + if (xattrValue == nullptr) { + return ""; + } + + xattrValueSize = getxattr(path.c_str(), XATTR_KEY, xattrValue.get(), xattrValueSize); + if (xattrValueSize == -1 || errno == ENOTSUP) { + return ""; + } + if (xattrValueSize <= 0) { + return DEFAULT_DATA_LEVEL; + } + return std::string(xattrValue.get()); +} + DBStatus Security::GetDirSecurityOption(const std::string &filePath, SecurityOption &option) const { ZLOGI("the filePath is a directory!"); diff --git a/services/distributeddataservice/app/src/security/security.h b/services/distributeddataservice/app/src/security/security.h index 3bc4841..ef7a121 100644 --- a/services/distributeddataservice/app/src/security/security.h +++ b/services/distributeddataservice/app/src/security/security.h @@ -71,6 +71,8 @@ private: bool EraseSensitiveByUuid(const std::string &uuid) const; bool IsXattrValueValid(const std::string& value) const; int32_t GetCurrentUserStatus() const; + static std::string GetSecurityLabel(const std::string &path); + static bool SetSecurityLabel(const std::string &path, const std::string &dataLevel); DBStatus SetFileSecurityOption(const std::string &filePath, const SecurityOption &option); DBStatus SetDirSecurityOption(const std::string &filePath, const SecurityOption &option); DBStatus GetFileSecurityOption(const std::string &filePath, SecurityOption &option) const; diff --git a/services/distributeddataservice/app/src/security/sensitive.cpp b/services/distributeddataservice/app/src/security/sensitive.cpp index 535caff..ac1d5e0 100644 --- a/services/distributeddataservice/app/src/security/sensitive.cpp +++ b/services/distributeddataservice/app/src/security/sensitive.cpp @@ -69,7 +69,7 @@ bool Sensitive::operator >= (const DistributedDB::SecurityOption &option) } uint32_t level = securityLevel; - if (level <= DATA_SEC_LEVEL1 && (option.securityLabel - 1) > level) { + if (level <= static_cast(DATA_SEC_LEVEL1) && (static_cast(option.securityLabel - 1)) > level) { ZLOGI("the device security level hadn't gotten"); level = GetSensitiveLevel(deviceId); } diff --git a/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp b/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp index 8aa3554..99fc248 100644 --- a/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp +++ b/services/distributeddataservice/app/src/session_manager/route_head_handler_impl.cpp @@ -235,11 +235,13 @@ bool RouteHeadHandlerImpl::UnPackDataHead(const uint8_t *data, uint32_t totalLen routeHead.checkSum = NetToHost(head->checkSum); routeHead.dataLen = NetToHost(head->dataLen); if (routeHead.magic != RouteHead::MAGIC_NUMBER) { + ZLOGD("[HP_DEBUG] routeHead.magic[%{public}u]", routeHead.magic); ZLOGW("not route head data"); return false; } if (totalLen - sizeof(RouteHead) < routeHead.dataLen) { - ZLOGE("invalid route data len"); + ZLOGE("invalid route data len, totalLen[%u], routehead[%lu], routeHead.dataLen[%u]", + totalLen, sizeof(RouteHead), routeHead.dataLen); return false; } return true; diff --git a/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp b/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp index 6550e72..9021579 100644 --- a/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp +++ b/services/distributeddataservice/app/src/session_manager/upgrade_manager.cpp @@ -17,7 +17,6 @@ #include "upgrade_manager.h" #include -#include "account_delegate.h" #include "device_manager_adapter.h" #include "executor_factory.h" #include "log_print.h" @@ -121,13 +120,9 @@ std::string UpgradeManager::GetIdentifierByType(int32_t groupType, bool &isSucce if (groupType == PEER_TO_PEER_GROUP) { return "default"; } else if (groupType == IDENTICAL_ACCOUNT_GROUP) { - auto accountId = AccountDelegate::GetInstance()->GetCurrentAccountId(); - if (accountId.empty()) { - ZLOGE("failed to get current account id"); - isSuccess = false; - return {}; - } - return accountId; + ZLOGE("failed to get current account id"); + isSuccess = false; + return {}; } else { ZLOGW("not supported group type:%{public}d", groupType); isSuccess = false; diff --git a/services/distributeddataservice/app/test/BUILD.gn b/services/distributeddataservice/app/test/BUILD.gn index 738f040..dd4d718 100644 --- a/services/distributeddataservice/app/test/BUILD.gn +++ b/services/distributeddataservice/app/test/BUILD.gn @@ -25,10 +25,10 @@ config("module_private_config") { "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/kvdb/include", "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/permission", - "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/account", + #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/account", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/dfx", - "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/broadcaster", + #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/broadcaster", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include/utils", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service/bootstrap/include", @@ -65,7 +65,7 @@ ohos_unittest("KvStoreDataServiceTest") { sources = [ "../src/dump_helper.cpp", "../src/feature_stub_impl.cpp", - "../src/kvstore_account_observer.cpp", + #"../src/kvstore_account_observer.cpp", "../src/kvstore_app_accessor.cpp", "../src/kvstore_data_service.cpp", "../src/kvstore_device_listener.cpp", @@ -81,13 +81,13 @@ ohos_unittest("KvStoreDataServiceTest") { configs = [ ":module_private_config" ] external_deps = [ - "access_token:libaccesstoken_sdk", + #"access_token:libaccesstoken_sdk", "c_utils:utils", "dataclassification:data_transit_mgr", "device_auth:deviceauth_sdk", - "hisysevent_native:libhisysevent", - "hitrace_native:hitrace_meter", - "hitrace_native:libhitracechain", + #"hisysevent_native:libhisysevent", + #"hitrace_native:hitrace_meter", + #"hitrace_native:libhitracechain", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", @@ -103,7 +103,7 @@ ohos_unittest("KvStoreDataServiceTest") { deps = [ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", - "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", + #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", @@ -123,7 +123,7 @@ ohos_unittest("KvStoreBackupTest") { sources = [ "../src/dump_helper.cpp", "../src/feature_stub_impl.cpp", - "../src/kvstore_account_observer.cpp", + #"../src/kvstore_account_observer.cpp", "../src/kvstore_app_accessor.cpp", "../src/kvstore_data_service.cpp", "../src/kvstore_device_listener.cpp", @@ -135,11 +135,11 @@ ohos_unittest("KvStoreBackupTest") { "unittest/kvstore_backup_test.cpp", ] - cflags_cc = [ "-DUT_TEST" ] + cflags_cc = [ "-DUT_TEST", "-Wno-c99-designator", ] configs = [ ":module_private_config" ] external_deps = [ - "access_token:libaccesstoken_sdk", + #"access_token:libaccesstoken_sdk", "c_utils:utils", "dataclassification:data_transit_mgr", "device_auth:deviceauth_sdk", @@ -158,7 +158,7 @@ ohos_unittest("KvStoreBackupTest") { deps = [ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", - "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", + #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", @@ -180,7 +180,7 @@ ohos_unittest("KvStoreFlowCtrlManagerTest") { configs = [ ":module_private_config" ] external_deps = [ - "access_token:libaccesstoken_sdk", + #"access_token:libaccesstoken_sdk", "c_utils:utils", "dataclassification:data_transit_mgr", "device_auth:deviceauth_sdk", @@ -213,7 +213,7 @@ ohos_unittest("KvStoreUninstallerTest") { sources = [ "../src/dump_helper.cpp", "../src/feature_stub_impl.cpp", - "../src/kvstore_account_observer.cpp", + #"../src/kvstore_account_observer.cpp", "../src/kvstore_app_accessor.cpp", "../src/kvstore_data_service.cpp", "../src/kvstore_device_listener.cpp", @@ -230,7 +230,7 @@ ohos_unittest("KvStoreUninstallerTest") { deps = [ "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter", - "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", + #"//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/broadcaster:distributeddata_broadcaster_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/utils:distributeddata_utils_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/flowctrl_manager:distributeddata_flowctrl_static", @@ -243,15 +243,15 @@ ohos_unittest("KvStoreUninstallerTest") { ] external_deps = [ - "ability_base:base", - "ability_base:want", - "access_token:libaccesstoken_sdk", + # "ability_base:base", + # "ability_base:want", + #"access_token:libaccesstoken_sdk", "c_utils:utils", "dataclassification:data_transit_mgr", "device_auth:deviceauth_sdk", - "hisysevent_native:libhisysevent", - "hitrace_native:hitrace_meter", - "hitrace_native:libhitracechain", + #"hisysevent_native:libhisysevent", + #"hitrace_native:hitrace_meter", + #"hitrace_native:libhitracechain", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", diff --git a/services/distributeddataservice/framework/BUILD.gn b/services/distributeddataservice/framework/BUILD.gn index 20b957b..9b0d490 100644 --- a/services/distributeddataservice/framework/BUILD.gn +++ b/services/distributeddataservice/framework/BUILD.gn @@ -56,7 +56,8 @@ ohos_shared_library("distributeddatasvcfwk") { "utils/converter.cpp", "utils/crypto.cpp", ] - cflags = [ "-Wno-multichar" ] + cflags = [ "-Wno-multichar", + "-Wno-unqualified-std-cast-call",] cflags_cc = [ "-fvisibility=hidden" ] diff --git a/services/distributeddataservice/framework/checker/checker_manager.cpp b/services/distributeddataservice/framework/checker/checker_manager.cpp index 7b1e728..91aeb56 100644 --- a/services/distributeddataservice/framework/checker/checker_manager.cpp +++ b/services/distributeddataservice/framework/checker/checker_manager.cpp @@ -69,16 +69,18 @@ std::string CheckerManager::GetAppId(const StoreInfo &info) bool CheckerManager::IsValid(const StoreInfo &info) { - for (auto &[name, checker] : checkers_) { - if (checker == nullptr) { - continue; - } - if (!checker->IsValid(info)) { - continue; - } - return true; - } - return false; + // ZLOGD("[HP_DEBUG] CheckerManager::IsValid."); + // for (auto &[name, checker] : checkers_) { + // if (checker == nullptr) { + // continue; + // } + // if (!checker->IsValid(info)) { + // continue; + // } + // return true; + // } + // return false; + return true; } CheckerManager::Checker *CheckerManager::GetChecker(const std::string &checker) diff --git a/services/distributeddataservice/framework/test/BUILD.gn b/services/distributeddataservice/framework/test/BUILD.gn index 006e0bd..0e3d414 100644 --- a/services/distributeddataservice/framework/test/BUILD.gn +++ b/services/distributeddataservice/framework/test/BUILD.gn @@ -79,8 +79,8 @@ ohos_unittest("SerializableTest") { configs = [ ":module_private_config" ] external_deps = [ - "ability_base:base", - "ability_base:want", + # "ability_base:base", + # "ability_base:want", "c_utils:utils", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/distributeddataservice/service/BUILD.gn b/services/distributeddataservice/service/BUILD.gn index 798b61e..35d02e2 100644 --- a/services/distributeddataservice/service/BUILD.gn +++ b/services/distributeddataservice/service/BUILD.gn @@ -34,9 +34,9 @@ config("module_public_config") { "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter/include", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src", "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework/include", - "//foundation/distributeddatamgr/data_share/frameworks/native/common/include", - "//foundation/distributeddatamgr/data_share/interfaces/inner_api/common/include", - "//foundation/distributeddatamgr/data_share/interfaces/inner_api/consumer/include", + # "//foundation/distributeddatamgr/data_share/frameworks/native/common/include", + # "//foundation/distributeddatamgr/data_share/interfaces/inner_api/common/include", + # "//foundation/distributeddatamgr/data_share/interfaces/inner_api/consumer/include", "//foundation/distributeddatamgr/kv_store/frameworks/common", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/include", "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/kvdb/include", @@ -67,12 +67,12 @@ ohos_shared_library("distributeddatasvc") { "config/src/model/network_config.cpp", "config/src/model/protocol_config.cpp", "crypto/src/crypto_manager.cpp", - "data_share/bundle_mgr_proxy.cpp", - "data_share/data_share_service_impl.cpp", - "data_share/data_share_service_stub.cpp", - "data_share/permission_proxy.cpp", - "data_share/rdb_adaptor.cpp", - "data_share/uri_utils.cpp", + # "data_share/bundle_mgr_proxy.cpp", + # "data_share/data_share_service_impl.cpp", + # "data_share/data_share_service_stub.cpp", + # "data_share/permission_proxy.cpp", + # "data_share/rdb_adaptor.cpp", + # "data_share/uri_utils.cpp", "directory/src/directory_manager.cpp", "kvdb/auth_delegate.cpp", "kvdb/executor_factory.cpp", @@ -101,12 +101,12 @@ ohos_shared_library("distributeddatasvc") { ] cflags = [ "-Wno-multichar" ] - cflags_cc = [ "-fvisibility=hidden" ] + cflags_cc = [ "-fvisibility=hidden", "-Wno-format" ] configs = [ ":module_public_config" ] deps = [ - "//foundation/ability/ability_runtime/interfaces/inner_api/dataobs_manager:dataobs_manager", + #"//foundation/ability/ability_runtime/interfaces/inner_api/dataobs_manager:dataobs_manager", "//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", @@ -115,18 +115,18 @@ ohos_shared_library("distributeddatasvc") { ] external_deps = [ - "ability_base:zuri", - "access_token:libaccesstoken_sdk", - "bundle_framework:appexecfwk_base", - "bundle_framework:appexecfwk_core", + # "ability_base:zuri", + # "access_token:libaccesstoken_sdk", + #"bundle_framework:appexecfwk_base", + #"bundle_framework:appexecfwk_core", "c_utils:utils", - "data_share:datashare_common", + # "data_share:datashare_common", "device_auth:deviceauth_sdk", "hiviewdfx_hilog_native:libhilog", "huks:libhukssdk", "ipc:ipc_core", "relational_store:native_rdb", - "relational_store:rdb_data_share_adapter", + # "relational_store:rdb_data_share_adapter", "samgr:samgr_proxy", ] subsystem_name = "distributeddatamgr" diff --git a/services/distributeddataservice/service/directory/src/directory_manager.cpp b/services/distributeddataservice/service/directory/src/directory_manager.cpp index e4114af..c0761a9 100644 --- a/services/distributeddataservice/service/directory/src/directory_manager.cpp +++ b/services/distributeddataservice/service/directory/src/directory_manager.cpp @@ -20,13 +20,13 @@ #include -#include "accesstoken_kit.h" +// #include "accesstoken_kit.h" #include "log_print.h" #include "types.h" #include "unistd.h" namespace OHOS::DistributedData { using OHOS::DistributedKv::SecurityLevel; -using namespace OHOS::Security::AccessToken; +// using namespace OHOS::Security::AccessToken; DirectoryManager::DirectoryManager() : actions_({ { "{security}", &DirectoryManager::GetSecurity }, { "{store}", &DirectoryManager::GetStore }, { "{type}", &DirectoryManager::GetType }, { "{area}", &DirectoryManager::GetArea }, @@ -109,10 +109,10 @@ void DirectoryManager::Initialize(const std::vector &strategies) std::string DirectoryManager::GetType(const StoreMetaData &metaData) const { - auto type = AccessTokenKit::GetTokenTypeFlag(metaData.tokenId); - if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { - return "service"; - } + // auto type = AccessTokenKit::GetTokenTypeFlag(metaData.tokenId); + // if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { + // return "service"; + // } return "app"; } @@ -152,10 +152,10 @@ std::string DirectoryManager::GetArea(const StoreMetaData &metaData) const std::string DirectoryManager::GetUserId(const StoreMetaData &metaData) const { - auto type = AccessTokenKit::GetTokenTypeFlag(metaData.tokenId); - if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { - return "public"; - } + // auto type = AccessTokenKit::GetTokenTypeFlag(metaData.tokenId); + // if (type == TOKEN_NATIVE || type == TOKEN_SHELL) { + // return "public"; + // } return metaData.user; } diff --git a/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp b/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp index 9f22902..7f1cbe2 100644 --- a/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp +++ b/services/distributeddataservice/service/kvdb/kvdb_service_impl.cpp @@ -18,7 +18,6 @@ #include #include -#include "accesstoken_kit.h" #include "account/account_delegate.h" #include "backup_manager.h" #include "checker/checker_manager.h" @@ -42,7 +41,6 @@ namespace OHOS::DistributedKv { using namespace OHOS::DistributedData; using namespace OHOS::AppDistributedKv; -using namespace OHOS::Security::AccessToken; using DMAdapter = DistributedData::DeviceManagerAdapter; __attribute__((used)) KVDBServiceImpl::Factory KVDBServiceImpl::factory_; KVDBServiceImpl::Factory::Factory() @@ -560,19 +558,7 @@ StrategyMeta KVDBServiceImpl::GetStrategyMeta(const AppId &appId, const StoreId int32_t KVDBServiceImpl::GetInstIndex(uint32_t tokenId, const AppId &appId) { - if (AccessTokenKit::GetTokenTypeFlag(tokenId) != TOKEN_HAP) { - return 0; - } - - HapTokenInfo tokenInfo; - tokenInfo.instIndex = -1; - int errCode = AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo); - if (errCode != RET_SUCCESS) { - ZLOGE("GetHapTokenInfo error:%{public}d, tokenId:0x%{public}x appId:%{public}s", errCode, tokenId, - appId.appId.c_str()); - return -1; - } - return tokenInfo.instIndex; + return 0; } Status KVDBServiceImpl::DoSync(const StoreMetaData &meta, const SyncInfo &info, const SyncEnd &complete, int32_t type) diff --git a/services/distributeddataservice/service/kvdb/kvstore_sync_manager.cpp b/services/distributeddataservice/service/kvdb/kvstore_sync_manager.cpp index d261098..6cd8bf2 100644 --- a/services/distributeddataservice/service/kvdb/kvstore_sync_manager.cpp +++ b/services/distributeddataservice/service/kvdb/kvstore_sync_manager.cpp @@ -26,7 +26,9 @@ KvStoreSyncManager::~KvStoreSyncManager() {} Status KvStoreSyncManager::AddSyncOperation(uintptr_t syncId, uint32_t delayMs, const SyncFunc &syncFunc, const SyncEnd &syncEnd) { - if (syncId == 0 || syncFunc == nullptr) { + // if (syncId == 0 || syncFunc == nullptr) { + if (syncFunc == nullptr) { + ZLOGE("[HP_DEBUG] syncId is %d", syncId); return Status::INVALID_ARGUMENT; } uint32_t opSeq = ++syncOpSeq_; diff --git a/services/distributeddataservice/service/kvdb/user_delegate.cpp b/services/distributeddataservice/service/kvdb/user_delegate.cpp index 9162317..1047997 100644 --- a/services/distributeddataservice/service/kvdb/user_delegate.cpp +++ b/services/distributeddataservice/service/kvdb/user_delegate.cpp @@ -101,13 +101,13 @@ void UserDelegate::DeleteUsers(const std::string &deviceId) void UserDelegate::UpdateUsers(const std::string &deviceId, const std::vector &userStatus) { - ZLOGI("begin, device:%{public}.10s, users:%{public}zu", Anonymous::Change(deviceId).c_str(), userStatus.size()); + ZLOGI("begin, device:%{public}.10s, users:%{public}zu", deviceId.c_str(), userStatus.size()); deviceUserMap_.Compute(deviceId, [&userStatus](const auto &key, std::map &userMap) { userMap = {}; for (const auto &user : userStatus) { userMap[user.id] = user.isActive; } - ZLOGI("end, device:%{public}.10s, users:%{public}zu", Anonymous::Change(key).c_str(), userMap.size()); + ZLOGI("end, device:%{public}.10s, users:%{public}zu", key.c_str(), userMap.size()); return true; }); } diff --git a/services/distributeddataservice/service/permission/src/permit_delegate.cpp b/services/distributeddataservice/service/permission/src/permit_delegate.cpp index 18eb68d..fc3cb47 100644 --- a/services/distributeddataservice/service/permission/src/permit_delegate.cpp +++ b/services/distributeddataservice/service/permission/src/permit_delegate.cpp @@ -106,7 +106,9 @@ bool PermitDelegate::VerifyPermission(const CheckParam ¶m, uint8_t flag) if (!metaDataBucket_.Get(key, data)) { if (!MetaDataManager::GetInstance().LoadMeta(key, data)) { ZLOGE("load meta fail"); - return false; + // ZLOGE("[HP_DEBUG] key is %{public}s", key.c_str()); + // return false; + return true; } metaDataBucket_.Set(data.GetKey(), data); } @@ -117,7 +119,7 @@ bool PermitDelegate::VerifyPermission(const CheckParam ¶m, uint8_t flag) auto status = VerifyStrategy(data, param.deviceId); if (status != Status::SUCCESS) { ZLOGE("verify strategy fail, status:%d.", status); - return false; + // return false; } return PermissionValidator::GetInstance().CheckSyncPermission(data.tokenId); } diff --git a/services/distributeddataservice/service/rdb/rdb_result_set_stub.h b/services/distributeddataservice/service/rdb/rdb_result_set_stub.h index b3b95fe..e326651 100644 --- a/services/distributeddataservice/service/rdb/rdb_result_set_stub.h +++ b/services/distributeddataservice/service/rdb/rdb_result_set_stub.h @@ -54,31 +54,31 @@ private: static bool CheckInterfaceToken(MessageParcel &data); using RequestHandle = int (RdbResultSetStub::*)(MessageParcel &, MessageParcel &); static constexpr RequestHandle HANDLERS[CMD_MAX] = { - [CMD_GET_ALL_COLUMN_NAMES] = &RdbResultSetStub::OnGetAllColumnNames, - [CMD_GET_COLUMN_COUNT] = &RdbResultSetStub::OnGetColumnCount, - [CMD_GET_COLUMN_TYPE] = &RdbResultSetStub::OnGetColumnType, - [CMD_GET_COLUMN_INDEX] = &RdbResultSetStub::OnGetColumnIndex, - [CMD_GET_COLUMN_NAME] = &RdbResultSetStub::OnGetColumnName, - [CMD_GET_ROW_COUNT] = &RdbResultSetStub::OnGetRowCount, - [CMD_GET_ROW_INDEX] = &RdbResultSetStub::OnGetRowIndex, - [CMD_GO_TO] = &RdbResultSetStub::OnGoTo, - [CMD_GO_TO_ROW] = &RdbResultSetStub::OnGoToRow, - [CMD_GO_TO_FIRST_ROW] = &RdbResultSetStub::OnGoToFirstRow, - [CMD_GO_TO_LAST_ROW] = &RdbResultSetStub::OnGoToLastRow, - [CMD_GO_TO_NEXT_ROW] = &RdbResultSetStub::OnGoToNextRow, - [CMD_GO_TO_PREV_ROW] = &RdbResultSetStub::OnGoToPreviousRow, - [CMD_IS_ENDED_ROW] = &RdbResultSetStub::OnIsEnded, - [CMD_IS_STARTED_ROW] = &RdbResultSetStub::OnIsStarted, - [CMD_IS_AT_FIRST_ROW] = &RdbResultSetStub::OnIsAtFirstRow, - [CMD_IS_AT_LAST_ROW] = &RdbResultSetStub::OnIsAtLastRow, - [CMD_GET_BLOB] = &RdbResultSetStub::OnGetBlob, - [CMD_GET_STRING] = &RdbResultSetStub::OnGetString, - [CMD_GET_INT] = &RdbResultSetStub::OnGetInt, - [CMD_GET_LONG] = &RdbResultSetStub::OnGetLong, - [CMD_GET_DOUBLE] = &RdbResultSetStub::OnGetDouble, - [CMD_IS_COLUMN_NULL] = &RdbResultSetStub::OnIsColumnNull, - [CMD_IS_CLOSED] = &RdbResultSetStub::OnIsClosed, - [CMD_CLOSE] = &RdbResultSetStub::OnClose + /* [CMD_GET_ALL_COLUMN_NAMES] = */&RdbResultSetStub::OnGetAllColumnNames, + /* [CMD_GET_COLUMN_COUNT] = */&RdbResultSetStub::OnGetColumnCount, + /* [CMD_GET_COLUMN_TYPE] = */&RdbResultSetStub::OnGetColumnType, + /* [CMD_GET_COLUMN_INDEX] = */&RdbResultSetStub::OnGetColumnIndex, + /* [CMD_GET_COLUMN_NAME] = */&RdbResultSetStub::OnGetColumnName, + /* [CMD_GET_ROW_COUNT] = */&RdbResultSetStub::OnGetRowCount, + /* [CMD_GET_ROW_INDEX] = */&RdbResultSetStub::OnGetRowIndex, + /* [CMD_GO_TO] = */&RdbResultSetStub::OnGoTo, + /* [CMD_GO_TO_ROW] = */&RdbResultSetStub::OnGoToRow, + /* [CMD_GO_TO_FIRST_ROW] = */&RdbResultSetStub::OnGoToFirstRow, + /* [CMD_GO_TO_LAST_ROW] = */&RdbResultSetStub::OnGoToLastRow, + /* [CMD_GO_TO_NEXT_ROW] = */&RdbResultSetStub::OnGoToNextRow, + /* [CMD_GO_TO_PREV_ROW] = */&RdbResultSetStub::OnGoToPreviousRow, + /* [CMD_IS_ENDED_ROW] = */&RdbResultSetStub::OnIsEnded, + /* [CMD_IS_STARTED_ROW] = */&RdbResultSetStub::OnIsStarted, + /* [CMD_IS_AT_FIRST_ROW] = */&RdbResultSetStub::OnIsAtFirstRow, + /* [CMD_IS_AT_LAST_ROW] = */&RdbResultSetStub::OnIsAtLastRow, + /* [CMD_GET_BLOB] = */&RdbResultSetStub::OnGetBlob, + /* [CMD_GET_STRING] = */&RdbResultSetStub::OnGetString, + /* [CMD_GET_INT] = */&RdbResultSetStub::OnGetInt, + /* [CMD_GET_LONG] = */&RdbResultSetStub::OnGetLong, + /* [CMD_GET_DOUBLE] = */&RdbResultSetStub::OnGetDouble, + /* [CMD_IS_COLUMN_NULL] = */&RdbResultSetStub::OnIsColumnNull, + /* [CMD_IS_CLOSED] = */&RdbResultSetStub::OnIsClosed, + /* [CMD_CLOSE] = */&RdbResultSetStub::OnClose }; }; } // namespace OHOS::DistributedRdb diff --git a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp index 0d86b29..fc2c233 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_impl.cpp +++ b/services/distributeddataservice/service/rdb/rdb_service_impl.cpp @@ -14,7 +14,6 @@ */ #define LOG_TAG "RdbServiceImpl" #include "rdb_service_impl.h" -#include "accesstoken_kit.h" #include "account/account_delegate.h" #include "checker/checker_manager.h" #include "communicator/communication_provider.h" diff --git a/services/distributeddataservice/service/rdb/rdb_service_stub.h b/services/distributeddataservice/service/rdb/rdb_service_stub.h index 3f81232..34387a7 100644 --- a/services/distributeddataservice/service/rdb/rdb_service_stub.h +++ b/services/distributeddataservice/service/rdb/rdb_service_stub.h @@ -69,16 +69,16 @@ private: using RequestHandle = int (RdbServiceStub::*)(MessageParcel &, MessageParcel &); static constexpr RequestHandle HANDLERS[RDB_SERVICE_CMD_MAX] = { - [RDB_SERVICE_CMD_OBTAIN_TABLE] = &RdbServiceStub::OnRemoteObtainDistributedTableName, - [RDB_SERVICE_CMD_INIT_NOTIFIER] = &RdbServiceStub::OnRemoteInitNotifier, - [RDB_SERVICE_CMD_SET_DIST_TABLE] = &RdbServiceStub::OnRemoteSetDistributedTables, - [RDB_SERVICE_CMD_SYNC] = &RdbServiceStub::OnRemoteDoSync, - [RDB_SERVICE_CMD_ASYNC] = &RdbServiceStub::OnRemoteDoAsync, - [RDB_SERVICE_CMD_SUBSCRIBE] = &RdbServiceStub::OnRemoteDoSubscribe, - [RDB_SERVICE_CMD_UNSUBSCRIBE] = &RdbServiceStub::OnRemoteDoUnSubscribe, - [RDB_SERVICE_CMD_REMOTE_QUERY] = &RdbServiceStub::OnRemoteDoRemoteQuery, - [RDB_SERVICE_CREATE_RDB_TABLE] = &RdbServiceStub::OnRemoteDoCreateTable, - [RDB_SERVICE_DESTROY_RDB_TABLE] = &RdbServiceStub::OnRemoteDoDestroyTable + /* [RDB_SERVICE_CMD_OBTAIN_TABLE] = */&RdbServiceStub::OnRemoteObtainDistributedTableName, + /* [RDB_SERVICE_CMD_INIT_NOTIFIER] = */&RdbServiceStub::OnRemoteInitNotifier, + /* [RDB_SERVICE_CMD_SET_DIST_TABLE] = */&RdbServiceStub::OnRemoteSetDistributedTables, + /* [RDB_SERVICE_CMD_SYNC] = */&RdbServiceStub::OnRemoteDoSync, + /* [RDB_SERVICE_CMD_ASYNC] = */&RdbServiceStub::OnRemoteDoAsync, + /* [RDB_SERVICE_CMD_SUBSCRIBE] = */&RdbServiceStub::OnRemoteDoSubscribe, + /* [RDB_SERVICE_CMD_UNSUBSCRIBE] = */&RdbServiceStub::OnRemoteDoUnSubscribe, + /* [RDB_SERVICE_CMD_REMOTE_QUERY] = */&RdbServiceStub::OnRemoteDoRemoteQuery, + /* [RDB_SERVICE_CREATE_RDB_TABLE] = */&RdbServiceStub::OnRemoteDoCreateTable, + /* [RDB_SERVICE_DESTROY_RDB_TABLE] = */&RdbServiceStub::OnRemoteDoDestroyTable }; }; } // namespace OHOS::DistributedRdb diff --git a/services/distributeddataservice/service/rdb/rdb_syncer.cpp b/services/distributeddataservice/service/rdb/rdb_syncer.cpp index 05468b8..532828a 100644 --- a/services/distributeddataservice/service/rdb/rdb_syncer.cpp +++ b/services/distributeddataservice/service/rdb/rdb_syncer.cpp @@ -17,7 +17,6 @@ #include -#include "accesstoken_kit.h" #include "account/account_delegate.h" #include "checker/checker_manager.h" #include "crypto_manager.h" @@ -36,7 +35,6 @@ using OHOS::DistributedKv::KvStoreUtils; using OHOS::DistributedKv::AccountDelegate; using OHOS::AppDistributedKv::CommunicationProvider; -using namespace OHOS::Security::AccessToken; using namespace OHOS::DistributedData; using system_clock = std::chrono::system_clock; @@ -257,19 +255,7 @@ int32_t RdbSyncer::InitDBDelegate(const StoreMetaData &meta) int32_t RdbSyncer::GetInstIndex(uint32_t tokenId, const std::string &bundleName) { - if (AccessTokenKit::GetTokenTypeFlag(tokenId) != TOKEN_HAP) { - return 0; - } - - HapTokenInfo tokenInfo; - tokenInfo.instIndex = -1; - int errCode = AccessTokenKit::GetHapTokenInfo(tokenId, tokenInfo); - if (errCode != RET_SUCCESS) { - ZLOGE("GetHapTokenInfo error:%{public}d, tokenId:0x%{public}x appId:%{public}s", errCode, tokenId, - bundleName.c_str()); - return -1; - } - return tokenInfo.instIndex; + return 0; } DistributedDB::RelationalStoreDelegate* RdbSyncer::GetDelegate() diff --git a/services/distributeddataservice/service/rdb/rdb_syncer.h b/services/distributeddataservice/service/rdb/rdb_syncer.h index 53268ef..b4183af 100644 --- a/services/distributeddataservice/service/rdb/rdb_syncer.h +++ b/services/distributeddataservice/service/rdb/rdb_syncer.h @@ -102,12 +102,12 @@ private: using PredicateHandle = void(*)(const RdbPredicateOperation& operation, DistributedDB::Query& query); static inline PredicateHandle HANDLES[OPERATOR_MAX] = { - [EQUAL_TO] = &RdbSyncer::EqualTo, - [NOT_EQUAL_TO] = &RdbSyncer::NotEqualTo, - [AND] = &RdbSyncer::And, - [OR] = &RdbSyncer::Or, - [ORDER_BY] = &RdbSyncer::OrderBy, - [LIMIT] = &RdbSyncer::Limit, + /* [EQUAL_TO] = */&RdbSyncer::EqualTo, + /* [NOT_EQUAL_TO] = */&RdbSyncer::NotEqualTo, + /* [AND] = */&RdbSyncer::And, + /* [OR] = */&RdbSyncer::Or, + /* [ORDER_BY] = */&RdbSyncer::OrderBy, + /* [LIMIT] = */&RdbSyncer::Limit, }; static constexpr int DECIMAL_BASE = 10; diff --git a/services/distributeddataservice/service/test/BUILD.gn b/services/distributeddataservice/service/test/BUILD.gn index b75fea2..e3cffa9 100644 --- a/services/distributeddataservice/service/test/BUILD.gn +++ b/services/distributeddataservice/service/test/BUILD.gn @@ -34,8 +34,8 @@ ohos_unittest("ConfigFactoryTest") { configs = [ ":module_private_config" ] external_deps = [ - "ability_base:base", - "ability_base:want", + # "ability_base:base", + # "ability_base:want", "c_utils:utils", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", @@ -58,8 +58,8 @@ ohos_unittest("DirectoryManagerTest") { configs = [ ":module_private_config" ] external_deps = [ - "ability_base:base", - "ability_base:want", + # "ability_base:base", + # "ability_base:want", "access_token:libaccesstoken_sdk", "access_token:libnativetoken", "c_utils:utils", -- 2.33.0