mirror of
https://github.com/openharmony/notification_ces_standard.git
synced 2026-07-01 04:39:51 -04:00
support 64
Signed-off-by: zero-cyc <chenlien@huawei.com> Change-Id: I754efd76cabe6f89e4cc5b1cebd85f07e4c5897c
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#ifndef FOUNDATION_EVENT_COMMON_LOG_INCLUDE_EVENT_LOG_WRAPPER_H
|
||||
#define FOUNDATION_EVENT_COMMON_LOG_INCLUDE_EVENT_LOG_WRAPPER_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <string>
|
||||
#include "hilog/log.h"
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
* @return Returns true if successful; false otherwise.
|
||||
*/
|
||||
bool FinishReceiver(
|
||||
const sptr<IRemoteObject> &proxy, const int &code, const std::string &data, const bool &abortEvent);
|
||||
const sptr<IRemoteObject> &proxy, const int32_t &code, const std::string &data, const bool &abortEvent);
|
||||
|
||||
/**
|
||||
* Dumps state of common event service.
|
||||
@@ -179,7 +179,7 @@ private:
|
||||
sptr<ICommonEvent> commonEventProxy_;
|
||||
std::map<std::shared_ptr<CommonEventSubscriber>, sptr<CommonEventListener>> eventListeners_;
|
||||
sptr<IRemoteObject::DeathRecipient> recipient_;
|
||||
const unsigned int SUBSCRIBER_MAX_SIZE = 200;
|
||||
const size_t SUBSCRIBER_MAX_SIZE = 200;
|
||||
static const uint8_t ALREADY_SUBSCRIBED = 0;
|
||||
static const uint8_t INITIAL_SUBSCRIPTION = 1;
|
||||
static const uint8_t SUBSCRIBE_FAILED = 2;
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
* @param abortEvent Indicates whether the current ordered common event should be aborted.
|
||||
* @return Returns true if successful; false otherwise.
|
||||
*/
|
||||
virtual bool FinishReceiver(const sptr<IRemoteObject> &proxy, const int &code, const std::string &receiverData,
|
||||
virtual bool FinishReceiver(const sptr<IRemoteObject> &proxy, const int32_t &code, const std::string &receiverData,
|
||||
const bool &abortEvent) override;
|
||||
|
||||
/**
|
||||
|
||||
@@ -99,8 +99,8 @@ public:
|
||||
* @param abortEvent Indicates whether the current ordered common event should be aborted.
|
||||
* @return Returns true if successful; false otherwise.
|
||||
*/
|
||||
virtual bool FinishReceiver(
|
||||
const sptr<IRemoteObject> &proxy, const int &code, const std::string &receiverData, const bool &abortEvent) = 0;
|
||||
virtual bool FinishReceiver(const sptr<IRemoteObject> &proxy, const int32_t &code,
|
||||
const std::string &receiverData, const bool &abortEvent) = 0;
|
||||
|
||||
/**
|
||||
* Freezes the specified process.
|
||||
|
||||
@@ -178,7 +178,7 @@ bool CommonEvent::GetStickyCommonEvent(const std::string &event, CommonEventData
|
||||
}
|
||||
|
||||
bool CommonEvent::FinishReceiver(
|
||||
const sptr<IRemoteObject> &proxy, const int &code, const std::string &data, const bool &abortEvent)
|
||||
const sptr<IRemoteObject> &proxy, const int32_t &code, const std::string &data, const bool &abortEvent)
|
||||
{
|
||||
EVENT_LOGI("enter");
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ void CommonEventListener::OnReceiveEvent(
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
int code = commonEventData.GetCode();
|
||||
int32_t code = commonEventData.GetCode();
|
||||
std::string data = commonEventData.GetData();
|
||||
|
||||
std::shared_ptr<AsyncCommonEventResult> result =
|
||||
|
||||
@@ -256,7 +256,7 @@ bool CommonEventProxy::DumpState(const std::string &event, const int32_t &userId
|
||||
if (ret) {
|
||||
int32_t stackNum = reply.ReadInt32();
|
||||
stackNum = stackNum > MAX_HISTORY_SIZE ? MAX_HISTORY_SIZE : stackNum;
|
||||
for (int i = 0; i < stackNum; i++) {
|
||||
for (int32_t i = 0; i < stackNum; i++) {
|
||||
std::string stack = Str16ToStr8(reply.ReadString16());
|
||||
state.emplace_back(stack);
|
||||
}
|
||||
@@ -267,7 +267,7 @@ bool CommonEventProxy::DumpState(const std::string &event, const int32_t &userId
|
||||
}
|
||||
|
||||
bool CommonEventProxy::FinishReceiver(
|
||||
const sptr<IRemoteObject> &proxy, const int &code, const std::string &receiverData, const bool &abortEvent)
|
||||
const sptr<IRemoteObject> &proxy, const int32_t &code, const std::string &receiverData, const bool &abortEvent)
|
||||
{
|
||||
EVENT_LOGD("start");
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ int CommonEventStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Message
|
||||
if (hasLastSubscriber) {
|
||||
sptr<IRemoteObject> commonEventListener = data.ReadRemoteObject();
|
||||
}
|
||||
int uid = data.ReadInt32();
|
||||
int32_t uid = data.ReadInt32();
|
||||
int32_t userId = data.ReadInt32();
|
||||
if (!event) {
|
||||
EVENT_LOGE("Failed to ReadParcelable<CommonEventData>");
|
||||
@@ -151,7 +151,7 @@ int CommonEventStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Message
|
||||
EVENT_LOGE("Failed to ReadRemoteObject");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int receiverCode = data.ReadInt32();
|
||||
int32_t receiverCode = data.ReadInt32();
|
||||
std::string receiverData = Str16ToStr8(data.ReadString16());
|
||||
bool abortEvent = data.ReadBool();
|
||||
bool ret = FinishReceiver(proxy, receiverCode, receiverData, abortEvent);
|
||||
@@ -163,7 +163,7 @@ int CommonEventStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Message
|
||||
}
|
||||
|
||||
case static_cast<uint32_t>(ICommonEvent::Message::CES_FREEZE): {
|
||||
int uid = data.ReadInt32();
|
||||
int32_t uid = data.ReadInt32();
|
||||
bool ret = Freeze(uid);
|
||||
if (!reply.WriteBool(ret)) {
|
||||
EVENT_LOGE("Failed to write reply");
|
||||
@@ -173,7 +173,7 @@ int CommonEventStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Message
|
||||
}
|
||||
|
||||
case static_cast<uint32_t>(ICommonEvent::Message::CES_UNFREEZE): {
|
||||
int uid = data.ReadInt32();
|
||||
int32_t uid = data.ReadInt32();
|
||||
bool ret = Unfreeze(uid);
|
||||
if (!reply.WriteBool(ret)) {
|
||||
EVENT_LOGE("Failed to write reply");
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace EventFwk {
|
||||
AsyncCommonEventResult::AsyncCommonEventResult(const int &resultCode, const std::string &resultData,
|
||||
AsyncCommonEventResult::AsyncCommonEventResult(const int32_t &resultCode, const std::string &resultData,
|
||||
const bool &ordered, const bool &sticky, const sptr<IRemoteObject> &token)
|
||||
: abortEvent_(false), finished_(false)
|
||||
{
|
||||
@@ -34,7 +34,7 @@ AsyncCommonEventResult::AsyncCommonEventResult(const int &resultCode, const std:
|
||||
AsyncCommonEventResult::~AsyncCommonEventResult()
|
||||
{}
|
||||
|
||||
bool AsyncCommonEventResult::SetCode(const int &code)
|
||||
bool AsyncCommonEventResult::SetCode(const int32_t &code)
|
||||
{
|
||||
if (!CheckSynchronous()) {
|
||||
return false;
|
||||
@@ -45,7 +45,7 @@ bool AsyncCommonEventResult::SetCode(const int &code)
|
||||
return true;
|
||||
}
|
||||
|
||||
int AsyncCommonEventResult::GetCode() const
|
||||
int32_t AsyncCommonEventResult::GetCode() const
|
||||
{
|
||||
return resultCode_;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ std::string AsyncCommonEventResult::GetData() const
|
||||
return resultData_;
|
||||
}
|
||||
|
||||
bool AsyncCommonEventResult::SetCodeAndData(const int &code, const std::string &data)
|
||||
bool AsyncCommonEventResult::SetCodeAndData(const int32_t &code, const std::string &data)
|
||||
{
|
||||
if (!CheckSynchronous()) {
|
||||
return false;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "common_event_data.h"
|
||||
|
||||
#include "event_log_wrapper.h"
|
||||
@@ -29,7 +28,7 @@ CommonEventData::CommonEventData(const Want &want) : want_(want), code_(0)
|
||||
{
|
||||
}
|
||||
|
||||
CommonEventData::CommonEventData(const Want &want, const int &code, const std::string &data)
|
||||
CommonEventData::CommonEventData(const Want &want, const int32_t &code, const std::string &data)
|
||||
: want_(want), code_(code), data_(data)
|
||||
{
|
||||
}
|
||||
@@ -38,12 +37,12 @@ CommonEventData::~CommonEventData()
|
||||
{
|
||||
}
|
||||
|
||||
void CommonEventData::SetCode(const int &code)
|
||||
void CommonEventData::SetCode(const int32_t &code)
|
||||
{
|
||||
code_ = code;
|
||||
}
|
||||
|
||||
int CommonEventData::GetCode() const
|
||||
int32_t CommonEventData::GetCode() const
|
||||
{
|
||||
return code_;
|
||||
}
|
||||
@@ -75,7 +74,7 @@ bool CommonEventData::Marshalling(Parcel &parcel) const
|
||||
EVENT_LOGE("Type conversion failed");
|
||||
return false;
|
||||
}
|
||||
if (!messageParcel->WriteUint32(data_.size() + 1)) {
|
||||
if (!messageParcel->WriteUint64(data_.size() + 1)) {
|
||||
EVENT_LOGE("Failed to write data size");
|
||||
return false;
|
||||
}
|
||||
@@ -105,14 +104,14 @@ bool CommonEventData::ReadFromParcel(Parcel &parcel)
|
||||
EVENT_LOGE("Type conversion failed");
|
||||
return false;
|
||||
}
|
||||
uint32_t length = messageParcel->ReadUint32();
|
||||
uint64_t length = messageParcel->ReadUint64();
|
||||
if (length == 0) {
|
||||
EVENT_LOGE("Invalid data length");
|
||||
return false;
|
||||
}
|
||||
const char *data = reinterpret_cast<const char *>(messageParcel->ReadRawData(length));
|
||||
if (!data) {
|
||||
EVENT_LOGE("Fail to read raw data, length = %{public}u", length);
|
||||
EVENT_LOGE("Fail to read raw data, length = %{public}" PRIu64 "", length);
|
||||
return false;
|
||||
}
|
||||
data_ = data;
|
||||
|
||||
@@ -68,7 +68,7 @@ bool CommonEventPublishInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
EVENT_LOGD("enter");
|
||||
|
||||
// write subscriberpermissions
|
||||
// write subscriber permissions
|
||||
std::vector<std::u16string> permissionVec_;
|
||||
for (std::vector<std::string>::size_type i = 0; i < subscriberPermissions_.size(); ++i) {
|
||||
permissionVec_.emplace_back(Str8ToStr16(subscriberPermissions_[i]));
|
||||
@@ -97,7 +97,7 @@ bool CommonEventPublishInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
EVENT_LOGD("enter");
|
||||
|
||||
// read subscriberpermissions
|
||||
// read subscriber permissions
|
||||
std::vector<std::u16string> permissionVec_;
|
||||
if (!parcel.ReadString16Vector(&permissionVec_)) {
|
||||
EVENT_LOGE("ReadFromParcel read permission error");
|
||||
|
||||
@@ -33,7 +33,7 @@ const CommonEventSubscribeInfo &CommonEventSubscriber::GetSubscribeInfo() const
|
||||
return subscribeInfo_;
|
||||
}
|
||||
|
||||
bool CommonEventSubscriber::SetCode(const int &code)
|
||||
bool CommonEventSubscriber::SetCode(const int32_t &code)
|
||||
{
|
||||
if (!CheckSynchronous()) {
|
||||
return false;
|
||||
@@ -42,7 +42,7 @@ bool CommonEventSubscriber::SetCode(const int &code)
|
||||
return result_->SetCode(code);
|
||||
}
|
||||
|
||||
int CommonEventSubscriber::GetCode() const
|
||||
int32_t CommonEventSubscriber::GetCode() const
|
||||
{
|
||||
if (!CheckSynchronous()) {
|
||||
return 0;
|
||||
@@ -69,7 +69,7 @@ std::string CommonEventSubscriber::GetData() const
|
||||
return result_->GetData();
|
||||
}
|
||||
|
||||
bool CommonEventSubscriber::SetCodeAndData(const int &code, const std::string &data)
|
||||
bool CommonEventSubscriber::SetCodeAndData(const int32_t &code, const std::string &data)
|
||||
{
|
||||
if (!CheckSynchronous()) {
|
||||
return false;
|
||||
|
||||
@@ -32,10 +32,10 @@ MatchingSkills::MatchingSkills(const MatchingSkills &matchingSkills)
|
||||
MatchingSkills::~MatchingSkills()
|
||||
{}
|
||||
|
||||
std::string MatchingSkills::GetEntity(int index) const
|
||||
std::string MatchingSkills::GetEntity(size_t index) const
|
||||
{
|
||||
std::string entity;
|
||||
if ((index >= 0) && (index < static_cast<int>(entities_.size()))) {
|
||||
if ((index >= 0) && (index < entities_.size())) {
|
||||
entity = entities_[index];
|
||||
}
|
||||
return entity;
|
||||
@@ -62,7 +62,7 @@ void MatchingSkills::RemoveEntity(const std::string &entity)
|
||||
}
|
||||
}
|
||||
|
||||
int MatchingSkills::CountEntities() const
|
||||
size_t MatchingSkills::CountEntities() const
|
||||
{
|
||||
return entities_.size();
|
||||
}
|
||||
@@ -75,15 +75,15 @@ void MatchingSkills::AddEvent(const std::string &event)
|
||||
}
|
||||
}
|
||||
|
||||
int MatchingSkills::CountEvent() const
|
||||
size_t MatchingSkills::CountEvent() const
|
||||
{
|
||||
return events_.size();
|
||||
}
|
||||
|
||||
std::string MatchingSkills::GetEvent(int index) const
|
||||
std::string MatchingSkills::GetEvent(size_t index) const
|
||||
{
|
||||
std::string event;
|
||||
if (index >= 0 && index < static_cast<int>(events_.size())) {
|
||||
if (index >= 0 && index < events_.size()) {
|
||||
event = events_[index];
|
||||
}
|
||||
return event;
|
||||
@@ -107,10 +107,10 @@ bool MatchingSkills::HasEvent(const std::string &event) const
|
||||
return std::find(events_.cbegin(), events_.cend(), event) != events_.cend();
|
||||
}
|
||||
|
||||
std::string MatchingSkills::GetScheme(int index) const
|
||||
std::string MatchingSkills::GetScheme(size_t index) const
|
||||
{
|
||||
std::string schemes;
|
||||
if ((index >= 0) && (index < static_cast<int>(schemes_.size()))) {
|
||||
if ((index >= 0) && (index < schemes_.size())) {
|
||||
schemes = schemes_[index];
|
||||
}
|
||||
return schemes;
|
||||
@@ -137,7 +137,7 @@ void MatchingSkills::RemoveScheme(const std::string &scheme)
|
||||
}
|
||||
}
|
||||
|
||||
int MatchingSkills::CountSchemes() const
|
||||
size_t MatchingSkills::CountSchemes() const
|
||||
{
|
||||
return schemes_.size();
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
virtual ~CommonEventStubTest()
|
||||
{}
|
||||
|
||||
virtual bool FinishReceiver(const OHOS::sptr<IRemoteObject> &proxy, const int &code,
|
||||
virtual bool FinishReceiver(const OHOS::sptr<IRemoteObject> &proxy, const int32_t &code,
|
||||
const std::string &receiverData, const bool &abortEvent)
|
||||
{
|
||||
return false;
|
||||
@@ -502,7 +502,7 @@ HWTEST_F(CommonEventSubscribeTest, CommonEventSubscribe_014, TestSize.Level1)
|
||||
CommonEventListener commonEventListener(subscriber);
|
||||
commonEventListener.runner_ = nullptr;
|
||||
|
||||
int result = commonEventListener.IsReady();
|
||||
bool result = commonEventListener.IsReady();
|
||||
|
||||
EXPECT_EQ(false, result);
|
||||
}
|
||||
@@ -525,7 +525,7 @@ HWTEST_F(CommonEventSubscribeTest, CommonEventSubscribe_015, TestSize.Level1)
|
||||
CommonEventListener commonEventListener(subscriber);
|
||||
commonEventListener.handler_ = nullptr;
|
||||
|
||||
int result = commonEventListener.IsReady();
|
||||
bool result = commonEventListener.IsReady();
|
||||
|
||||
EXPECT_EQ(false, result);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
virtual ~CommonEventStubTest()
|
||||
{}
|
||||
|
||||
virtual bool FinishReceiver(const OHOS::sptr<IRemoteObject> &proxy, const int &code,
|
||||
virtual bool FinishReceiver(const OHOS::sptr<IRemoteObject> &proxy, const int32_t &code,
|
||||
const std::string &receiverData, const bool &abortEvent)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -25,8 +25,8 @@ using namespace testing::ext;
|
||||
using namespace OHOS::EventFwk;
|
||||
using OHOS::Parcel;
|
||||
|
||||
static const int SET_COUNT = 1;
|
||||
static const int MAX_COUNT = 100;
|
||||
static const size_t SET_COUNT = 1;
|
||||
static const size_t MAX_COUNT = 100;
|
||||
|
||||
class MatchingSkillsTest : public testing::Test {
|
||||
public:
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
* @param sticky Indicates the type of the current sticky common event is sticky or not.
|
||||
* @param token Indicates the remote object of the current ordered common event.
|
||||
*/
|
||||
AsyncCommonEventResult(const int &resultCode, const std::string &resultData, const bool &ordered,
|
||||
AsyncCommonEventResult(const int32_t &resultCode, const std::string &resultData, const bool &ordered,
|
||||
const bool &sticky, const sptr<IRemoteObject> &token);
|
||||
|
||||
~AsyncCommonEventResult();
|
||||
@@ -42,14 +42,14 @@ public:
|
||||
* @param code Indicates the result code of the current ordered common event
|
||||
* @return Returns true if successful; false otherwise.
|
||||
*/
|
||||
bool SetCode(const int &code);
|
||||
bool SetCode(const int32_t &code);
|
||||
|
||||
/**
|
||||
* Obtains the result code of the current ordered common event.
|
||||
*
|
||||
* @return Returns the result code of the current ordered common event
|
||||
*/
|
||||
int GetCode() const;
|
||||
int32_t GetCode() const;
|
||||
|
||||
/**
|
||||
* Sets the result data of the current ordered common event.
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
* @param data Indicates the result data of the current ordered common event.
|
||||
* @return Returns true if successful; false otherwise.
|
||||
*/
|
||||
bool SetCodeAndData(const int &code, const std::string &data);
|
||||
bool SetCodeAndData(const int32_t &code, const std::string &data);
|
||||
|
||||
/**
|
||||
* Cancels the current ordered common event.
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
bool CheckSynchronous() const;
|
||||
|
||||
private:
|
||||
int resultCode_;
|
||||
int32_t resultCode_;
|
||||
std::string resultData_;
|
||||
bool ordered_;
|
||||
bool sticky_;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
* @param code Indicates the code of a common event.
|
||||
* @param data Indicates the data of a common event.
|
||||
*/
|
||||
CommonEventData(const Want &want, const int &code, const std::string &data);
|
||||
CommonEventData(const Want &want, const int32_t &code, const std::string &data);
|
||||
|
||||
~CommonEventData();
|
||||
|
||||
@@ -66,14 +66,14 @@ public:
|
||||
*
|
||||
* @param code Indicates the code of a common event.
|
||||
*/
|
||||
void SetCode(const int &code);
|
||||
void SetCode(const int32_t &code);
|
||||
|
||||
/**
|
||||
* Obtains the result code of a common event.
|
||||
*
|
||||
* @return Returns the code of a common event.
|
||||
*/
|
||||
int GetCode() const;
|
||||
int32_t GetCode() const;
|
||||
|
||||
/**
|
||||
* Sets the result data of a common event.
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
|
||||
private:
|
||||
Want want_;
|
||||
int code_;
|
||||
int32_t code_;
|
||||
std::string data_;
|
||||
};
|
||||
} // namespace EventFwk
|
||||
|
||||
@@ -56,14 +56,14 @@ public:
|
||||
* @param code Indicates the result code of the current ordered common event
|
||||
* @return Returns true if success; false otherwise.
|
||||
*/
|
||||
bool SetCode(const int &code);
|
||||
bool SetCode(const int32_t &code);
|
||||
|
||||
/**
|
||||
* Obtains the result code of the current ordered common event.
|
||||
*
|
||||
* @return Returns the result code of the current ordered common event.
|
||||
*/
|
||||
int GetCode() const;
|
||||
int32_t GetCode() const;
|
||||
|
||||
/**
|
||||
* Sets the result data of the current ordered common event.
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
* @param data Indicates the result data of the current ordered common event.
|
||||
* @return Returns true if success; false otherwise.
|
||||
*/
|
||||
bool SetCodeAndData(const int &code, const std::string &data);
|
||||
bool SetCodeAndData(const int32_t &code, const std::string &data);
|
||||
|
||||
/**
|
||||
* Cancels the current ordered common event.
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
* @param index Indicates the entity index.
|
||||
* @return Returns entity.
|
||||
*/
|
||||
std::string GetEntity(int index) const;
|
||||
std::string GetEntity(size_t index) const;
|
||||
|
||||
/**
|
||||
* Adds an entity to this MatchingSkills object.
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
*
|
||||
* @return Returns entity count.
|
||||
*/
|
||||
int CountEntities() const;
|
||||
size_t CountEntities() const;
|
||||
|
||||
/**
|
||||
* Adds an event to this MatchingSkills object.
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
*
|
||||
* @return Indicates the event count in MatchingSkills object.
|
||||
*/
|
||||
int CountEvent() const;
|
||||
size_t CountEvent() const;
|
||||
|
||||
/**
|
||||
* Gets event.
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
* @param index Indicates the scheme index.
|
||||
* @return Returns the event in MatchingSkills object.
|
||||
*/
|
||||
std::string GetEvent(int index) const;
|
||||
std::string GetEvent(size_t index) const;
|
||||
|
||||
/**
|
||||
* Gets events.
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
* @param index Indicates the scheme index.
|
||||
* @return Retruns scheme.
|
||||
*/
|
||||
std::string GetScheme(int index) const;
|
||||
std::string GetScheme(size_t index) const;
|
||||
|
||||
/**
|
||||
* Adds scheme to this MatchingSkills object.
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
*
|
||||
* @return Retruns scheme count.
|
||||
*/
|
||||
int CountSchemes() const;
|
||||
size_t CountSchemes() const;
|
||||
|
||||
/**
|
||||
* Matches want.
|
||||
|
||||
@@ -101,7 +101,7 @@ struct AsyncCallbackInfoGetCode {
|
||||
napi_env env = nullptr;
|
||||
napi_async_work asyncWork;
|
||||
SubscriberInstance *objectInfo = nullptr;
|
||||
int code = 0;
|
||||
int32_t code = 0;
|
||||
CallbackPromiseInfo info;
|
||||
};
|
||||
|
||||
@@ -109,7 +109,7 @@ struct AsyncCallbackInfoSetCode {
|
||||
napi_env env = nullptr;
|
||||
napi_async_work asyncWork;
|
||||
SubscriberInstance *objectInfo = nullptr;
|
||||
int code = 0;
|
||||
int32_t code = 0;
|
||||
CallbackPromiseInfo info;
|
||||
};
|
||||
|
||||
@@ -133,7 +133,7 @@ struct AsyncCallbackInfoSetCodeAndData {
|
||||
napi_env env = nullptr;
|
||||
napi_async_work asyncWork;
|
||||
SubscriberInstance *objectInfo = nullptr;
|
||||
int code = 0;
|
||||
int32_t code = 0;
|
||||
std::string data;
|
||||
CallbackPromiseInfo info;
|
||||
};
|
||||
@@ -188,7 +188,7 @@ struct AsyncCallbackInfoPublish {
|
||||
struct CommonEventPublishDataByjs {
|
||||
std::string bundleName;
|
||||
std::string data;
|
||||
int code = 0;
|
||||
int32_t code = 0;
|
||||
std::vector<std::string> subscriberPermissions;
|
||||
bool isOrdered = false;
|
||||
bool isSticky = false;
|
||||
@@ -199,7 +199,7 @@ struct CommonEventDataWorker {
|
||||
napi_env env = nullptr;
|
||||
napi_ref ref = nullptr;
|
||||
Want want;
|
||||
int code = 0;
|
||||
int32_t code = 0;
|
||||
std::string data;
|
||||
};
|
||||
|
||||
@@ -288,7 +288,7 @@ std::shared_ptr<AsyncCommonEventResult> GetAsyncResult(const SubscriberInstance
|
||||
napi_value GetCode(napi_env env, napi_callback_info info);
|
||||
|
||||
napi_value ParseParametersBySetCode(
|
||||
const napi_env &env, const napi_value (&argv)[2], size_t argc, int &code, napi_ref &callback);
|
||||
const napi_env &env, const napi_value (&argv)[2], size_t argc, int32_t &code, napi_ref &callback);
|
||||
|
||||
void PaddingAsyncCallbackInfoSetCode(const napi_env &env, const size_t &argc,
|
||||
AsyncCallbackInfoSetCode *&asynccallbackinfo, const napi_ref &callback, napi_value &promise);
|
||||
@@ -310,8 +310,8 @@ void PaddingAsyncCallbackInfoSetData(const napi_env &env, const size_t &argc,
|
||||
|
||||
napi_value SetData(napi_env env, napi_callback_info info);
|
||||
|
||||
napi_value ParseParametersBySetCodeAndData(
|
||||
const napi_env &env, const napi_value (&argv)[3], size_t argc, int &code, std::string &data, napi_ref &callback);
|
||||
napi_value ParseParametersBySetCodeAndData(const napi_env &env, const napi_value (&argv)[3],
|
||||
size_t argc, int32_t &code, std::string &data, napi_ref &callback);
|
||||
|
||||
void PaddingAsyncCallbackInfoSetCodeAndData(const napi_env &env, const size_t &argc,
|
||||
AsyncCallbackInfoSetCodeAndData *&asynccallbackinfo, const napi_ref &callback, napi_value &promise);
|
||||
@@ -359,7 +359,7 @@ napi_value GetBundlenameByPublish(const napi_env &env, const napi_value &value,
|
||||
|
||||
napi_value GetDataByPublish(const napi_env &env, const napi_value &value, std::string &data);
|
||||
|
||||
napi_value GetCodeByPublish(const napi_env &env, const napi_value &value, int &code);
|
||||
napi_value GetCodeByPublish(const napi_env &env, const napi_value &value, int32_t &code);
|
||||
|
||||
napi_value GetSubscriberPermissionsByPublish(
|
||||
const napi_env &env, const napi_value &value, std::vector<std::string> &subscriberPermissions);
|
||||
|
||||
@@ -897,7 +897,7 @@ napi_value GetCode(napi_env env, napi_callback_info info)
|
||||
}
|
||||
|
||||
napi_value ParseParametersBySetCode(
|
||||
const napi_env &env, const napi_value (&argv)[SET_CODE_MAX_PARA], size_t argc, int &code, napi_ref &callback)
|
||||
const napi_env &env, const napi_value (&argv)[SET_CODE_MAX_PARA], size_t argc, int32_t &code, napi_ref &callback)
|
||||
{
|
||||
napi_valuetype valuetype;
|
||||
|
||||
@@ -942,7 +942,7 @@ napi_value SetCode(napi_env env, napi_callback_info info)
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL));
|
||||
|
||||
napi_ref callback = nullptr;
|
||||
int code = 0;
|
||||
int32_t code = 0;
|
||||
if (ParseParametersBySetCode(env, argv, argc, code, callback) == nullptr) {
|
||||
return NapiGetNull(env);
|
||||
}
|
||||
@@ -1220,7 +1220,7 @@ napi_value SetData(napi_env env, napi_callback_info info)
|
||||
|
||||
napi_value ParseParametersBySetCodeAndData(
|
||||
const napi_env &env, const napi_value (&argv)[SET_CODE_AND_DATA_MAX_PARA],
|
||||
size_t argc, int &code, std::string &data, napi_ref &callback)
|
||||
size_t argc, int32_t &code, std::string &data, napi_ref &callback)
|
||||
{
|
||||
napi_valuetype valuetype;
|
||||
size_t strLen = 0;
|
||||
@@ -1279,7 +1279,7 @@ napi_value SetCodeAndData(napi_env env, napi_callback_info info)
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, NULL));
|
||||
|
||||
napi_ref callback = nullptr;
|
||||
int code = 0;
|
||||
int32_t code = 0;
|
||||
std::string data;
|
||||
if (ParseParametersBySetCodeAndData(env, argv, argc, code, data, callback) == nullptr) {
|
||||
return NapiGetNull(env);
|
||||
@@ -1889,7 +1889,7 @@ napi_value GetDataByPublish(const napi_env &env, const napi_value &value, std::s
|
||||
return NapiGetNull(env);
|
||||
}
|
||||
|
||||
napi_value GetCodeByPublish(const napi_env &env, const napi_value &value, int &code)
|
||||
napi_value GetCodeByPublish(const napi_env &env, const napi_value &value, int32_t &code)
|
||||
{
|
||||
EVENT_LOGI("GetCodeByPublish start");
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
* @param uid Indicates the uid of the application.
|
||||
* @return Returns the bundle name.
|
||||
*/
|
||||
std::string GetBundleName(int uid);
|
||||
std::string GetBundleName(uid_t uid);
|
||||
|
||||
/**
|
||||
* Queries extension information.
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
* @param abortEvent Indicates whether to cancel the current common event.
|
||||
* @return Returns true if success; false otherwise.
|
||||
*/
|
||||
bool FinishReceiverAction(std::shared_ptr<OrderedEventRecord> recordPtr, const int &code,
|
||||
bool FinishReceiverAction(std::shared_ptr<OrderedEventRecord> recordPtr, const int32_t &code,
|
||||
const std::string &receiverData, const bool &abortEvent);
|
||||
|
||||
/**
|
||||
@@ -128,18 +128,18 @@ private:
|
||||
|
||||
bool ScheduleOrderedCommonEvent();
|
||||
|
||||
bool NotifyOrderedEvent(std::shared_ptr<OrderedEventRecord> &eventRecordPtr, int index);
|
||||
bool NotifyOrderedEvent(std::shared_ptr<OrderedEventRecord> &eventRecordPtr, size_t index);
|
||||
|
||||
void SetTime(int recIdx, std::shared_ptr<OrderedEventRecord> &sp, bool timeoutMessage);
|
||||
void SetTime(size_t recIdx, std::shared_ptr<OrderedEventRecord> &sp, bool timeoutMessage);
|
||||
|
||||
bool SetTimeout(int64_t timeoutTime);
|
||||
|
||||
bool CancelTimeout();
|
||||
|
||||
bool FinishReceiver(std::shared_ptr<OrderedEventRecord> recordPtr, const int &code, const std::string &receiverData,
|
||||
const bool &abortEvent);
|
||||
bool FinishReceiver(std::shared_ptr<OrderedEventRecord> recordPtr, const int32_t &code,
|
||||
const std::string &receiverData, const bool &abortEvent);
|
||||
|
||||
int CheckPermission(const EventSubscriberRecord &subscriberRecord, const CommonEventRecord &eventRecord);
|
||||
int8_t CheckPermission(const EventSubscriberRecord &subscriberRecord, const CommonEventRecord &eventRecord);
|
||||
|
||||
bool CheckSubscriberPermission(const EventSubscriberRecord &subscriberRecord, const CommonEventRecord &eventRecord);
|
||||
|
||||
@@ -182,7 +182,7 @@ private:
|
||||
std::mutex orderedMutex_;
|
||||
std::mutex unorderedMutex_;
|
||||
std::mutex historyMutex_;
|
||||
const unsigned int HISTORY_MAX_SIZE = 100;
|
||||
const size_t HISTORY_MAX_SIZE = 100;
|
||||
};
|
||||
} // namespace EventFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
* @param abortEvent Indicates Whether to cancel the current common event.
|
||||
* @return Returns true if successful; false otherwise.
|
||||
*/
|
||||
virtual bool FinishReceiver(const sptr<IRemoteObject> &proxy, const int &code, const std::string &receiverData,
|
||||
virtual bool FinishReceiver(const sptr<IRemoteObject> &proxy, const int32_t &code, const std::string &receiverData,
|
||||
const bool &abortEvent) override;
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,7 @@ struct HistoryEventRecord {
|
||||
};
|
||||
|
||||
Want want;
|
||||
int code;
|
||||
int32_t code;
|
||||
std::string data;
|
||||
|
||||
bool sticky;
|
||||
@@ -68,7 +68,7 @@ struct HistoryEventRecord {
|
||||
std::vector<int> deliveryState;
|
||||
int64_t dispatchTime;
|
||||
int64_t receiverTime;
|
||||
int state;
|
||||
int8_t state;
|
||||
bool resultAbort;
|
||||
|
||||
HistoryEventRecord()
|
||||
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
* @return Returns true if successful; false otherwise.
|
||||
*/
|
||||
void FinishReceiver(
|
||||
const sptr<IRemoteObject> &proxy, const int &code, const std::string &receiverData, const bool &abortEvent);
|
||||
const sptr<IRemoteObject> &proxy, const int32_t &code, const std::string &receiverData, const bool &abortEvent);
|
||||
|
||||
/**
|
||||
* Freezes application.
|
||||
|
||||
@@ -39,12 +39,12 @@ struct OrderedEventRecord : public CommonEventRecord {
|
||||
sptr<IRemoteObject> resultTo;
|
||||
sptr<IRemoteObject> curReceiver;
|
||||
std::vector<int> deliveryState;
|
||||
int enqueueClockTime;
|
||||
int32_t enqueueClockTime;
|
||||
int64_t dispatchTime;
|
||||
int64_t receiverTime;
|
||||
int64_t finishTime;
|
||||
int nextReceiver;
|
||||
int state;
|
||||
size_t nextReceiver;
|
||||
int8_t state;
|
||||
bool resultAbort;
|
||||
|
||||
OrderedEventRecord()
|
||||
|
||||
@@ -35,7 +35,7 @@ BundleManagerHelper::BundleManagerHelper() : sptrBundleMgr_(nullptr), bmsDeath_(
|
||||
BundleManagerHelper::~BundleManagerHelper()
|
||||
{}
|
||||
|
||||
std::string BundleManagerHelper::GetBundleName(int uid)
|
||||
std::string BundleManagerHelper::GetBundleName(uid_t uid)
|
||||
{
|
||||
EVENT_LOGI("enter");
|
||||
|
||||
|
||||
@@ -27,8 +27,9 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace EventFwk {
|
||||
constexpr int LENGTH = 80;
|
||||
constexpr int DOUBLE = 2;
|
||||
constexpr int32_t LENGTH = 80;
|
||||
constexpr int32_t DOUBLE = 2;
|
||||
constexpr unsigned int TIMEVAL = 5000;
|
||||
const std::string CONNECTOR = " or ";
|
||||
using frozenRecords = std::map<std::shared_ptr<EventSubscriberRecord>, std::vector<std::shared_ptr<CommonEventRecord>>>;
|
||||
|
||||
@@ -107,7 +108,7 @@ bool CommonEventControlManager::NotifyFreezeEvents(
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = CheckPermission(subscriberRecord, eventRecord);
|
||||
int8_t ret = CheckPermission(subscriberRecord, eventRecord);
|
||||
if (ret != OrderedEventRecord::DELIVERED) {
|
||||
EVENT_LOGE("check permission is failed");
|
||||
return false;
|
||||
@@ -134,8 +135,7 @@ bool CommonEventControlManager::GetUnorderedEventHandler()
|
||||
}
|
||||
if (handler_->GetEventRunner() != nullptr) {
|
||||
std::string threadName = handler_->GetEventRunner()->GetRunnerThreadName();
|
||||
static unsigned int timeval = 5000;
|
||||
if (HiviewDFX::Watchdog::GetInstance().AddThread(threadName, handler_, timeval) != 0) {
|
||||
if (HiviewDFX::Watchdog::GetInstance().AddThread(threadName, handler_, TIMEVAL) != 0) {
|
||||
EVENT_LOGE("Failed to Add handler Thread");
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ bool CommonEventControlManager::NotifyUnorderedEvent(std::shared_ptr<OrderedEven
|
||||
EVENT_LOGI("event = %{public}s, receivers size = %{public}zu",
|
||||
eventRecord->commonEventData->GetWant().GetAction().c_str(), eventRecord->receivers.size());
|
||||
for (auto vec : eventRecord->receivers) {
|
||||
int index = eventRecord->nextReceiver++;
|
||||
size_t index = eventRecord->nextReceiver++;
|
||||
eventRecord->curReceiver = vec->commonEventListener;
|
||||
if (vec->isFreeze) {
|
||||
eventRecord->deliveryState[index] = OrderedEventRecord::SKIPPED;
|
||||
@@ -165,7 +165,7 @@ bool CommonEventControlManager::NotifyUnorderedEvent(std::shared_ptr<OrderedEven
|
||||
EVENT_LOGE("Failed to get IEventReceive proxy");
|
||||
continue;
|
||||
}
|
||||
int ret = CheckPermission(*vec, *eventRecord);
|
||||
int8_t ret = CheckPermission(*vec, *eventRecord);
|
||||
eventRecord->deliveryState[index] = ret;
|
||||
if (ret == OrderedEventRecord::DELIVERED) {
|
||||
eventRecord->state = OrderedEventRecord::RECEIVEING;
|
||||
@@ -258,8 +258,7 @@ bool CommonEventControlManager::GetOrderedEventHandler()
|
||||
}
|
||||
if (handlerOrdered_->GetEventRunner() != nullptr) {
|
||||
std::string threadName = handlerOrdered_->GetEventRunner()->GetRunnerThreadName();
|
||||
static unsigned int timeval = 5000;
|
||||
if (HiviewDFX::Watchdog::GetInstance().AddThread(threadName, handlerOrdered_, timeval) != 0) {
|
||||
if (HiviewDFX::Watchdog::GetInstance().AddThread(threadName, handlerOrdered_, TIMEVAL) != 0) {
|
||||
EVENT_LOGE("Failed to Add Ordered Thread");
|
||||
}
|
||||
}
|
||||
@@ -397,22 +396,22 @@ bool CommonEventControlManager::ScheduleOrderedCommonEvent()
|
||||
return handlerOrdered_->SendEvent(InnerEvent::Get(OrderedEventHandler::ORDERED_EVENT_START));
|
||||
}
|
||||
|
||||
bool CommonEventControlManager::NotifyOrderedEvent(std::shared_ptr<OrderedEventRecord> &eventRecordPtr, int index)
|
||||
bool CommonEventControlManager::NotifyOrderedEvent(std::shared_ptr<OrderedEventRecord> &eventRecordPtr, size_t index)
|
||||
{
|
||||
EVENT_LOGI("enter with index %{public}d", index);
|
||||
EVENT_LOGI("enter with index %{public}zu", index);
|
||||
|
||||
if (eventRecordPtr == nullptr) {
|
||||
EVENT_LOGE("eventRecordPtr = nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
int receiverNum = static_cast<int>(eventRecordPtr->receivers.size());
|
||||
size_t receiverNum = eventRecordPtr->receivers.size();
|
||||
if ((index < 0) || (index >= receiverNum)) {
|
||||
EVENT_LOGE("Invalid index (= %{public}d)", index);
|
||||
EVENT_LOGE("Invalid index (= %{public}zu)", index);
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = CheckPermission(*(eventRecordPtr->receivers[index]), *eventRecordPtr);
|
||||
int8_t ret = CheckPermission(*(eventRecordPtr->receivers[index]), *eventRecordPtr);
|
||||
if (ret == OrderedEventRecord::SKIPPED) {
|
||||
eventRecordPtr->deliveryState[index] = ret;
|
||||
} else if (ret == OrderedEventRecord::DELIVERED) {
|
||||
@@ -466,7 +465,7 @@ void CommonEventControlManager::ProcessNextOrderedEvent(bool isSendMsg)
|
||||
|
||||
sp = orderedEventQueue_.front();
|
||||
bool forceReceive = false;
|
||||
int numReceivers = static_cast<int>(sp->receivers.size());
|
||||
size_t numReceivers = sp->receivers.size();
|
||||
int64_t nowSysTime = SystemTime::GetNowSysTime();
|
||||
|
||||
if (sp->dispatchTime > 0) {
|
||||
@@ -505,7 +504,7 @@ void CommonEventControlManager::ProcessNextOrderedEvent(bool isSendMsg)
|
||||
}
|
||||
} while (sp == nullptr);
|
||||
|
||||
int recIdx = sp->nextReceiver++;
|
||||
size_t recIdx = sp->nextReceiver++;
|
||||
SetTime(recIdx, sp, pendingTimeoutMessage_);
|
||||
|
||||
NotifyOrderedEvent(sp, recIdx);
|
||||
@@ -517,7 +516,7 @@ void CommonEventControlManager::ProcessNextOrderedEvent(bool isSendMsg)
|
||||
return;
|
||||
}
|
||||
|
||||
void CommonEventControlManager::SetTime(int recIdx, std::shared_ptr<OrderedEventRecord> &sp, bool timeoutMessage)
|
||||
void CommonEventControlManager::SetTime(size_t recIdx, std::shared_ptr<OrderedEventRecord> &sp, bool timeoutMessage)
|
||||
{
|
||||
EVENT_LOGI("enter");
|
||||
|
||||
@@ -599,7 +598,7 @@ void CommonEventControlManager::CurrentOrderedEventTimeout(bool isFromMsg)
|
||||
}
|
||||
|
||||
// Forced to finish the current receiver to process the next receiver
|
||||
int code = sp->commonEventData->GetCode();
|
||||
int32_t code = sp->commonEventData->GetCode();
|
||||
const std::string &strRef = sp->commonEventData->GetData();
|
||||
bool abort = sp->resultAbort;
|
||||
FinishReceiver(sp, code, strRef, abort);
|
||||
@@ -609,7 +608,7 @@ void CommonEventControlManager::CurrentOrderedEventTimeout(bool isFromMsg)
|
||||
return;
|
||||
}
|
||||
|
||||
bool CommonEventControlManager::FinishReceiver(std::shared_ptr<OrderedEventRecord> recordPtr, const int &code,
|
||||
bool CommonEventControlManager::FinishReceiver(std::shared_ptr<OrderedEventRecord> recordPtr, const int32_t &code,
|
||||
const std::string &receiverData, const bool &abortEvent)
|
||||
{
|
||||
EVENT_LOGI("enter");
|
||||
@@ -621,7 +620,7 @@ bool CommonEventControlManager::FinishReceiver(std::shared_ptr<OrderedEventRecor
|
||||
|
||||
EVENT_LOGI("enter recordPtr->state=%{public}d", recordPtr->state);
|
||||
|
||||
int state = recordPtr->state;
|
||||
int8_t state = recordPtr->state;
|
||||
recordPtr->state = OrderedEventRecord::IDLE;
|
||||
recordPtr->curReceiver = nullptr;
|
||||
recordPtr->commonEventData->SetCode(code);
|
||||
@@ -631,7 +630,7 @@ bool CommonEventControlManager::FinishReceiver(std::shared_ptr<OrderedEventRecor
|
||||
return state == OrderedEventRecord::RECEIVED;
|
||||
}
|
||||
|
||||
bool CommonEventControlManager::FinishReceiverAction(std::shared_ptr<OrderedEventRecord> recordPtr, const int &code,
|
||||
bool CommonEventControlManager::FinishReceiverAction(std::shared_ptr<OrderedEventRecord> recordPtr, const int32_t &code,
|
||||
const std::string &receiverData, const bool &abortEvent)
|
||||
{
|
||||
EVENT_LOGI("enter");
|
||||
@@ -650,7 +649,7 @@ bool CommonEventControlManager::FinishReceiverAction(std::shared_ptr<OrderedEven
|
||||
return true;
|
||||
}
|
||||
|
||||
int CommonEventControlManager::CheckPermission(
|
||||
int8_t CommonEventControlManager::CheckPermission(
|
||||
const EventSubscriberRecord &subscriberRecord, const CommonEventRecord &eventRecord)
|
||||
{
|
||||
EVENT_LOGI("enter");
|
||||
@@ -908,7 +907,7 @@ void CommonEventControlManager::DumpStateByCommonEventRecord(
|
||||
|
||||
std::string permission = "\tRequiredPermission: ";
|
||||
std::string separator;
|
||||
int permissionNum = 0;
|
||||
size_t permissionNum = 0;
|
||||
for (auto permissionVec : record->publishInfo->GetSubscriberPermissions()) {
|
||||
if (permissionNum == 0) {
|
||||
separator = "";
|
||||
@@ -941,7 +940,7 @@ void CommonEventControlManager::DumpStateByCommonEventRecord(
|
||||
std::string action = "\t\tAction: " + record->commonEventData->GetWant().GetAction() + "\n";
|
||||
|
||||
std::string entities = "\t\tEntity: ";
|
||||
int entityNum = 0;
|
||||
size_t entityNum = 0;
|
||||
for (auto entitiesVec : record->commonEventData->GetWant().GetEntities()) {
|
||||
if (entityNum == 0) {
|
||||
separator = "";
|
||||
@@ -1022,7 +1021,7 @@ void CommonEventControlManager::DumpHistoryStateByCommonEventRecord(
|
||||
|
||||
std::string permission = "\tRequiredPermission: ";
|
||||
std::string separator;
|
||||
int permissionNum = 0;
|
||||
size_t permissionNum = 0;
|
||||
for (auto permissionVec : record.subscriberPermissions) {
|
||||
if (permissionNum == 0) {
|
||||
separator = "";
|
||||
@@ -1055,7 +1054,7 @@ void CommonEventControlManager::DumpHistoryStateByCommonEventRecord(
|
||||
std::string action = "\t\tAction: " + record.want.GetAction() + "\n";
|
||||
|
||||
std::string entities = "\t\tEntity: ";
|
||||
int entityNum = 0;
|
||||
size_t entityNum = 0;
|
||||
for (auto entitiesVec : record.want.GetEntities()) {
|
||||
if (entityNum == 0) {
|
||||
separator = "";
|
||||
@@ -1118,7 +1117,7 @@ void CommonEventControlManager::DumpStateBySubscriberRecord(
|
||||
return;
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
size_t num = 0;
|
||||
for (auto receiver : record->receivers) {
|
||||
num++;
|
||||
|
||||
@@ -1163,7 +1162,7 @@ void CommonEventControlManager::DumpHistoryStateBySubscriberRecord(
|
||||
return;
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
size_t num = 0;
|
||||
for (auto receiver : record.receivers) {
|
||||
num++;
|
||||
|
||||
@@ -1248,7 +1247,7 @@ void CommonEventControlManager::DumpState(
|
||||
return;
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
size_t num = 0;
|
||||
for (auto record : records) {
|
||||
num++;
|
||||
|
||||
@@ -1281,7 +1280,7 @@ void CommonEventControlManager::DumpHistoryState(
|
||||
return;
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
size_t num = 0;
|
||||
for (auto record : records) {
|
||||
num++;
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ bool CommonEventManagerService::DumpState(const std::string &event, const int32_
|
||||
}
|
||||
|
||||
bool CommonEventManagerService::FinishReceiver(
|
||||
const sptr<IRemoteObject> &proxy, const int &code, const std::string &receiverData, const bool &abortEvent)
|
||||
const sptr<IRemoteObject> &proxy, const int32_t &code, const std::string &receiverData, const bool &abortEvent)
|
||||
{
|
||||
EVENT_LOGI("enter");
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace EventFwk {
|
||||
const int REVERSE = 3;
|
||||
constexpr size_t REVERSE = 3;
|
||||
|
||||
static const std::unordered_map<std::string, std::pair<PermissionState, std::vector<std::string>>> COMMON_EVENT_MAP {
|
||||
{CommonEventSupport::COMMON_EVENT_BOOT_COMPLETED,
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace EventFwk {
|
||||
constexpr int LENGTH = 80;
|
||||
constexpr int32_t LENGTH = 80;
|
||||
|
||||
int CommonEventStickyManager::FindStickyEvents(
|
||||
const SubscribeInfoPtr &subscribeInfo, std::vector<CommonEventRecordPtr> &commonEventRecords)
|
||||
@@ -85,7 +85,7 @@ void CommonEventStickyManager::DumpState(
|
||||
return;
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
size_t num = 0;
|
||||
for (auto record : records) {
|
||||
num++;
|
||||
|
||||
@@ -106,7 +106,7 @@ void CommonEventStickyManager::DumpState(
|
||||
|
||||
std::string permission = "\tRequiredPermission: ";
|
||||
std::string separator;
|
||||
int permissionNum = 0;
|
||||
size_t permissionNum = 0;
|
||||
for (auto permissionVec : record->publishInfo->GetSubscriberPermissions()) {
|
||||
if (permissionNum == 0) {
|
||||
separator = "";
|
||||
@@ -137,7 +137,7 @@ void CommonEventStickyManager::DumpState(
|
||||
std::string action = "\t\tAction: " + record->commonEventData->GetWant().GetAction() + "\n";
|
||||
|
||||
std::string entities = "\t\tEntity: ";
|
||||
int entityNum = 0;
|
||||
size_t entityNum = 0;
|
||||
for (auto entitiesVec : record->commonEventData->GetWant().GetEntities()) {
|
||||
if (entityNum == 0) {
|
||||
separator = "";
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace EventFwk {
|
||||
const int LENGTH = 80;
|
||||
constexpr int32_t LENGTH = 80;
|
||||
|
||||
CommonEventSubscriberManager::CommonEventSubscriberManager()
|
||||
: death_(sptr<IRemoteObject::DeathRecipient>(new SubscriberDeathRecipient()))
|
||||
@@ -106,6 +106,10 @@ std::vector<std::shared_ptr<EventSubscriberRecord>> CommonEventSubscriberManager
|
||||
void CommonEventSubscriberManager::DumpDetailed(
|
||||
const std::string &title, const SubscriberRecordPtr &record, const std::string format, std::string &dumpInfo)
|
||||
{
|
||||
if (record == nullptr || record->eventSubscribeInfo == nullptr) {
|
||||
EVENT_LOGE("record or eventSubscribeInfo is null");
|
||||
return;
|
||||
}
|
||||
char systime[LENGTH];
|
||||
strftime(systime, sizeof(char) * LENGTH, "%Y%m%d %I:%M %p", &record->recordTime);
|
||||
|
||||
@@ -132,7 +136,8 @@ void CommonEventSubscriberManager::DumpDetailed(
|
||||
|
||||
std::string events = format + "\tEvent: ";
|
||||
std::string separator;
|
||||
for (int eventNum = 0; eventNum < record->eventSubscribeInfo->GetMatchingSkills().CountEvent(); ++eventNum) {
|
||||
size_t countSize = record->eventSubscribeInfo->GetMatchingSkills().CountEvent();
|
||||
for (auto eventNum = 0; eventNum < countSize; ++eventNum) {
|
||||
if (eventNum == 0) {
|
||||
separator = "";
|
||||
} else {
|
||||
@@ -143,7 +148,8 @@ void CommonEventSubscriberManager::DumpDetailed(
|
||||
events = events + "\n";
|
||||
|
||||
std::string entities = format + "\tEntity: ";
|
||||
for (int entityNum = 0; entityNum < record->eventSubscribeInfo->GetMatchingSkills().CountEntities(); ++entityNum) {
|
||||
size_t entitySize = record->eventSubscribeInfo->GetMatchingSkills().CountEntities();
|
||||
for (size_t entityNum = 0; entityNum < entitySize; ++entityNum) {
|
||||
if (entityNum == 0) {
|
||||
separator = "";
|
||||
} else {
|
||||
@@ -154,7 +160,8 @@ void CommonEventSubscriberManager::DumpDetailed(
|
||||
entities = entities + "\n";
|
||||
|
||||
std::string scheme = format + "\tScheme: ";
|
||||
for (int schemeNum = 0; schemeNum < record->eventSubscribeInfo->GetMatchingSkills().CountSchemes(); ++schemeNum) {
|
||||
size_t schemeSize = record->eventSubscribeInfo->GetMatchingSkills().CountSchemes();
|
||||
for (size_t schemeNum = 0; schemeNum < schemeSize; ++schemeNum) {
|
||||
if (schemeNum == 0) {
|
||||
separator = "";
|
||||
} else {
|
||||
@@ -195,7 +202,7 @@ void CommonEventSubscriberManager::DumpState(const std::string &event, const int
|
||||
return;
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
size_t num = 0;
|
||||
for (auto record : records) {
|
||||
num++;
|
||||
std::string title = std::to_string(num);
|
||||
|
||||
@@ -179,7 +179,7 @@ bool InnerCommonEventManager::UnsubscribeCommonEvent(const sptr<IRemoteObject> &
|
||||
std::shared_ptr<OrderedEventRecord> sp = controlPtr_->GetMatchingOrderedReceiver(commonEventListener);
|
||||
if (sp) {
|
||||
EVENT_LOGI("Unsubscribe the subscriber who is waiting to receive finish feedback");
|
||||
int code = sp->commonEventData->GetCode();
|
||||
int32_t code = sp->commonEventData->GetCode();
|
||||
std::string data = sp->commonEventData->GetData();
|
||||
controlPtr_->FinishReceiverAction(sp, code, data, sp->resultAbort);
|
||||
}
|
||||
@@ -216,7 +216,7 @@ void InnerCommonEventManager::DumpState(const std::string &event, const int32_t
|
||||
}
|
||||
|
||||
void InnerCommonEventManager::FinishReceiver(
|
||||
const sptr<IRemoteObject> &proxy, const int &code, const std::string &receiverData, const bool &abortEvent)
|
||||
const sptr<IRemoteObject> &proxy, const int32_t &code, const std::string &receiverData, const bool &abortEvent)
|
||||
{
|
||||
EVENT_LOGI("enter");
|
||||
|
||||
|
||||
+4
-4
@@ -53,10 +53,10 @@ std::mutex g_mtx;
|
||||
std::mutex g_mtxAnother;
|
||||
const time_t TIME_OUT_SECONDS_LIMIT = 5;
|
||||
const time_t TIME_OUT_SECONDS_MIDDLE = 15;
|
||||
const int INITCODE = 0;
|
||||
const int CHANGECODE = 1;
|
||||
const int LOWPRIORITY = 0;
|
||||
const int HIGHPRIORITY = 100;
|
||||
const int32_t INITCODE = 0;
|
||||
const int32_t CHANGECODE = 1;
|
||||
const int32_t LOWPRIORITY = 0;
|
||||
const int32_t HIGHPRIORITY = 100;
|
||||
} // namespace
|
||||
|
||||
class CesPublishOrderedEventModuleTest : public testing::Test {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
constexpr uint16_t SYSTEM_UID = 1000;
|
||||
constexpr int SYSTEM_UID = 1000;
|
||||
|
||||
void MockBundleMgrService::MockSetIsSystemApp(bool isSystemApp)
|
||||
{
|
||||
@@ -28,12 +28,12 @@ void MockBundleMgrService::MockSetIsSystemApp(bool isSystemApp)
|
||||
isSystemApp_ = isSystemApp;
|
||||
}
|
||||
|
||||
bool MockBundleMgrService::CheckIsSystemAppByUid(const int uid)
|
||||
bool MockBundleMgrService::CheckIsSystemAppByUid(const int32_t uid)
|
||||
{
|
||||
if (isSystemAppMock_) {
|
||||
return isSystemApp_;
|
||||
}
|
||||
return (uid > SYSTEM_UID) ? false : true;
|
||||
return uid <= SYSTEM_UID;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -28,7 +28,7 @@ void MockBundleMgrService::MockSetIsSystemApp(bool isSystemApp)
|
||||
isSystemApp_ = isSystemApp;
|
||||
}
|
||||
|
||||
bool MockBundleMgrService::CheckIsSystemAppByUid(const int uid)
|
||||
bool MockBundleMgrService::CheckIsSystemAppByUid(const int32_t uid)
|
||||
{
|
||||
if (isSystemAppMock_) {
|
||||
return isSystemApp_;
|
||||
|
||||
+4
-4
@@ -48,10 +48,10 @@ std::mutex g_mtx;
|
||||
std::mutex g_mtxAnother;
|
||||
const time_t TIME_OUT_SECONDS_LIMIT = 5;
|
||||
const time_t TIME_OUT_SECONDS_MIDDLE = 15;
|
||||
const int INITCODE = 0;
|
||||
const int CHANGECODE = 1;
|
||||
const int LOWPRIORITY = 0;
|
||||
const int HIGHPRIORITY = 100;
|
||||
const int32_t INITCODE = 0;
|
||||
const int32_t CHANGECODE = 1;
|
||||
const int32_t LOWPRIORITY = 0;
|
||||
const int32_t HIGHPRIORITY = 100;
|
||||
} // namespace
|
||||
|
||||
class CESPublishOrderedEventSystmTest : public testing::Test {
|
||||
|
||||
+2
-2
@@ -43,8 +43,8 @@ const time_t TIME_OUT_SECONDS_TWO = 2;
|
||||
const time_t TIME_OUT_SECONDS_ = 3;
|
||||
const time_t TIME_OUT_SECONDS_TEN = 10;
|
||||
const time_t TIME_OUT_SECONDS_TWENTY = 20;
|
||||
const unsigned int SUBSCRIBER_MAX_SIZE = 200;
|
||||
const unsigned int SUBSCRIBER_MAX_SIZE_PLUS = 201;
|
||||
const size_t SUBSCRIBER_MAX_SIZE = 200;
|
||||
const size_t SUBSCRIBER_MAX_SIZE_PLUS = 201;
|
||||
|
||||
const std::string CompareStr = "cesComparesStrForCase";
|
||||
const std::string CompareStrFalse = "cesComparesStrForCaseFalse";
|
||||
|
||||
@@ -61,8 +61,7 @@ public:
|
||||
*/
|
||||
CommonEventCommand(int argc, char *argv[]);
|
||||
|
||||
~CommonEventCommand() override
|
||||
{}
|
||||
~CommonEventCommand() override = default;
|
||||
|
||||
private:
|
||||
ErrCode CreateCommandMap() override;
|
||||
|
||||
@@ -27,8 +27,6 @@ namespace OHOS {
|
||||
namespace EventFwk {
|
||||
namespace {
|
||||
const std::string HELP_MSG_NO_OPTION = "error: you must specify an option at least.";
|
||||
|
||||
const int OFFSET_REQUIRED_ARGUMENT = 2;
|
||||
} // namespace
|
||||
|
||||
class ShellCommand {
|
||||
@@ -79,7 +77,7 @@ public:
|
||||
* @param code Indicates the code.
|
||||
* @return Returns the message from the code.
|
||||
*/
|
||||
std::string GetMessageFromCode(const int32_t code) const;
|
||||
std::string GetMessageFromCode(int32_t code) const;
|
||||
|
||||
/**
|
||||
* Creates the command map.
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include "shell_command.h"
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
#include <utility>
|
||||
#include "event_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -33,12 +35,11 @@ ShellCommand::ShellCommand(int argc, char *argv[], std::string name)
|
||||
}
|
||||
cmd_ = argv[1];
|
||||
for (int i = 2; i < argc; i++) {
|
||||
argList_.push_back(argv[i]);
|
||||
argList_.emplace_back(argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ShellCommand::~ShellCommand()
|
||||
{}
|
||||
ShellCommand::~ShellCommand() = default;
|
||||
|
||||
ErrCode ShellCommand::OnCommand()
|
||||
{
|
||||
@@ -103,7 +104,7 @@ std::string ShellCommand::GetUnknownOptionMsg(std::string &unknownOption) const
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string ShellCommand::GetMessageFromCode(const int32_t code) const
|
||||
std::string ShellCommand::GetMessageFromCode(int32_t code) const
|
||||
{
|
||||
EVENT_LOGI("[%{public}s(%{public}s)] enter", __FILE__, __FUNCTION__);
|
||||
EVENT_LOGI("code = %{public}d", code);
|
||||
@@ -111,7 +112,7 @@ std::string ShellCommand::GetMessageFromCode(const int32_t code) const
|
||||
std::string result = "";
|
||||
if (messageMap_.find(code) != messageMap_.end()) {
|
||||
std::string message = messageMap_.at(code);
|
||||
if (message.size() != 0) {
|
||||
if (!message.empty()) {
|
||||
result.append(message + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OHOS {
|
||||
namespace EventFwk {
|
||||
class MockCommonEventStub : public CommonEventStub {
|
||||
public:
|
||||
MOCK_METHOD4(FinishReceiver, bool(const sptr<IRemoteObject> &proxy, const int &code,
|
||||
MOCK_METHOD4(FinishReceiver, bool(const sptr<IRemoteObject> &proxy, const int32_t &code,
|
||||
const std::string &receiverData, const bool &abortEvent));
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ using namespace OHOS::EventFwk;
|
||||
namespace {
|
||||
const std::string STRING_EVENT = "com.ces.event";
|
||||
const std::string STRING_NO_SUBSCRIBERS = "Subscribers:\tNo information\n";
|
||||
const int TIME_DELAY_FOR_SERVICES = 2;
|
||||
const int32_t TIME_DELAY_FOR_SERVICES = 2;
|
||||
|
||||
std::string ExecuteCommand(const std::string &command)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ const std::string STRING_DATA_TWO = "data_two";
|
||||
const std::string STRING_DEVICE_ID_001 = "device_001";
|
||||
const std::string STRING_DEVICE_ID_002 = "device_002";
|
||||
const std::string STRING_DEVICE_ID_003 = "device_003";
|
||||
const int TIME_DELAY_FOR_SERVICES = 2;
|
||||
const int32_t TIME_DELAY_FOR_SERVICES = 2;
|
||||
const time_t TIME_OUT_SECONDS_LIMIT = 5;
|
||||
std::mutex mtx;
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
std::string deviceId = GetSubscribeInfo().GetDeviceId();
|
||||
GTEST_LOG_(INFO) << "deviceId = " << deviceId;
|
||||
|
||||
int code = commonEventData.GetCode();
|
||||
int32_t code = commonEventData.GetCode();
|
||||
GTEST_LOG_(INFO) << "code = " << code;
|
||||
|
||||
std::string data = commonEventData.GetData();
|
||||
|
||||
Reference in New Issue
Block a user