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_DB_H
16 #define I_APP_LAUNCH_SCENE_DB_H
17 
18 #include <string>
19 
20 namespace OHOS {
21 namespace HiviewDFX {
22 class IAppLaunchSceneDb {
23 public:
24     const static int INVALID = -1;
25 
26     struct InteractionResponse {
27         uint64_t time{0};
28         std::string domain{""};
29         std::string eventName{""};
30 
31         int32_t appPid{0};
32         int32_t versionCode{0};
33         std::string versionName{""};
34         std::string bundleName{""};
35         std::string processName{""};
36         std::string abilityName{""};
37         std::string pageUrl{""};
38         std::string sceneId{""};
39         std::string sourceType{""};
40         uint64_t inputTime{0};
41         uint64_t animationStartTime{0};
42         uint64_t renderTime{0};
43         uint64_t responseLatency{0};
44         std::string note{""};
45     };
46 
47     struct StartAbility {
48         uint64_t time{0};
49         std::string domain{""};
50         std::string eventName{""};
51 
52         std::string bundleName{""};
53         std::string moduleName{""};
54         std::string abilityName{""};
55     };
56 
57     struct AppStartupType {
58         uint64_t time{0};
59         std::string domain{""};
60         std::string eventName{""};
61 
62         int32_t appPid{0};
63         int32_t versionCode{0};
64         std::string versionName{""};
65         std::string bundleName{""};
66         std::string abilityName{""};
67         int32_t startType{0}; //0-cool,1-hot
68     };
69 
70     struct ProcessStart {
71         uint64_t time{0};
72         std::string domain{""};
73         std::string eventName{""};
74 
75         std::string bundleName{""};
76         uint64_t startupTime{0};
77         int32_t startupAbilityType{0};
78         int32_t startupExtensionType{0};
79         std::string callerBundleName{""};
80         int32_t callerUid{0};
81         std::string callerProcessName{""};
82     };
83 
84     struct AppAttach {
85         uint64_t time{0};
86         std::string domain{""};
87         std::string eventName{""};
88 
89         std::string bundleName{""};
90         int32_t appPid{0};
91         int32_t versionCode{0};
92         std::string versionName{""};
93         std::string processName{""};
94     };
95 
96     struct AppForeground {
97         uint64_t time{0};
98         std::string domain{""};
99         std::string eventName{""};
100 
101         std::string bundleName{""};
102         int32_t appPid{0};
103         int32_t versionCode{0};
104         std::string versionName{""};
105         std::string processName{""};
106         int32_t bundleType{0};
107         std::string callerBundleName{""};
108     };
109 
110     struct AbilityForeground {
111         uint64_t time{0};
112         std::string domain{""};
113         std::string eventName{""};
114 
115         std::string bundleName{""};
116         std::string moduleName{""};
117         std::string abilityName{""};
118         int32_t bundleType{0};
119         std::string callerBundleName{""};
120     };
121 
122     struct StartWindow {
123         uint64_t time{0};
124         std::string domain{""};
125         std::string eventName{""};
126 
127         std::string bundleName{""};
128         int32_t appPid{0};
129         std::string processName{""};
130         std::string windowName{""};
131     };
132 
133     struct DrawnCompleted {
134         uint64_t time{0};
135         std::string domain{""};
136         std::string eventName{""};
137 
138         int32_t appUid{0};
139         int32_t appPid{0};
140         std::string bundleName{""};
141         std::string moduleName{""};
142         std::string abilityName{""};
143     };
144 
145     struct FirstFrameDrawn {
146         uint64_t time{0};
147         std::string domain{""};
148         std::string eventName{""};
149 
150         int32_t appPid{0};
151     };
152 
153     struct InteractionCompleted {
154         uint64_t time{0};
155         std::string domain{""};
156         std::string eventName{""};
157 
158         std::string bundleName{""};
159         int32_t appPid{0};
160         int32_t versionCode{0};
161         std::string versionName{""};
162         std::string abilityName{""};
163         std::string processName{""};
164         std::string pageUrl{""};
165         std::string sceneId{""};
166         std::string sourceType{""};
167         uint64_t inputTime{0};
168         uint64_t animationStartLatency{0};
169         uint64_t animationEndLatency{0};
170         uint64_t e2eLatency{0};
171         std::string note{""};
172     };
173 
174     struct AppStartRecord {
175         int32_t appPid{0};
176         std::string bundleName{""};
177 
178         InteractionResponse interactionResponse;
179         StartAbility startAbility;
180         AppStartupType appStartupType;
181         ProcessStart processStart;
182         AppAttach appAttach;
183         AppForeground appForeground;
184         AbilityForeground abilityForeground;
185         StartWindow startWindow;
186         DrawnCompleted drawnCompleted;
187         FirstFrameDrawn firstFrameDrawn;
188         InteractionCompleted interactionCompleted;
189     };
190 public:
191     virtual void CreateRecord(const std::string& bundleName, const AppStartRecord& record) = 0;
192     virtual void UpdateRecord(const std::string& bundleName, const AppStartRecord& record) = 0;
193     virtual void DeleteRecord(const std::string& bundleName) = 0;
194     virtual AppStartRecord QueryRecord(const std::string& bundleName) = 0;
195     virtual void CreateRecord(const AppStartRecord& record) = 0;
196     virtual void UpdateRecord(const AppStartRecord& record) = 0;
197     virtual ~IAppLaunchSceneDb() = default;
198 };
199 } // HiviewDFX
200 } // OHOS
201 #endif