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 JANK_ANIMATOR_MONITOR_CONVERTER_H 16 #define JANK_ANIMATOR_MONITOR_CONVERTER_H 17 18 #include "IJankAnimatorReporter.h" 19 #include "IAnimatorSceneDataProcessor.h" 20 21 using AnimatorMetrics = IAnimatorSceneDataProcessor::AnimatorMetrics; 22 23 class JankAnimatorMonitorConverter { 24 public: ConverterReportData(AnimatorMetrics metricData)25 static JankAnimatorReportEvent ConverterReportData(AnimatorMetrics metricData) 26 { 27 return ConverterReportData(metricData, "", ""); 28 } 29 ConverterReportData(AnimatorMetrics metrics,std::string traceFileName,std::string infoFileName)30 static JankAnimatorReportEvent ConverterReportData(AnimatorMetrics metrics, 31 std::string traceFileName, std::string infoFileName) 32 { 33 JankAnimatorReportEvent event; 34 event.appPid = metrics.appInfo.appPid; 35 event.versionCode = metrics.basicInfo.versionCode; 36 event.versionName = metrics.basicInfo.versionName; 37 event.bundleName = metrics.basicInfo.moduleName; 38 event.processName = metrics.basicInfo.processName; 39 event.abilityName = metrics.basicInfo.abilityName; 40 event.pageUrl = metrics.basicInfo.pageUrl; 41 event.sceneId = metrics.basicInfo.sceneId; 42 event.bundleNameEx = metrics.basicInfo.bundleNameEx; 43 event.isFocus = metrics.focus; 44 event.startTime = metrics.appInfo.startTime; 45 event.durition = metrics.appInfo.durition; 46 event.totalAppFrames = metrics.appInfo.totalFrames; 47 event.totalAppMissedFrames = metrics.appInfo.totalMissedFrames; 48 event.maxAppFrameTime = metrics.appInfo.maxFrameTime; 49 event.maxAppSeqMissedFrames = metrics.appInfo.maxSeqMissedFrames; 50 event.isDisplayAnimator = metrics.appInfo.isDisplayAnimator; 51 event.totalRenderFrames = metrics.rsInfo.totalFrames; 52 event.totalRenderMissedFrames = metrics.rsInfo.totalMissedFrames; 53 event.maxRenderFrameTime = metrics.rsInfo.maxFrameTime; 54 event.averageRenderFrameTime = metrics.rsInfo.averageFrameTime; 55 event.maxRenderSeqMissedFrames = metrics.rsInfo.maxSeqMissedFrames; 56 event.isFoldDisp = metrics.rsInfo.isFoldDisp; 57 event.happenTime = (metrics.appInfo.startTime == 0) ? metrics.rsInfo.happenTime : metrics.appInfo.startTime; 58 event.traceFileName = traceFileName; 59 event.infoFileName = infoFileName; 60 return event; 61 } 62 }; 63 64 #endif