修改看板告警

Signed-off-by: 师皓杰 <shihaojie10@huawei.com>
This commit is contained in:
师皓杰 2024-09-02 16:00:55 +08:00
parent a4ac09d4f1
commit bf984d2286
5 changed files with 289 additions and 130 deletions

View File

@ -45,10 +45,11 @@ public:
private:
DmsSaClient() {};
~DmsSaClient() {};
bool hasSubscribeDmsSA_ = false;
std::atomic<bool> hasSubscribeDmsSA_ = false;
OHOS::sptr<ISystemAbilityManager> saMgrProxy_;
std::map<DSchedEventType, sptr<IDSchedEventListener>> listeners_;
std::mutex eventMutex_;
std::mutex saMgrMutex_;
};
class DmsSystemAbilityStatusChange : public SystemAbilityStatusChangeStub {

View File

@ -47,7 +47,10 @@ bool DmsSaClient::SubscribeDmsSA()
int32_t DmsSaClient::AddDSchedEventListener(const DSchedEventType& type, const sptr<IDSchedEventListener>& listener)
{
HILOGI("%{public}s called, the type is %{public}d", __func__, type);
{
std::lock_guard<std::mutex> lock(saMgrMutex_);
saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
}
if (saMgrProxy_ == nullptr) {
HILOGE("fail to get saMgrProxy.");
return AAFwk::INNER_ERR;
@ -56,11 +59,13 @@ int32_t DmsSaClient::AddDSchedEventListener(const DSchedEventType& type, const s
DistributedClient distributedClient;
distributedClient.RegisterDSchedEventListener(type, listener);
}
std::lock_guard<std::mutex> lock(eventMutex_);
if (!hasSubscribeDmsSA_) {
if (SubscribeDmsSA()) {
hasSubscribeDmsSA_ = true;
{
std::lock_guard<std::mutex> lock(eventMutex_);
listeners_[type] = listener;
}
} else {
return AAFwk::INNER_ERR;
}
@ -71,7 +76,10 @@ int32_t DmsSaClient::AddDSchedEventListener(const DSchedEventType& type, const s
int32_t DmsSaClient::DelDSchedEventListener(const DSchedEventType& type, const sptr<IDSchedEventListener>& listener)
{
HILOGI("%{public}s called, the type is %{public}d", __func__, type);
{
std::lock_guard<std::mutex> lock(saMgrMutex_);
saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
}
if (saMgrProxy_ == nullptr) {
HILOGE("fail to get saMgrProxy.");
return AAFwk::INNER_ERR;
@ -88,7 +96,10 @@ int32_t DmsSaClient::DelDSchedEventListener(const DSchedEventType& type, const s
int32_t DmsSaClient::GetContinueInfo(ContinueInfo &continueInfo)
{
HILOGI("%{public}s called", __func__);
{
std::lock_guard<std::mutex> lock(saMgrMutex_);
saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
}
if (saMgrProxy_ == nullptr) {
HILOGE("fail to get saMgrProxy.");
return AAFwk::INNER_ERR;
@ -103,7 +114,10 @@ int32_t DmsSaClient::GetContinueInfo(ContinueInfo &continueInfo)
int32_t DmsSaClient::GetDSchedEventInfo(const DSchedEventType &type, std::vector<EventNotify> &events)
{
HILOGI("%{public}s called", __func__);
{
std::lock_guard<std::mutex> lock(saMgrMutex_);
saMgrProxy_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
}
if (saMgrProxy_ == nullptr) {
HILOGE("Get SA manager proxy fail.");
return AAFwk::INNER_ERR;

View File

@ -19,6 +19,7 @@
#include <map>
#include <set>
#include <vector>
#include "base_interfaces.h"
#include "parcel.h"
#include "refbase.h"
@ -57,9 +58,6 @@ public:
static bool CompareInterface(const sptr<AAFwk::IInterface> iIt1, const sptr<AAFwk::IInterface> iIt2, int typeId);
static bool CompareNumberInterface(const sptr<AAFwk::IInterface> iIt1,
const sptr<AAFwk::IInterface> iIt2, int typeId);
static int GetDataType(const sptr<AAFwk::IInterface> iIt);
static int GetNumberDataType(const sptr<AAFwk::IInterface> iIt);
@ -89,39 +87,29 @@ public:
AAFwk::WantParams ToWantParams();
private:
enum {
VALUE_TYPE_NULL = -1,
VALUE_TYPE_BOOLEAN = 1,
VALUE_TYPE_BYTE = 2,
VALUE_TYPE_CHAR = 3,
VALUE_TYPE_SHORT = 4,
VALUE_TYPE_INT = 5,
VALUE_TYPE_LONG = 6,
VALUE_TYPE_FLOAT = 7,
VALUE_TYPE_DOUBLE = 8,
VALUE_TYPE_STRING = 9,
VALUE_TYPE_CHARSEQUENCE = 10,
VALUE_TYPE_BOOLEANARRAY = 11,
VALUE_TYPE_BYTEARRAY = 12,
VALUE_TYPE_CHARARRAY = 13,
VALUE_TYPE_SHORTARRAY = 14,
VALUE_TYPE_INTARRAY = 15,
VALUE_TYPE_LONGARRAY = 16,
VALUE_TYPE_FLOATARRAY = 17,
VALUE_TYPE_DOUBLEARRAY = 18,
VALUE_TYPE_STRINGARRAY = 19,
VALUE_TYPE_CHARSEQUENCEARRAY = 20,
static std::string BooleanQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string ByteQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string CharQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string ShortQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string IntegerQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string LongQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string FloatQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string DoubleQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string StringQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string ArrayQueryToStr(const sptr<AAFwk::IInterface> iIt);
static std::string DistributedWantParamsQueryToStr(const sptr<AAFwk::IInterface> iIt);
VALUE_TYPE_PARCELABLE = 21,
VALUE_TYPE_PARCELABLEARRAY = 22,
VALUE_TYPE_SERIALIZABLE = 23,
VALUE_TYPE_LIST = 50,
VALUE_TYPE_WANTPARAMS = 101,
VALUE_TYPE_ARRAY = 102,
VALUE_TYPE_FD = 103,
VALUE_TYPE_REMOTE_OBJECT = 104
};
static bool BooleanQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool ByteQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool CharQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool StringQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool ArrayQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool DistributedWantParamsQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool ShortQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool IntegerQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool LongQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool FloatQueryEquals(const sptr<AAFwk::IInterface> iIt);
static bool DoubleQueryEquals(const sptr<AAFwk::IInterface> iIt);
bool WriteArrayToParcel(Parcel& parcel, AAFwk::IArray* ao) const;
bool ReadArrayToParcel(Parcel& parcel, int type, sptr<AAFwk::IArray>& ao);
@ -178,11 +166,52 @@ private:
bool DoMarshalling(Parcel& parcel) const;
bool ReadUnsupportedData(Parcel& parcel, const std::string& key, int type);
friend class DistributedWantParamWrapper;
friend class DistributedWant;
// inner use function
bool NewArrayData(AAFwk::IArray* source, sptr<AAFwk::IArray>& dest);
bool NewParams(const DistributedWantParams& source, DistributedWantParams& dest);
private:
enum {
VALUE_TYPE_NULL = -1,
VALUE_TYPE_BOOLEAN = 1,
VALUE_TYPE_BYTE = 2,
VALUE_TYPE_CHAR = 3,
VALUE_TYPE_SHORT = 4,
VALUE_TYPE_INT = 5,
VALUE_TYPE_LONG = 6,
VALUE_TYPE_FLOAT = 7,
VALUE_TYPE_DOUBLE = 8,
VALUE_TYPE_STRING = 9,
VALUE_TYPE_CHARSEQUENCE = 10,
VALUE_TYPE_BOOLEANARRAY = 11,
VALUE_TYPE_BYTEARRAY = 12,
VALUE_TYPE_CHARARRAY = 13,
VALUE_TYPE_SHORTARRAY = 14,
VALUE_TYPE_INTARRAY = 15,
VALUE_TYPE_LONGARRAY = 16,
VALUE_TYPE_FLOATARRAY = 17,
VALUE_TYPE_DOUBLEARRAY = 18,
VALUE_TYPE_STRINGARRAY = 19,
VALUE_TYPE_CHARSEQUENCEARRAY = 20,
VALUE_TYPE_PARCELABLE = 21,
VALUE_TYPE_PARCELABLEARRAY = 22,
VALUE_TYPE_SERIALIZABLE = 23,
VALUE_TYPE_LIST = 50,
VALUE_TYPE_WANTPARAMS = 101,
VALUE_TYPE_ARRAY = 102,
VALUE_TYPE_FD = 103,
VALUE_TYPE_REMOTE_OBJECT = 104
};
friend class DistributedWantParamWrapper;
friend class DistributedWant;
using InterfaceQueryToStrFunc = std::string (*)(const sptr<AAFwk::IInterface> iIt);
using InterfaceQueryEqualsFunc = bool (*)(const sptr<AAFwk::IInterface> iIt);
static std::map<int, InterfaceQueryToStrFunc> interfaceQueryToStrMap;
static std::map<int, InterfaceQueryEqualsFunc> interfaceQueryEqualsMap;
// inner use function
std::map<std::string, sptr<AAFwk::IInterface>> params_;
std::map<std::string, int> fds_;
std::vector<DistributedUnsupportedData> cachedUnsupportedData_;

View File

@ -44,6 +44,57 @@ const char* TYPE_PROPERTY = "type";
const char* VALUE_PROPERTY = "value";
const std::string TAG = "DistributedUnsupportedData";
}
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc> DistributedWantParams::interfaceQueryToStrMap = {
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_BOOLEAN, &DistributedWantParams::BooleanQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_BYTE, &DistributedWantParams::ByteQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_CHAR, &DistributedWantParams::CharQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_SHORT, &DistributedWantParams::ShortQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_INT, &DistributedWantParams::IntegerQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_LONG, &DistributedWantParams::LongQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_FLOAT, &DistributedWantParams::FloatQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_DOUBLE, &DistributedWantParams::DoubleQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_STRING, &DistributedWantParams::StringQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_ARRAY, &DistributedWantParams::ArrayQueryToStr),
std::map<int, DistributedWantParams::InterfaceQueryToStrFunc>::value_type(
DistributedWantParams::VALUE_TYPE_WANTPARAMS, &DistributedWantParams::DistributedWantParamsQueryToStr),
};
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc> DistributedWantParams::interfaceQueryEqualsMap = {
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_BOOLEAN, &DistributedWantParams::BooleanQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_BYTE, &DistributedWantParams::ByteQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_CHAR, &DistributedWantParams::CharQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_STRING, &DistributedWantParams::StringQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_ARRAY, &DistributedWantParams::ArrayQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_WANTPARAMS, &DistributedWantParams::DistributedWantParamsQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_SHORT, &DistributedWantParams::ShortQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_INT, &DistributedWantParams::IntegerQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_LONG, &DistributedWantParams::LongQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_FLOAT, &DistributedWantParams::FloatQueryEquals),
std::map<int, DistributedWantParams::InterfaceQueryEqualsFunc>::value_type(
DistributedWantParams::VALUE_TYPE_DOUBLE, &DistributedWantParams::DoubleQueryEquals),
};
DistributedUnsupportedData::~DistributedUnsupportedData()
{
if (buffer != nullptr) {
@ -114,32 +165,144 @@ DistributedUnsupportedData& DistributedUnsupportedData::operator=(DistributedUns
return *this;
}
std::string DistributedWantParams::BooleanQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IBoolean* obj = AAFwk::IBoolean::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::Boolean*>(obj)->ToString();
}
std::string DistributedWantParams::ByteQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IByte* obj = AAFwk::IByte::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::Byte*>(obj)->ToString();
}
std::string DistributedWantParams::CharQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IChar* obj = AAFwk::IChar::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::Char*>(obj)->ToString();
}
std::string DistributedWantParams::ShortQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IShort* obj = AAFwk::IShort::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::Short*>(obj)->ToString();
}
std::string DistributedWantParams::IntegerQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IInteger* obj = AAFwk::IInteger::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::Integer*>(obj)->ToString();
}
std::string DistributedWantParams::LongQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::ILong* obj = AAFwk::ILong::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::Long*>(obj)->ToString();
}
std::string DistributedWantParams::FloatQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IFloat* obj = AAFwk::IFloat::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::Float*>(obj)->ToString();
}
std::string DistributedWantParams::DoubleQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IDouble* obj = AAFwk::IDouble::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::Double*>(obj)->ToString();
}
std::string DistributedWantParams::StringQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IString* obj = AAFwk::IString::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::String*>(obj)->ToString();
}
std::string DistributedWantParams::ArrayQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IArray* obj = AAFwk::IArray::Query(iIt);
return obj == nullptr ? "" : static_cast<AAFwk::Array*>(obj)->ToString();
}
std::string DistributedWantParams::DistributedWantParamsQueryToStr(const sptr<AAFwk::IInterface> iIt)
{
IDistributedWantParams* obj = IDistributedWantParams::Query(iIt);
return obj == nullptr ? "" : static_cast<DistributedWantParamWrapper*>(obj)->ToString();
}
bool DistributedWantParams::BooleanQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IBoolean* obj = AAFwk::IBoolean::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::Boolean*>(obj)->Equals(*static_cast<AAFwk::Boolean*>(obj));
}
bool DistributedWantParams::ByteQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IByte* obj = AAFwk::IByte::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::Byte*>(obj)->Equals(*static_cast<AAFwk::Byte*>(obj));
}
bool DistributedWantParams::CharQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IChar* obj = AAFwk::IChar::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::Char*>(obj)->Equals(*static_cast<AAFwk::Char*>(obj));
}
bool DistributedWantParams::StringQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IString* obj = AAFwk::IString::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::String*>(obj)->Equals(*static_cast<AAFwk::String*>(obj));
}
bool DistributedWantParams::ArrayQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IArray* obj = AAFwk::IArray::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::Array*>(obj)->Equals(*static_cast<AAFwk::Array*>(obj));
}
bool DistributedWantParams::DistributedWantParamsQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
IDistributedWantParams* obj = IDistributedWantParams::Query(iIt);
return obj == nullptr ? false : static_cast<DistributedWantParamWrapper*>(obj)
->Equals(*static_cast<DistributedWantParamWrapper*>(obj));
}
bool DistributedWantParams::ShortQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IShort* obj = AAFwk::IShort::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::Short*>(obj)->Equals(*static_cast<AAFwk::Short*>(obj));
}
bool DistributedWantParams::IntegerQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IInteger* obj = AAFwk::IInteger::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::Integer*>(obj)->Equals(*static_cast<AAFwk::Integer*>(obj));
}
bool DistributedWantParams::LongQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::ILong* obj = AAFwk::ILong::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::Long*>(obj)->Equals(*static_cast<AAFwk::Long*>(obj));
}
bool DistributedWantParams::FloatQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IFloat* obj = AAFwk::IFloat::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::Float*>(obj)->Equals(*static_cast<AAFwk::Float*>(obj));
}
bool DistributedWantParams::DoubleQueryEquals(const sptr<AAFwk::IInterface> iIt)
{
AAFwk::IDouble* obj = AAFwk::IDouble::Query(iIt);
return obj == nullptr ? false : static_cast<AAFwk::Double*>(obj)->Equals(*static_cast<AAFwk::Double*>(obj));
}
std::string DistributedWantParams::GetStringByType(const sptr<AAFwk::IInterface> iIt, int typeId)
{
if (typeId == VALUE_TYPE_BOOLEAN) {
return static_cast<AAFwk::Boolean*>(AAFwk::IBoolean::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_BYTE) {
return static_cast<AAFwk::Byte*>(AAFwk::IByte::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_CHAR) {
return static_cast<AAFwk::Char*>(AAFwk::IChar::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_SHORT) {
return static_cast<AAFwk::Short*>(AAFwk::IShort::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_INT) {
return static_cast<AAFwk::Integer*>(AAFwk::IInteger::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_LONG) {
return static_cast<AAFwk::Long*>(AAFwk::ILong::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_FLOAT) {
return static_cast<AAFwk::Float*>(AAFwk::IFloat::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_DOUBLE) {
return static_cast<AAFwk::Double*>(AAFwk::IDouble::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_STRING) {
return static_cast<AAFwk::String*>(AAFwk::IString::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_ARRAY) {
return static_cast<AAFwk::Array*>(AAFwk::IArray::Query(iIt))->ToString();
} else if (typeId == VALUE_TYPE_WANTPARAMS) {
return static_cast<DistributedWantParamWrapper*>(IDistributedWantParams::Query(iIt))->ToString();
} else {
return "";
auto iter = interfaceQueryToStrMap.find(typeId);
if (iter != interfaceQueryToStrMap.end()) {
DistributedWantParams::InterfaceQueryToStrFunc &func = iter->second;
return (*func)(iIt);
}
return "";
}
@ -311,68 +474,13 @@ sptr<IInterface> DistributedWantParams::GetInterfaceByType(int typeId, const std
return nullptr;
}
bool DistributedWantParams::CompareNumberInterface(const sptr<IInterface> iIt1,
const sptr<IInterface> iIt2, int typeId)
{
bool flag = false;
switch (typeId) {
case VALUE_TYPE_SHORT:
flag = static_cast<AAFwk::Short*>(AAFwk::IShort::Query(iIt1))
->Equals(*(static_cast<AAFwk::Short*>(AAFwk::IShort::Query(iIt1))));
break;
case VALUE_TYPE_INT:
flag = static_cast<AAFwk::Integer*>(AAFwk::IInteger::Query(iIt1))
->Equals(*(static_cast<AAFwk::Integer*>(AAFwk::IInteger::Query(iIt1))));
break;
case VALUE_TYPE_LONG:
flag = static_cast<AAFwk::Long*>(AAFwk::ILong::Query(iIt1))
->Equals(*(static_cast<AAFwk::Long*>(AAFwk::ILong::Query(iIt1))));
break;
case VALUE_TYPE_FLOAT:
flag = static_cast<AAFwk::Float*>(AAFwk::IFloat::Query(iIt1))
->Equals(*(static_cast<AAFwk::Float*>(AAFwk::IFloat::Query(iIt1))));
break;
case VALUE_TYPE_DOUBLE:
flag = static_cast<AAFwk::Double*>(AAFwk::IDouble::Query(iIt1))
->Equals(*(static_cast<AAFwk::Double*>(AAFwk::IDouble::Query(iIt1))));
break;
default:
break;
}
return flag;
}
bool DistributedWantParams::CompareInterface(const sptr<IInterface> iIt1, const sptr<IInterface> iIt2, int typeId)
{
bool flag = false;
switch (typeId) {
case VALUE_TYPE_BOOLEAN:
flag = static_cast<AAFwk::Boolean*>(AAFwk::IBoolean::Query(iIt1))
->Equals(*(static_cast<AAFwk::Boolean*>(AAFwk::IBoolean::Query(iIt1))));
break;
case VALUE_TYPE_BYTE:
flag = static_cast<AAFwk::Byte*>(AAFwk::IByte::Query(iIt1))
->Equals(*(static_cast<AAFwk::Byte*>(AAFwk::IByte::Query(iIt1))));
break;
case VALUE_TYPE_CHAR:
flag = static_cast<AAFwk::Char*>(AAFwk::IChar::Query(iIt1))
->Equals(*(static_cast<AAFwk::Char*>(AAFwk::IChar::Query(iIt1))));
break;
case VALUE_TYPE_STRING:
flag = static_cast<AAFwk::String*>(AAFwk::IString::Query(iIt1))
->Equals(*(static_cast<AAFwk::String*>(AAFwk::IString::Query(iIt1))));
break;
case VALUE_TYPE_ARRAY:
flag = static_cast<AAFwk::Array*>(AAFwk::IArray::Query(iIt1))
->Equals(*(static_cast<AAFwk::Array*>(AAFwk::IArray::Query(iIt1))));
break;
case VALUE_TYPE_WANTPARAMS:
flag = static_cast<DistributedWantParamWrapper*>(IDistributedWantParams::Query(iIt1))
->Equals(*(static_cast<DistributedWantParamWrapper*>(IDistributedWantParams::Query(iIt1))));
break;
default:
flag = CompareNumberInterface(iIt1, iIt2, typeId);
break;
auto iter = interfaceQueryEqualsMap.find(typeId);
if (iter != interfaceQueryEqualsMap.end()) {
DistributedWantParams::InterfaceQueryEqualsFunc &func = iter->second;
return (*func)(iIt1);
}
return flag;
}
@ -465,8 +573,12 @@ bool DistributedWantParams::WriteToParcelWantParams(Parcel& parcel, sptr<IInterf
if (!parcel.WriteInt32(VALUE_TYPE_WANTPARAMS)) {
return false;
}
return parcel.WriteString16(Str8ToStr16(
static_cast<DistributedWantParamWrapper*>(IDistributedWantParams::Query(o))->ToString()));
auto wantParams = static_cast<DistributedWantParamWrapper*>(IDistributedWantParams::Query(o));
if (wantParams == nullptr) {
return false;
}
return parcel.WriteString16(Str8ToStr16(wantParams->ToString()));
}
bool DistributedWantParams::WriteToParcelFD(Parcel& parcel, const DistributedWantParams& value) const

View File

@ -733,6 +733,9 @@ bool DistributedSchedPermission::CheckTargetAbilityVisible(const AppExecFwk::Abi
void DistributedSchedPermission::RemoveRemoteObjectFromWant(std::shared_ptr<AAFwk::Want> want) const
{
if (want == nullptr) {
return;
}
WantParams wantParams = want->GetParams();
std::map<std::string, sptr<IInterface>> params = wantParams.GetParams();
for (auto param : params) {