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