diff --git a/hisysevent.yaml b/hisysevent.yaml index 893a393f1..58313e0ba 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -257,4 +257,16 @@ BMS_DISK_SPACE: __BASE: {type: BEHAVIOR, level: MINOR, desc: description the disk space in insufficient when an applicaiton is begin installed ir uninstall} FILE_NAME: {type: STRING, desc: file name} FREE_SIZE: {type: INT64, desc: free size} - OPERATION_TYPE: {type: INT32, desc: operation type} \ No newline at end of file + OPERATION_TYPE: {type: INT32, desc: operation type} + +APP_CONTROL_RULE: + __BASE: {type: BEHAVIOR, level: MINOR, desc: app contitol rule} + PNAMEID: {type: STRING, desc: package name} + PVERSIONID: {type: STRING, desc: application version} + APP_IDS: {type: STRING, arrsize: 100, desc: appIds} + USERID: {type: INT32, desc: userId of the bundle} + CALLING_NAME: {type: STRING, desc: calling name} + OPERATION_TYPE: {type: INT32, desc: operation type} + ACTION_TYPE: {type: INT32, desc: action type} + RULE: {type: STRING, desc: rule} + APP_INDEX: {type: INT32, desc: app index} \ No newline at end of file diff --git a/services/bundlemgr/include/event_report.h b/services/bundlemgr/include/event_report.h index 66d4453c9..5680abc8f 100644 --- a/services/bundlemgr/include/event_report.h +++ b/services/bundlemgr/include/event_report.h @@ -49,7 +49,8 @@ enum class BMSEventType : uint8_t { AOT_COMPILE_RECORD, QUERY_OF_CONTINUE_TYPE, FREE_INSTALL_EVENT, - BMS_DISK_SPACE + BMS_DISK_SPACE, + APP_CONTROL_RULE }; enum class BundleEventType : uint8_t { @@ -146,6 +147,10 @@ struct EventInfo { std::string fileName; int64_t freeSize = 0; int32_t operationType = 0; + std::vector appIds; + std::string callingName; + int32_t actionType = 0; + std::string rule; void Reset() { @@ -187,6 +192,10 @@ struct EventInfo { fileName.clear(); freeSize = 0; operationType = 0; + appIds.clear(); + callingName.clear(); + actionType = 0; + rule.clear(); } }; @@ -285,6 +294,12 @@ public: */ static void SendDiskSpaceEvent(const std::string &fileName, int64_t freeSize, int32_t operationType); + + /** + * @brief Send info when add or remove app contitol rule. + * @param eventInfo report info. + */ + static void SendAppConitolRuleEvent(const EventInfo& eventInfo); }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/include/inner_event_report.h b/services/bundlemgr/include/inner_event_report.h index f2b439a28..d5a5c8043 100644 --- a/services/bundlemgr/include/inner_event_report.h +++ b/services/bundlemgr/include/inner_event_report.h @@ -59,6 +59,7 @@ private: static void InnerSendQueryOfContinueTypeEvent(const EventInfo& eventInfo); static void InnerSendFreeInstallEvent(const EventInfo& eventInfo); static void InnerSendBmsDiskSpaceEvent(const EventInfo& eventInfo); + static void InnerSendAppConitolRule(const EventInfo& eventInfo); template static void InnerEventWrite(const std::string &eventName, diff --git a/services/bundlemgr/src/app_control/app_control_manager_rdb.cpp b/services/bundlemgr/src/app_control/app_control_manager_rdb.cpp index 335f0d16d..93dd4202d 100644 --- a/services/bundlemgr/src/app_control/app_control_manager_rdb.cpp +++ b/services/bundlemgr/src/app_control/app_control_manager_rdb.cpp @@ -19,6 +19,7 @@ #include "app_log_tag_wrapper.h" #include "bms_extension_client.h" #include "bundle_util.h" +#include "event_report.h" #include "hitrace_meter.h" #include "scope_guard.h" @@ -49,6 +50,18 @@ namespace { EDM = 100, APP_MARKET = 200, }; + + enum class ACTION_TYPE_ENUM : int8_t { + ACTION_TYPE_OF_INSTALL = 1, + ACTION_TYPE_OF_RUNUING = 2, + ACTION_TYPE_DISPOSE_STATUS = 3, + ACTION_TYPE_DISPOSE_RULE = 4, + }; + + enum class OPERATION_TYPE_ENUM : int8_t { + OPERATION_TYPE_ADD_RULE = 1, + OPERATION_TYPE_REMOVE_RULE = 2, + }; } AppControlManagerRdb::AppControlManagerRdb() { @@ -98,6 +111,14 @@ ErrCode AppControlManagerRdb::AddAppInstallControlRule(const std::string &callin LOG_E(BMS_TAG_DEFAULT, "BatchInsert failed"); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.appIds = appIds; + info.rule = controlRuleType; + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_ADD_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_OF_INSTALL); + EventReport::SendAppConitolRuleEvent(info); if (valuesBuckets.size() != static_cast(insertNum)) { LOG_E(BMS_TAG_DEFAULT, "BatchInsert size not expected"); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; @@ -120,6 +141,14 @@ ErrCode AppControlManagerRdb::DeleteAppInstallControlRule(const std::string &cal callingName.c_str(), appId.c_str(), userId); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.appIds.push_back(appId); + info.rule = controlRuleType; + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_OF_INSTALL); + EventReport::SendAppConitolRuleEvent(info); } return ERR_OK; } @@ -137,6 +166,13 @@ ErrCode AppControlManagerRdb::DeleteAppInstallControlRule(const std::string &cal callingName.c_str(), controlRuleType.c_str()); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.rule = controlRuleType; + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_OF_INSTALL); + EventReport::SendAppConitolRuleEvent(info); return ERR_OK; } @@ -208,6 +244,16 @@ ErrCode AppControlManagerRdb::AddAppRunningControlRule(const std::string &callin LOG_E(BMS_TAG_DEFAULT, "BatchInsert AddAppRunningControlRule failed"); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + for (auto &controlRule : controlRules) { + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.rule = controlRule.controlMessage; + info.appIds.push_back(controlRule.appId); + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_ADD_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_OF_RUNUING); + EventReport::SendAppConitolRuleEvent(info); + } if (valuesBuckets.size() != static_cast(insertNum)) { LOG_E(BMS_TAG_DEFAULT, "BatchInsert size not expected"); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; @@ -230,6 +276,13 @@ ErrCode AppControlManagerRdb::DeleteAppRunningControlRule(const std::string &cal callingName.c_str(), rule.appId.c_str(), userId); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.appIds.push_back(rule.appId); + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_OF_RUNUING); + EventReport::SendAppConitolRuleEvent(info); } return ERR_OK; } @@ -245,6 +298,12 @@ ErrCode AppControlManagerRdb::DeleteAppRunningControlRule(const std::string &cal callingName.c_str(), userId); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_OF_RUNUING); + EventReport::SendAppConitolRuleEvent(info); return ERR_OK; } @@ -370,6 +429,14 @@ ErrCode AppControlManagerRdb::SetDisposedStatus(const std::string &callingName, callingName.c_str(), appId.c_str()); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.appIds.push_back(appId); + info.rule = want.ToString(); + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_ADD_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_DISPOSE_STATUS); + EventReport::SendAppConitolRuleEvent(info); return ERR_OK; } @@ -388,6 +455,13 @@ ErrCode AppControlManagerRdb::DeleteDisposedStatus(const std::string &callingNam callingName.c_str(), appId.c_str()); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.appIds.push_back(appId); + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_DISPOSE_STATUS); + EventReport::SendAppConitolRuleEvent(info); return ERR_OK; } @@ -445,6 +519,13 @@ ErrCode AppControlManagerRdb::DeleteOldControlRule(const std::string &callingNam callingName.c_str(), appId.c_str(), controlRuleType.c_str(), userId); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.appIds.push_back(appId); + info.rule = controlRuleType; + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE); + EventReport::SendAppConitolRuleEvent(info); return ERR_OK; } @@ -472,6 +553,15 @@ ErrCode AppControlManagerRdb::SetDisposedRule(const std::string &callingName, callingName.c_str(), appId.c_str()); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.appIds.push_back(appId); + info.rule = rule.ToString(); + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_ADD_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_DISPOSE_RULE); + info.appIndex = appIndex; + EventReport::SendAppConitolRuleEvent(info); return ERR_OK; } @@ -490,6 +580,14 @@ ErrCode AppControlManagerRdb::DeleteDisposedRule(const std::string &callingName, callingName.c_str(), appId.c_str()); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.callingName = callingName; + info.userId = userId; + info.appIds.push_back(appId); + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_DISPOSE_RULE); + info.appIndex = appIndex; + EventReport::SendAppConitolRuleEvent(info); return ERR_OK; } @@ -509,6 +607,13 @@ ErrCode AppControlManagerRdb::DeleteAllDisposedRuleByBundle(const std::string &a LOG_E(BMS_TAG_DEFAULT, "DeleteAllDisposedRuleByBundle appId:%{private}s failed", appId.c_str()); return ERR_BUNDLE_MANAGER_APP_CONTROL_INTERNAL_ERROR; } + EventInfo info; + info.userId = userId; + info.appIds.push_back(appId); + info.operationType = static_cast(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE); + info.actionType = static_cast(ACTION_TYPE_ENUM::ACTION_TYPE_DISPOSE_RULE); + info.appIndex = appIndex; + EventReport::SendAppConitolRuleEvent(info); return ERR_OK; } diff --git a/services/bundlemgr/src/event_report.cpp b/services/bundlemgr/src/event_report.cpp index afef2e766..9b0eb5bd7 100644 --- a/services/bundlemgr/src/event_report.cpp +++ b/services/bundlemgr/src/event_report.cpp @@ -193,6 +193,11 @@ void EventReport::SendDiskSpaceEvent(const std::string &fileName, EventReport::SendSystemEvent(BMSEventType::BMS_DISK_SPACE, eventInfo); } +void EventReport::SendAppConitolRuleEvent(const EventInfo& eventInfo) +{ + EventReport::SendSystemEvent(BMSEventType::APP_CONTROL_RULE, eventInfo); +} + void EventReport::SendSystemEvent(BMSEventType bmsEventType, const EventInfo& eventInfo) { #ifdef HISYSEVENT_ENABLE diff --git a/services/bundlemgr/src/inner_event_report.cpp b/services/bundlemgr/src/inner_event_report.cpp index c18ab5880..d9602b3c1 100644 --- a/services/bundlemgr/src/inner_event_report.cpp +++ b/services/bundlemgr/src/inner_event_report.cpp @@ -46,6 +46,7 @@ constexpr const char* AOT_COMPILE_SUMMARY = "AOT_COMPILE_SUMMARY"; constexpr const char* AOT_COMPILE_RECORD = "AOT_COMPILE_RECORD"; constexpr const char* QUERY_OF_CONTINUE_TYPE = "QUERY_OF_CONTINUE_TYPE"; constexpr const char* BMS_DISK_SPACE = "BMS_DISK_SPACE"; +constexpr const char* APP_CONTROL_RULE = "APP_CONTROL_RULE"; // event params const char* EVENT_PARAM_PNAMEID = "PNAMEID"; @@ -77,6 +78,12 @@ const char* EVENT_PARAM_SCENE_ID = "SCENE_ID"; const char* EVENT_PARAM_HAPPEN_TIME = "HAPPEN_TIME"; const char* EVENT_PARAM_MODULE_NAME = "MODULE_NAME"; const char* EVENT_PARAM_IS_FREE_INSTALL = "IS_FREE_INSTALL"; +const char* EVENT_PARAM_APP_IDS = "APP_IDS"; +const char* EVENT_PARAM_CALLING_NAME = "CALLING_NAME"; +const char* EVENT_PARAM_OPERATION_TYPE = "OPERATION_TYPE"; +const char* EVENT_PARAM_ACTION_TYPE = "ACTION_TYPE"; +const char* EVENT_PARAM_RULE = "ACTION_RULE"; +const char* EVENT_PARAM_APP_INDEX = "APP_INDEX"; const char* FREE_INSTALL_TYPE = "FreeInstall"; const char* PRE_BUNDLE_INSTALL_TYPE = "PreBundleInstall"; @@ -268,6 +275,10 @@ std::unordered_map { BMSEventType::BMS_DISK_SPACE, [](const EventInfo& eventInfo) { InnerSendBmsDiskSpaceEvent(eventInfo); + } }, + { BMSEventType::APP_CONTROL_RULE, + [](const EventInfo& eventInfo) { + InnerSendAppConitolRule(eventInfo); } } }; @@ -591,6 +602,22 @@ void InnerEventReport::InnerSendBmsDiskSpaceEvent(const EventInfo& eventInfo) OPERATION_TYPE, eventInfo.operationType); } +void InnerEventReport::InnerSendAppConitolRule(const EventInfo& eventInfo) +{ + InnerEventWrite( + APP_CONTROL_RULE, + HiSysEventType::BEHAVIOR, + EVENT_PARAM_PNAMEID, eventInfo.packageName, + EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion, + EVENT_PARAM_APP_IDS, eventInfo.appIds, + EVENT_PARAM_USERID, eventInfo.userId, + EVENT_PARAM_CALLING_NAME, eventInfo.callingName, + EVENT_PARAM_OPERATION_TYPE, eventInfo.operationType, + EVENT_PARAM_ACTION_TYPE, eventInfo.actionType, + EVENT_PARAM_RULE, eventInfo.rule, + EVENT_PARAM_APP_INDEX, eventInfo.appIndex); +} + template void InnerEventReport::InnerEventWrite( const std::string &eventName,