!11 同步 sp2 next分支

From: @muyuying1 
Reviewed-by: @heppen 
Signed-off-by: @heppen
This commit is contained in:
openeuler-ci-bot 2023-10-30 13:21:07 +00:00 committed by Gitee
commit 509253a256
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
11 changed files with 16112 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,543 @@
From 6a40f67e7cb56c491bec6089b940ad35f6594aea Mon Sep 17 00:00:00 2001
From: muyuying1 <muyuying1@huawei.com>
Date: Thu, 3 Aug 2023 17:01:05 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A3=81=E5=89=AAhitrace=E5=92=8Chisysevent?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
frameworks/common/dds_trace.h | 115 +++++++++---------
.../src/distributed_kv_data_manager.cpp | 26 ++--
.../src/kvstore_sync_callback_client.cpp | 2 +-
.../kvdb/src/single_store_impl.cpp | 62 +++++-----
.../common/src/db_dfx_adapter.cpp | 4 +-
5 files changed, 105 insertions(+), 104 deletions(-)
diff --git a/frameworks/common/dds_trace.h b/frameworks/common/dds_trace.h
index a80b19d..2370a19 100644
--- a/frameworks/common/dds_trace.h
+++ b/frameworks/common/dds_trace.h
@@ -16,13 +16,13 @@
#ifndef DDS_TRACE_H
#define DDS_TRACE_H
-#include <atomic>
-#include <cinttypes>
-#include <string>
-#include <functional>
-#include <chrono>
-#include "hitrace/trace.h"
-#include "hitrace_meter.h"
+// #include <atomic>
+// #include <cinttypes>
+// #include <string>
+// #include <functional>
+// #include <chrono>
+// // #include "hitrace/trace.h"
+// // #include "hitrace_meter.h"
namespace OHOS {
namespace DistributedDataDfx {
enum TraceSwitch {
@@ -31,58 +31,59 @@ enum TraceSwitch {
API_PERFORMANCE_TRACE_ON = 0x02,
TRACE_CHAIN_ON = 0x04,
};
-class __attribute__((visibility("hidden"))) DdsTrace {
-public:
- using Action = std::function<void(const std::string &value, uint64_t delta)>;
- using System = std::chrono::system_clock;
- DdsTrace(const std::string &value, unsigned int option = BYTRACE_ON, Action action = nullptr)
- {
- traceSwitch_ = option;
- traceValue_ = value;
- action_ = action;
- static std::atomic_bool enable = false;
- if (!enable.exchange(true)) {
- UpdateTraceLabel();
- }
- Start(value);
- }
+// class __attribute__((visibility("hidden"))) DdsTrace {
+// public:
+// using Action = std::function<void(const std::string &value, uint64_t delta)>;
+// using System = std::chrono::system_clock;
+// DdsTrace(const std::string &value, unsigned int option = BYTRACE_ON, Action action = nullptr)
+// {
+// traceSwitch_ = option;
+// traceValue_ = value;
+// action_ = action;
+// static std::atomic_bool enable = false;
+// // if (!enable.exchange(true)) {
+// // UpdateTraceLabel();
+// // }
+// Start(value);
+// }
- ~DdsTrace()
- {
- Finish(traceValue_);
- }
+// ~DdsTrace()
+// {
+// Finish(traceValue_);
+// }
-private:
- void Start(const std::string &value)
- {
- if ((traceSwitch_ & BYTRACE_ON) == BYTRACE_ON) {
- StartTrace(HITRACE_TAG_DISTRIBUTEDDATA, value);
- }
- if ((traceSwitch_ & TRACE_CHAIN_ON) == TRACE_CHAIN_ON) {
- traceId_ = OHOS::HiviewDFX::HiTraceChain::Begin(value, HITRACE_FLAG_DEFAULT);
- }
- if ((traceSwitch_ & API_PERFORMANCE_TRACE_ON) == API_PERFORMANCE_TRACE_ON) {
- lastTime_ = System::now();
- }
- }
- void Finish(const std::string &value)
- {
- if ((traceSwitch_ & BYTRACE_ON) == BYTRACE_ON) {
- FinishTrace(HITRACE_TAG_DISTRIBUTEDDATA);
- }
- if ((traceSwitch_ & TRACE_CHAIN_ON) == TRACE_CHAIN_ON) {
- OHOS::HiviewDFX::HiTraceChain::End(traceId_);
- }
- if ((traceSwitch_ & API_PERFORMANCE_TRACE_ON) == API_PERFORMANCE_TRACE_ON && action_) {
- action_(value, std::chrono::duration_cast<std::chrono::milliseconds>(System::now() - lastTime_).count());
- }
- }
- Action action_;
- std::string traceValue_{ };
- HiviewDFX::HiTraceId traceId_;
- uint32_t traceSwitch_{ 0 };
- System::time_point lastTime_;
-};
+// private:
+// void Start(const std::string &value)
+// {
+// // if ((traceSwitch_ & BYTRACE_ON) == BYTRACE_ON) {
+// // StartTrace(HITRACE_TAG_DISTRIBUTEDDATA, value);
+// // }
+// // if ((traceSwitch_ & TRACE_CHAIN_ON) == TRACE_CHAIN_ON) {
+// // traceId_ = OHOS::HiviewDFX::HiTraceChain::Begin(value, HITRACE_FLAG_DEFAULT);
+// // }
+// if ((traceSwitch_ & API_PERFORMANCE_TRACE_ON) == API_PERFORMANCE_TRACE_ON) {
+// lastTime_ = System::now();
+// }
+// }
+// void Finish(const std::string &value)
+// {
+// // if ((traceSwitch_ & BYTRACE_ON) == BYTRACE_ON) {
+// // FinishTrace(HITRACE_TAG_DISTRIBUTEDDATA);
+// // }
+// // if ((traceSwitch_ & TRACE_CHAIN_ON) == TRACE_CHAIN_ON) {
+// // OHOS::HiviewDFX::HiTraceChain::End(traceId_);
+// // }
+// if ((traceSwitch_ & API_PERFORMANCE_TRACE_ON) == API_PERFORMANCE_TRACE_ON && action_) {
+// action_(value, std::chrono::duration_cast<std::chrono::milliseconds>(System::now() - lastTime_).count());
+// }
+// }
+// Action action_;
+// std::string traceValue_{ };
+// // HiviewDFX::HiTraceId traceId_;
+// uint32_t traceSwitch_{ 0 };
+// System::time_point lastTime_;
+// };
} // namespace DistributedDataDfx
} // namespace OHOS
+
#endif
diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp
index 73e0fb3..85faa27 100644
--- a/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp
+++ b/frameworks/innerkitsimpl/distributeddatafwk/src/distributed_kv_data_manager.cpp
@@ -36,8 +36,8 @@ DistributedKvDataManager::~DistributedKvDataManager()
Status DistributedKvDataManager::GetSingleKvStore(const Options &options, const AppId &appId, const StoreId &storeId,
std::shared_ptr<SingleKvStore> &singleKvStore)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
- TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
+ // TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
singleKvStore = nullptr;
if (!storeId.IsValid()) {
@@ -57,7 +57,7 @@ Status DistributedKvDataManager::GetSingleKvStore(const Options &options, const
Status DistributedKvDataManager::GetAllKvStoreId(const AppId &appId, std::vector<StoreId> &storeIds)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
KvStoreServiceDeathNotifier::SetAppId(appId);
return StoreManager::GetInstance().GetStoreIds(appId, storeIds);
@@ -65,8 +65,8 @@ Status DistributedKvDataManager::GetAllKvStoreId(const AppId &appId, std::vector
Status DistributedKvDataManager::CloseKvStore(const AppId &appId, const StoreId &storeId)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
- TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
+ // TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
KvStoreServiceDeathNotifier::SetAppId(appId);
if (!storeId.IsValid()) {
@@ -79,8 +79,8 @@ Status DistributedKvDataManager::CloseKvStore(const AppId &appId, const StoreId
Status DistributedKvDataManager::CloseKvStore(const AppId &appId, std::shared_ptr<SingleKvStore> &kvStorePtr)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
- TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
+ // TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
if (kvStorePtr == nullptr) {
ZLOGE("kvStorePtr is nullptr.");
@@ -95,8 +95,8 @@ Status DistributedKvDataManager::CloseKvStore(const AppId &appId, std::shared_pt
Status DistributedKvDataManager::CloseAllKvStore(const AppId &appId)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
- TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
+ // TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
KvStoreServiceDeathNotifier::SetAppId(appId);
return StoreManager::GetInstance().CloseAllKVStore(appId);
@@ -104,8 +104,8 @@ Status DistributedKvDataManager::CloseAllKvStore(const AppId &appId)
Status DistributedKvDataManager::DeleteKvStore(const AppId &appId, const StoreId &storeId, const std::string &path)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
- TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
+ // TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
if (!storeId.IsValid()) {
ZLOGE("invalid storeId.");
@@ -122,8 +122,8 @@ Status DistributedKvDataManager::DeleteKvStore(const AppId &appId, const StoreId
Status DistributedKvDataManager::DeleteAllKvStore(const AppId &appId, const std::string &path)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
- TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__),
+ // TraceSwitch::BYTRACE_ON | TraceSwitch::TRACE_CHAIN_ON);
if (path.empty()) {
ZLOGE("path empty");
return Status::INVALID_ARGUMENT;
diff --git a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp
index 5e70f0d..75b7846 100644
--- a/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp
+++ b/frameworks/innerkitsimpl/distributeddatafwk/src/kvstore_sync_callback_client.cpp
@@ -31,7 +31,7 @@ KvStoreSyncCallbackClient::~KvStoreSyncCallbackClient()
void KvStoreSyncCallbackClient::SyncCompleted(const std::map<std::string, Status> &results, uint64_t sequenceId)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), TraceSwitch::BYTRACE_ON);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), TraceSwitch::BYTRACE_ON);
auto finded = syncCallbackInfo_.Find(sequenceId);
if (finded.first) {
finded.second->SyncCompleted(results);
diff --git a/frameworks/innerkitsimpl/kvdb/src/single_store_impl.cpp b/frameworks/innerkitsimpl/kvdb/src/single_store_impl.cpp
index a82529f..6826238 100644
--- a/frameworks/innerkitsimpl/kvdb/src/single_store_impl.cpp
+++ b/frameworks/innerkitsimpl/kvdb/src/single_store_impl.cpp
@@ -64,7 +64,7 @@ StoreId SingleStoreImpl::GetStoreId() const
Status SingleStoreImpl::Put(const Key &key, const Value &value)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -90,7 +90,7 @@ Status SingleStoreImpl::Put(const Key &key, const Value &value)
Status SingleStoreImpl::PutBatch(const std::vector<Entry> &entries)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -120,7 +120,7 @@ Status SingleStoreImpl::PutBatch(const std::vector<Entry> &entries)
Status SingleStoreImpl::Delete(const Key &key)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -144,7 +144,7 @@ Status SingleStoreImpl::Delete(const Key &key)
Status SingleStoreImpl::DeleteBatch(const std::vector<Key> &keys)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -172,7 +172,7 @@ Status SingleStoreImpl::DeleteBatch(const std::vector<Key> &keys)
Status SingleStoreImpl::StartTransaction()
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -189,7 +189,7 @@ Status SingleStoreImpl::StartTransaction()
Status SingleStoreImpl::Commit()
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -206,7 +206,7 @@ Status SingleStoreImpl::Commit()
Status SingleStoreImpl::Rollback()
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -223,7 +223,7 @@ Status SingleStoreImpl::Rollback()
Status SingleStoreImpl::SubscribeKvStore(SubscribeType type, std::shared_ptr<Observer> observer)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -262,7 +262,7 @@ Status SingleStoreImpl::SubscribeKvStore(SubscribeType type, std::shared_ptr<Obs
Status SingleStoreImpl::UnSubscribeKvStore(SubscribeType type, std::shared_ptr<Observer> observer)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -300,7 +300,7 @@ Status SingleStoreImpl::UnSubscribeKvStore(SubscribeType type, std::shared_ptr<O
Status SingleStoreImpl::Get(const Key &key, Value &value)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -325,7 +325,7 @@ Status SingleStoreImpl::Get(const Key &key, Value &value)
Status SingleStoreImpl::GetEntries(const Key &prefix, std::vector<Entry> &entries) const
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
DBKey dbPrefix = convertor_.GetPrefix(prefix);
if (dbPrefix.empty() && !prefix.Empty()) {
ZLOGE("invalid prefix:%{public}s size:%{public}zu", StoreUtil::Anonymous(prefix.ToString()).c_str(),
@@ -344,7 +344,7 @@ Status SingleStoreImpl::GetEntries(const Key &prefix, std::vector<Entry> &entrie
Status SingleStoreImpl::GetEntries(const DataQuery &query, std::vector<Entry> &entries) const
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
DBQuery dbQuery = convertor_.GetDBQuery(query);
auto status = GetEntries(dbQuery, entries);
if (status != SUCCESS) {
@@ -355,7 +355,7 @@ Status SingleStoreImpl::GetEntries(const DataQuery &query, std::vector<Entry> &e
Status SingleStoreImpl::GetResultSet(const Key &prefix, std::shared_ptr<ResultSet> &resultSet) const
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
DBKey dbPrefix = convertor_.GetPrefix(prefix);
if (dbPrefix.empty() && !prefix.Empty()) {
ZLOGE("invalid prefix:%{public}s size:%{public}zu", StoreUtil::Anonymous(prefix.ToString()).c_str(),
@@ -374,7 +374,7 @@ Status SingleStoreImpl::GetResultSet(const Key &prefix, std::shared_ptr<ResultSe
Status SingleStoreImpl::GetResultSet(const DataQuery &query, std::shared_ptr<ResultSet> &resultSet) const
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
DBQuery dbQuery = convertor_.GetDBQuery(query);
auto status = GetResultSet(dbQuery, resultSet);
if (status != SUCCESS) {
@@ -385,7 +385,7 @@ Status SingleStoreImpl::GetResultSet(const DataQuery &query, std::shared_ptr<Res
Status SingleStoreImpl::CloseResultSet(std::shared_ptr<ResultSet> &resultSet)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
if (resultSet == nullptr) {
ZLOGE("input is nullptr");
return INVALID_ARGUMENT;
@@ -401,7 +401,7 @@ Status SingleStoreImpl::CloseResultSet(std::shared_ptr<ResultSet> &resultSet)
Status SingleStoreImpl::GetCount(const DataQuery &query, int &result) const
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -419,7 +419,7 @@ Status SingleStoreImpl::GetCount(const DataQuery &query, int &result) const
Status SingleStoreImpl::GetSecurityLevel(SecurityLevel &secLevel) const
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -438,7 +438,7 @@ Status SingleStoreImpl::GetSecurityLevel(SecurityLevel &secLevel) const
Status SingleStoreImpl::RemoveDeviceData(const std::string &device)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
std::shared_lock<decltype(rwMutex_)> lock(rwMutex_);
if (dbStore_ == nullptr) {
ZLOGE("db:%{public}s already closed!", storeId_.c_str());
@@ -464,7 +464,7 @@ Status SingleStoreImpl::RemoveDeviceData(const std::string &device)
Status SingleStoreImpl::Sync(const std::vector<std::string> &devices, SyncMode mode, uint32_t delay)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
KVDBService::SyncInfo syncInfo;
syncInfo.seqId = StoreUtil::GenSequenceId();
syncInfo.mode = mode;
@@ -476,7 +476,7 @@ Status SingleStoreImpl::Sync(const std::vector<std::string> &devices, SyncMode m
Status SingleStoreImpl::Sync(const std::vector<std::string> &devices, SyncMode mode, const DataQuery &query,
std::shared_ptr<SyncCallback> syncCallback)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
KVDBService::SyncInfo syncInfo;
syncInfo.seqId = StoreUtil::GenSequenceId();
syncInfo.mode = mode;
@@ -487,7 +487,7 @@ Status SingleStoreImpl::Sync(const std::vector<std::string> &devices, SyncMode m
Status SingleStoreImpl::RegisterSyncCallback(std::shared_ptr<SyncCallback> callback)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), TraceSwitch::BYTRACE_ON);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), TraceSwitch::BYTRACE_ON);
if (callback == nullptr) {
ZLOGW("INVALID_ARGUMENT.");
return INVALID_ARGUMENT;
@@ -498,14 +498,14 @@ Status SingleStoreImpl::RegisterSyncCallback(std::shared_ptr<SyncCallback> callb
Status SingleStoreImpl::UnRegisterSyncCallback()
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), TraceSwitch::BYTRACE_ON);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), TraceSwitch::BYTRACE_ON);
syncObserver_->Clean();
return SUCCESS;
}
Status SingleStoreImpl::SetSyncParam(const KvSyncParam &syncParam)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
auto service = KVDBServiceClient::GetInstance();
if (service == nullptr) {
return SERVER_UNAVAILABLE;
@@ -515,7 +515,7 @@ Status SingleStoreImpl::SetSyncParam(const KvSyncParam &syncParam)
Status SingleStoreImpl::GetSyncParam(KvSyncParam &syncParam)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
auto service = KVDBServiceClient::GetInstance();
if (service == nullptr) {
return SERVER_UNAVAILABLE;
@@ -525,7 +525,7 @@ Status SingleStoreImpl::GetSyncParam(KvSyncParam &syncParam)
Status SingleStoreImpl::SetCapabilityEnabled(bool enabled) const
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
auto service = KVDBServiceClient::GetInstance();
if (service == nullptr) {
return SERVER_UNAVAILABLE;
@@ -539,7 +539,7 @@ Status SingleStoreImpl::SetCapabilityEnabled(bool enabled) const
Status SingleStoreImpl::SetCapabilityRange(const std::vector<std::string> &localLabels,
const std::vector<std::string> &remoteLabels) const
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
auto service = KVDBServiceClient::GetInstance();
if (service == nullptr) {
return SERVER_UNAVAILABLE;
@@ -549,7 +549,7 @@ Status SingleStoreImpl::SetCapabilityRange(const std::vector<std::string> &local
Status SingleStoreImpl::SubscribeWithQuery(const std::vector<std::string> &devices, const DataQuery &query)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
auto service = KVDBServiceClient::GetInstance();
if (service == nullptr) {
return SERVER_UNAVAILABLE;
@@ -570,7 +570,7 @@ Status SingleStoreImpl::SubscribeWithQuery(const std::vector<std::string> &devic
Status SingleStoreImpl::UnsubscribeWithQuery(const std::vector<std::string> &devices, const DataQuery &query)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
auto service = KVDBServiceClient::GetInstance();
if (service == nullptr) {
return SERVER_UNAVAILABLE;
@@ -614,7 +614,7 @@ int32_t SingleStoreImpl::Close(bool isForce)
Status SingleStoreImpl::Backup(const std::string &file, const std::string &baseDir)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
auto status = BackupManager::GetInstance().Backup(file, baseDir, storeId_, dbStore_);
if (status != SUCCESS) {
ZLOGE("status:0x%{public}x storeId:%{public}s backup:%{public}s ", status, storeId_.c_str(), file.c_str());
@@ -624,7 +624,7 @@ Status SingleStoreImpl::Backup(const std::string &file, const std::string &baseD
Status SingleStoreImpl::Restore(const std::string &file, const std::string &baseDir)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
auto status = BackupManager::GetInstance().Restore(file, baseDir, appId_, storeId_, dbStore_);
if (status != SUCCESS) {
ZLOGE("status:0x%{public}x storeId:%{public}s backup:%{public}s ", status, storeId_.c_str(), file.c_str());
@@ -635,7 +635,7 @@ Status SingleStoreImpl::Restore(const std::string &file, const std::string &base
Status SingleStoreImpl::DeleteBackup(const std::vector<std::string> &files, const std::string &baseDir,
std::map<std::string, DistributedKv::Status> &results)
{
- DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
+ // DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__));
for (auto &file : files) {
results.emplace(file, DEVICE_NOT_FOUND);
}
diff --git a/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp b/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp
index 6ffcc0d..c2a9e3a 100644
--- a/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp
+++ b/frameworks/libs/distributeddb/common/src/db_dfx_adapter.cpp
@@ -27,8 +27,8 @@
#include "runtime_context.h"
#include "sqlite_utils.h"
#ifdef USE_DFX_ABILITY
-#include "hitrace_meter.h"
-#include "hisysevent.h"
+// #include "hitrace_meter.h"
+// #include "hisysevent.h"
#endif
namespace DistributedDB {
--
2.24.3 (Apple Git-128)

View File

@ -0,0 +1,235 @@
From 740bc65fec83e5410d4fc9e5b389e8be65c943ec Mon Sep 17 00:00:00 2001
From: muyuying1 <muyuying1@huawei.com>
Date: Thu, 3 Aug 2023 17:06:02 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9compile=E7=9B=B8=E5=85=B3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../include/ikvstore_data_service.h | 22 +++++-----
.../innerkitsimpl/kvdb/src/system_api.cpp | 40 +++++++++----------
.../innerkitsimpl/rdb/include/rdb_notifier.h | 4 +-
frameworks/libs/distributeddb/BUILD.gn | 6 +--
.../src/kv_store_delegate_manager.cpp | 6 +++
.../storage/src/result_entries_window.cpp | 2 +-
6 files changed, 43 insertions(+), 37 deletions(-)
diff --git a/frameworks/innerkitsimpl/distributeddatafwk/include/ikvstore_data_service.h b/frameworks/innerkitsimpl/distributeddatafwk/include/ikvstore_data_service.h
index b67e248..af25e6b 100644
--- a/frameworks/innerkitsimpl/distributeddatafwk/include/ikvstore_data_service.h
+++ b/frameworks/innerkitsimpl/distributeddatafwk/include/ikvstore_data_service.h
@@ -64,17 +64,17 @@ private:
using RequestHandler = int32_t(KvStoreDataServiceStub::*)(MessageParcel&, MessageParcel&);
static constexpr RequestHandler HANDLERS[SERVICE_CMD_LAST] = {
- [GET_FEATURE_INTERFACE] = &KvStoreDataServiceStub::GetFeatureInterfaceOnRemote,
- [REGISTERCLIENTDEATHOBSERVER] = &KvStoreDataServiceStub::RegisterClientDeathObserverOnRemote,
- [CLOSEKVSTORE] = &KvStoreDataServiceStub::NoSupport,
- [CLOSEALLKVSTORE] = &KvStoreDataServiceStub::NoSupport,
- [DELETEKVSTORE] = &KvStoreDataServiceStub::NoSupport,
- [DELETEALLKVSTORE] = &KvStoreDataServiceStub::NoSupport,
- [GETSINGLEKVSTORE] = &KvStoreDataServiceStub::NoSupport,
- [GETLOCALDEVICE] = &KvStoreDataServiceStub::NoSupport,
- [GETREMOTEDEVICES] = &KvStoreDataServiceStub::NoSupport,
- [STARTWATCHDEVICECHANGE] = &KvStoreDataServiceStub::NoSupport,
- [STOPWATCHDEVICECHANGE] = &KvStoreDataServiceStub::NoSupport,
+ /* [GET_FEATURE_INTERFACE] = */&KvStoreDataServiceStub::GetFeatureInterfaceOnRemote,
+ /* [REGISTERCLIENTDEATHOBSERVER] = */&KvStoreDataServiceStub::RegisterClientDeathObserverOnRemote,
+ /* [CLOSEKVSTORE] = */&KvStoreDataServiceStub::NoSupport,
+ /* [CLOSEALLKVSTORE] = */&KvStoreDataServiceStub::NoSupport,
+ /* [DELETEKVSTORE] = */&KvStoreDataServiceStub::NoSupport,
+ /* [DELETEALLKVSTORE] = */&KvStoreDataServiceStub::NoSupport,
+ /* [GETSINGLEKVSTORE] = */&KvStoreDataServiceStub::NoSupport,
+ /* [GETLOCALDEVICE] = */&KvStoreDataServiceStub::NoSupport,
+ /* [GETREMOTEDEVICES] = */&KvStoreDataServiceStub::NoSupport,
+ /* [STARTWATCHDEVICECHANGE] = */&KvStoreDataServiceStub::NoSupport,
+ /* [STOPWATCHDEVICECHANGE] = */&KvStoreDataServiceStub::NoSupport,
};
};
diff --git a/frameworks/innerkitsimpl/kvdb/src/system_api.cpp b/frameworks/innerkitsimpl/kvdb/src/system_api.cpp
index b1d147d..f6cd62f 100644
--- a/frameworks/innerkitsimpl/kvdb/src/system_api.cpp
+++ b/frameworks/innerkitsimpl/kvdb/src/system_api.cpp
@@ -18,12 +18,12 @@
#include <sys/stat.h>
#include <unistd.h>
#include "log_print.h"
-#include "security_label.h"
+// #include "security_label.h"
#include "store_util.h"
namespace OHOS::DistributedKv {
using Label = DistributedDB::SecurityLabel;
using Flag = DistributedDB::SecurityFlag;
-using SecurityLabel = DistributedFS::ModuleSecurityLabel::SecurityLabel;
+// using SecurityLabel = DistributedFS::ModuleSecurityLabel::SecurityLabel;
SystemApi::SystemApi()
{
}
@@ -44,9 +44,9 @@ bool SystemApi::IsAccessControlled() const
SystemApi::DBStatus SystemApi::SetSecurityOption(const std::string &filePath, const DBOption &option)
{
- if (filePath.empty() || option.securityLabel < Label::NOT_SET || option.securityLabel > Label::S4) {
- return DBStatus::INVALID_ARGS;
- }
+ // if (filePath.empty() || option.securityLabel < Label::NOT_SET || option.securityLabel > Label::S4) {
+ // return DBStatus::INVALID_ARGS;
+ // }
struct stat curStat;
stat(filePath.c_str(), &curStat);
@@ -58,17 +58,17 @@ SystemApi::DBStatus SystemApi::SetSecurityOption(const std::string &filePath, co
return DBStatus::INVALID_ARGS;
}
- if (option.securityLabel == Label::NOT_SET) {
- return DBStatus::OK;
- }
+ // if (option.securityLabel == Label::NOT_SET) {
+ // return DBStatus::OK;
+ // }
auto secLevel = std::string("s") + std::to_string(option.securityLabel - 1);
- bool result = SecurityLabel::SetSecurityLabel(filePath, secLevel);
- if (!result) {
- ZLOGE("set label failed! level:%{public}s, file:%{public}s", secLevel.c_str(),
- StoreUtil::Anonymous(filePath).c_str());
- return DBStatus::DB_ERROR;
- }
+ // bool result = SecurityLabel::SetSecurityLabel(filePath, secLevel);
+ // if (!result) {
+ // ZLOGE("set label failed! level:%{public}s, file:%{public}s", secLevel.c_str(),
+ // StoreUtil::Anonymous(filePath).c_str());
+ // return DBStatus::DB_ERROR;
+ // }
return DBStatus::OK;
}
@@ -90,12 +90,12 @@ SystemApi::DBStatus SystemApi::GetSecurityOption(const std::string &filePath, DB
return DBStatus::OK;
}
- std::string value = SecurityLabel::GetSecurityLabel(filePath);
- if (!std::regex_match(value, std::regex("s([01234])"))) {
- option = {Label::NOT_SET, Flag::ECE};
- return DBStatus::OK;
- }
- option = { (value[1] - '0') + 1, value[1] == '3' ? Flag::SECE : Flag::ECE};
+ // std::string value = SecurityLabel::GetSecurityLabel(filePath);
+ // if (!std::regex_match(value, std::regex("s([01234])"))) {
+ // option = {Label::NOT_SET, Flag::ECE};
+ // return DBStatus::OK;
+ // }
+ // option = { (value[1] - '0') + 1, value[1] == '3' ? Flag::SECE : Flag::ECE};
return DBStatus::OK;
}
diff --git a/frameworks/innerkitsimpl/rdb/include/rdb_notifier.h b/frameworks/innerkitsimpl/rdb/include/rdb_notifier.h
index 4c0eb28..32fc087 100644
--- a/frameworks/innerkitsimpl/rdb/include/rdb_notifier.h
+++ b/frameworks/innerkitsimpl/rdb/include/rdb_notifier.h
@@ -73,8 +73,8 @@ private:
using RequestHandle = int32_t (RdbNotifierStub::*)(MessageParcel&, MessageParcel&);
static constexpr RequestHandle HANDLES[RDB_NOTIFIER_CMD_MAX] = {
- [RDB_NOTIFIER_CMD_SYNC_COMPLETE] = &RdbNotifierStub::OnCompleteInner,
- [RDB_NOTIFIER_CMD_DATA_CHANGE] = &RdbNotifierStub::OnChangeInner,
+ /* [RDB_NOTIFIER_CMD_SYNC_COMPLETE] = */&RdbNotifierStub::OnCompleteInner,
+ /* [RDB_NOTIFIER_CMD_DATA_CHANGE] = */&RdbNotifierStub::OnChangeInner,
};
RdbSyncCompleteNotifier completeNotifier_;
diff --git a/frameworks/libs/distributeddb/BUILD.gn b/frameworks/libs/distributeddb/BUILD.gn
index 209bf90..d08716e 100644
--- a/frameworks/libs/distributeddb/BUILD.gn
+++ b/frameworks/libs/distributeddb/BUILD.gn
@@ -46,7 +46,7 @@ config("distrdb_config") {
"OMIT_FLATBUFFER",
"RELATIONAL_STORE",
"SQLITE_DISTRIBUTE_RELATIONAL",
- "USE_DFX_ABILITY",
+ # "USE_DFX_ABILITY",
]
if (is_debug) {
defines += [ "TRACE_SQLITE_EXECUTE" ]
@@ -285,8 +285,8 @@ ohos_shared_library("distributeddb") {
external_deps = [
"c_utils:utils",
- "hisysevent_native:libhisysevent",
- "hitrace_native:hitrace_meter",
+ # "hisysevent_native:libhisysevent",
+ # "hitrace_native:hitrace_meter",
"hiviewdfx_hilog_native:libhilog",
]
diff --git a/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp b/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp
index b075ed1..c18b390 100644
--- a/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp
+++ b/frameworks/libs/distributeddb/interfaces/src/kv_store_delegate_manager.cpp
@@ -251,6 +251,7 @@ bool KvStoreDelegateManager::GetKvStoreParamCheck(const std::string &storeId, co
}
if (!ParamCheckUtils::CheckStoreParameter(storeId, appId_, userId_) ||
(GetKvStorePath().empty() && !option.isMemoryDb)) {
+ LOGE("[HP_DEBUG] GetKvStorePath is empty[%d], ismemorydb[%d]", GetKvStorePath().empty(), option.isMemoryDb);
LOGE("[KvStoreMgr] Invalid id or path info for the store");
callback(INVALID_ARGS, nullptr);
return false;
@@ -294,6 +295,7 @@ void KvStoreDelegateManager::GetKvStore(const std::string &storeId, const KvStor
const std::function<void(DBStatus, KvStoreNbDelegate *)> &callback)
{
if (!GetKvStoreParamCheck(storeId, option, callback)) {
+ LOGI("[HP_DEBUG] Param check failed!");
return;
}
// check if schema is supported and valid
@@ -301,6 +303,7 @@ void KvStoreDelegateManager::GetKvStore(const std::string &storeId, const KvStor
DBStatus retCode = CheckAndGetSchema(option.isMemoryDb, option.schema, schema);
if (retCode != OK) {
callback(retCode, nullptr);
+ LOGI("[HP_DEBUG] CheckAndGetSchema failed!");
return;
}
KvDBProperties properties;
@@ -315,6 +318,7 @@ void KvStoreDelegateManager::GetKvStore(const std::string &storeId, const KvStor
DBStatus status = TransferDBErrno(errCode);
if (conn == nullptr) {
callback(status, nullptr);
+ LOGI("[HP_DEBUG] GetOneConnectionWithRetry failed!");
return;
}
@@ -323,6 +327,7 @@ void KvStoreDelegateManager::GetKvStore(const std::string &storeId, const KvStor
conn->Close();
conn = nullptr;
callback(DB_ERROR, nullptr);
+ LOGI("[HP_DEBUG] new KvStoreNbDelegateImpl failed!");
return;
}
@@ -330,6 +335,7 @@ void KvStoreDelegateManager::GetKvStore(const std::string &storeId, const KvStor
if (status != OK) {
CloseKvStore(kvStore);
callback(status, nullptr);
+ LOGI("[HP_DEBUG] SetObserverNotifier failed!");
return;
}
diff --git a/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp b/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp
index 5709380..f01365b 100644
--- a/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp
+++ b/frameworks/libs/distributeddb/storage/src/result_entries_window.cpp
@@ -176,7 +176,7 @@ int ResultEntriesWindow::LoadData(int begin, int target) const
continue;
}
bufferSize += next.key.size() + next.value.size();
- buffer_.push_back(move(next));
+ buffer_.push_back(std::move(next));
}
if (buffer_.size() == static_cast<size_t>(totalCount_)) {
(void)(rawCursor_->Close());
--
2.24.3 (Apple Git-128)

View File

@ -0,0 +1,569 @@
From 1a119f78a70ff04a2fe4415986a02d9991894802 Mon Sep 17 00:00:00 2001
From: wang--ge <wang__ge@126.com>
Date: Sat, 15 Jul 2023 11:12:16 +0800
Subject: [PATCH] add huks component
---
huks/BUILD.gn | 0
huks/bundle.json | 77 ++++++++++++++++
.../huks_standard/main/os_dependency/BUILD.gn | 10 +++
.../ipc/include/hks_client_ipc.h | 90 +++++++++++++++++++
.../os_dependency/ipc/include/hks_ipc_check.h | 55 ++++++++++++
.../ipc/include/hks_ipc_serialization.h | 76 ++++++++++++++++
.../os_dependency/ipc/include/hks_ipc_slice.h | 34 +++++++
.../os_dependency/ipc/include/hks_request.h | 69 ++++++++++++++
.../ipc/include/hks_samgr_client.h | 32 +++++++
.../innerkits/huks_standard/main/BUILD.gn | 23 +++++
.../innerkits/huks_standard/main/include | 1 +
12 files changed, 482 insertions(+)
create mode 100755 huks/.gitattributes
create mode 100644 huks/BUILD.gn
create mode 100644 huks/bundle.json
create mode 100644 huks/frameworks/huks_standard/main/os_dependency/BUILD.gn
create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_client_ipc.h
create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_check.h
create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_serialization.h
create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_slice.h
create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_request.h
create mode 100644 huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_samgr_client.h
create mode 100644 huks/interfaces/innerkits/huks_standard/main/BUILD.gn
create mode 120000 huks/interfaces/innerkits/huks_standard/main/include
diff --git a/huks/BUILD.gn b/huks/BUILD.gn
new file mode 100644
index 0000000..e69de29
diff --git a/huks/bundle.json b/huks/bundle.json
new file mode 100644
index 0000000..635f7ed
--- /dev/null
+++ b/huks/bundle.json
@@ -0,0 +1,77 @@
+{
+ "name": "@ohos/huks",
+ "description": "The provider of key and certificate manangement capbility, which belongs to security subsystem",
+ "version": "3.1",
+ "license": "Apache License 2.0",
+ "publishAs": "code-segment",
+ "segment": {
+ "destPath": "base/security/huks"
+ },
+ "dirs":{},
+ "scripts": {
+ "install": "DEST_PATH=${DEP_BUNDLE_BASE}/base/security/huks && mkdir -p $DEST_PATH && cp -r ./* $DEST_PATH"
+ },
+ "author": {},
+ "repository": "",
+ "component": {
+ "name": "huks",
+ "subsystem": "security",
+ "syscap": [
+ "SystemCapability.Security.Huks",
+ "SystemCapability.Security.Cipher"
+ ],
+ "features": [],
+ "adapted_system_type": [
+ "standard",
+ "small",
+ "mini"
+ ],
+ "rom": "5000KB",
+ "ram": "500kB",
+ "deps": {
+ "components": [
+ "ability_base",
+ "access_token",
+ "bundle_framework",
+ "common",
+ "common_event_service",
+ "hisysevent_native",
+ "hitrace_native",
+ "hiviewdfx_hilog_native",
+ "ipc",
+ "napi",
+ "os_account",
+ "safwk",
+ "samgr",
+ "thirdparty_bounds_checking_function",
+ "c_utils"
+ ],
+ "third_party": [
+ "openssl",
+ "bounds_checking_function"
+ ]
+ },
+ "build": {
+ "group_type": {
+ "base_group": [],
+ "fwk_group": [
+
+ ],
+ "service_group": [
+
+ ]
+ },
+ "inner_kits": [
+ {
+ "name": "//base/security/huks/interfaces/innerkits/huks_standard/main:libhukssdk",
+ "header": {
+ "header_files": [
+ "hks_api.h"
+ ],
+ "header_base": "//base/security/huks/interfaces/innerkits/huks_standard/main/include"
+ }
+ }
+ ]
+ }
+ }
+ }
diff --git a/huks/frameworks/huks_standard/main/os_dependency/BUILD.gn b/huks/frameworks/huks_standard/main/os_dependency/BUILD.gn
new file mode 100644
index 0000000..3cc5c64
--- /dev/null
+++ b/huks/frameworks/huks_standard/main/os_dependency/BUILD.gn
@@ -0,0 +1,10 @@
+import("//build/ohos.gni")
+
+config("huks_config") {
+ include_dirs = ["//base/security/huks/frameworks/huks_standard/main/os_dependency/ipc/include"]
+ libs = ["huks_os_dependency_standard_static"]
+}
+
+group("libhuks_os_dependency_standard_static") {
+ public_configs = [":huks_config"]
+}
diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_client_ipc.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_client_ipc.h
new file mode 100644
index 0000000..206dfd4
--- /dev/null
+++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_client_ipc.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2021-2022 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.
+ */
+
+#ifndef HKS_CLIENT_IPC_H
+#define HKS_CLIENT_IPC_H
+
+#include "hks_type_inner.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int32_t HksClientInitialize(void);
+
+int32_t HksClientRefreshKeyInfo(void);
+
+int32_t HksClientGenerateKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSetIn,
+ struct HksParamSet *paramSetOut);
+
+int32_t HksClientImportKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet,
+ const struct HksBlob *key);
+
+int32_t HksClientExportPublicKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet,
+ struct HksBlob *key);
+
+int32_t HksClientImportWrappedKey(const struct HksBlob *keyAlias, const struct HksBlob *wrappingKeyAlias,
+ const struct HksParamSet *paramSet, const struct HksBlob *wrappedKeyData);
+
+int32_t HksClientDeleteKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet);
+
+int32_t HksClientGetKeyParamSet(const struct HksBlob *keyAlias, struct HksParamSet *paramSet);
+
+int32_t HksClientKeyExist(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet);
+
+int32_t HksClientGenerateRandom(struct HksBlob *random, const struct HksParamSet *paramSet);
+
+int32_t HksClientSign(const struct HksBlob *key, const struct HksParamSet *paramSet,
+ const struct HksBlob *srcData, struct HksBlob *signature);
+
+int32_t HksClientVerify(const struct HksBlob *key, const struct HksParamSet *paramSet,
+ const struct HksBlob *srcData, const struct HksBlob *signature);
+
+int32_t HksClientEncrypt(const struct HksBlob *key, const struct HksParamSet *paramSet,
+ const struct HksBlob *plainText, struct HksBlob *cipherText);
+
+int32_t HksClientDecrypt(const struct HksBlob *key, const struct HksParamSet *paramSet,
+ const struct HksBlob *cipherText, struct HksBlob *plainText);
+
+int32_t HksClientAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey,
+ const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey);
+
+int32_t HksClientDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *mainKey,
+ struct HksBlob *derivedKey);
+
+int32_t HksClientMac(const struct HksBlob *key, const struct HksParamSet *paramSet, const struct HksBlob *srcData,
+ struct HksBlob *mac);
+
+int32_t HksClientGetKeyInfoList(struct HksKeyInfo *keyInfoList, uint32_t *listCount);
+
+int32_t HksClientAttestKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet,
+ struct HksCertChain *certChain);
+
+int32_t HksClientInit(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet, struct HksBlob *handle,
+ struct HksBlob *token);
+
+int32_t HksClientUpdate(const struct HksBlob *handle, const struct HksParamSet *paramSet, const struct HksBlob *inData,
+ struct HksBlob *outData);
+
+int32_t HksClientFinish(const struct HksBlob *handle, const struct HksParamSet *paramSet, const struct HksBlob *inData,
+ struct HksBlob *outData);
+
+int32_t HksClientAbort(const struct HksBlob *handle, const struct HksParamSet *paramSet);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HKS_CLIENT_IPC_H */
diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_check.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_check.h
new file mode 100644
index 0000000..761247c
--- /dev/null
+++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_check.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+#ifndef HKS_CRYPTO_CHECK_H
+#define HKS_CRYPTO_CHECK_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "hks_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int32_t HksCheckIpcGenerateKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSetIn);
+
+int32_t HksCheckIpcImportKey(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet,
+ const struct HksBlob *key);
+
+int32_t HksCheckIpcImportWrappedKey(const struct HksBlob *keyAlias, const struct HksBlob *wrappingKeyAlias,
+ const struct HksParamSet *paramSet, const struct HksBlob *wrappedKeyData);
+
+int32_t HksCheckIpcExportPublicKey(const struct HksBlob *keyAlias, const struct HksBlob *key);
+
+int32_t HksCheckIpcGetKeyParamSet(const struct HksBlob *keyAlias, struct HksParamSet *paramSet);
+
+int32_t HksCheckIpcAgreeKey(const struct HksParamSet *paramSet, const struct HksBlob *privateKey,
+ const struct HksBlob *peerPublicKey, const struct HksBlob *agreedKey);
+
+int32_t HksCheckIpcDeriveKey(const struct HksParamSet *paramSet, const struct HksBlob *mainKey,
+ const struct HksBlob *derivedKey);
+
+int32_t HksCheckIpcGetKeyInfoList(const struct HksKeyInfo *keyInfoList, uint32_t listCount);
+
+int32_t HksCheckIpcCertificateChain(const struct HksBlob *keyAlias, const struct HksParamSet *paramSet,
+ const struct HksCertChain *certChain);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_serialization.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_serialization.h
new file mode 100644
index 0000000..59cf16e
--- /dev/null
+++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_serialization.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2021-2022 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.
+ */
+
+#ifndef HKS_IPC_SERIALIZATION_H
+#define HKS_IPC_SERIALIZATION_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "hks_type_inner.h"
+
+#define MAX_IPC_BUF_SIZE 0x10000 /* Maximun IPC message buffer size. */
+#define MAX_IPC_RSV_SIZE 0x400 /* Reserve IPC message buffer size */
+#define MAX_PROCESS_SIZE (MAX_IPC_BUF_SIZE - MAX_IPC_RSV_SIZE)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int32_t CopyUint32ToBuffer(uint32_t value, const struct HksBlob *destBlob, uint32_t *destOffset);
+
+int32_t HksGenerateKeyPack(struct HksBlob *destData, const struct HksBlob *keyAlias,
+ const struct HksParamSet *paramSetIn, const struct HksBlob *keyOut);
+
+int32_t HksImportKeyPack(struct HksBlob *destData, const struct HksBlob *keyAlias, const struct HksParamSet *paramSet,
+ const struct HksBlob *key);
+
+int32_t HksImportWrappedKeyPack(struct HksBlob *destData, const struct HksBlob *keyAlias,
+ const struct HksBlob *wrappingKeyAlias, const struct HksParamSet *paramSet, const struct HksBlob *wrappedKeyData);
+
+int32_t HksExportPublicKeyPack(struct HksBlob *destData, const struct HksBlob *keyAlias, const struct HksBlob *key);
+
+int32_t HksGetKeyParamSetPack(struct HksBlob *destData, const struct HksBlob *keyAlias, const struct HksBlob *keyOut);
+
+int32_t HksOnceParamPack(struct HksBlob *destData, const struct HksBlob *key, const struct HksParamSet *paramSet,
+ uint32_t *offset);
+
+int32_t HksOnceDataPack(struct HksBlob *destData, const struct HksBlob *inputData, const struct HksBlob *rsvData,
+ const struct HksBlob *outputData, uint32_t *offset);
+
+int32_t HksAgreeKeyPack(struct HksBlob *destData, const struct HksParamSet *paramSet, const struct HksBlob *privateKey,
+ const struct HksBlob *peerPublicKey, const struct HksBlob *agreedKey);
+
+int32_t HksDeriveKeyPack(struct HksBlob *destData, const struct HksParamSet *paramSet, const struct HksBlob *kdfKey,
+ const struct HksBlob *derivedKey);
+
+int32_t HksGetKeyInfoListPack(struct HksBlob *destData, uint32_t listCount, const struct HksKeyInfo *keyInfoList);
+
+int32_t HksGetKeyInfoListUnpackFromService(const struct HksBlob *srcData, uint32_t *listCount,
+ struct HksKeyInfo *keyInfoList);
+
+int32_t HksCertificateChainPack(struct HksBlob *destData, const struct HksBlob *keyAlias,
+ const struct HksParamSet *paramSet, const struct HksBlob *certChainBlob);
+
+int32_t HksCertificateChainUnpackFromService(const struct HksBlob *srcData, bool needEncode,
+ struct HksCertChain *certChain);
+
+int32_t HksParamsToParamSet(struct HksParam *params, uint32_t cnt, struct HksParamSet **outParamSet);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HKS_IPC_SERIALIZATION_H */
\ No newline at end of file
diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_slice.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_slice.h
new file mode 100644
index 0000000..a712cc1
--- /dev/null
+++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_ipc_slice.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+#ifndef HKS_IPC_SLICE_H
+#define HKS_IPC_SLICE_H
+
+#include <stdint.h>
+
+#include "hks_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int32_t HksSliceDataEntry(uint32_t cmdId, const struct HksBlob *key, const struct HksParamSet *paramSet,
+ struct HksBlob *inData, struct HksBlob *outData);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HKS_SLICE_H */
\ No newline at end of file
diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_request.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_request.h
new file mode 100644
index 0000000..332fb99
--- /dev/null
+++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_request.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2021-2022 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.
+ */
+
+#ifndef HKS_REQUEST_H
+#define HKS_REQUEST_H
+
+#include "hks_type_inner.h"
+
+enum HksMessage {
+#ifndef _HKS_L1_TEE_
+ HKS_MSG_BASE = 0x3a400, /* range of message value defined by router. globally unique */
+#else
+ HKS_MSG_BASE = 1000, /* range of message value defined by SmartLock. Max 65535 */
+#endif
+ HKS_MSG_GEN_KEY = HKS_MSG_BASE,
+ HKS_MSG_IMPORT_KEY,
+ HKS_MSG_EXPORT_PUBLIC_KEY,
+ HKS_MSG_IMPORT_WRAPPED_KEY,
+ HKS_MSG_DELETE_KEY,
+ HKS_MSG_GET_KEY_PARAMSET,
+ HKS_MSG_KEY_EXIST,
+ HKS_MSG_GENERATE_RANDOM,
+ HKS_MSG_SIGN,
+ HKS_MSG_VERIFY,
+ HKS_MSG_ENCRYPT,
+ HKS_MSG_DECRYPT,
+ HKS_MSG_AGREE_KEY,
+ HKS_MSG_DERIVE_KEY,
+ HKS_MSG_MAC,
+ HKS_MSG_GET_KEY_INFO_LIST,
+ HKS_MSG_ATTEST_KEY,
+ HKS_MSG_GET_CERTIFICATE_CHAIN,
+ HKS_MSG_INIT,
+ HKS_MSG_UPDATE,
+ HKS_MSG_FINISH,
+ HKS_MSG_ABORT,
+ HKS_MSG_MAX, /* new cmd type must be added before HKS_MSG_MAX */
+};
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * SendRequest - Send the request message to target module by function call or ipc or other ways.
+ * @type: the request message type.
+ * @inBlob: the input serialized data blob.
+ * @outBlob: the output serialized data blob, can be null.
+ */
+int32_t HksSendRequest(enum HksMessage type, const struct HksBlob *inBlob, struct HksBlob *outBlob,
+ const struct HksParamSet *paramSet);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HKS_REQUEST_H */
diff --git a/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_samgr_client.h b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_samgr_client.h
new file mode 100644
index 0000000..b20f73b
--- /dev/null
+++ b/huks/frameworks/huks_standard/main/os_dependency/ipc/include/hks_samgr_client.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2021 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.
+ */
+
+#ifndef HKS_SAMGR_CLIENT_H
+#define HKS_SAMGR_CLIENT_H
+
+#include "hks_samgr_server.h"
+#include "iproxy_client.h"
+
+typedef struct {
+ INHERIT_CLIENT_IPROXY;
+ int32_t (*IpcAsyncCallBack)(IUnknown *iUnknown, enum HksMessageType type, const struct HksBlob *inBlob,
+ struct HksBlob *outBlob);
+} HksMgrClientApi;
+
+typedef struct {
+ INHERIT_IUNKNOWNENTRY(HksMgrClientApi);
+} HksMgrClientEntry;
+
+#endif
\ No newline at end of file
diff --git a/huks/interfaces/innerkits/huks_standard/main/BUILD.gn b/huks/interfaces/innerkits/huks_standard/main/BUILD.gn
new file mode 100644
index 0000000..a539688
--- /dev/null
+++ b/huks/interfaces/innerkits/huks_standard/main/BUILD.gn
@@ -0,0 +1,23 @@
+# Copyright (C) 2021-2022 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")
+
+config("huks_config") {
+ include_dirs = [ "//base/security/huks/interfaces/innerkits/huks_standard/main/include" ]
+ libs = [ "hukssdk.z" ]
+}
+
+group("libhukssdk") {
+ public_configs = [ ":huks_config" ]
+}
diff --git a/huks/interfaces/innerkits/huks_standard/main/include b/huks/interfaces/innerkits/huks_standard/main/include
new file mode 120000
index 0000000..98a2378
--- /dev/null
+++ b/huks/interfaces/innerkits/huks_standard/main/include
@@ -0,0 +1 @@
+/usr/include/huks
\ No newline at end of file
--
2.33.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
From 1514ae3615cd6c376e6413c8b63775de39d9a2c1 Mon Sep 17 00:00:00 2001
From: wang--ge <wang__ge@126.com>
Date: Mon, 17 Jul 2023 17:55:44 +0800
Subject: [PATCH] establish kvstore dependence on boundscheck
---
.../kv_store/frameworks/libs/distributeddb/BUILD.gn | 1 +
1 file changed, 1 insertion(+)
diff --git a/distributeddatamgr/kv_store/frameworks/libs/distributeddb/BUILD.gn b/distributeddatamgr/kv_store/frameworks/libs/distributeddb/BUILD.gn
index d08716e..536f8ee 100644
--- a/distributeddatamgr/kv_store/frameworks/libs/distributeddb/BUILD.gn
+++ b/distributeddatamgr/kv_store/frameworks/libs/distributeddb/BUILD.gn
@@ -273,6 +273,7 @@ ohos_shared_library("distributeddb") {
deps = [
"//third_party/sqlite:sqlite",
"//third_party/zlib:shared_libz",
+ "//third_party/bounds_checking_function:libsec_shared",
]
configs += [ "//third_party/jsoncpp:jsoncpp_config" ]
--
2.33.0

116
bundle.json Normal file
View File

@ -0,0 +1,116 @@
{
"name": "@openharmony/distributeddatamgr_kv_store",
"version": "1.0.0",
"license": "Apache License 2.0",
"description": "",
"domain": "os",
"language": "",
"publishAs": "code-segment",
"private": false,
"tags": [
"foundation"
],
"keywords": [
"distributeddatamgr",
"kv_store"
],
"envs": [],
"author": {
"name": "",
"email": "",
"url": ""
},
"contributors": [
{
"name": "",
"email": "",
"url": ""
}
],
"segment": {
"destPath": "foundation/distributeddatamgr/kv_store"
},
"dirs": {},
"scripts": {},
"component": {
"name": "kv_store",
"subsystem": "distributeddatamgr",
"syscap": [
"SystemCapability.DistributedDataManager.KVStore.Core",
"SystemCapability.DistributedDataManager.KVStore.Lite",
"SystemCapability.DistributedDataManager.KVStore.DistributedKVStore"
],
"features": [],
"adapted_system_type": [
"standard"
],
"rom": "",
"ram": "",
"hisysevent_config": [],
"deps": {
"thrid_party": [
"uv_static",
"sqlite",
"libz",
"jsoncpp",
"libcrypto_shared"
],
"kernel_special": {},
"board_special": {},
"components": [
"libuv",
"common_event_service",
"bundle_framework",
"safwk",
"zlib",
"init",
"os_account",
"common",
"samgr",
"dataclassification",
"dsoftbus",
"jsoncpp",
"hitrace_native",
"access_token",
"huks",
"ability_base",
"ability_runtime",
"hiviewdfx_hilog_native",
"hisysevent_native",
"device_auth",
"ipc",
"napi"
]
},
"build": {
"sub_component": [
"//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:build_module",
"//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata:build_module"
],
"inner_kits": [
{
"name": "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata:distributeddata_inner",
"header": {
"header_files": [
"blob.h",
"change_notification.h",
"distributed_kv_data_manager.h",
"kvstore.h",
"kvstore_death_recipient.h",
"kvstore_observer.h",
"kvstore_result_set.h",
"kvstore_sync_callback.h",
"single_kvstore.h",
"types.h",
"visibility.h",
"data_query.h",
"device_status_change_listener.h",
"store_errno.h"
],
"header_base": "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata/include"
}
}
]
}
}
}

View File

@ -0,0 +1,120 @@
%define debug_package %{nil}
%global oh_version OpenHarmony-v3.2-Release
%global kv_store_dir %{_builddir}/foundation/distributeddatamgr/
%global build_opt /opt/distributed-middleware-build
%global bundle_dir %{build_opt}/openeuler/compiler_gn/foundation/distributeddatamgr/kv_store
%global frameworks_dir %{bundle_dir}/frameworks/libs/distributeddb
%global interface_dir %{bundle_dir}/interfaces/innerkits/distributeddata
Name: distributeddatamgr_kv_store
Version: 1.0.0
Release: 3
Summary: Supports distributed key-value and document-based data management, and supports the use of schemas to describe data formats.
License: Apache-2.0
Url: https://gitee.com/openharmony/distributeddatamgr_kv_store
Source0: https://gitee.com/openharmony/distributeddatamgr_kv_store/repository/archive/OpenHarmony-v3.2-Release.tar.gz#/distributeddatamgr_kv_store-OpenHarmony-v3.2-Release.tar.gz
Source1: frameworks.BUILD.gn
Source2: interface.BUILD.gn
Source3: bundle.json
Patch0: 0001-remove-useless-dependency-datashare.patch
Patch1: 0002-remove-useless-dependency-hitrace-hisysevent.patch
Patch2: 0003-remove-useless-dependency-compile.patch
Patch3: 0004-add-huks-component.patch
Patch4: 0005-add-third-part-component.patch
Patch5: 0006-establish-kvstore-dependence-on-boundscheck.patch
BuildRequires: libatomic libicu-devel libxml2-devel openssl-devel
BuildRequires: distributed-build distributed-build_lite hilog distributed-utils
BuildRequires: jsoncpp jsoncpp-devel
Requires: jsoncpp jsoncpp-devel hilog distributed-utils
%description
KV database (KV store) is developed based on the KV storage capability provided by the current public basic library,and provides key-value pair data management capabilities for device applications. On a platform with processes, the parameter management provided by KV storage is accessed by a single process and cannot be used by other processes. On such platforms, KV storage is loaded in the application process as a basic library to ensure that it is not accessed by other processes.
%prep
rm -rf %{_builddir}/*
# 在rpmbuild/BUILD目录下构建变成目录结构
cd %{_builddir}
cp -rp %{build_opt} %{_builddir}/build
[ ! -L "%{_builddir}/build.sh" ] && ln -s %{_builddir}/build/build_scripts/build.sh %{_builddir}/build.sh
[ ! -L "%{_builddir}/.gn" ] && ln -s %{_builddir}/build/core/gn/dotfile.gn %{_builddir}/.gn
[ ! -L "%{_builddir}/build.py" ] && ln -s %{_builddir}/build/lite/build.py %{_builddir}/build.py
mv build/openeuler/vendor %{_builddir}/
cp -rf build/openeuler/compiler_gn/* %{_builddir}/
%setup -q -T -a 0 -c -n %{kv_store_dir}
mv %{kv_store_dir}%{name}-%{oh_version} %{kv_store_dir}kv_store
%patch0 -p1 -d %{kv_store_dir}kv_store
%patch1 -p1 -d %{kv_store_dir}kv_store
%patch2 -p1 -d %{kv_store_dir}kv_store
%patch3 -p1 -d %{_builddir}/base/security
%patch4 -p1 -d %{_builddir}/third_party
%patch5 -p1 -d %{_builddir}/foundation
%build
cd %{_builddir}
rm -rf %{_builddir}/out
%ifarch x86_64
./build.sh --product-name openeuler --target-cpu x86_64
%endif
%ifarch aarch64
./build.sh --product-name openeuler --target-cpu arm64
%endif
%install
install -d -m 0755 %{buildroot}%{_includedir}/kv_store
install -d -m 0755 %{buildroot}%{_libdir}
install -d %{buildroot}%{frameworks_dir}
install -d %{buildroot}%{interface_dir}
install -d -m 0755 %{buildroot}/system/lib64
cp %{SOURCE1} %{buildroot}%{frameworks_dir}/BUILD.gn
cp %{SOURCE2} %{buildroot}%{interface_dir}/BUILD.gn
cp %{SOURCE3} %{buildroot}%{bundle_dir}
%ifarch aarch64
module_out_path="out/openeuler/linux_clang_arm64/distributeddatamgr/kv_store"
header_out_path="out/openeuler/innerkits/linux-arm64/kv_store"
%endif
%ifarch x86_64
module_out_path="out/openeuler/linux_clang_x86_64/distributeddatamgr/kv_store"
header_out_path="out/openeuler/innerkits/linux-x86_64/kv_store"
%endif
install -m 0755 %{_builddir}/${module_out_path}/*.so %{buildroot}%{_libdir}
install -m 0755 %{_builddir}/${module_out_path}/*.so %{buildroot}/system/lib64/
# 对外头文件使用kv_store功能的头文件
find %{_builddir}/${header_out_path} -name *.h -print0 | xargs -0 -i cp -rf {} %{buildroot}%{_includedir}/kv_store/
cp -vf %{_builddir}/foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/rdb/include/*.h %{buildroot}%{_includedir}/kv_store/
# 导出所有的头文件,给其他组件编译使用
pushd %{_builddir}/foundation/distributeddatamgr/kv_store
for include_file in `find . \( -name kvstoremock -o -name test -o -name jskitsimpl \) -prune -o -name "*.h" -type f`
do
if [[ ${include_file} != *.h ]]; then
continue
fi
cp --parents ${include_file} %{buildroot}%{bundle_dir}
done
popd
%files
%{_libdir}/*.so
%{_includedir}/kv_store/*
%{bundle_dir}/*
/system/*
%changelog
* Fri Aug 04 2023 Yuying Mu <muyuying1@huawei.com> - 1.0.0-3
- Disassemble the original patch according to its function.
* Thu Aug 03 2023 Peng He <hepeng68@huawei.com> - 1.0.0-2
- Add requires and rectify the contents of the RPM package.
* Tue Jul 18 2023 Ge Wang <wang__ge@126.com> - 1.0.0-1
- init package

20
frameworks.BUILD.gn Normal file
View File

@ -0,0 +1,20 @@
import("//build/ohos.gni")
config("distrdb_config") {
include_dirs = [
"interfaces/include",
"interfaces/include/relational",
"include"
# "/usr/include/kv_store",
# "/usr/include/openssl",
]
libs = [ "distributeddb.z" ]
}
group("distributeddb") {
public_configs = [ ":distrdb_config" ]
}
group("build_module") {
deps = [ ":distributeddb" ]
}

20
interface.BUILD.gn Normal file
View File

@ -0,0 +1,20 @@
import("//build/ohos.gni")
group("build_module") {
deps = [ ":distributeddata_inner" ]
}
config("distributeddatall_config") {
include_dirs = [
"include",
"../../../frameworks/innerkitsimpl/rdb/include",
"../../../frameworks/innerkitsimpl/object/include",
"../../../frameworks/innerkitsimpl/distributeddatafwk/include",
"//commonlibrary/c_utils/base/include",
]
libs = [ "distributeddata_inner.z" ]
}
group("distributeddata_inner") {
public_configs = [ ":distributeddatall_config" ]
}