mirror of
https://gitee.com/openharmony/distributeddatamgr_datamgr_service
synced 2024-11-23 06:50:35 +00:00
change inner kits to be better
Signed-off-by: Sven Wang <wanghancai@huawei.com>
This commit is contained in:
parent
96ed9e0237
commit
9c373a7266
@ -25,9 +25,7 @@ ChangeNotification::ChangeNotification(std::vector<Entry> &&insertEntries, std::
|
||||
std::vector<Entry> &&deleteEntries, const std::string &deviceId, bool isClear)
|
||||
: insertEntries_(std::move(insertEntries)), updateEntries_(std::move(updateEntries)),
|
||||
deleteEntries_(std::move(deleteEntries)), deviceId_(deviceId), isClear_(isClear)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
ChangeNotification::~ChangeNotification()
|
||||
{}
|
||||
@ -153,7 +151,8 @@ ChangeNotification *ChangeNotification::Unmarshalling(Parcel &parcel)
|
||||
std::string deviceId = parcel.ReadString();
|
||||
bool isClear = parcel.ReadBool();
|
||||
|
||||
return new ChangeNotification(std::move(insertEntries), std::move(updateEntries), std::move(deleteEntries), deviceId, isClear);
|
||||
return new ChangeNotification(std::move(insertEntries), std::move(updateEntries), std::move(deleteEntries),
|
||||
deviceId, isClear);
|
||||
}
|
||||
} // namespace DistributedKv
|
||||
} // namespace OHOS
|
||||
|
@ -36,7 +36,7 @@ DistributedKvDataManager::~DistributedKvDataManager()
|
||||
{}
|
||||
|
||||
Status DistributedKvDataManager::GetKvStore(const Options &options, const AppId &appId, const StoreId &storeId,
|
||||
std::shared_ptr<KvStore> &kvStore)
|
||||
std::shared_ptr<KvStore> &kvStore)
|
||||
{
|
||||
DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
|
||||
|
||||
|
@ -219,14 +219,14 @@ int32_t KvStoreObserverStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
|
||||
std::string deviceId = data.ReadString();
|
||||
bool isClear = data.ReadBool();
|
||||
ChangeNotification changeNotification(std::move(insertEntries), std::move(updateEntries), std::move(deleteEntries), deviceId, isClear);
|
||||
ChangeNotification change(std::move(insertEntries), std::move(updateEntries), std::move(deleteEntries), deviceId, isClear);
|
||||
sptr<IRemoteObject> remote = data.ReadRemoteObject();
|
||||
if (remote != nullptr) {
|
||||
sptr<IKvStoreSnapshotImpl> kvStoreSnapshotProxy = iface_cast<IKvStoreSnapshotImpl>(remote);
|
||||
OnChange(changeNotification, std::move(kvStoreSnapshotProxy));
|
||||
OnChange(change, std::move(kvStoreSnapshotProxy));
|
||||
} else {
|
||||
ZLOGD("read kvstoreSnapshot is nullptr.");
|
||||
OnChange(changeNotification, nullptr);
|
||||
OnChange(change, nullptr);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -42,11 +42,10 @@ StoreId KvStoreClient::GetStoreId() const
|
||||
return storeId;
|
||||
}
|
||||
Status KvStoreClient::GetKvStoreSnapshot(std::shared_ptr<KvStoreObserver> observer,
|
||||
std::shared_ptr<KvStoreSnapshot> &snapshot) const
|
||||
std::shared_ptr<KvStoreSnapshot> &snapshot) const
|
||||
{
|
||||
DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
|
||||
|
||||
|
||||
snapshot = nullptr;
|
||||
if (kvStoreProxy_ == nullptr) {
|
||||
ZLOGE("kvstore proxy is nullptr.");
|
||||
|
@ -92,7 +92,8 @@ Status SingleKvStoreClient::GetResultSet(const Key &prefixKey, std::shared_ptr<K
|
||||
return statusTmp;
|
||||
}
|
||||
|
||||
Status SingleKvStoreClient::GetResultSetWithQuery(const std::string &query, std::shared_ptr<KvStoreResultSet> &resultSet) const
|
||||
Status SingleKvStoreClient::GetResultSetWithQuery(const std::string &query,
|
||||
std::shared_ptr<KvStoreResultSet> &resultSet) const
|
||||
{
|
||||
DdsTrace trace(std::string(LOG_TAG "::") + std::string(__FUNCTION__), true);
|
||||
|
||||
@ -124,7 +125,8 @@ Status SingleKvStoreClient::GetResultSetWithQuery(const std::string &query, std:
|
||||
return statusTmp;
|
||||
}
|
||||
|
||||
Status SingleKvStoreClient::GetResultSetWithQuery(const DataQuery &query, std::shared_ptr<KvStoreResultSet> &resultSet) const
|
||||
Status SingleKvStoreClient::GetResultSetWithQuery(const DataQuery &query,
|
||||
std::shared_ptr<KvStoreResultSet> &resultSet) const
|
||||
{
|
||||
return GetResultSetWithQuery(query.ToString(), resultSet);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ HWTEST_F(DistributedKvDataManagerEncryptTest, kvstore_ddm_createEncryptedStore_0
|
||||
|
||||
std::shared_ptr<KvStoreSnapshot> snapshot;
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
status = kvStorePtr->GetKvStoreSnapshot(nullptr,snapshot);
|
||||
status = kvStorePtr->GetKvStoreSnapshot(nullptr, snapshot);
|
||||
EXPECT_EQ(Status::SUCCESS, status) << "KvStore GetKvStoreSnapshot data return wrong status";
|
||||
ASSERT_NE(nullptr, snapshot) << "snapshot is nullptr";
|
||||
// get value from kvstore.
|
||||
|
@ -490,7 +490,7 @@ HWTEST_F(DistributedKvDataManagerTest, CloseKvStoreMulti003, TestSize.Level1)
|
||||
status = existKvStorePtr2->Put(keyInt, valueInt);
|
||||
EXPECT_EQ(Status::SUCCESS, status) << "KvStore put data return wrong status";
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
existKvStorePtr2->GetKvStoreSnapshot(nullptr,kvStoreSnapshotPtr);
|
||||
existKvStorePtr2->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
|
||||
|
@ -68,7 +68,7 @@ void KvStoreClientTest::SetUpTestCase(void)
|
||||
statusGetKvStore = manager.GetKvStore(options, appId, storeId, kvStorePtr);
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
statusGetSnapshot = kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
statusGetSnapshot = kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
}
|
||||
|
||||
void KvStoreClientTest::TearDownTestCase(void)
|
||||
@ -99,7 +99,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmGetKvStoreSnapshot001, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get values from KvStore before putting them into KvStore.
|
||||
@ -111,7 +111,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmGetKvStoreSnapshot001, TestSize.Level2)
|
||||
|
||||
Status status = kvStorePtr->Put(key, value); // insert or update key-value
|
||||
EXPECT_EQ(Status::SUCCESS, status) << "KvStore put data failed, wrong status";
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get values from KvStore after putting them into KvStore.
|
||||
@ -144,7 +144,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut001, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get int value from kvstore.
|
||||
@ -177,7 +177,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut002, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get float value from kvstore.
|
||||
@ -211,7 +211,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut003, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get double value from kvstore.
|
||||
@ -245,7 +245,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut004, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get unsigned int value from kvstore.
|
||||
@ -279,7 +279,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut005, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get long int value from kvstore.
|
||||
@ -311,7 +311,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut006, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get json value from kvstore.
|
||||
@ -344,7 +344,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut007, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get string value from kvstore.
|
||||
@ -377,7 +377,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut008, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get string value from kvstore.
|
||||
@ -414,7 +414,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut009, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get string value from kvstore.
|
||||
@ -535,7 +535,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPut014, TestSize.Level2)
|
||||
EXPECT_EQ(Status::SUCCESS, status) << "KvStore put data failed, wrong status";
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get values greater than MAX_VALUE_SIZE from KvStore.
|
||||
@ -570,7 +570,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmDelete001, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get value from kvstore.
|
||||
@ -602,7 +602,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmDelete002, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get value from kvstore.
|
||||
@ -659,7 +659,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmClear001, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
Value valueRet1;
|
||||
@ -727,7 +727,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPutBatch001, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get value from kvstore.
|
||||
@ -794,7 +794,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPutBatch002, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get value from kvstore.
|
||||
@ -960,7 +960,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmPutBatch006, TestSize.Level2)
|
||||
EXPECT_EQ(Status::SUCCESS, status) << "KvStore putbatch data failed, wrong status";
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get value from kvstore.
|
||||
@ -1023,7 +1023,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmDeleteBatch001, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
Key keyPrefixStudent = "student_name_";
|
||||
@ -1077,7 +1077,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmDeleteBatch002, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
Key keyPrefixStudent = "student_name_";
|
||||
@ -1129,7 +1129,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmDeleteBatch003, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
Key keyPrefixStudent = "student_name_";
|
||||
@ -1181,7 +1181,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmDeleteBatch004, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
Key keyPrefixStudent = "student_name_";
|
||||
@ -1234,7 +1234,7 @@ HWTEST_F(KvStoreClientTest, KvStoreDdmDeleteBatch005, TestSize.Level2)
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
Key keyPrefixStudent = "student_name_";
|
||||
|
@ -101,7 +101,7 @@ HWTEST_F(KvStoreSnapshotClientTest, KvStoreSnapshotDdmGet001, TestSize.Level1)
|
||||
|
||||
std::shared_ptr<KvStoreSnapshot> snapshot;
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
status = kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */snapshot);
|
||||
status = kvStorePtr->GetKvStoreSnapshot(nullptr, snapshot);
|
||||
EXPECT_EQ(Status::SUCCESS, status) << "KvStore GetKvStoreSnapshot return wrong status";
|
||||
EXPECT_NE(nullptr, snapshot) << "kvStoreSnapshotPtr is nullptr";
|
||||
// get value from kvstore.
|
||||
@ -136,7 +136,7 @@ HWTEST_F(KvStoreSnapshotClientTest, KvStoreSnapshotDdmGet002, TestSize.Level1)
|
||||
|
||||
std::shared_ptr<KvStoreSnapshot> snapshot;
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
status1 = kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */snapshot);
|
||||
status1 = kvStorePtr->GetKvStoreSnapshot(nullptr, snapshot);
|
||||
EXPECT_EQ(Status::SUCCESS, status1) << "KvStore GetKvStoreSnapshot return wrong status";
|
||||
EXPECT_NE(nullptr, snapshot) << "kvStoreSnapshotPtr is nullptr";
|
||||
|
||||
@ -163,7 +163,7 @@ HWTEST_F(KvStoreSnapshotClientTest, KvStoreSnapshotDdmGet003, TestSize.Level1)
|
||||
EXPECT_NE(nullptr, kvStorePtr) << "kvStorePtr is nullptr";
|
||||
std::shared_ptr<KvStoreSnapshot> snapshot;
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
Status status = kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */snapshot);
|
||||
Status status = kvStorePtr->GetKvStoreSnapshot(nullptr, snapshot);
|
||||
EXPECT_EQ(Status::SUCCESS, status) << "GetKvStoreSnapshot return wrong status";
|
||||
EXPECT_NE(nullptr, snapshot) << "kvStoreSnapshotPtr is nullptr";
|
||||
|
||||
@ -214,7 +214,7 @@ HWTEST_F(KvStoreSnapshotClientTest, KvStoreSnapshotDdmGetEntries001, TestSize.Le
|
||||
Status statusTmp = Status::ERROR;
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
statusTmp = kvStoreSnapshotPtr->GetEntries(keyPrefixStudent, students);
|
||||
@ -260,7 +260,7 @@ HWTEST_F(KvStoreSnapshotClientTest, KvStoreSnapshotDdmGetEntries002, TestSize.Le
|
||||
Status statusTmp = Status::ERROR;
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
statusTmp = kvStoreSnapshotPtr->GetEntries(keyPrefixStudent, students);
|
||||
@ -306,7 +306,7 @@ HWTEST_F(KvStoreSnapshotClientTest, KvStoreSnapshotDdmGetEntries003, TestSize.Le
|
||||
Status statusTmp = Status::ERROR;
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
statusTmp = kvStoreSnapshotPtr->GetEntries(keyPrefixStudent, students);
|
||||
@ -352,7 +352,7 @@ HWTEST_F(KvStoreSnapshotClientTest, KvStoreSnapshotDdmGetEntries004, TestSize.Le
|
||||
Status statusTmp = Status::ERROR;
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
statusTmp = kvStoreSnapshotPtr->GetEntries(keyPrefixStudent, students);
|
||||
@ -408,7 +408,7 @@ HWTEST_F(KvStoreSnapshotClientTest, KvStoreSnapshotDdmGetEntries005, TestSize.Le
|
||||
Status statusTmp = Status::ERROR;
|
||||
std::shared_ptr<KvStoreSnapshot> kvStoreSnapshotPtr;
|
||||
// [create and] open and initialize kvstore snapshot instance.
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, /* (KvStoreObserver ) */ kvStoreSnapshotPtr);
|
||||
kvStorePtr->GetKvStoreSnapshot(nullptr, kvStoreSnapshotPtr);
|
||||
|
||||
EXPECT_NE(nullptr, kvStoreSnapshotPtr) << "kvStoreSnapshotPtr is nullptr";
|
||||
statusTmp = kvStoreSnapshotPtr->GetEntries(keyPrefixStudent, students);
|
||||
|
@ -38,12 +38,10 @@ public:
|
||||
|
||||
// Creates a snapshot of the kvstore, allowing the client app to read a
|
||||
// consistent data of the content of the kvstore.
|
||||
//
|
||||
// If observer is provided, it will receive notifications for changes of the
|
||||
// kvstore newer than the resulting snapshot.
|
||||
// Parameters:
|
||||
// observer: observer for subscribe.
|
||||
// callback: including status and KvStoreSnapshot instance returned by this call.
|
||||
// snapshot: [output] the KvStoreSnapshot instance.
|
||||
KVSTORE_API virtual Status GetKvStoreSnapshot(std::shared_ptr<KvStoreObserver> observer,
|
||||
std::shared_ptr<KvStoreSnapshot> &snapshot) const = 0;
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
// nextKey: The first key to start in this search.
|
||||
// callback: all entries satisfied perfixKey, status of this call and the first key of the next part of data.
|
||||
[[deprecated]]
|
||||
KVSTORE_API virtual Status GetEntries(const Key &prefixKey, Key &nextKey,std::vector<Entry> &entries) = 0;
|
||||
KVSTORE_API virtual Status GetEntries(const Key &prefixKey, Key &nextKey, std::vector<Entry> &entries) = 0;
|
||||
|
||||
// Get a list of entries from kvstore by keyPrefix,
|
||||
// key length must be less than 1024,
|
||||
|
@ -65,7 +65,8 @@ public:
|
||||
// resultSet: resultSet will be returned in this parameter.
|
||||
// Return:
|
||||
// Status of this GetResultSet operation.
|
||||
KVSTORE_API virtual Status GetResultSet(const Key &prefixKey, std::shared_ptr<KvStoreResultSet> &resultSet) const = 0;
|
||||
KVSTORE_API virtual Status GetResultSet(const Key &prefixKey,
|
||||
std::shared_ptr<KvStoreResultSet> &resultSet) const = 0;
|
||||
|
||||
// Get ResultSet in this store by Query.
|
||||
// Parameters:
|
||||
@ -73,7 +74,8 @@ public:
|
||||
// resultSet: resultSet will be returned in this parameter.
|
||||
// Return:
|
||||
// Status of this GetResultSet operation.
|
||||
KVSTORE_API virtual Status GetResultSetWithQuery(const std::string &query, std::shared_ptr<KvStoreResultSet> &resultSet) const = 0;
|
||||
KVSTORE_API virtual Status GetResultSetWithQuery(const std::string &query,
|
||||
std::shared_ptr<KvStoreResultSet> &resultSet) const = 0;
|
||||
|
||||
// Get ResultSet in this store by Query.
|
||||
// Parameters:
|
||||
@ -81,7 +83,8 @@ public:
|
||||
// resultSet: resultSet will be returned in this parameter.
|
||||
// Return:
|
||||
// Status of this GetResultSet operation.
|
||||
KVSTORE_API virtual Status GetResultSetWithQuery(const DataQuery &query, std::shared_ptr<KvStoreResultSet> &resultSet) const = 0;
|
||||
KVSTORE_API virtual Status GetResultSetWithQuery(const DataQuery &query,
|
||||
std::shared_ptr<KvStoreResultSet> &resultSet) const = 0;
|
||||
|
||||
// Close the ResultSet returned by GetResultSet.
|
||||
// Parameters:
|
||||
|
@ -40,7 +40,8 @@ struct UserId {
|
||||
// app identifier from Bms
|
||||
struct AppId {
|
||||
std::string appId;
|
||||
inline bool IsValid() const {
|
||||
inline bool IsValid() const
|
||||
{
|
||||
if (appId.empty() || appId.size() > MAX_APP_ID_LEN) {
|
||||
return false;
|
||||
}
|
||||
@ -64,7 +65,8 @@ private:
|
||||
// and can not be empty and all space.
|
||||
struct StoreId {
|
||||
std::string storeId;
|
||||
inline bool IsValid() const {
|
||||
inline bool IsValid() const
|
||||
{
|
||||
if (storeId.empty() || storeId.size() > MAX_STORE_ID_LEN) {
|
||||
return false;
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ void DeviceKvStoreObserverImpl::OnChange(const DistributedDB::KvStoreChangedData
|
||||
if (deviceId.empty()) {
|
||||
ZLOGE("Did NOT find any valid deviceId");
|
||||
}
|
||||
ChangeNotification changeNotification(std::move(inserts), std::move(updates), std::move(deleteds), deviceId, false);
|
||||
ChangeNotification change(std::move(inserts), std::move(updates), std::move(deleteds), deviceId, false);
|
||||
if (observerProxy_ != nullptr) {
|
||||
observerProxy_->OnChange(changeNotification, nullptr);
|
||||
observerProxy_->OnChange(change, nullptr);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
|
@ -16,9 +16,10 @@
|
||||
#define LOG_TAG "KvStoreAccountObserver"
|
||||
|
||||
#include "kvstore_account_observer.h"
|
||||
#include <atomic>
|
||||
#include "kvstore_data_service.h"
|
||||
#include "log_print.h"
|
||||
#include <atomic>
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedKv {
|
||||
std::atomic<int> g_kvStoreAccountEventStatus {0};
|
||||
|
@ -292,7 +292,7 @@ Status KvStoreMetaManager::CheckUpdateServiceMeta(const std::vector<uint8_t> &me
|
||||
Status KvStoreMetaManager::GenerateRootKey()
|
||||
{
|
||||
ZLOGI("GenerateRootKey.");
|
||||
struct HksBlob rootKeyName = { static_cast<uint32_t>(vecRootKeyAlias_.size()), &(vecRootKeyAlias_[0]) };
|
||||
struct HksBlob rootKeyName = { uint32_t(vecRootKeyAlias_.size()), &(vecRootKeyAlias_[0]) };
|
||||
struct HksParamSet *paramSet = nullptr;
|
||||
int32_t ret = HksInitParamSet(¶mSet);
|
||||
if (ret != HKS_SUCCESS) {
|
||||
@ -368,10 +368,10 @@ Status KvStoreMetaManager::CheckRootKeyExist()
|
||||
|
||||
std::vector<uint8_t> KvStoreMetaManager::EncryptWorkKey(const std::vector<uint8_t> &key)
|
||||
{
|
||||
struct HksBlob blobAad = { static_cast<uint32_t>(vecAad_.size()), &(vecAad_[0]) };
|
||||
struct HksBlob blobNonce = { static_cast<uint32_t>(vecNonce_.size()), &(vecNonce_[0]) };
|
||||
struct HksBlob rootKeyName = { static_cast<uint32_t>(vecRootKeyAlias_.size()), &(vecRootKeyAlias_[0]) };
|
||||
struct HksBlob plainKey = { static_cast<uint32_t>(key.size()), const_cast<uint8_t *>(&(key[0])) };
|
||||
struct HksBlob blobAad = { uint32_t(vecAad_.size()), &(vecAad_[0]) };
|
||||
struct HksBlob blobNonce = { uint32_t(vecNonce_.size()), &(vecNonce_[0]) };
|
||||
struct HksBlob rootKeyName = { uint32_t(vecRootKeyAlias_.size()), &(vecRootKeyAlias_[0]) };
|
||||
struct HksBlob plainKey = { uint32_t(key.size()), const_cast<uint8_t *>(&(key[0])) };
|
||||
uint8_t cipherBuf[256] = { 0 };
|
||||
struct HksBlob encryptedKey = { sizeof(cipherBuf), cipherBuf };
|
||||
std::vector<uint8_t> encryptedKeyVec;
|
||||
@ -420,10 +420,10 @@ std::vector<uint8_t> KvStoreMetaManager::EncryptWorkKey(const std::vector<uint8_
|
||||
|
||||
bool KvStoreMetaManager::DecryptWorkKey(const std::vector<uint8_t> &encryptedKey, std::vector<uint8_t> &key)
|
||||
{
|
||||
struct HksBlob blobAad = { static_cast<uint32_t>(vecAad_.size()), &(vecAad_[0]) };
|
||||
struct HksBlob blobNonce = { static_cast<uint32_t>(vecNonce_.size()), &(vecNonce_[0]) };
|
||||
struct HksBlob rootKeyName = { static_cast<uint32_t>(vecRootKeyAlias_.size()), &(vecRootKeyAlias_[0]) };
|
||||
struct HksBlob encryptedKeyBlob = { static_cast<uint32_t>(encryptedKey.size()), const_cast<uint8_t *>(&(encryptedKey[0])) };
|
||||
struct HksBlob blobAad = { uint32_t(vecAad_.size()), &(vecAad_[0]) };
|
||||
struct HksBlob blobNonce = { uint32_t(vecNonce_.size()), &(vecNonce_[0]) };
|
||||
struct HksBlob rootKeyName = { uint32_t(vecRootKeyAlias_.size()), &(vecRootKeyAlias_[0]) };
|
||||
struct HksBlob encryptedKeyBlob = { uint32_t(encryptedKey.size()), const_cast<uint8_t *>(&(encryptedKey[0])) };
|
||||
uint8_t plainBuf[256] = { 0 };
|
||||
struct HksBlob plainKeyBlob = { sizeof(plainBuf), plainBuf };
|
||||
struct HksParamSet *decryptParamSet = nullptr;
|
||||
|
@ -78,9 +78,9 @@ void KvStoreObserverImpl::OnChange(const DistributedDB::KvStoreChangedData &data
|
||||
deleteds.push_back(tmpEntry);
|
||||
}
|
||||
|
||||
ChangeNotification changeNotification(std::move(inserts), std::move(updates), std::move(deleteds), std::string(), false);
|
||||
ChangeNotification change(std::move(inserts), std::move(updates), std::move(deleteds), std::string(), false);
|
||||
ZLOGI("call proxy OnChange");
|
||||
observerProxy_->OnChange(changeNotification, nullptr);
|
||||
observerProxy_->OnChange(change, nullptr);
|
||||
}
|
||||
|
||||
SubscribeType KvStoreObserverImpl::GetSubscribeType() const
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "constant.h"
|
||||
#include "common_event_subscriber.h"
|
||||
#include "common_event_support.h"
|
||||
#include "common_event_define.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "ohos/aafwk/content/intent.h"
|
||||
#include "ohos_account_kits.h"
|
||||
|
Loading…
Reference in New Issue
Block a user