diff --git a/hisysevent.yaml b/hisysevent.yaml index 3a22ba600ed55f430939d65976697ab071908f45..5fdb732767b09ca45220cb808264614a6d8fca51 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -104,6 +104,7 @@ START_ABILITY_ERROR: MODULE_NAME: {type: STRING, desc: module name} ABILITY_NAME: {type: STRING, desc: ability name} ERROR_MESSAGE: {type: STRING, desc: start ability error message} + CALLER_BUNDLE_NAME: {type: STRING, desc: caller bundle name} TERMINATE_ABILITY_ERROR: __BASE: {type: FAULT, level: MINOR, tag: ability, desc: terminate ability error} diff --git a/services/abilitymgr/src/utils/update_caller_info_util.cpp b/services/abilitymgr/src/utils/update_caller_info_util.cpp index f503f4e82d81eb7fbf448d4f9220da842f2080c1..ff585d38c5dc4882b80ef02c5f7f416c71de7129 100644 --- a/services/abilitymgr/src/utils/update_caller_info_util.cpp +++ b/services/abilitymgr/src/utils/update_caller_info_util.cpp @@ -341,6 +341,13 @@ void UpdateCallerInfoUtil::ClearProtectedWantParam(Want &want) eventInfo.bundleName = want.GetElement().GetBundleName(); eventInfo.moduleName = want.GetElement().GetModuleName(); eventInfo.abilityName = want.GetElement().GetAbilityName(); + int32_t callerUid = IPCSkeleton::GetCallingUid(); + std::string callerBundleName; + auto bundleMgr = AbilityUtil::GetBundleManagerHelper(); + if (bundleMgr != nullptr) { + IN_PROCESS_CALL(bundleMgr->GetNameForUid(callerUid, callerBundleName)); + } + eventInfo.callerBundleName = callerBundleName.empty() ? std::to_string(callerUid) : callerBundleName; AbilityEventUtil eventUtil; eventUtil.SendStartAbilityErrorEvent(eventInfo, AAFwk::ERR_NOT_EXPECTED_NATIVE_CALLER_NAME, std::string("no expected caller native name: ") + want.GetStringParam(Want::PARAM_RESV_CALLER_NATIVE_NAME)); diff --git a/services/common/include/event_report.h b/services/common/include/event_report.h index 09135bb2e5fe14d70a57e81f7948ff2bb91f72e7..8df05a04a5561cb01c706ca8e031ee60a8da9c6a 100644 --- a/services/common/include/event_report.h +++ b/services/common/include/event_report.h @@ -164,6 +164,7 @@ public: private: static std::string ConvertEventName(const EventName &eventName); static void LogErrorEvent(const std::string &name, HiSysEventType type, const EventInfo &eventInfo); + static void LogStartErrorEvent(const std::string &name, HiSysEventType type, const EventInfo &eventInfo); static void LogStartAbilityEvent(const std::string &name, HiSysEventType type, const EventInfo &eventInfo); static void LogTerminateAbilityEvent(const std::string &name, HiSysEventType type, const EventInfo &eventInfo); static void LogAbilityOnForegroundEvent(const std::string &name, HiSysEventType type, const EventInfo &eventInfo); diff --git a/services/common/src/event_report.cpp b/services/common/src/event_report.cpp index 2ea04fd823e246ecc3a77f401aba197ae067971b..3c7d231483d65c99248ab504f439bad342129ae7 100644 --- a/services/common/src/event_report.cpp +++ b/services/common/src/event_report.cpp @@ -145,6 +145,22 @@ void EventReport::LogErrorEvent(const std::string &name, HiSysEventType type, co EVENT_KEY_ERROR_MESSAGE, eventInfo.errMsg); } +void EventReport::LogStartErrorEvent(const std::string &name, HiSysEventType type, const EventInfo &eventInfo) +{ + HiSysEventWrite( + HiSysEvent::Domain::AAFWK, + name, + type, + EVENT_KEY_USERID, eventInfo.userId, + EVENT_KEY_APP_INDEX, eventInfo.appIndex, + EVENT_KEY_BUNDLE_NAME, eventInfo.bundleName, + EVENT_KEY_MODULE_NAME, eventInfo.moduleName, + EVENT_KEY_ABILITY_NAME, eventInfo.abilityName, + EVENT_KEY_ERROR_CODE, eventInfo.errCode, + EVENT_KEY_ERROR_MESSAGE, eventInfo.errMsg, + EVENT_KEY_CALLER_BUNDLE_NAME, eventInfo.callerBundleName); +} + void EventReport::LogSystemErrorEvent(const std::string &name, HiSysEventType type, const EventInfo &eventInfo) { HiSysEventWrite( @@ -331,6 +347,8 @@ void EventReport::SendAbilityEvent(const EventName &eventName, HiSysEventType ty } switch (eventName) { case EventName::START_ABILITY_ERROR: + LogStartErrorEvent(name, type, eventInfo); + break; case EventName::TERMINATE_ABILITY_ERROR: LogErrorEvent(name, type, eventInfo); break;