mirror of
https://gitee.com/openharmony/notification_common_event_service
synced 2024-11-23 16:10:07 +00:00
commit
c7a803d475
@ -72,7 +72,7 @@ public:
|
|||||||
EXPORT bool SubscribeCommonEvent(const CommonEventSubscribeInfo &subscribeInfo,
|
EXPORT bool SubscribeCommonEvent(const CommonEventSubscribeInfo &subscribeInfo,
|
||||||
const sptr<IRemoteObject> &commonEventListener, const struct tm &recordTime, const pid_t &pid, const uid_t &uid,
|
const sptr<IRemoteObject> &commonEventListener, const struct tm &recordTime, const pid_t &pid, const uid_t &uid,
|
||||||
const Security::AccessToken::AccessTokenID &callerToken, const std::string &bundleName,
|
const Security::AccessToken::AccessTokenID &callerToken, const std::string &bundleName,
|
||||||
const int32_t instanceKey = 0);
|
const int32_t instanceKey = 0, const int64_t startTime = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsubscribes from common events.
|
* Unsubscribes from common events.
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "system_ability_definition.h"
|
#include "system_ability_definition.h"
|
||||||
#include "xcollie/watchdog.h"
|
#include "xcollie/watchdog.h"
|
||||||
#include "ces_inner_error_code.h"
|
#include "ces_inner_error_code.h"
|
||||||
|
#include "system_time.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
@ -235,6 +236,7 @@ int32_t CommonEventManagerService::SubscribeCommonEvent(const CommonEventSubscri
|
|||||||
std::string bundleName = DelayedSingleton<BundleManagerHelper>::GetInstance()->GetBundleName(callingUid);
|
std::string bundleName = DelayedSingleton<BundleManagerHelper>::GetInstance()->GetBundleName(callingUid);
|
||||||
Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
|
Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
|
||||||
std::weak_ptr<InnerCommonEventManager> wp = innerCommonEventManager_;
|
std::weak_ptr<InnerCommonEventManager> wp = innerCommonEventManager_;
|
||||||
|
int64_t startTime = SystemTime::GetNowSysTime();
|
||||||
std::function<void()> subscribeCommonEventFunc = [wp,
|
std::function<void()> subscribeCommonEventFunc = [wp,
|
||||||
subscribeInfo,
|
subscribeInfo,
|
||||||
commonEventListener,
|
commonEventListener,
|
||||||
@ -243,7 +245,8 @@ int32_t CommonEventManagerService::SubscribeCommonEvent(const CommonEventSubscri
|
|||||||
callingUid,
|
callingUid,
|
||||||
callerToken,
|
callerToken,
|
||||||
bundleName,
|
bundleName,
|
||||||
instanceKey] () {
|
instanceKey,
|
||||||
|
startTime] () {
|
||||||
std::shared_ptr<InnerCommonEventManager> innerCommonEventManager = wp.lock();
|
std::shared_ptr<InnerCommonEventManager> innerCommonEventManager = wp.lock();
|
||||||
if (innerCommonEventManager == nullptr) {
|
if (innerCommonEventManager == nullptr) {
|
||||||
EVENT_LOGE("innerCommonEventManager not exist");
|
EVENT_LOGE("innerCommonEventManager not exist");
|
||||||
@ -256,7 +259,8 @@ int32_t CommonEventManagerService::SubscribeCommonEvent(const CommonEventSubscri
|
|||||||
callingUid,
|
callingUid,
|
||||||
callerToken,
|
callerToken,
|
||||||
bundleName,
|
bundleName,
|
||||||
instanceKey);
|
instanceKey,
|
||||||
|
startTime);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
EVENT_LOGE("failed to subscribe event");
|
EVENT_LOGE("failed to subscribe event");
|
||||||
}
|
}
|
||||||
|
@ -161,9 +161,10 @@ bool InnerCommonEventManager::PublishCommonEvent(const CommonEventData &data, co
|
|||||||
bool InnerCommonEventManager::SubscribeCommonEvent(const CommonEventSubscribeInfo &subscribeInfo,
|
bool InnerCommonEventManager::SubscribeCommonEvent(const CommonEventSubscribeInfo &subscribeInfo,
|
||||||
const sptr<IRemoteObject> &commonEventListener, const struct tm &recordTime,
|
const sptr<IRemoteObject> &commonEventListener, const struct tm &recordTime,
|
||||||
const pid_t &pid, const uid_t &uid, const Security::AccessToken::AccessTokenID &callerToken,
|
const pid_t &pid, const uid_t &uid, const Security::AccessToken::AccessTokenID &callerToken,
|
||||||
const std::string &bundleName, const int32_t instanceKey)
|
const std::string &bundleName, const int32_t instanceKey, const int64_t startTime)
|
||||||
{
|
{
|
||||||
HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__);
|
HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__);
|
||||||
|
int64_t taskStartTime = SystemTime::GetNowSysTime();
|
||||||
EVENT_LOGD("enter %{public}s(pid = %{public}d, uid = %{public}d, userId = %{public}d)",
|
EVENT_LOGD("enter %{public}s(pid = %{public}d, uid = %{public}d, userId = %{public}d)",
|
||||||
bundleName.c_str(), pid, uid, subscribeInfo.GetUserId());
|
bundleName.c_str(), pid, uid, subscribeInfo.GetUserId());
|
||||||
|
|
||||||
@ -203,8 +204,10 @@ bool InnerCommonEventManager::SubscribeCommonEvent(const CommonEventSubscribeInf
|
|||||||
subCount.fetch_add(1);
|
subCount.fetch_add(1);
|
||||||
eventRecordInfo.subId = subId;
|
eventRecordInfo.subId = subId;
|
||||||
EVENT_LOGI("SubscribeCommonEvent %{public}s(pid = %{public}d, uid = %{public}d, "
|
EVENT_LOGI("SubscribeCommonEvent %{public}s(pid = %{public}d, uid = %{public}d, "
|
||||||
"userId = %{public}d, instanceKey = %{public}d, subId = %{public}s)",
|
"userId = %{public}d, instanceKey = %{public}d, subId = %{public}s, "
|
||||||
bundleName.c_str(), pid, uid, subscribeInfo.GetUserId(), instanceKey, subId.c_str());
|
"ffrtCost = %{public}s, taskCost = %{public}s",
|
||||||
|
bundleName.c_str(), pid, uid, subscribeInfo.GetUserId(), instanceKey, subId.c_str(),
|
||||||
|
std::to_string(taskStartTime - startTime).c_str(), std::to_string(now - taskStartTime).c_str());
|
||||||
|
|
||||||
auto record = DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->InsertSubscriber(
|
auto record = DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->InsertSubscriber(
|
||||||
sp, commonEventListener, recordTime, eventRecordInfo);
|
sp, commonEventListener, recordTime, eventRecordInfo);
|
||||||
|
@ -349,6 +349,7 @@ bool CommonEventDumpTest::SubscribeCommonEvent(const std::shared_ptr<CommonEvent
|
|||||||
callingUid,
|
callingUid,
|
||||||
tokenID,
|
tokenID,
|
||||||
bundleName,
|
bundleName,
|
||||||
|
0,
|
||||||
0);
|
0);
|
||||||
return handler_->PostTask(SubscribeCommonEventFunc);
|
return handler_->PostTask(SubscribeCommonEventFunc);
|
||||||
}
|
}
|
||||||
|
@ -300,6 +300,7 @@ bool CommonEventFreezeTest::SubscribeCommonEvent(const std::shared_ptr<CommonEve
|
|||||||
callingUid,
|
callingUid,
|
||||||
tokenID,
|
tokenID,
|
||||||
bundleName,
|
bundleName,
|
||||||
|
0,
|
||||||
0);
|
0);
|
||||||
return handler_->PostTask(SubscribeCommonEventFunc);
|
return handler_->PostTask(SubscribeCommonEventFunc);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user