1 /*
2 * Copyright (c) 2022-2025 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_event_report.h"
17
18 #include "hisysevent.h"
19
20 namespace OHOS {
21 namespace AppExecFwk {
22 namespace {
23 // event type
24 constexpr const char* BUNDLE_INSTALL_EXCEPTION = "BUNDLE_INSTALL_EXCEPTION";
25 constexpr const char* BUNDLE_UNINSTALL_EXCEPTION = "BUNDLE_UNINSTALL_EXCEPTION";
26 constexpr const char* BUNDLE_UPDATE_EXCEPTION = "BUNDLE_UPDATE_EXCEPTION";
27 constexpr const char* PRE_BUNDLE_RECOVER_EXCEPTION = "PRE_BUNDLE_RECOVER_EXCEPTION";
28 constexpr const char* BUNDLE_STATE_CHANGE_EXCEPTION = "BUNDLE_STATE_CHANGE_EXCEPTION";
29 constexpr const char* BUNDLE_CLEAN_CACHE_EXCEPTION = "BUNDLE_CLEAN_CACHE_EXCEPTION";
30
31 constexpr const char* BOOT_SCAN_START = "BOOT_SCAN_START";
32 constexpr const char* BOOT_SCAN_END = "BOOT_SCAN_END";
33 constexpr const char* BUNDLE_INSTALL = "BUNDLE_INSTALL";
34 constexpr const char* BUNDLE_UNINSTALL = "BUNDLE_UNINSTALL";
35 constexpr const char* BUNDLE_UPDATE = "BUNDLE_UPDATE";
36 constexpr const char* PRE_BUNDLE_RECOVER = "PRE_BUNDLE_RECOVER";
37 constexpr const char* BUNDLE_STATE_CHANGE = "BUNDLE_STATE_CHANGE";
38 constexpr const char* BUNDLE_CLEAN_CACHE = "BUNDLE_CLEAN_CACHE";
39 constexpr const char* BMS_USER_EVENT = "BMS_USER_EVENT";
40 constexpr const char* BUNDLE_QUICK_FIX = "BUNDLE_QUICK_FIX";
41 constexpr const char* CPU_SCENE_ENTRY = "CPU_SCENE_ENTRY";
42 constexpr const char* FREE_INSTALL_EVENT = "FREE_INSTALL_EVENT";
43 static constexpr char PERFORMANCE_DOMAIN[] = "PERFORMANCE";
44 static constexpr char BUNDLE_MANAGER[] = "BUNDLE_MANAGER";
45 constexpr const char* AOT_COMPILE_SUMMARY = "AOT_COMPILE_SUMMARY";
46 constexpr const char* AOT_COMPILE_RECORD = "AOT_COMPILE_RECORD";
47 constexpr const char* QUERY_OF_CONTINUE_TYPE = "QUERY_OF_CONTINUE_TYPE";
48 constexpr const char* BMS_DISK_SPACE = "BMS_DISK_SPACE";
49 constexpr const char* APP_CONTROL_RULE = "APP_CONTROL_RULE";
50 constexpr const char* DB_ERROR = "DB_ERROR";
51 constexpr const char* DEFAULT_APP = "DEFAULT_APP";
52 constexpr const char* QUERY_BUNDLE_INFO = "QUERY_BUNDLE_INFO";
53
54 // event params
55 const char* EVENT_PARAM_PNAMEID = "PNAMEID";
56 const char* EVENT_PARAM_PVERSIONID = "PVERSIONID";
57 const char* EVENT_PARAM_USERID = "USERID";
58 const char* EVENT_PARAM_UID = "UID";
59 const char* EVENT_PARAM_BUNDLE_NAME = "BUNDLE_NAME";
60 const char* EVENT_PARAM_ERROR_CODE = "ERROR_CODE";
61 const char* EVENT_PARAM_ABILITY_NAME = "ABILITY_NAME";
62 const char* EVENT_PARAM_TIME = "TIME";
63 const char* EVENT_PARAM_VERSION = "VERSION";
64 const char* EVENT_PARAM_SCENE = "SCENE";
65 const char* EVENT_PARAM_CLEAN_TYPE = "CLEAN_TYPE";
66 const char* EVENT_PARAM_INSTALL_TYPE = "INSTALL_TYPE";
67 const char* EVENT_PARAM_STATE = "STATE";
68 const char* EVENT_PARAM_CALLING_BUNDLE_NAME = "CALLING_BUNDLE_NAME";
69 const char* EVENT_PARAM_CALLING_UID = "CALLING_UID";
70 const char* EVENT_PARAM_CALLING_APPID = "CALLING_APPID";
71 const char* EVENT_PARAM_FINGERPRINT = "FINGERPRINT";
72 const char* EVENT_PARAM_HIDE_DESKTOP_ICON = "HIDE_DESKTOP_ICON";
73 const char* EVENT_PARAM_APP_DISTRIBUTION_TYPE = "APP_DISTRIBUTION_TYPE";
74 const char* EVENT_PARAM_FILE_PATH = "FILE_PATH";
75 const char* EVENT_PARAM_HASH_VALUE = "HASH_VALUE";
76 const char* EVENT_PARAM_INSTALL_TIME = "INSTALL_TIME";
77 const char* EVENT_PARAM_APPLY_QUICK_FIX_FREQUENCY = "APPLY_QUICK_FIX_FREQUENCY";
78 const char* EVENT_PARAM_CONTINUE_TYPE = "CONTINUE_TYPE";
79 const char* EVENT_PARAM_PACKAGE_NAME = "PACKAGE_NAME";
80 const char* EVENT_PARAM_SCENE_ID = "SCENE_ID";
81 const char* EVENT_PARAM_HAPPEN_TIME = "HAPPEN_TIME";
82 const char* EVENT_PARAM_MODULE_NAME = "MODULE_NAME";
83 const char* EVENT_PARAM_IS_FREE_INSTALL = "IS_FREE_INSTALL";
84 const char* EVENT_PARAM_APP_IDS = "APP_IDS";
85 const char* EVENT_PARAM_CALLING_NAME = "CALLING_NAME";
86 const char* EVENT_PARAM_OPERATION_TYPE = "OPERATION_TYPE";
87 const char* EVENT_PARAM_ACTION_TYPE = "ACTION_TYPE";
88 const char* EVENT_PARAM_RULE = "ACTION_RULE";
89 const char* EVENT_PARAM_APP_INDEX = "APP_INDEX";
90 const char* EVENT_PARAM_IS_PATCH = "IS_PATCH";
91 const char* EVENT_PARAM_IS_INTERCEPTED = "IS_INTERCEPTED";
92 const char* FILE_OR_FOLDER_PATH = "FILE_OR_FOLDER_PATH";
93 const char* FILE_OR_FOLDER_SIZE = "FILE_OR_FOLDER_SIZE";
94 const char* COMPONENT_NAME_KEY = "COMPONENT_NAME";
95 const char* PARTITION_NAME_KEY = "PARTITION_NAME";
96 const char* REMAIN_PARTITION_SIZE_KEY = "REMAIN_PARTITION_SIZE";
97 const char* USER_DATA_SIZE = "USER_DATA_SIZE";
98 const char* EVENT_PARAM_WANT = "WANT";
99 const char* EVENT_PARAM_UTD = "UTD";
100
101 const char* FREE_INSTALL_TYPE = "FreeInstall";
102 const char* PRE_BUNDLE_INSTALL_TYPE = "PreBundleInstall";
103 const char* NORMAL_INSTALL_TYPE = "normalInstall";
104 const char* NORMAL_SCENE = "Normal";
105 const char* BOOT_SCENE = "Boot";
106 const char* REBOOT_SCENE = "Reboot";
107 const char* CREATE_USER_SCENE = "CreateUser";
108 const char* REMOVE_USER_SCENE = "RemoveUser";
109 const char* CLEAN_CACHE = "cleanCache";
110 const char* CLEAN_DATA = "cleanData";
111 const char* ENABLE = "enable";
112 const char* DISABLE = "disable";
113 const char* APPLICATION = "application";
114 const char* ABILITY = "ability";
115 const char* TYPE = "TYPE";
116 const char* UNKNOW = "Unknow";
117 const char* CREATE_START = "CreateUserStart";
118 const char* CREATE_END = "CreateUserEnd";
119 const char* REMOVE_START = "RemoveUserStart";
120 const char* REMOVE_END = "RemoveUserEnd";
121 const char* CREATE_WITH_SKIP_PRE_INSTALL_START = "CreateUserWithSkipPreInstallStart";
122 const char* CREATE_WITH_SKIP_PRE_INSTALL_END = "CreateUserWithSkipPreInstallEnd";
123 // AOT
124 const char* TOTAL_BUNDLE_NAMES = "totalBundleNames";
125 const char* TOTAL_SIZE = "totalSize";
126 const char* SUCCESS_SIZE = "successSize";
127 const char* COST_TIME_SECONDS = "costTimeSeconds";
128 const char* COMPILE_MODE = "compileMode";
129 const char* COMPILE_RESULT = "compileResult";
130 const char* FAILURE_REASON = "failureReason";
131 const char* FILE_NAME = "fileName";
132 const char* FREE_SIZE = "freeSize";
133 const char* OPERATION_TYPE = "operationType";
134 const char* DB_NAME = "dbName";
135 const char* ERROR_CODE = "errorCode";
136 const char* REBUILD_TYPE = "rebuildType";
137 const char* COMPONENT_NAME = "hisevent";
138 const char* PARTITION_NAME = "/data";
139 // query event
140 const char* EVENT_PARAM_FUNC_ID_LIST = "FUNC_ID_LIST";
141 const char* EVENT_PARAM_USER_ID_LIST = "USER_ID_LIST";
142 const char* EVENT_PARAM_UID_LIST = "UID_LIST";
143 const char* EVENT_PARAM_APP_INDEX_LIST = "APP_INDEX_LIST";
144 const char* EVENT_PARAM_FLAG_LIST = "FLAG_LIST";
145 const char* EVENT_PARAM_BUNDLE_NAME_LIST = "BUNDLE_NAME_LIST";
146 const char* EVENT_PARAM_CALLING_UID_LIST = "CALLING_UID_LIST";
147 const char* EVENT_PARAM_CALLING_BUNDLE_NAME_LIST = "CALLING_BUNDLE_NAME_LIST";
148 const char* EVENT_PARAM_CALLING_APP_ID_LIST = "CALLING_APP_ID_LIST";
149
150 const InstallScene INSTALL_SCENE_STR_MAP_KEY[] = {
151 InstallScene::NORMAL,
152 InstallScene::BOOT,
153 InstallScene::REBOOT,
154 InstallScene::CREATE_USER,
155 InstallScene::REMOVE_USER,
156 };
157 const char* g_installSceneStrMapValue[] = {
158 NORMAL_SCENE,
159 BOOT_SCENE,
160 REBOOT_SCENE,
161 CREATE_USER_SCENE,
162 REMOVE_USER_SCENE,
163 };
164
165 const UserEventType USER_TYPE_STR_MAP_KEY[] = {
166 UserEventType::CREATE_START,
167 UserEventType::CREATE_END,
168 UserEventType::REMOVE_START,
169 UserEventType::REMOVE_END,
170 UserEventType::CREATE_WITH_SKIP_PRE_INSTALL_START,
171 UserEventType::CREATE_WITH_SKIP_PRE_INSTALL_END,
172 };
173 const char* g_userTypeStrMapValue[] = {
174 CREATE_START,
175 CREATE_END,
176 REMOVE_START,
177 REMOVE_END,
178 CREATE_WITH_SKIP_PRE_INSTALL_START,
179 CREATE_WITH_SKIP_PRE_INSTALL_END,
180 };
181
GetInstallType(const EventInfo & eventInfo)182 std::string GetInstallType(const EventInfo& eventInfo)
183 {
184 std::string installType = NORMAL_INSTALL_TYPE;
185 if (eventInfo.isFreeInstallMode) {
186 installType = FREE_INSTALL_TYPE;
187 } else if (eventInfo.isPreInstallApp) {
188 installType = PRE_BUNDLE_INSTALL_TYPE;
189 }
190
191 return installType;
192 }
193
GetInstallScene(const EventInfo & eventInfo)194 std::string GetInstallScene(const EventInfo& eventInfo)
195 {
196 std::string installScene = NORMAL_SCENE;
197 size_t len = sizeof(INSTALL_SCENE_STR_MAP_KEY) / sizeof(INSTALL_SCENE_STR_MAP_KEY[0]);
198 for (size_t i = 0; i < len; i++) {
199 if (eventInfo.preBundleScene == INSTALL_SCENE_STR_MAP_KEY[i]) {
200 installScene = g_installSceneStrMapValue[i];
201 break;
202 }
203 }
204
205 return installScene;
206 }
207
GetUserEventType(const EventInfo & eventInfo)208 std::string GetUserEventType(const EventInfo& eventInfo)
209 {
210 std::string type = UNKNOW;
211 size_t len = sizeof(USER_TYPE_STR_MAP_KEY) / sizeof(USER_TYPE_STR_MAP_KEY[0]);
212 for (size_t i = 0; i < len; i++) {
213 if (eventInfo.userEventType == USER_TYPE_STR_MAP_KEY[i]) {
214 type = g_userTypeStrMapValue[i];
215 break;
216 }
217 }
218
219 return type;
220 }
221 }
222
223 std::unordered_map<BMSEventType, void (*)(const EventInfo& eventInfo)>
224 InnerEventReport::bmsSysEventMap_ = {
225 { BMSEventType::BUNDLE_INSTALL_EXCEPTION,
__anon84d3652d0202() 226 [](const EventInfo& eventInfo) {
227 InnerSendBundleInstallExceptionEvent(eventInfo);
228 } },
229 { BMSEventType::BUNDLE_UNINSTALL_EXCEPTION,
__anon84d3652d0302() 230 [](const EventInfo& eventInfo) {
231 InnerSendBundleUninstallExceptionEvent(eventInfo);
232 } },
233 { BMSEventType::BUNDLE_UPDATE_EXCEPTION,
__anon84d3652d0402() 234 [](const EventInfo& eventInfo) {
235 InnerSendBundleUpdateExceptionEvent(eventInfo);
236 } },
237 { BMSEventType::PRE_BUNDLE_RECOVER_EXCEPTION,
__anon84d3652d0502() 238 [](const EventInfo& eventInfo) {
239 InnerSendPreBundleRecoverExceptionEvent(eventInfo);
240 } },
241 { BMSEventType::BUNDLE_STATE_CHANGE_EXCEPTION,
__anon84d3652d0602() 242 [](const EventInfo& eventInfo) {
243 InnerSendBundleStateChangeExceptionEvent(eventInfo);
244 } },
245 { BMSEventType::BUNDLE_CLEAN_CACHE_EXCEPTION,
__anon84d3652d0702() 246 [](const EventInfo& eventInfo) {
247 InnerSendBundleCleanCacheExceptionEvent(eventInfo);
248 } },
249 { BMSEventType::BOOT_SCAN_START,
__anon84d3652d0802() 250 [](const EventInfo& eventInfo) {
251 InnerSendBootScanStartEvent(eventInfo);
252 } },
253 { BMSEventType::BOOT_SCAN_END,
__anon84d3652d0902() 254 [](const EventInfo& eventInfo) {
255 InnerSendBootScanEndEvent(eventInfo);
256 } },
257 { BMSEventType::BUNDLE_INSTALL,
__anon84d3652d0a02() 258 [](const EventInfo& eventInfo) {
259 InnerSendBundleInstallEvent(eventInfo);
260 } },
261 { BMSEventType::BUNDLE_UNINSTALL,
__anon84d3652d0b02() 262 [](const EventInfo& eventInfo) {
263 InnerSendBundleUninstallEvent(eventInfo);
264 } },
265 { BMSEventType::BUNDLE_UPDATE,
__anon84d3652d0c02() 266 [](const EventInfo& eventInfo) {
267 InnerSendBundleUpdateEvent(eventInfo);
268 } },
269 { BMSEventType::PRE_BUNDLE_RECOVER,
__anon84d3652d0d02() 270 [](const EventInfo& eventInfo) {
271 InnerSendPreBundleRecoverEvent(eventInfo);
272 } },
273 { BMSEventType::BUNDLE_STATE_CHANGE,
__anon84d3652d0e02() 274 [](const EventInfo& eventInfo) {
275 InnerSendBundleStateChangeEvent(eventInfo);
276 } },
277 { BMSEventType::BUNDLE_CLEAN_CACHE,
__anon84d3652d0f02() 278 [](const EventInfo& eventInfo) {
279 InnerSendBundleCleanCacheEvent(eventInfo);
280 } },
281 { BMSEventType::BMS_USER_EVENT,
__anon84d3652d1002() 282 [](const EventInfo& eventInfo) {
283 InnerSendUserEvent(eventInfo);
284 } },
285 { BMSEventType::APPLY_QUICK_FIX,
__anon84d3652d1102() 286 [](const EventInfo& eventInfo) {
287 InnerSendQuickFixEvent(eventInfo);
288 } },
289 { BMSEventType::CPU_SCENE_ENTRY,
__anon84d3652d1202() 290 [](const EventInfo& eventInfo) {
291 InnerSendCpuSceneEvent(eventInfo);
292 } },
293 { BMSEventType::AOT_COMPILE_SUMMARY,
__anon84d3652d1302() 294 [](const EventInfo& eventInfo) {
295 InnerSendAOTSummaryEvent(eventInfo);
296 } },
297 { BMSEventType::AOT_COMPILE_RECORD,
__anon84d3652d1402() 298 [](const EventInfo& eventInfo) {
299 InnerSendAOTRecordEvent(eventInfo);
300 } },
301 { BMSEventType::QUERY_OF_CONTINUE_TYPE,
__anon84d3652d1502() 302 [](const EventInfo& eventInfo) {
303 InnerSendQueryOfContinueTypeEvent(eventInfo);
304 } },
305 { BMSEventType::FREE_INSTALL_EVENT,
__anon84d3652d1602() 306 [](const EventInfo& eventInfo) {
307 InnerSendFreeInstallEvent(eventInfo);
308 } },
309 { BMSEventType::BMS_DISK_SPACE,
__anon84d3652d1702() 310 [](const EventInfo& eventInfo) {
311 InnerSendBmsDiskSpaceEvent(eventInfo);
312 } },
313 { BMSEventType::APP_CONTROL_RULE,
__anon84d3652d1802() 314 [](const EventInfo& eventInfo) {
315 InnerSendAppControlRule(eventInfo);
316 } },
317 { BMSEventType::DATA_PARTITION_USAGE_EVENT,
__anon84d3652d1902() 318 [](const EventInfo& eventInfo) {
319 InnerSendDataPartitionUsageEvent(eventInfo);
320 } },
321 { BMSEventType::DB_ERROR,
__anon84d3652d1a02() 322 [](const EventInfo& eventInfo) {
323 InnerSendDbErrorEvent(eventInfo);
324 } },
325 { BMSEventType::DEFAULT_APP,
__anon84d3652d1b02() 326 [](const EventInfo& eventInfo) {
327 InnerSendDefaultAppEvent(eventInfo);
328 } },
329 { BMSEventType::QUERY_BUNDLE_INFO,
__anon84d3652d1c02() 330 [](const EventInfo& eventInfo) {
331 InnerSendQueryBundleInfoEvent(eventInfo);
332 } },
333 };
334
SendSystemEvent(BMSEventType bmsEventType,const EventInfo & eventInfo)335 void InnerEventReport::SendSystemEvent(BMSEventType bmsEventType, const EventInfo& eventInfo)
336 {
337 auto iter = bmsSysEventMap_.find(bmsEventType);
338 if (iter == bmsSysEventMap_.end()) {
339 return;
340 }
341
342 iter->second(eventInfo);
343 }
344
InnerSendBundleInstallExceptionEvent(const EventInfo & eventInfo)345 void InnerEventReport::InnerSendBundleInstallExceptionEvent(const EventInfo& eventInfo)
346 {
347 if (eventInfo.errCode == ERR_APPEXECFWK_INSTALL_ZERO_USER_WITH_NO_SINGLETON) {
348 return;
349 }
350 InnerEventWrite(
351 BUNDLE_INSTALL_EXCEPTION,
352 HiSysEventType::FAULT,
353 EVENT_PARAM_PNAMEID, eventInfo.packageName,
354 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
355 EVENT_PARAM_USERID, eventInfo.userId,
356 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
357 EVENT_PARAM_VERSION, eventInfo.versionCode,
358 EVENT_PARAM_INSTALL_TYPE, GetInstallType(eventInfo),
359 EVENT_PARAM_SCENE, std::to_string(eventInfo.callingUid),
360 EVENT_PARAM_ERROR_CODE, eventInfo.errCode,
361 EVENT_PARAM_APP_INDEX, eventInfo.appIndex,
362 EVENT_PARAM_IS_PATCH, eventInfo.isPatch,
363 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
364 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
365 EVENT_PARAM_IS_INTERCEPTED, eventInfo.isIntercepted);
366 }
367
InnerSendBundleUninstallExceptionEvent(const EventInfo & eventInfo)368 void InnerEventReport::InnerSendBundleUninstallExceptionEvent(const EventInfo& eventInfo)
369 {
370 if (eventInfo.errCode == ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_BUNDLE ||
371 eventInfo.errCode == ERR_APPEXECFWK_UNINSTALL_MISSING_INSTALLED_MODULE ||
372 eventInfo.errCode == ERR_APPEXECFWK_UNINSTALL_SYSTEM_APP_ERROR) {
373 return;
374 }
375 InnerEventWrite(
376 BUNDLE_UNINSTALL_EXCEPTION,
377 HiSysEventType::FAULT,
378 EVENT_PARAM_PNAMEID, eventInfo.packageName,
379 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
380 EVENT_PARAM_USERID, eventInfo.userId,
381 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
382 EVENT_PARAM_VERSION, eventInfo.versionCode,
383 EVENT_PARAM_INSTALL_TYPE, std::to_string(eventInfo.callingUid),
384 EVENT_PARAM_ERROR_CODE, eventInfo.errCode,
385 EVENT_PARAM_APP_INDEX, eventInfo.appIndex,
386 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
387 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
388 EVENT_PARAM_IS_INTERCEPTED, eventInfo.isIntercepted);
389 }
390
InnerSendBundleUpdateExceptionEvent(const EventInfo & eventInfo)391 void InnerEventReport::InnerSendBundleUpdateExceptionEvent(const EventInfo& eventInfo)
392 {
393 InnerEventWrite(
394 BUNDLE_UPDATE_EXCEPTION,
395 HiSysEventType::FAULT,
396 EVENT_PARAM_PNAMEID, eventInfo.packageName,
397 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
398 EVENT_PARAM_USERID, eventInfo.userId,
399 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
400 EVENT_PARAM_VERSION, eventInfo.versionCode,
401 EVENT_PARAM_INSTALL_TYPE, std::to_string(eventInfo.callingUid),
402 EVENT_PARAM_ERROR_CODE, eventInfo.errCode,
403 EVENT_PARAM_IS_PATCH, eventInfo.isPatch,
404 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
405 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
406 EVENT_PARAM_IS_INTERCEPTED, eventInfo.isIntercepted);
407 }
408
InnerSendPreBundleRecoverExceptionEvent(const EventInfo & eventInfo)409 void InnerEventReport::InnerSendPreBundleRecoverExceptionEvent(const EventInfo& eventInfo)
410 {
411 InnerEventWrite(
412 PRE_BUNDLE_RECOVER_EXCEPTION,
413 HiSysEventType::FAULT,
414 EVENT_PARAM_PNAMEID, eventInfo.packageName,
415 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
416 EVENT_PARAM_USERID, eventInfo.userId,
417 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
418 EVENT_PARAM_VERSION, eventInfo.versionCode,
419 EVENT_PARAM_INSTALL_TYPE, PRE_BUNDLE_INSTALL_TYPE,
420 EVENT_PARAM_ERROR_CODE, eventInfo.errCode,
421 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
422 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
423 EVENT_PARAM_IS_INTERCEPTED, eventInfo.isIntercepted);
424 }
425
InnerSendBundleStateChangeExceptionEvent(const EventInfo & eventInfo)426 void InnerEventReport::InnerSendBundleStateChangeExceptionEvent(const EventInfo& eventInfo)
427 {
428 std::string type = eventInfo.abilityName.empty() ? APPLICATION : ABILITY;
429 InnerEventWrite(
430 BUNDLE_STATE_CHANGE_EXCEPTION,
431 HiSysEventType::FAULT,
432 EVENT_PARAM_PNAMEID, eventInfo.packageName,
433 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
434 EVENT_PARAM_USERID, eventInfo.userId,
435 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
436 EVENT_PARAM_ABILITY_NAME, eventInfo.abilityName,
437 TYPE, type,
438 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
439 EVENT_PARAM_APP_INDEX, eventInfo.appIndex);
440 }
441
InnerSendBundleCleanCacheExceptionEvent(const EventInfo & eventInfo)442 void InnerEventReport::InnerSendBundleCleanCacheExceptionEvent(const EventInfo& eventInfo)
443 {
444 std::string cleanType = eventInfo.isCleanCache ? CLEAN_CACHE : CLEAN_DATA;
445 InnerEventWrite(
446 BUNDLE_CLEAN_CACHE_EXCEPTION,
447 HiSysEventType::FAULT,
448 EVENT_PARAM_PNAMEID, eventInfo.packageName,
449 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
450 EVENT_PARAM_USERID, eventInfo.userId,
451 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
452 EVENT_PARAM_CLEAN_TYPE, cleanType,
453 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
454 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName);
455 }
456
InnerSendBootScanStartEvent(const EventInfo & eventInfo)457 void InnerEventReport::InnerSendBootScanStartEvent(const EventInfo& eventInfo)
458 {
459 InnerEventWrite(
460 BOOT_SCAN_START,
461 HiSysEventType::BEHAVIOR,
462 EVENT_PARAM_PNAMEID, eventInfo.packageName,
463 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
464 EVENT_PARAM_TIME, eventInfo.timeStamp);
465 }
466
InnerSendBootScanEndEvent(const EventInfo & eventInfo)467 void InnerEventReport::InnerSendBootScanEndEvent(const EventInfo& eventInfo)
468 {
469 InnerEventWrite(
470 BOOT_SCAN_END,
471 HiSysEventType::BEHAVIOR,
472 EVENT_PARAM_PNAMEID, eventInfo.packageName,
473 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
474 EVENT_PARAM_TIME, eventInfo.timeStamp);
475 }
476
InnerSendBundleInstallEvent(const EventInfo & eventInfo)477 void InnerEventReport::InnerSendBundleInstallEvent(const EventInfo& eventInfo)
478 {
479 InnerEventWrite(
480 BUNDLE_INSTALL,
481 HiSysEventType::BEHAVIOR,
482 EVENT_PARAM_PNAMEID, eventInfo.packageName,
483 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
484 EVENT_PARAM_USERID, eventInfo.userId,
485 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
486 EVENT_PARAM_VERSION, eventInfo.versionCode,
487 EVENT_PARAM_APP_DISTRIBUTION_TYPE, eventInfo.appDistributionType,
488 EVENT_PARAM_INSTALL_TIME, eventInfo.timeStamp,
489 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
490 EVENT_PARAM_CALLING_APPID, eventInfo.callingAppId,
491 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
492 EVENT_PARAM_FILE_PATH, eventInfo.filePath,
493 EVENT_PARAM_HASH_VALUE, eventInfo.hashValue,
494 EVENT_PARAM_FINGERPRINT, eventInfo.fingerprint,
495 EVENT_PARAM_HIDE_DESKTOP_ICON, eventInfo.hideDesktopIcon,
496 EVENT_PARAM_INSTALL_TYPE, GetInstallType(eventInfo),
497 EVENT_PARAM_SCENE, GetInstallScene(eventInfo),
498 EVENT_PARAM_APP_INDEX, eventInfo.appIndex,
499 EVENT_PARAM_IS_PATCH, eventInfo.isPatch);
500 }
501
InnerSendBundleUninstallEvent(const EventInfo & eventInfo)502 void InnerEventReport::InnerSendBundleUninstallEvent(const EventInfo& eventInfo)
503 {
504 InnerEventWrite(
505 BUNDLE_UNINSTALL,
506 HiSysEventType::BEHAVIOR,
507 EVENT_PARAM_PNAMEID, eventInfo.packageName,
508 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
509 EVENT_PARAM_USERID, eventInfo.userId,
510 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
511 EVENT_PARAM_VERSION, eventInfo.versionCode,
512 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
513 EVENT_PARAM_CALLING_APPID, eventInfo.callingAppId,
514 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
515 EVENT_PARAM_INSTALL_TYPE, GetInstallType(eventInfo),
516 EVENT_PARAM_APP_INDEX, eventInfo.appIndex);
517 }
518
InnerSendBundleUpdateEvent(const EventInfo & eventInfo)519 void InnerEventReport::InnerSendBundleUpdateEvent(const EventInfo& eventInfo)
520 {
521 InnerEventWrite(
522 BUNDLE_UPDATE,
523 HiSysEventType::BEHAVIOR,
524 EVENT_PARAM_PNAMEID, eventInfo.packageName,
525 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
526 EVENT_PARAM_USERID, eventInfo.userId,
527 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
528 EVENT_PARAM_VERSION, eventInfo.versionCode,
529 EVENT_PARAM_APP_DISTRIBUTION_TYPE, eventInfo.appDistributionType,
530 EVENT_PARAM_INSTALL_TIME, eventInfo.timeStamp,
531 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
532 EVENT_PARAM_CALLING_APPID, eventInfo.callingAppId,
533 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
534 EVENT_PARAM_FILE_PATH, eventInfo.filePath,
535 EVENT_PARAM_HASH_VALUE, eventInfo.hashValue,
536 EVENT_PARAM_FINGERPRINT, eventInfo.fingerprint,
537 EVENT_PARAM_HIDE_DESKTOP_ICON, eventInfo.hideDesktopIcon,
538 EVENT_PARAM_INSTALL_TYPE, GetInstallType(eventInfo),
539 EVENT_PARAM_IS_PATCH, eventInfo.isPatch);
540 }
541
InnerSendPreBundleRecoverEvent(const EventInfo & eventInfo)542 void InnerEventReport::InnerSendPreBundleRecoverEvent(const EventInfo& eventInfo)
543 {
544 InnerEventWrite(
545 PRE_BUNDLE_RECOVER,
546 HiSysEventType::BEHAVIOR,
547 EVENT_PARAM_PNAMEID, eventInfo.packageName,
548 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
549 EVENT_PARAM_USERID, eventInfo.userId,
550 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
551 EVENT_PARAM_VERSION, eventInfo.versionCode,
552 EVENT_PARAM_APP_DISTRIBUTION_TYPE, eventInfo.appDistributionType,
553 EVENT_PARAM_INSTALL_TIME, eventInfo.timeStamp,
554 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
555 EVENT_PARAM_CALLING_APPID, eventInfo.callingAppId,
556 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
557 EVENT_PARAM_FINGERPRINT, eventInfo.fingerprint,
558 EVENT_PARAM_HIDE_DESKTOP_ICON, eventInfo.hideDesktopIcon,
559 EVENT_PARAM_INSTALL_TYPE, PRE_BUNDLE_INSTALL_TYPE);
560 }
561
InnerSendBundleStateChangeEvent(const EventInfo & eventInfo)562 void InnerEventReport::InnerSendBundleStateChangeEvent(const EventInfo& eventInfo)
563 {
564 std::string type = eventInfo.abilityName.empty() ? APPLICATION : ABILITY;
565 std::string state = eventInfo.isEnable ? ENABLE : DISABLE;
566 InnerEventWrite(
567 BUNDLE_STATE_CHANGE,
568 HiSysEventType::BEHAVIOR,
569 EVENT_PARAM_PNAMEID, eventInfo.packageName,
570 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
571 EVENT_PARAM_USERID, eventInfo.userId,
572 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
573 EVENT_PARAM_ABILITY_NAME, eventInfo.abilityName,
574 TYPE, type,
575 EVENT_PARAM_STATE, state,
576 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName,
577 EVENT_PARAM_APP_INDEX, eventInfo.appIndex);
578 }
579
InnerSendBundleCleanCacheEvent(const EventInfo & eventInfo)580 void InnerEventReport::InnerSendBundleCleanCacheEvent(const EventInfo& eventInfo)
581 {
582 std::string cleanType = eventInfo.isCleanCache ? CLEAN_CACHE : CLEAN_DATA;
583 InnerEventWrite(
584 BUNDLE_CLEAN_CACHE,
585 HiSysEventType::BEHAVIOR,
586 EVENT_PARAM_PNAMEID, eventInfo.packageName,
587 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
588 EVENT_PARAM_USERID, eventInfo.userId,
589 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
590 EVENT_PARAM_CLEAN_TYPE, cleanType,
591 EVENT_PARAM_CALLING_UID, eventInfo.callingUid,
592 EVENT_PARAM_CALLING_BUNDLE_NAME, eventInfo.callingBundleName);
593 }
594
InnerSendUserEvent(const EventInfo & eventInfo)595 void InnerEventReport::InnerSendUserEvent(const EventInfo& eventInfo)
596 {
597 InnerEventWrite(
598 BMS_USER_EVENT,
599 HiSysEventType::BEHAVIOR,
600 EVENT_PARAM_PNAMEID, eventInfo.packageName,
601 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
602 TYPE, GetUserEventType(eventInfo),
603 EVENT_PARAM_USERID, eventInfo.userId,
604 EVENT_PARAM_TIME, eventInfo.timeStamp);
605 }
606
InnerSendQuickFixEvent(const EventInfo & eventInfo)607 void InnerEventReport::InnerSendQuickFixEvent(const EventInfo& eventInfo)
608 {
609 InnerEventWrite(
610 BUNDLE_QUICK_FIX,
611 HiSysEventType::BEHAVIOR,
612 EVENT_PARAM_PNAMEID, eventInfo.packageName,
613 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
614 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
615 EVENT_PARAM_APP_DISTRIBUTION_TYPE, eventInfo.appDistributionType,
616 EVENT_PARAM_APPLY_QUICK_FIX_FREQUENCY, eventInfo.applyQuickFixFrequency,
617 EVENT_PARAM_FILE_PATH, eventInfo.filePath,
618 EVENT_PARAM_HASH_VALUE, eventInfo.hashValue);
619 }
620
InnerSendCpuSceneEvent(const EventInfo & eventInfo)621 void InnerEventReport::InnerSendCpuSceneEvent(const EventInfo& eventInfo)
622 {
623 HiSysEventWrite(
624 PERFORMANCE_DOMAIN,
625 CPU_SCENE_ENTRY,
626 HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
627 EVENT_PARAM_PACKAGE_NAME, eventInfo.processName,
628 EVENT_PARAM_SCENE_ID, std::to_string(eventInfo.sceneId).c_str(),
629 EVENT_PARAM_HAPPEN_TIME, eventInfo.timeStamp);
630 }
631
InnerSendAOTSummaryEvent(const EventInfo & eventInfo)632 void InnerEventReport::InnerSendAOTSummaryEvent(const EventInfo& eventInfo)
633 {
634 InnerEventWrite(
635 AOT_COMPILE_SUMMARY,
636 HiSysEventType::BEHAVIOR,
637 TOTAL_BUNDLE_NAMES, eventInfo.totalBundleNames,
638 TOTAL_SIZE, eventInfo.totalBundleNames.size(),
639 SUCCESS_SIZE, eventInfo.successCnt,
640 COST_TIME_SECONDS, eventInfo.costTimeSeconds,
641 EVENT_PARAM_TIME, eventInfo.timeStamp);
642 }
643
InnerSendAOTRecordEvent(const EventInfo & eventInfo)644 void InnerEventReport::InnerSendAOTRecordEvent(const EventInfo& eventInfo)
645 {
646 InnerEventWrite(
647 AOT_COMPILE_RECORD,
648 HiSysEventType::BEHAVIOR,
649 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
650 COMPILE_RESULT, eventInfo.compileResult,
651 FAILURE_REASON, eventInfo.failureReason,
652 COST_TIME_SECONDS, eventInfo.costTimeSeconds,
653 COMPILE_MODE, eventInfo.compileMode,
654 EVENT_PARAM_TIME, eventInfo.timeStamp);
655 }
656
InnerSendQueryOfContinueTypeEvent(const EventInfo & eventInfo)657 void InnerEventReport::InnerSendQueryOfContinueTypeEvent(const EventInfo& eventInfo)
658 {
659 InnerEventWrite(
660 QUERY_OF_CONTINUE_TYPE,
661 HiSysEventType::BEHAVIOR,
662 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
663 EVENT_PARAM_ABILITY_NAME, eventInfo.abilityName,
664 EVENT_PARAM_ERROR_CODE, eventInfo.errCode,
665 EVENT_PARAM_USERID, eventInfo.userId,
666 EVENT_PARAM_CONTINUE_TYPE, eventInfo.continueType);
667 }
668
InnerSendFreeInstallEvent(const EventInfo & eventInfo)669 void InnerEventReport::InnerSendFreeInstallEvent(const EventInfo& eventInfo)
670 {
671 InnerEventWrite(
672 FREE_INSTALL_EVENT,
673 HiSysEventType::BEHAVIOR,
674 EVENT_PARAM_BUNDLE_NAME, eventInfo.bundleName,
675 EVENT_PARAM_ABILITY_NAME, eventInfo.abilityName,
676 EVENT_PARAM_MODULE_NAME, eventInfo.moduleName,
677 EVENT_PARAM_IS_FREE_INSTALL, eventInfo.isFreeInstall,
678 EVENT_PARAM_TIME, eventInfo.timeStamp);
679 }
680
InnerSendBmsDiskSpaceEvent(const EventInfo & eventInfo)681 void InnerEventReport::InnerSendBmsDiskSpaceEvent(const EventInfo& eventInfo)
682 {
683 InnerEventWrite(
684 BMS_DISK_SPACE,
685 HiSysEventType::BEHAVIOR,
686 FILE_NAME, eventInfo.fileName,
687 FREE_SIZE, eventInfo.freeSize,
688 OPERATION_TYPE, eventInfo.operationType);
689 }
690
InnerSendAppControlRule(const EventInfo & eventInfo)691 void InnerEventReport::InnerSendAppControlRule(const EventInfo& eventInfo)
692 {
693 InnerEventWrite(
694 APP_CONTROL_RULE,
695 HiSysEventType::BEHAVIOR,
696 EVENT_PARAM_PNAMEID, eventInfo.packageName,
697 EVENT_PARAM_PVERSIONID, eventInfo.applicationVersion,
698 EVENT_PARAM_APP_IDS, eventInfo.appIds,
699 EVENT_PARAM_USERID, eventInfo.userId,
700 EVENT_PARAM_CALLING_NAME, eventInfo.callingName,
701 EVENT_PARAM_OPERATION_TYPE, eventInfo.operationType,
702 EVENT_PARAM_ACTION_TYPE, eventInfo.actionType,
703 EVENT_PARAM_RULE, eventInfo.rule,
704 EVENT_PARAM_APP_INDEX, eventInfo.appIndex);
705 }
706
InnerSendDbErrorEvent(const EventInfo & eventInfo)707 void InnerEventReport::InnerSendDbErrorEvent(const EventInfo& eventInfo)
708 {
709 InnerSystemEventWrite(
710 DB_ERROR,
711 HiSysEventType::BEHAVIOR,
712 DB_NAME, eventInfo.dbName,
713 OPERATION_TYPE, eventInfo.operationType,
714 ERROR_CODE, eventInfo.errorCode);
715 }
716
InnerSendDataPartitionUsageEvent(const EventInfo & eventInfo)717 void InnerEventReport::InnerSendDataPartitionUsageEvent(const EventInfo& eventInfo)
718 {
719 HiSysEventWrite(
720 #ifdef USE_EXTENSION_DATA
721 OHOS::HiviewDFX::HiSysEvent::Domain::FILEMANAGEMENT,
722 #else
723 OHOS::HiviewDFX::HiSysEvent::Domain::BUNDLEMANAGER_UE,
724 #endif
725 USER_DATA_SIZE,
726 HiviewDFX::HiSysEvent::EventType::STATISTIC,
727 COMPONENT_NAME_KEY, COMPONENT_NAME,
728 PARTITION_NAME_KEY, PARTITION_NAME,
729 REMAIN_PARTITION_SIZE_KEY, eventInfo.partitionSize,
730 FILE_OR_FOLDER_PATH, eventInfo.filePath,
731 FILE_OR_FOLDER_SIZE, eventInfo.fileSize);
732 }
733
InnerSendDefaultAppEvent(const EventInfo & eventInfo)734 void InnerEventReport::InnerSendDefaultAppEvent(const EventInfo& eventInfo)
735 {
736 InnerEventWrite(
737 DEFAULT_APP,
738 HiSysEventType::BEHAVIOR,
739 EVENT_PARAM_USERID, eventInfo.userId,
740 EVENT_PARAM_CALLING_NAME, eventInfo.callingName,
741 EVENT_PARAM_ACTION_TYPE, eventInfo.actionType,
742 EVENT_PARAM_WANT, eventInfo.want,
743 EVENT_PARAM_UTD, eventInfo.utd);
744 }
745
746 template<typename... Types>
InnerEventWrite(const std::string & eventName,HiSysEventType type,Types...keyValues)747 void InnerEventReport::InnerEventWrite(
748 const std::string &eventName,
749 HiSysEventType type,
750 Types... keyValues)
751 {
752 HiSysEventWrite(
753 OHOS::HiviewDFX::HiSysEvent::Domain::BUNDLEMANAGER_UE,
754 eventName,
755 static_cast<OHOS::HiviewDFX::HiSysEvent::EventType>(type),
756 keyValues...);
757 }
758
759 template<typename... Types>
InnerSystemEventWrite(const std::string & eventName,HiSysEventType type,Types...keyValues)760 void InnerEventReport::InnerSystemEventWrite(
761 const std::string &eventName,
762 HiSysEventType type,
763 Types... keyValues)
764 {
765 HiSysEventWrite(
766 OHOS::HiviewDFX::HiSysEvent::Domain::BUNDLE_MANAGER,
767 eventName,
768 static_cast<OHOS::HiviewDFX::HiSysEvent::EventType>(type),
769 keyValues...);
770 }
771
InnerSendQueryBundleInfoEvent(const EventInfo & eventInfo)772 void InnerEventReport::InnerSendQueryBundleInfoEvent(const EventInfo& eventInfo)
773 {
774 InnerSystemEventWrite(
775 QUERY_BUNDLE_INFO,
776 HiSysEventType::STATISTIC,
777 EVENT_PARAM_FUNC_ID_LIST, eventInfo.funcIdList,
778 EVENT_PARAM_USER_ID_LIST, eventInfo.userIdList,
779 EVENT_PARAM_UID_LIST, eventInfo.uidList,
780 EVENT_PARAM_APP_INDEX_LIST, eventInfo.appIndexList,
781 EVENT_PARAM_FLAG_LIST, eventInfo.flagList,
782 EVENT_PARAM_BUNDLE_NAME_LIST, eventInfo.bundleNameList,
783 EVENT_PARAM_CALLING_UID_LIST, eventInfo.callingUidList,
784 EVENT_PARAM_CALLING_BUNDLE_NAME_LIST, eventInfo.callingBundleNameList,
785 EVENT_PARAM_CALLING_APP_ID_LIST, eventInfo.callingAppIdList,
786 EVENT_PARAM_ERROR_CODE, eventInfo.errCode);
787 }
788 } // namespace AppExecFwk
789 } // namespace OHOS