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