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 I_APP_LAUNCH_SCENE_DATA_PROCESSOR_H
16 #define I_APP_LAUNCH_SCENE_DATA_PROCESSOR_H
17 
18 #include <string>
19 
20 class IAppLaunchSceneDataProcessor {
21 public:
22     struct AppStartCheckPointData {
23         uint64_t time{0};
24         std::string domain{""};
25         std::string eventName{""};
26         std::string bundleName{""};
27         std::string abilityName{""};
28         std::string processName{""};
29         std::string pageUrl{""};
30         std::string sceneId{""};
31         std::string sourceType{""};
32         uint64_t inputTime{0};
33         uint64_t animationStartTime{0};
34         uint64_t renderTime{0};
35         uint64_t responseLatency{0};
36         std::string moduleName{""};
37         int32_t versionCode{0};
38         std::string versionName{""};
39         int32_t startType{0};
40         uint64_t startupTime{0};
41         int32_t startupAbilityType{0};
42         int32_t startupExtensionType{0};
43         int32_t callerUid{0};
44         std::string callerProcessName{""};
45         std::string callerBundleName{""};
46         int32_t appPid{0};
47         int32_t appUid{0};
48         std::string windowName{""};
49         uint64_t animationStartLatency{0};
50         uint64_t animationEndLatency{0};
51         uint64_t e2eLatency{0};
52         int32_t bundleType{0};
53         std::string note{""};
54     };
55 
56     struct AppStartMetrics {
57         int32_t appPid{0};
58         int32_t versionCode{0};
59         std::string versionName{""};
60         std::string processName{""};
61         std::string bundleName{""};
62         std::string abilityName{""};
63         std::string pageUrl{""};
64         std::string sceneId{""};
65         int32_t startType{0};
66         std::string sourceType{""};
67         uint64_t inputTime{0};
68         uint64_t happenTime{0};
69         uint64_t responseLatency{0};
70         uint64_t launcherToAmsStartAbilityDur{0};
71         uint64_t amsStartAbilityToProcessStartDuration{0};
72         uint64_t amsProcessStartToAppAttachDuration{0};
73         uint64_t amsAppAttachToAppForegroundDuration{0};
74         uint64_t amsStartAbilityToAppForegroundDuration{0};
75         uint64_t amsAppFgToAbilityFgDur{0};
76         uint64_t amsAbilityFgToWmsStartWinDur{0};
77         uint64_t drawnLatency{0};
78         uint64_t firstFrameDrawnLatency{0};
79         uint64_t animationEndLatency{0}; //form animation_start to animation_end
80         uint64_t animationLatency{0}; //from input_time to animation_end
81         uint64_t e2eLatency{0};
82     };
83 
84     class MetricReporter {
85     public:
86         virtual void ReportMetrics(const AppStartMetrics& metrics) = 0;
87         virtual ~MetricReporter() = default;
88     };
89 public:
90     virtual void SetMetricReporter(MetricReporter* metricReporter) = 0;
91     virtual void ProcessSceneData(const AppStartCheckPointData& data) = 0;
92     virtual ~IAppLaunchSceneDataProcessor() = default;
93 };
94 #endif