• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef APP_LAUNCH_MONITOR_CONVERTER_H
16 #define APP_LAUNCH_MONITOR_CONVERTER_H
17 
18 #include "IAppLaunchSceneDataProcessor.h"
19 #include "IAppStartReporter.h"
20 #include "AppMonitorDataConverter.h"
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 const std::string COMMENT_APP_START = "APP_START";
25 const std::string COMMENT_APP_START_SLOW = "APP_START_SLOW";
26 
27 const unsigned int APP_START_ACTION_ID = 11;
28 const unsigned int APP_START_EVENT_ID = 902500019;
29 
30 using AppStartCheckPointData = IAppLaunchSceneDataProcessor::AppStartCheckPointData;
31 using AppEvtData = IAppThrExecutor::AppEvtData;
32 using AppStartMetrics = IAppLaunchSceneDataProcessor::AppStartMetrics;
33 
34 class AppLaunchMonitorConverter : public AppMonitorDataConverter {
35 public:
ConvertAppEvtDataToCheckPointData(const AppEvtData & appEvtData)36     static AppStartCheckPointData ConvertAppEvtDataToCheckPointData(const AppEvtData& appEvtData)
37     {
38         AppStartCheckPointData checkPointData;
39         checkPointData.time = appEvtData.time;
40         checkPointData.domain = appEvtData.domain;
41         checkPointData.eventName = appEvtData.eventName;
42         checkPointData.bundleName= appEvtData.bundleName;
43         checkPointData.abilityName = appEvtData.abilityName;
44         checkPointData.processName = appEvtData.processName;
45         checkPointData.pageUrl = appEvtData.pageUrl;
46         checkPointData.sceneId = appEvtData.sceneId;
47         checkPointData.sourceType = appEvtData.sourceType;
48         checkPointData.inputTime = appEvtData.inputTime;
49         checkPointData.animationStartTime = appEvtData.animationStartTime;
50         checkPointData.renderTime = appEvtData.renderTime;
51         checkPointData.responseLatency = appEvtData.responseLatency;
52         checkPointData.moduleName = appEvtData.moduleName;
53         checkPointData.versionCode = appEvtData.versionCode;
54         checkPointData.versionName = appEvtData.versionName;
55         checkPointData.startType = appEvtData.startType;
56         checkPointData.startupTime = appEvtData.startupTime;
57         checkPointData.startupAbilityType = appEvtData.startupAbilityType;
58         checkPointData.startupExtensionType = appEvtData.startupExtensionType;
59         checkPointData.callerBundleName = appEvtData.callerBundleName;
60         checkPointData.callerUid = appEvtData.callerUid;
61         checkPointData.callerProcessName = appEvtData.callerProcessName;
62         checkPointData.appPid = appEvtData.appPid;
63         checkPointData.appUid = appEvtData.appUid;
64         checkPointData.windowName = appEvtData.windowName;
65         checkPointData.bundleType = appEvtData.bundleType;
66         checkPointData.animationEndLatency = appEvtData.animationEndLatency;
67         checkPointData.e2eLatency = appEvtData.e2eLatency;
68         checkPointData.note = appEvtData.note;
69         checkPointData.animationStartLatency = appEvtData.animationStartLatency;
70 
71         return checkPointData;
72     }
73 
ConvertMetricToReportEvent(IAppLaunchSceneDataProcessor::AppStartMetrics metrics)74     static AppStartReportEvent ConvertMetricToReportEvent(IAppLaunchSceneDataProcessor::AppStartMetrics metrics)
75     {
76         AppStartReportEvent reportEvent;
77         reportEvent.appPid = metrics.appPid;
78         reportEvent.versionCode = metrics.versionCode;
79         reportEvent.versionName = metrics.versionName;
80         reportEvent.processName = metrics.processName;
81         reportEvent.bundleName = metrics.bundleName;
82         reportEvent.abilityName = metrics.abilityName;
83         reportEvent.pageUrl = metrics.pageUrl;
84         reportEvent.sceneId = metrics.sceneId;
85         reportEvent.startType = metrics.startType;
86         reportEvent.sourceType = metrics.sourceType;
87         reportEvent.inputTime = metrics.inputTime;
88         reportEvent.responseLatency = metrics.responseLatency;
89         reportEvent.launcherToAmsStartAbilityDur = metrics.launcherToAmsStartAbilityDur;
90         reportEvent.amsStartAbilityToProcessStartDuration = metrics.amsStartAbilityToProcessStartDuration;
91         reportEvent.amsProcessStartToAppAttachDuration = metrics.amsProcessStartToAppAttachDuration;
92         reportEvent.amsAppAttachToAppForegroundDuration = metrics.amsAppAttachToAppForegroundDuration;
93         reportEvent.amsStartAbilityToAppForegroundDuration = metrics.amsStartAbilityToAppForegroundDuration;
94         reportEvent.amsAppFgToAbilityFgDur = metrics.amsAppFgToAbilityFgDur;
95         reportEvent.amsAbilityFgToWmsStartWinDur = metrics.amsAbilityFgToWmsStartWinDur;
96         reportEvent.drawnLatency = metrics.drawnLatency;
97         reportEvent.firstFrameDrawnLatency = metrics.firstFrameDrawnLatency;
98         reportEvent.animationEndLatency = metrics.animationEndLatency;
99         reportEvent.animationLatency = metrics.animationLatency;
100         reportEvent.e2eLatency = metrics.e2eLatency;
101         reportEvent.happenTime = metrics.happenTime;
102 
103         reportEvent.actionId = APP_START_ACTION_ID;
104         reportEvent.eventId = APP_START_EVENT_ID;
105         return reportEvent;
106     }
107 };
108 } // HiviewDFX
109 } // OHOS
110 #endif