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 #include "EventsPoster.h" 16 #include "hiview_logger.h" 17 18 namespace OHOS { 19 namespace HiviewDFX { 20 DEFINE_LOG_LABEL(0xD002D66, "Hiview-XPerformance"); 21 RegObserver(IEventObserver* observer)22void EventsPoster::RegObserver(IEventObserver* observer) 23 { 24 this->observer = observer; 25 } 26 PostAppStartEvent(const AppStartEventInfo& evt)27void EventsPoster::PostAppStartEvent(const AppStartEventInfo& evt) 28 { 29 HIVIEW_LOGI("EventsPoster::PostAppStartEvent"); 30 AppStartInfo appStartInfo = ConvertToAppStartInfo(evt); 31 observer->PostAppStartEvent(appStartInfo); 32 } 33 PostScrollJankEvent(const ScrollJankEventInfo& evt)34void EventsPoster::PostScrollJankEvent(const ScrollJankEventInfo& evt) 35 { 36 ScrollJankInfo scrollJankInfo = ConvertToScrollJankInfo(evt); 37 observer->PostScrollJankEvent(scrollJankInfo); 38 } 39 ConvertToAppStartInfo(const AppStartEventInfo& event)40AppStartInfo EventsPoster::ConvertToAppStartInfo(const AppStartEventInfo& event) 41 { 42 AppStartInfo info; 43 info.appPid = event.appPid; 44 info.versionCode = event.versionCode; 45 info.versionName = event.versionName; 46 info.processName = event.processName; 47 info.bundleName = event.bundleName; 48 info.abilityName = event.abilityName; 49 info.pageUrl = event.pageUrl; 50 info.sceneId = event.sceneId; 51 info.startType = event.startType; 52 info.sourceType = event.sourceType; 53 info.inputTime = event.inputTime; 54 info.responseLatency = event.responseLatency; 55 info.launcherToAmsStartAbilityDur = event.launcherToAmsStartAbilityDur; 56 info.amsStartAbilityToProcessStartDuration = event.amsStartAbilityToProcessStartDuration; 57 info.amsProcessStartToAppAttachDuration = event.amsProcessStartToAppAttachDuration; 58 info.amsAppAttachToAppForegroundDuration = event.amsAppAttachToAppForegroundDuration; 59 info.amsStartAbilityToAppForegroundDuration = event.amsStartAbilityToAppForegroundDuration; 60 info.amsAppFgToAbilityFgDur = event.amsAppFgToAbilityFgDur; 61 info.amsAbilityFgToWmsStartWinDur = event.amsAbilityFgToWmsStartWinDur; 62 info.drawnLatency = event.drawnLatency; 63 info.firstFrameDrawnLatency = event.firstFrameDrawnLatency; 64 info.animationLatency = event.animationLatency; 65 info.e2eLatency = event.e2eLatency; 66 info.actionId = event.actionId; 67 info.eventId = event.eventId; 68 info.traceFileName = event.traceFileName; 69 info.infoFileName = event.infoFileName; 70 info.happenTime = event.happenTime; 71 return info; 72 } 73 ConvertToScrollJankInfo(const ScrollJankEventInfo& event)74ScrollJankInfo EventsPoster::ConvertToScrollJankInfo(const ScrollJankEventInfo& event) 75 { 76 ScrollJankInfo info; 77 info.appPid = event.appPid; 78 info.versionCode = event.versionCode; 79 info.versionName = event.versionName; 80 info.bundleName = event.bundleName; 81 info.processName = event.processName; 82 info.abilityName = event.abilityName; 83 info.pageUrl = event.pageUrl; 84 info.sceneId = event.sceneId; 85 info.bundleNameEx = event.bundleNameEx; 86 info.isFocus = event.isFocus; 87 info.startTime = event.startTime; 88 info.duration = event.duration; 89 info.totalAppFrames = event.totalAppFrames; 90 info.totalAppMissedFrames = event.totalAppMissedFrames; 91 info.maxAppFrameTime = event.maxAppFrameTime; 92 info.maxAppSeqMissedFrames = event.maxAppSeqMissedFrames; 93 info.isDisplayAnimator = event.isDisplayAnimator; 94 info.totalRenderFrames = event.totalRenderFrames; 95 info.totalRenderMissedFrames = event.totalRenderMissedFrames; 96 info.maxRenderFrameTime = event.maxRenderFrameTime; 97 info.averageRenderFrameTime = event.averageRenderFrameTime; 98 info.maxRenderSeqMissedFrames = event.maxRenderSeqMissedFrames; 99 info.isFoldDisp = event.isFoldDisp; 100 info.traceFileName = event.traceFileName; 101 info.infoFileName = event.infoFileName; 102 info.happenTime = event.happenTime; 103 return info; 104 } 105 } // HiviewDFX 106 } // OHOS