mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
@@ -71,6 +71,7 @@ srms_inner_api_path =
|
||||
"${ability_runtime_path}/service_router_framework/interfaces/inner_api"
|
||||
fuzz_test_output_path = "ability_runtime/ability_runtime"
|
||||
accessibility_path = "//foundation/barrierfree/accessibility"
|
||||
kv_store_path = "//foundation/distributeddatamgr/kv_store"
|
||||
|
||||
declare_args() {
|
||||
background_task_mgr_continuous_task_enable = true
|
||||
|
||||
@@ -22,6 +22,7 @@ config("dataobs_manager_public_config") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native",
|
||||
"${ability_runtime_services_path}/dataobsmgr/include",
|
||||
"${ability_base_kits_path}/uri/include",
|
||||
"${kv_store_path}/frameworks/common",
|
||||
]
|
||||
cflags = []
|
||||
if (target_cpu == "arm") {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#define OHOS_ABILITY_RUNTIME_DATAOBS_MGR_CHANGENOTIFICATION_H
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "uri.h"
|
||||
#include "message_parcel.h"
|
||||
|
||||
@@ -29,14 +30,19 @@ struct ChangeInfo {
|
||||
OTHER,
|
||||
INVAILD,
|
||||
};
|
||||
using Value = std::variant<std::monostate, int64_t, double, std::string, bool, std::vector<uint8_t>>;
|
||||
using Values = std::vector<Value>;
|
||||
using VBucket = std::map<std::string, Value>;
|
||||
using VBuckets = std::vector<VBucket>;
|
||||
|
||||
static bool Marshalling(const ChangeInfo &input, MessageParcel &data);
|
||||
static bool Unmarshalling(ChangeInfo &output, MessageParcel &data);
|
||||
static bool Marshalling(const ChangeInfo &input, MessageParcel &parcel);
|
||||
static bool Unmarshalling(ChangeInfo &output, MessageParcel &parcel);
|
||||
|
||||
ChangeType changeType_ = INVAILD;
|
||||
mutable std::list<Uri> uris_ = {};
|
||||
void *data_ = nullptr;
|
||||
uint32_t size_ = 0;
|
||||
VBuckets valuesBucket_ = {};
|
||||
static constexpr int LIST_MAX_COUNT = 3000;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -14,32 +14,44 @@
|
||||
*/
|
||||
#include <limits>
|
||||
#include "dataobs_mgr_changeinfo.h"
|
||||
#include "itypes_util.h"
|
||||
#include "securec.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
bool ChangeInfo::Marshalling(const ChangeInfo &input, MessageParcel &data)
|
||||
using Value = std::variant<std::monostate, int64_t, double, std::string, bool, std::vector<uint8_t>>;
|
||||
using Values = std::vector<Value>;
|
||||
using VBucket = std::map<std::string, Value>;
|
||||
using VBuckets = std::vector<VBucket>;
|
||||
bool ChangeInfo::Marshalling(const ChangeInfo &input, MessageParcel &parcel)
|
||||
{
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(input.changeType_))) {
|
||||
if (!parcel.WriteUint32(static_cast<uint32_t>(input.changeType_))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (input.uris_.size() > std::numeric_limits<uint32_t>::max() ||
|
||||
!data.WriteUint32(static_cast<uint32_t>(input.uris_.size()))) {
|
||||
!parcel.WriteUint32(static_cast<uint32_t>(input.uris_.size()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto const &uri : input.uris_) {
|
||||
if (!data.WriteString(uri.ToString())) {
|
||||
if (!parcel.WriteString(uri.ToString())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.WriteUint32(input.size_)) {
|
||||
if (!parcel.WriteUint32(input.size_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return input.size_ == 0 || data.WriteBuffer(input.data_, input.size_);
|
||||
if (!(input.size_ == 0 || parcel.WriteBuffer(input.data_, input.size_))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ITypesUtil::Marshal(parcel, input.valuesBucket_)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChangeInfo::Unmarshalling(ChangeInfo &output, MessageParcel &parcel)
|
||||
@@ -75,10 +87,15 @@ bool ChangeInfo::Unmarshalling(ChangeInfo &output, MessageParcel &parcel)
|
||||
if (size > 0 && data == nullptr) {
|
||||
return false;
|
||||
}
|
||||
VBuckets bucket;
|
||||
if (!(ITypesUtil::Unmarshal(parcel, bucket))) {
|
||||
return false;
|
||||
}
|
||||
output.changeType_ = static_cast<ChangeType>(changeType);
|
||||
std::swap(output.uris_, uris);
|
||||
output.data_ = const_cast<uint8_t*>(data);
|
||||
output.size_ = size;
|
||||
output.valuesBucket_ = std::move(bucket);
|
||||
return true;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -101,7 +101,8 @@ Status DataObsMgrInnerExt::HandleNotifyChange(const ChangeInfo &changeInfo)
|
||||
}
|
||||
for (const auto &[obs, value] : changeRes) {
|
||||
if (obs != nullptr && !value.empty()) {
|
||||
obs->OnChangeExt({ changeInfo.changeType_, move(value), changeInfo.data_, changeInfo.size_ });
|
||||
obs->OnChangeExt(
|
||||
{ changeInfo.changeType_, move(value), changeInfo.data_, changeInfo.size_, changeInfo.valuesBucket_ });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user