mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-22 23:00:31 +00:00
处置规则新增打点上报
Signed-off-by: jiangminsen <jiangminsen@huawei.com>
This commit is contained in:
parent
ba527abb07
commit
d939dd1f82
@ -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}
|
||||
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}
|
@ -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<std::string> 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
|
||||
|
@ -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<typename... Types>
|
||||
static void InnerEventWrite(const std::string &eventName,
|
||||
|
@ -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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_ADD_RULE);
|
||||
info.actionType = static_cast<int32_t>(ACTION_TYPE_ENUM::ACTION_TYPE_OF_INSTALL);
|
||||
EventReport::SendAppConitolRuleEvent(info);
|
||||
if (valuesBuckets.size() != static_cast<uint64_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE);
|
||||
info.actionType = static_cast<int32_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE);
|
||||
info.actionType = static_cast<int32_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_ADD_RULE);
|
||||
info.actionType = static_cast<int32_t>(ACTION_TYPE_ENUM::ACTION_TYPE_OF_RUNUING);
|
||||
EventReport::SendAppConitolRuleEvent(info);
|
||||
}
|
||||
if (valuesBuckets.size() != static_cast<uint64_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE);
|
||||
info.actionType = static_cast<int32_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE);
|
||||
info.actionType = static_cast<int32_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_ADD_RULE);
|
||||
info.actionType = static_cast<int32_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE);
|
||||
info.actionType = static_cast<int32_t>(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<int32_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_ADD_RULE);
|
||||
info.actionType = static_cast<int32_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE);
|
||||
info.actionType = static_cast<int32_t>(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<int32_t>(OPERATION_TYPE_ENUM::OPERATION_TYPE_REMOVE_RULE);
|
||||
info.actionType = static_cast<int32_t>(ACTION_TYPE_ENUM::ACTION_TYPE_DISPOSE_RULE);
|
||||
info.appIndex = appIndex;
|
||||
EventReport::SendAppConitolRuleEvent(info);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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, void (*)(const EventInfo& eventInfo)>
|
||||
{ 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<typename... Types>
|
||||
void InnerEventReport::InnerEventWrite(
|
||||
const std::string &eventName,
|
||||
|
Loading…
Reference in New Issue
Block a user