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_MONITOR_DATA_CONVERTER_H
16 #define APP_MONITOR_DATA_CONVERTER_H
17 
18 #include "XperfEvt.h"
19 #include "IAppThrExecutor.h"
20 
21 namespace OHOS {
22 namespace HiviewDFX {
23 using AppEvtData = IAppThrExecutor::AppEvtData;
24 
25 class AppMonitorDataConverter {
26 public:
ConvertXperfEvtToAppEvtData(const XperfEvt& evt)27     static AppEvtData ConvertXperfEvtToAppEvtData(const XperfEvt& evt)
28     {
29         AppEvtData appEvtData;
30         appEvtData.time = evt.time;
31         appEvtData.domain = evt.domain;
32         appEvtData.eventName = evt.eventName;
33         appEvtData.bundleName= evt.bundleName;
34         appEvtData.abilityName = evt.abilityName;
35         appEvtData.processName = evt.processName;
36         appEvtData.pageUrl = evt.pageUrl;
37         appEvtData.sceneId = evt.sceneId;
38         appEvtData.sourceType = evt.sourceType;
39         appEvtData.inputTime = evt.inputTime;
40         appEvtData.animationStartTime = evt.animationStartTime;
41         appEvtData.renderTime = evt.renderTime;
42         appEvtData.responseLatency = evt.responseLatency;
43         appEvtData.moduleName = evt.moduleName;
44         appEvtData.versionCode = evt.versionCode;
45         appEvtData.versionName = evt.versionName;
46         appEvtData.startType = evt.startType;
47         appEvtData.startupTime = evt.startupTime;
48         appEvtData.startupAbilityType = evt.startupAbilityType;
49         appEvtData.startupExtensionType = evt.startupExtensionType;
50         appEvtData.callerBundleName = evt.callerBundleName;
51         appEvtData.callerUid = evt.callerUid;
52         appEvtData.callerProcessName = evt.callerProcessName;
53         appEvtData.appPid = evt.appPid;
54         appEvtData.appUid = evt.appUid;
55         appEvtData.windowName = evt.windowName;
56         appEvtData.bundleType = evt.bundleType;
57         appEvtData.animationEndLatency = evt.animationEndLatency;
58         appEvtData.e2eLatency = evt.e2eLatency;
59         appEvtData.exitTime = evt.exitTime;
60         appEvtData.exitResult = evt.exitResult;
61         appEvtData.exitPid = evt.exitPid;
62         appEvtData.note = evt.note;
63         appEvtData.animationStartLatency = evt.animationStartLatency;
64 
65         return appEvtData;
66     }
67 };
68 } // HiviewDFX
69 } // OHOS
70 #endif