• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "inner_common_event_manager.h"
17 
18 #include "common_event_constant.h"
19 #include "common_event_record.h"
20 #include "common_event_sticky_manager.h"
21 #include "common_event_subscriber_manager.h"
22 #include "common_event_support.h"
23 #include "common_event_support_mapper.h"
24 #include "event_log_wrapper.h"
25 #include "event_report.h"
26 #include "hitrace_meter.h"
27 #include "ipc_skeleton.h"
28 #include "nlohmann/json.hpp"
29 #include "os_account_manager_helper.h"
30 #include "system_time.h"
31 #include "want.h"
32 
33 namespace OHOS {
34 namespace EventFwk {
35 static const int32_t PUBLISH_SYS_EVENT_INTERVAL = 10;  // 10s
36 
InnerCommonEventManager()37 InnerCommonEventManager::InnerCommonEventManager() : controlPtr_(std::make_shared<CommonEventControlManager>()),
38     staticSubscriberManager_(std::make_shared<StaticSubscriberManager>())
39 {}
40 
41 constexpr char HIDUMPER_HELP_MSG[] =
42     "Usage:dump <command> [options]\n"
43     "Description:\n"
44     "  -h, --help                   list available commands\n"
45     "  -a, --all                    dump the info of all events\n"
46     "  -e, --event <name>           dump the info of a specified event\n";
47 
48 const std::unordered_map<std::string, char> HIDUMPER_CMD_MAP = {
49     { "--help", 'h'},
50     { "--all", 'a'},
51     { "--event", 'e'},
52     { "-h", 'h' },
53     { "-a", 'a' },
54     { "-e", 'e' },
55 };
56 
57 const std::map<std::string, std::string> EVENT_COUNT_DISALLOW = {
58     { CommonEventSupport::COMMON_EVENT_TIME_TICK, "usual.event.TIME_TICK" },
59 };
60 
61 constexpr size_t HIDUMP_OPTION_MAX_SIZE = 2;
62 
PublishCommonEvent(const CommonEventData & data,const CommonEventPublishInfo & publishInfo,const sptr<IRemoteObject> & commonEventListener,const struct tm & recordTime,const pid_t & pid,const uid_t & uid,const Security::AccessToken::AccessTokenID & callerToken,const int32_t & userId,const std::string & bundleName,const sptr<IRemoteObject> & service)63 bool InnerCommonEventManager::PublishCommonEvent(const CommonEventData &data, const CommonEventPublishInfo &publishInfo,
64     const sptr<IRemoteObject> &commonEventListener, const struct tm &recordTime, const pid_t &pid, const uid_t &uid,
65     const Security::AccessToken::AccessTokenID &callerToken, const int32_t &userId, const std::string &bundleName,
66     const sptr<IRemoteObject> &service)
67 {
68     HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__);
69     EVENT_LOGI("enter %{public}s(pid = %{public}d, uid = %{public}d), event = %{public}s to userId = %{public}d",
70         bundleName.c_str(), pid, uid, data.GetWant().GetAction().c_str(), userId);
71 
72     if (data.GetWant().GetAction().empty()) {
73         EVENT_LOGE("the commonEventdata action is null");
74         return false;
75     }
76 
77     if ((!publishInfo.IsOrdered()) && (commonEventListener != nullptr)) {
78         EVENT_LOGE("When publishing unordered events, the subscriber object is not required.");
79         return false;
80     }
81 
82     std::string action = data.GetWant().GetAction();
83     bool isSystemEvent = DelayedSingleton<CommonEventSupport>::GetInstance()->IsSystemEvent(action);
84     int32_t user = userId;
85     bool isSubsystem = false;
86     bool isSystemApp = false;
87     bool isProxy = false;
88     if (!CheckUserId(pid, uid, callerToken, isSubsystem, isSystemApp, isProxy, user)) {
89         SendPublishHiSysEvent(user, bundleName, pid, uid, data.GetWant().GetAction(), false);
90         return false;
91     }
92 
93     if (isSystemEvent) {
94         EVENT_LOGI("System common event");
95         if (!isSystemApp && !isSubsystem) {
96             EVENT_LOGE(
97                 "No permission to send a system common event from %{public}s(pid = %{public}d, uid = %{public}d)"
98                 ", userId = %{public}d",
99                 bundleName.c_str(), pid, uid, userId);
100             SendPublishHiSysEvent(user, bundleName, pid, uid, data.GetWant().GetAction(), false);
101             return false;
102         }
103     }
104 
105     if (staticSubscriberManager_ != nullptr) {
106         staticSubscriberManager_->PublishCommonEvent(data, publishInfo, callerToken, user, service, bundleName);
107     }
108 
109     CommonEventRecord eventRecord;
110     eventRecord.commonEventData = std::make_shared<CommonEventData>(data);
111     eventRecord.publishInfo = std::make_shared<CommonEventPublishInfo>(publishInfo);
112     eventRecord.recordTime = recordTime;
113     eventRecord.eventRecordInfo.pid = pid;
114     eventRecord.eventRecordInfo.uid = uid;
115     eventRecord.eventRecordInfo.callerToken = callerToken;
116     eventRecord.userId = user;
117     eventRecord.eventRecordInfo.bundleName = bundleName;
118     eventRecord.eventRecordInfo.isSubsystem = isSubsystem;
119     eventRecord.eventRecordInfo.isSystemApp = isSystemApp;
120     eventRecord.eventRecordInfo.isProxy = isProxy;
121     eventRecord.isSystemEvent = isSystemEvent;
122 
123     if (publishInfo.IsSticky()) {
124         if (!ProcessStickyEvent(eventRecord)) {
125             SendPublishHiSysEvent(user, bundleName, pid, uid, data.GetWant().GetAction(), false);
126             return false;
127         }
128     }
129 
130     if (!controlPtr_) {
131         EVENT_LOGE("CommonEventControlManager ptr is nullptr");
132         SendPublishHiSysEvent(user, bundleName, pid, uid, data.GetWant().GetAction(), false);
133         return false;
134     }
135     controlPtr_->PublishCommonEvent(eventRecord, commonEventListener);
136 
137     std::string mappedSupport = "";
138     if (DelayedSingleton<CommonEventSupportMapper>::GetInstance()->GetMappedSupport(
139         eventRecord.commonEventData->GetWant().GetAction(), mappedSupport)) {
140         Want want = eventRecord.commonEventData->GetWant();
141         want.SetAction(mappedSupport);
142         CommonEventRecord mappedEventRecord = eventRecord;
143         mappedEventRecord.commonEventData->SetWant(want);
144         controlPtr_->PublishCommonEvent(mappedEventRecord, commonEventListener);
145     }
146 
147     if (time(nullptr) - sysEventTime >= PUBLISH_SYS_EVENT_INTERVAL &&
148         EVENT_COUNT_DISALLOW.find(data.GetWant().GetAction().c_str()) == EVENT_COUNT_DISALLOW.end()) {
149         SendPublishHiSysEvent(user, bundleName, pid, uid, data.GetWant().GetAction(), true);
150         sysEventTime = time(nullptr);
151     }
152 
153     return true;
154 }
155 
SubscribeCommonEvent(const CommonEventSubscribeInfo & subscribeInfo,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)156 bool InnerCommonEventManager::SubscribeCommonEvent(const CommonEventSubscribeInfo &subscribeInfo,
157     const sptr<IRemoteObject> &commonEventListener, const struct tm &recordTime, const pid_t &pid, const uid_t &uid,
158     const Security::AccessToken::AccessTokenID &callerToken, const std::string &bundleName)
159 {
160     HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__);
161     EVENT_LOGI("enter %{public}s(pid = %{public}d, uid = %{public}d, userId = %{public}d)",
162         bundleName.c_str(), pid, uid, subscribeInfo.GetUserId());
163 
164     if (subscribeInfo.GetMatchingSkills().CountEvent() == 0) {
165         EVENT_LOGE("the subscriber has no event");
166         return false;
167     }
168     if (commonEventListener == nullptr) {
169         EVENT_LOGE("InnerCommonEventManager::SubscribeCommonEvent:commonEventListener == nullptr");
170         return false;
171     }
172 
173     CommonEventSubscribeInfo subscribeInfo_(subscribeInfo);
174     int32_t userId = subscribeInfo_.GetUserId();
175     bool isSubsystem = false;
176     bool isSystemApp = false;
177     bool isProxy = false;
178     if (!CheckUserId(pid, uid, callerToken, isSubsystem, isSystemApp, isProxy, userId)) {
179         return false;
180     }
181     subscribeInfo_.SetUserId(userId);
182 
183     std::shared_ptr<CommonEventSubscribeInfo> sp = std::make_shared<CommonEventSubscribeInfo>(subscribeInfo_);
184 
185     // create EventRecordInfo here
186     EventRecordInfo eventRecordInfo;
187     eventRecordInfo.pid = pid;
188     eventRecordInfo.uid = uid;
189     eventRecordInfo.callerToken = callerToken;
190     eventRecordInfo.bundleName = bundleName;
191     eventRecordInfo.isSubsystem = isSubsystem;
192     eventRecordInfo.isSystemApp = isSystemApp;
193     eventRecordInfo.isProxy = isProxy;
194 
195     auto record = DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->InsertSubscriber(
196         sp, commonEventListener, recordTime, eventRecordInfo);
197 
198     PublishStickyEvent(sp, record);
199 
200     SendSubscribeHiSysEvent(userId, bundleName, pid, uid, subscribeInfo.GetMatchingSkills().GetEvents());
201     return true;
202 };
203 
UnsubscribeCommonEvent(const sptr<IRemoteObject> & commonEventListener)204 bool InnerCommonEventManager::UnsubscribeCommonEvent(const sptr<IRemoteObject> &commonEventListener)
205 {
206     HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__);
207     EVENT_LOGI("enter");
208 
209     if (commonEventListener == nullptr) {
210         EVENT_LOGE("commonEventListener == nullptr");
211         return false;
212     }
213 
214     if (!controlPtr_) {
215         EVENT_LOGE("CommonEventControlManager ptr is nullptr");
216         return false;
217     }
218 
219     std::shared_ptr<OrderedEventRecord> sp = controlPtr_->GetMatchingOrderedReceiver(commonEventListener);
220     if (sp) {
221         EVENT_LOGI("Unsubscribe the subscriber who is waiting to receive finish feedback");
222         int32_t code = sp->commonEventData->GetCode();
223         std::string data = sp->commonEventData->GetData();
224         controlPtr_->FinishReceiverAction(sp, code, data, sp->resultAbort);
225     }
226 
227     SendUnSubscribeHiSysEvent(commonEventListener);
228     DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->RemoveSubscriber(commonEventListener);
229 
230     return true;
231 }
232 
GetStickyCommonEvent(const std::string & event,CommonEventData & eventData)233 bool InnerCommonEventManager::GetStickyCommonEvent(const std::string &event, CommonEventData &eventData)
234 {
235     EVENT_LOGI("enter");
236 
237     return DelayedSingleton<CommonEventStickyManager>::GetInstance()->GetStickyCommonEvent(event, eventData);
238 }
239 
DumpState(const uint8_t & dumpType,const std::string & event,const int32_t & userId,std::vector<std::string> & state)240 void InnerCommonEventManager::DumpState(const uint8_t &dumpType, const std::string &event, const int32_t &userId,
241     std::vector<std::string> &state)
242 {
243     EVENT_LOGI("enter");
244 
245     switch (dumpType) {
246         case DumpEventType::SUBSCRIBER: {
247             DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->DumpState(event, userId, state);
248             break;
249         }
250         case DumpEventType::STICKY: {
251             DelayedSingleton<CommonEventStickyManager>::GetInstance()->DumpState(event, userId, state);
252             break;
253         }
254         case DumpEventType::PENDING: {
255             if (controlPtr_) {
256                 controlPtr_->DumpState(event, userId, state);
257             }
258             break;
259         }
260         case DumpEventType::HISTORY: {
261             if (controlPtr_) {
262                 controlPtr_->DumpHistoryState(event, userId, state);
263             }
264             break;
265         }
266         default: {
267             DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->DumpState(event, userId, state);
268             DelayedSingleton<CommonEventStickyManager>::GetInstance()->DumpState(event, userId, state);
269             if (controlPtr_) {
270                 controlPtr_->DumpState(event, userId, state);
271                 controlPtr_->DumpHistoryState(event, userId, state);
272             }
273             break;
274         }
275     }
276 
277     if (!controlPtr_) {
278         EVENT_LOGE("CommonEventControlManager ptr is nullptr");
279     }
280 }
281 
FinishReceiver(const sptr<IRemoteObject> & proxy,const int32_t & code,const std::string & receiverData,const bool & abortEvent)282 void InnerCommonEventManager::FinishReceiver(
283     const sptr<IRemoteObject> &proxy, const int32_t &code, const std::string &receiverData, const bool &abortEvent)
284 {
285     EVENT_LOGI("enter");
286 
287     if (!controlPtr_) {
288         EVENT_LOGE("CommonEventControlManager ptr is nullptr");
289         return;
290     }
291 
292     std::shared_ptr<OrderedEventRecord> sp = controlPtr_->GetMatchingOrderedReceiver(proxy);
293     if (sp) {
294         controlPtr_->FinishReceiverAction(sp, code, receiverData, abortEvent);
295     }
296 
297     return;
298 }
299 
Freeze(const uid_t & uid)300 void InnerCommonEventManager::Freeze(const uid_t &uid)
301 {
302     EVENT_LOGI("enter");
303     DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->UpdateFreezeInfo(
304         uid, true, SystemTime::GetNowSysTime());
305 }
306 
Unfreeze(const uid_t & uid)307 void InnerCommonEventManager::Unfreeze(const uid_t &uid)
308 {
309     EVENT_LOGI("enter");
310     DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->UpdateFreezeInfo(uid, false);
311     if (!controlPtr_) {
312         EVENT_LOGE("CommonEventControlManager ptr is nullptr");
313         return;
314     }
315     controlPtr_->PublishFreezeCommonEvent(uid);
316 }
317 
UnfreezeAll()318 void InnerCommonEventManager::UnfreezeAll()
319 {
320     EVENT_LOGI("enter");
321     DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->UpdateAllFreezeInfos(false);
322     if (!controlPtr_) {
323         EVENT_LOGE("CommonEventControlManager ptr is nullptr");
324         return;
325     }
326     controlPtr_->PublishAllFreezeCommonEvents();
327 }
328 
ProcessStickyEvent(const CommonEventRecord & record)329 bool InnerCommonEventManager::ProcessStickyEvent(const CommonEventRecord &record)
330 {
331     EVENT_LOGI("enter");
332     const std::string permission = "ohos.permission.COMMONEVENT_STICKY";
333     bool result = AccessTokenHelper::VerifyAccessToken(record.eventRecordInfo.callerToken, permission);
334     // Only subsystems and system apps with permissions can publish sticky common events
335     if ((result && record.eventRecordInfo.isSystemApp) ||
336         (!record.eventRecordInfo.isProxy && record.eventRecordInfo.isSubsystem)) {
337         DelayedSingleton<CommonEventStickyManager>::GetInstance()->UpdateStickyEvent(record);
338         return true;
339     } else {
340         EVENT_LOGE("No permission to send a sticky common event from %{public}s (pid = %{public}d, uid = %{public}d)",
341             record.eventRecordInfo.bundleName.c_str(), record.eventRecordInfo.pid, record.eventRecordInfo.uid);
342         return false;
343     }
344 }
345 
CheckUserId(const pid_t & pid,const uid_t & uid,const Security::AccessToken::AccessTokenID & callerToken,bool & isSubsystem,bool & isSystemApp,bool & isProxy,int32_t & userId)346 bool InnerCommonEventManager::CheckUserId(const pid_t &pid, const uid_t &uid,
347     const Security::AccessToken::AccessTokenID &callerToken, bool &isSubsystem, bool &isSystemApp, bool &isProxy,
348     int32_t &userId)
349 {
350     HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__);
351     EVENT_LOGI("enter");
352 
353     if (userId < UNDEFINED_USER) {
354         EVENT_LOGE("Invalid User ID %{public}d", userId);
355         return false;
356     }
357 
358     isSubsystem = AccessTokenHelper::VerifyNativeToken(callerToken);
359     if (!isSubsystem) {
360         isSystemApp = DelayedSingleton<BundleManagerHelper>::GetInstance()->CheckIsSystemAppByUid(uid);
361     }
362     isProxy = pid == UNDEFINED_PID;
363     if ((isSystemApp || isSubsystem) && !isProxy) {
364         if (userId == CURRENT_USER) {
365             DelayedSingleton<OsAccountManagerHelper>::GetInstance()->GetOsAccountLocalIdFromUid(uid, userId);
366         } else if (userId == UNDEFINED_USER) {
367             userId = ALL_USER;
368         }
369     } else {
370         if (userId == UNDEFINED_USER) {
371             DelayedSingleton<OsAccountManagerHelper>::GetInstance()->GetOsAccountLocalIdFromUid(uid, userId);
372         } else {
373             EVENT_LOGE("No permission to subscribe or send a common event to another user from uid = %{public}d", uid);
374             return false;
375         }
376     }
377 
378     return true;
379 }
380 
PublishStickyEvent(const std::shared_ptr<CommonEventSubscribeInfo> & sp,const std::shared_ptr<EventSubscriberRecord> & subscriberRecord)381 bool InnerCommonEventManager::PublishStickyEvent(
382     const std::shared_ptr<CommonEventSubscribeInfo> &sp, const std::shared_ptr<EventSubscriberRecord> &subscriberRecord)
383 {
384     HITRACE_METER_NAME(HITRACE_TAG_NOTIFICATION, __PRETTY_FUNCTION__);
385     EVENT_LOGI("enter");
386 
387     if (!sp) {
388         EVENT_LOGE("sp is null");
389         return false;
390     }
391 
392     if (!subscriberRecord) {
393         EVENT_LOGE("subscriberRecord is null");
394         return false;
395     }
396 
397     std::vector<std::shared_ptr<CommonEventRecord>> commonEventRecords;
398     if (DelayedSingleton<CommonEventStickyManager>::GetInstance()->FindStickyEvents(sp, commonEventRecords)) {
399         return false;
400     }
401 
402     for (auto commonEventRecord : commonEventRecords) {
403         if (!commonEventRecord) {
404             EVENT_LOGW("commonEventRecord is nullptr and get next");
405             continue;
406         }
407         EVENT_LOGI("publish sticky event : %{public}s",
408             commonEventRecord->commonEventData->GetWant().GetAction().c_str());
409 
410         if (!commonEventRecord->publishInfo->GetBundleName().empty() &&
411             commonEventRecord->publishInfo->GetBundleName() != subscriberRecord->eventRecordInfo.bundleName) {
412             EVENT_LOGW("commonEventRecord assigned to bundleName[%{public}s]",
413                 commonEventRecord->publishInfo->GetBundleName().c_str());
414             continue;
415         }
416 
417         commonEventRecord->publishInfo->SetOrdered(false);
418         if (!controlPtr_) {
419             EVENT_LOGE("CommonEventControlManager ptr is nullptr");
420             return false;
421         }
422         controlPtr_->PublishStickyCommonEvent(*commonEventRecord, subscriberRecord);
423     }
424 
425     return true;
426 }
427 
HiDump(const std::vector<std::u16string> & args,std::string & result)428 void InnerCommonEventManager::HiDump(const std::vector<std::u16string> &args, std::string &result)
429 {
430     if (args.size() == 0 || args.size() > HIDUMP_OPTION_MAX_SIZE) {
431         result = "error: unknown option.";
432         return;
433     }
434     std::string cmd = Str16ToStr8(args[0]);
435     if (HIDUMPER_CMD_MAP.find(cmd) == HIDUMPER_CMD_MAP.end()) {
436         result = "error: unknown option.";
437         return;
438     }
439     std::string event;
440     if (args.size() == HIDUMP_OPTION_MAX_SIZE) {
441         event = Str16ToStr8(args[1]);
442     }
443     char cmdValue = HIDUMPER_CMD_MAP.find(cmd)->second;
444     switch (cmdValue) {
445         case 'h' :
446             result = HIDUMPER_HELP_MSG;
447             return;
448         case 'a' :
449             event = "";
450             break;
451         case 'e' :
452             if (event.empty()) {
453                 result = "error: request a event value.";
454                 return;
455             }
456             break;
457         default:
458             break;
459     }
460     std::vector<std::string> records;
461     DumpState(DumpEventType::ALL, event, ALL_USER, records);
462     for (const auto &record : records) {
463         result.append(record).append("\n");
464     }
465 }
466 
SendSubscribeHiSysEvent(int32_t userId,const std::string & subscriberName,int32_t pid,int32_t uid,const std::vector<std::string> & events)467 void InnerCommonEventManager::SendSubscribeHiSysEvent(int32_t userId, const std::string &subscriberName, int32_t pid,
468     int32_t uid, const std::vector<std::string> &events)
469 {
470     EventInfo eventInfo;
471     eventInfo.userId = userId;
472     eventInfo.subscriberName = subscriberName;
473     eventInfo.pid = pid;
474     eventInfo.uid = uid;
475     eventInfo.eventName = std::accumulate(events.begin(), events.end(), std::string(""),
476         [events](std::string eventName, const std::string &str) {
477             return (str == events.front()) ? (eventName + str) : (eventName + "," + str);
478         });
479     EventReport::SendHiSysEvent(SUBSCRIBE, eventInfo);
480 }
481 
SendUnSubscribeHiSysEvent(const sptr<IRemoteObject> & commonEventListener)482 void InnerCommonEventManager::SendUnSubscribeHiSysEvent(const sptr<IRemoteObject> &commonEventListener)
483 {
484     auto subscriberRecord = DelayedSingleton<CommonEventSubscriberManager>::GetInstance()->GetSubscriberRecord(
485         commonEventListener);
486     if (subscriberRecord == nullptr) {
487         return;
488     }
489 
490     EventInfo eventInfo;
491     if (subscriberRecord->eventSubscribeInfo != nullptr) {
492         eventInfo.userId = subscriberRecord->eventSubscribeInfo->GetUserId();
493         std::vector<std::string> events = subscriberRecord->eventSubscribeInfo->GetMatchingSkills().GetEvents();
494         eventInfo.eventName = std::accumulate(events.begin(), events.end(), std::string(""),
495             [events](std::string eventName, const std::string &str) {
496                 return (str == events.front()) ? (eventName + str) : (eventName + "," + str);
497             });
498     }
499     eventInfo.subscriberName = subscriberRecord->eventRecordInfo.bundleName;
500     eventInfo.pid = subscriberRecord->eventRecordInfo.pid;
501     eventInfo.uid = static_cast<int32_t>(subscriberRecord->eventRecordInfo.uid);
502     EventReport::SendHiSysEvent(UNSUBSCRIBE, eventInfo);
503 }
504 
SendPublishHiSysEvent(int32_t userId,const std::string & publisherName,int32_t pid,int32_t uid,const std::string & event,bool succeed)505 void InnerCommonEventManager::SendPublishHiSysEvent(int32_t userId, const std::string &publisherName, int32_t pid,
506     int32_t uid, const std::string &event, bool succeed)
507 {
508     EventInfo eventInfo;
509     eventInfo.userId = userId;
510     eventInfo.publisherName = publisherName;
511     eventInfo.pid = pid;
512     eventInfo.uid = uid;
513     eventInfo.eventName = event;
514 
515     if (succeed) {
516         EventReport::SendHiSysEvent(PUBLISH, eventInfo);
517     } else {
518         EventReport::SendHiSysEvent(PUBLISH_ERROR, eventInfo);
519     }
520 }
521 }  // namespace EventFwk
522 }  // namespace OHOS
523