1 /*
2 * Copyright (c) 2024 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 #include "AppStartReporter.h"
16 #include "hisysevent.h"
17 #include "hiview_logger.h"
18
19 DEFINE_LOG_LABEL(0xD002D66, "Hiview-XPerformance");
20
21 static constexpr char EXEC_DOMAIN[] = "PERFORMANCE";
22 using OHOS::HiviewDFX::HiSysEvent;
23
ReportNormal(const AppStartReportData & data)24 void AppStartReporter::ReportNormal(const AppStartReportData& data)
25 {
26 HIVIEW_LOGD("AppStartReporter::ReportNormal");
27 HiSysEventWrite(EXEC_DOMAIN, "APP_START", HiSysEvent::EventType::BEHAVIOR,
28 "APP_PID", data.appPid,
29 "VERSION_CODE", data.versionCode,
30 "VERSION_NAME", data.versionName,
31 "PROCESS_NAME", data.processName,
32 "BUNDLE_NAME", data.bundleName,
33 "ABILITY_NAME", data.abilityName,
34 "PAGE_URL", data.pageUrl,
35 "SCENE_ID", data.sceneId,
36 "START_TYPE", data.startType,
37 "SOURCE_TYPE", data.sourceType,
38 "INPUT_TIME", data.inputTime,
39 "RESPONSE_LATENCY", data.responseLatency,
40 "LAUN_TO_START_ABILITY_DUR", data.launcherToAmsStartAbilityDur,
41 "STARTABILITY_PROCESSSTART_DUR", data.amsStartAbilityToProcessStartDuration,
42 "PROCESSSTART_TO_APPATTACH_DUR", data.amsProcessStartToAppAttachDuration,
43 "APPATTACH_TO_APPFOREGROUND_DUR", data.amsAppAttachToAppForegroundDuration,
44 "STARTABILITY_APPFOREGROUND_DUR", data.amsStartAbilityToAppForegroundDuration,
45 "APPFOREGR_ABILITYONFOREGR_DUR", data.amsAppFgToAbilityFgDur,
46 "ABILITYONFOREG_STARTWINDOW_DUR", data.amsAbilityFgToWmsStartWinDur,
47 "DRAWN_LATENCY", data.drawnLatency,
48 "FIRST_FRAEM_DRAWN_LATENCY", data.firstFrameDrawnLatency,
49 "ANIMATION_LATENCY", data.animationLatency,
50 "E2E_LATENCY", data.e2eLatency);
51 }
52
ReportFault(const AppStartReportData & data)53 void AppStartReporter::ReportFault(const AppStartReportData& data)
54 {
55 HIVIEW_LOGD("AppStartReporter::ReportFault");
56 HiSysEventWrite(EXEC_DOMAIN, "APP_START_SLOW", HiSysEvent::EventType::FAULT,
57 "APP_PID", data.appPid,
58 "VERSION_CODE", data.versionCode,
59 "VERSION_NAME", data.versionName,
60 "PROCESS_NAME", data.processName,
61 "BUNDLE_NAME", data.bundleName,
62 "ABILITY_NAME", data.abilityName,
63 "PAGE_URL", data.pageUrl,
64 "SCENE_ID", data.sceneId,
65 "START_TYPE", data.startType,
66 "SOURCE_TYPE", data.sourceType,
67 "INPUT_TIME", data.inputTime,
68 "HAPPEN_TIME", data.happenTime,
69 "RESPONSE_LATENCY", data.responseLatency,
70 "LAUN_TO_START_ABILITY_DUR", data.launcherToAmsStartAbilityDur,
71 "STARTABILITY_PROCESSSTART_DUR", data.amsStartAbilityToProcessStartDuration,
72 "PROCESSSTART_TO_APPATTACH_DUR", data.amsProcessStartToAppAttachDuration,
73 "APPATTACH_TO_APPFOREGROUND_DUR", data.amsAppAttachToAppForegroundDuration,
74 "STARTABILITY_APPFOREGROUND_DUR", data.amsStartAbilityToAppForegroundDuration,
75 "APPFOREGR_ABILITYONFOREGR_DUR", data.amsAppFgToAbilityFgDur,
76 "ABILITYONFOREG_STARTWINDOW_DUR", data.amsAbilityFgToWmsStartWinDur,
77 "DRAWN_LATENCY", data.drawnLatency,
78 "FIRST_FRAEM_DRAWN_LATENCY", data.firstFrameDrawnLatency,
79 "ANIMATION_LATENCY", data.animationLatency,
80 "E2E_LATENCY", data.e2eLatency,
81 "TRACE_NAME", data.traceFileName,
82 "INFO_FILE", data.infoFileName);
83 }