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 EVENT_OBSERVER_CONVERTER_H 16 #define EVENT_OBSERVER_CONVERTER_H 17 18 #include "IEventObserver.h" 19 #include "app_event_handler.h" 20 21 using AppLaunchInfo = OHOS::HiviewDFX::AppEventHandler::AppLaunchInfo; 22 using AppStartInfo = IEventObserver::AppStartInfo; 23 using ScrollJankEvtInfo = OHOS::HiviewDFX::AppEventHandler::ScrollJankInfo; 24 using ScrollJankInfo = IEventObserver::ScrollJankInfo; 25 26 class EventObserverConverter { 27 public: ConvertToAppStartInfo(const AppStartInfo & data)28 static AppLaunchInfo ConvertToAppStartInfo(const AppStartInfo& data) 29 { 30 AppLaunchInfo info; 31 info.bundleName = data.bundleName; 32 info.bundleVersion = data.versionName; 33 info.processName = data.processName; 34 info.startType = data.startType; 35 info.iconInputTime = data.inputTime; 36 info.animationFinishTime = data.animationLatency; 37 info.extendTime = data.drawnLatency; 38 return info; 39 } 40 ConvertToScrollJankEvtInfo(const ScrollJankInfo & data)41 static ScrollJankEvtInfo ConvertToScrollJankEvtInfo(const ScrollJankInfo& data) 42 { 43 ScrollJankEvtInfo info; 44 info.bundleVersion = data.versionName; 45 info.bundleName = data.bundleName; 46 info.processName = data.processName; 47 info.abilityName = data.abilityName; 48 info.beginTime = data.startTime; 49 info.duration = data.duration; 50 info.totalAppFrames = data.totalAppFrames; 51 info.totalAppMissedFrames = data.totalAppMissedFrames; 52 info.maxAppFrametime = data.maxAppFrameTime; 53 info.maxAppSeqFrames = data.maxAppSeqMissedFrames; 54 info.totalRenderFrames = data.totalRenderFrames; 55 info.totalRenderMissedFrames = data.totalRenderMissedFrames; 56 info.maxRenderFrametime = data.maxRenderFrameTime; 57 info.maxRenderSeqFrames = data.maxRenderSeqMissedFrames; 58 return info; 59 } 60 }; 61 #endif