page name adapter

Signed-off-by:user.name<zhanghaoshen1@huawei.com>
This commit is contained in:
wenyifei 2024-05-29 14:59:11 +08:00
parent 63a139f2e8
commit f8e66ca055
9 changed files with 58 additions and 1 deletions

View File

@ -79,6 +79,7 @@ constexpr char EVENT_KEY_HOVER_TIME[] = "HOVER_TIME";
constexpr char EVENT_KEY_IS_HOVER_MODE[] = "IS_HOVER_MODE";
constexpr char EVENT_KEY_APP_ROTATION[] = "APP_ROTATION";
constexpr char EVENT_KEY_WINDOW_MODE[] = "WINDOW_MODE";
constexpr char EVENT_KEY_PAGE_NAME[] = "PAGE_NAME";
constexpr int32_t MAX_PACKAGE_NAME_LENGTH = 128;
@ -359,6 +360,7 @@ void EventReport::ReportEventComplete(DataBase& data)
const auto& pageUrl = data.baseInfo.pageUrl;
const auto& versionCode = data.baseInfo.versionCode;
const auto& versionName = data.baseInfo.versionName;
const auto& pageName = data.baseInfo.pageName;
const auto& sceneId = data.sceneId;
const auto& sourceType = GetSourceTypeName(data.sourceType);
auto inputTime = data.inputTime;
@ -376,6 +378,7 @@ void EventReport::ReportEventComplete(DataBase& data)
EVENT_KEY_PAGE_URL, pageUrl,
EVENT_KEY_VERSION_CODE, versionCode,
EVENT_KEY_VERSION_NAME, versionName,
EVENT_KEY_PAGE_NAME, pageName,
EVENT_KEY_SCENE_ID, sceneId,
EVENT_KEY_SOURCE_TYPE, sourceType,
EVENT_KEY_INPUT_TIME, static_cast<uint64_t>(inputTime),
@ -399,6 +402,7 @@ void EventReport::ReportEventJankFrame(DataBase& data)
const auto& pageUrl = data.baseInfo.pageUrl;
const auto& versionCode = data.baseInfo.versionCode;
const auto& versionName = data.baseInfo.versionName;
const auto& pageName = data.baseInfo.pageName;
auto startTime = data.beginVsyncTime;
ConvertRealtimeToSystime(data.beginVsyncTime, startTime);
const auto& durition = (data.endVsyncTime - data.beginVsyncTime) / NS_TO_MS;
@ -418,6 +422,7 @@ void EventReport::ReportEventJankFrame(DataBase& data)
EVENT_KEY_PAGE_URL, pageUrl,
EVENT_KEY_VERSION_CODE, versionCode,
EVENT_KEY_VERSION_NAME, versionName,
EVENT_KEY_PAGE_NAME, pageName,
EVENT_KEY_STARTTIME, static_cast<uint64_t>(startTime),
EVENT_KEY_DURITION, static_cast<uint64_t>(durition),
EVENT_KEY_TOTAL_FRAMES, totalFrames,
@ -440,6 +445,7 @@ void EventReport::ReportJankFrameApp(JankInfo& info)
const auto& pageUrl = info.baseInfo.pageUrl;
const auto& versionCode = info.baseInfo.versionCode;
const auto& versionName = info.baseInfo.versionName;
const auto& pageName = info.baseInfo.pageName;
const auto& skippedFrameTime = info.skippedFrameTime;
HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName,
OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
@ -449,6 +455,7 @@ void EventReport::ReportJankFrameApp(JankInfo& info)
EVENT_KEY_PAGE_URL, pageUrl,
EVENT_KEY_VERSION_CODE, versionCode,
EVENT_KEY_VERSION_NAME, versionName,
EVENT_KEY_PAGE_NAME, pageName,
EVENT_KEY_SKIPPED_FRAME_TIME, static_cast<uint64_t>(skippedFrameTime));
ACE_SCOPED_TRACE("JANK_FRAME_APP: skipppedFrameTime=%lld(ms)", static_cast<long long>(skippedFrameTime / NS_TO_MS));
}
@ -462,6 +469,7 @@ void EventReport::ReportJankFrameFiltered(JankInfo& info)
const auto& pageUrl = info.baseInfo.pageUrl;
const auto& versionCode = info.baseInfo.versionCode;
const auto& versionName = info.baseInfo.versionName;
const auto& pageName = info.baseInfo.pageName;
const auto& skippedFrameTime = info.skippedFrameTime;
const auto& windowName = info.windowName;
HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, eventName,
@ -472,11 +480,18 @@ void EventReport::ReportJankFrameFiltered(JankInfo& info)
EVENT_KEY_PAGE_URL, pageUrl,
EVENT_KEY_VERSION_CODE, versionCode,
EVENT_KEY_VERSION_NAME, versionName,
EVENT_KEY_PAGE_NAME, pageName,
EVENT_KEY_SKIPPED_FRAME_TIME, static_cast<uint64_t>(skippedFrameTime));
ACE_SCOPED_TRACE("JANK_FRAME_FILTERED: skipppedFrameTime=%lld(ms), windowName=%s",
static_cast<long long>(skippedFrameTime / NS_TO_MS), windowName.c_str());
}
void EventReport::ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName)
{
HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::ACE, "APP_PAGE_INFO_UPDATE",
OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
EVENT_KEY_PAGE_URL, pageUrl, EVENT_KEY_BUNDLE_NAME, bundleName);
}
void EventReport::ReportDoubleClickTitle(int32_t stateChange)
{

View File

@ -77,4 +77,6 @@ void EventReport::ReportFunctionTimeout(const std::string& functionName, int64_t
void EventReport::ReportHoverStatusChange(int32_t foldStatus, int32_t time, bool isHoverMode,
int32_t appRotation, int32_t windowMode) {}
void EventReport::ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName) {}
} // namespace OHOS::Ace

View File

@ -194,6 +194,7 @@ public:
static void ReportFunctionTimeout(const std::string& functionName, int64_t time, int32_t threshold);
static void ReportHoverStatusChange(int32_t foldStatus, int32_t time, bool isHoverMode,
int32_t appRotation, int32_t windowMode);
static void ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName);
private:
static void SendEventInner(const EventInfo& eventInfo);

View File

@ -269,6 +269,7 @@ void PerfMonitor::Start(const std::string& sceneId, PerfActionType type, const s
if (IsSceneIdInSceneWhiteList(sceneId)) {
isExceptAnimator = true;
}
ACE_SCOPED_TRACE("Animation start and current sceneId=%s", sceneId.c_str());
if (record == nullptr) {
record = new SceneRecord();
record->InitRecord(sceneId, type, mSourceType, note, inputTime);
@ -282,6 +283,7 @@ void PerfMonitor::End(const std::string& sceneId, bool isRsRender)
{
std::lock_guard<std::mutex> Lock(mMutex);
SceneRecord* record = GetRecord(sceneId);
ACE_SCOPED_TRACE("Animation end and current sceneId=%s", sceneId.c_str());
if (record != nullptr) {
if (IsSceneIdInSceneWhiteList(sceneId)) {
isExceptAnimator = false;
@ -369,6 +371,21 @@ std::string PerfMonitor::GetPageUrl()
return baseInfo.pageUrl;
}
void PerfMonitor::SetPageName(const std::string& pageName)
{
baseInfo.pageName = pageName;
}
std::string PerfMonitor::GetPageName()
{
return baseInfo.pageName;
}
void PerfMonitor::ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName)
{
EventReport::ReportPageShowMsg(pageUrl, bundleName);
}
void PerfMonitor::RecordBaseInfo(SceneRecord* record)
{
baseInfo.pid = AceApplicationInfo::GetInstance().GetPid();

View File

@ -58,6 +58,7 @@ struct BaseInfo {
std::string processName {""};
std::string abilityName {""};
std::string pageUrl {""};
std::string pageName {""};
std::string note {""};
};
@ -126,10 +127,13 @@ public:
void ReportJankFrameApp(double jank);
void SetPageUrl(const std::string& pageUrl);
std::string GetPageUrl();
void SetPageName(const std::string& pageName);
std::string GetPageName();
void SetAppForeground(bool isShow);
void SetAppStartStatus();
static PerfMonitor* GetPerfMonitor();
static PerfMonitor* pMonitor;
void ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName);
private:
SceneRecord* GetRecord(const std::string& sceneId);

View File

@ -628,6 +628,9 @@ void NavigationPattern::NotifyPageShow(const std::string& pageName)
auto pageUrlChecker = container->GetPageUrlChecker();
CHECK_NULL_VOID(pageUrlChecker);
pageUrlChecker->NotifyPageShow(pageName);
if (PerfMonitor::GetPerfMonitor() != nullptr) {
PerfMonitor::GetPerfMonitor()->SetPageName(pageName);
}
}
void NavigationPattern::TransitionWithOutAnimation(const RefPtr<NavDestinationGroupNode>& preTopNavDestination,

View File

@ -221,7 +221,8 @@ void PagePattern::OnShow()
state_ = RouterPageState::ON_PAGE_SHOW;
UIObserverHandler::GetInstance().NotifyRouterPageStateChange(GetPageInfo(), state_);
JankFrameReport::GetInstance().StartRecord(pageInfo_->GetPageUrl());
PerfMonitor::GetPerfMonitor()->SetPageUrl(pageInfo_->GetPageUrl());
std::string bundleName = container->GetBundleName();
NotifyPerfMonitorPageMsg(pageInfo_->GetPageUrl(), bundleName);
auto pageUrlChecker = container->GetPageUrlChecker();
if (pageUrlChecker != nullptr) {
pageUrlChecker->NotifyPageShow(pageInfo_->GetPageUrl());
@ -429,6 +430,16 @@ bool PagePattern::RemoveOverlay()
return overlayManager_->RemoveOverlay(true);
}
void PagePattern::NotifyPerfMonitorPageMsg(const std::string& pageUrl, const std::string& bundleName)
{
if (PerfMonitor::GetPerfMonitor() != nullptr) {
PerfMonitor::GetPerfMonitor()->SetPageUrl(pageUrl);
// The page contains only page url but not the page name
PerfMonitor::GetPerfMonitor()->SetPageName("");
PerfMonitor::GetPerfMonitor()->ReportPageShowMsg(pageUrl, bundleName);
}
}
void PagePattern::MarkDirtyOverlay()
{
CHECK_NULL_VOID(overlayManager_);

View File

@ -217,6 +217,8 @@ private:
return true;
}
void NotifyPerfMonitorPageMsg(const std::string& pageUrl, const std::string& bundleName);
RefPtr<PageInfo> pageInfo_;
RefPtr<OverlayManager> overlayManager_;

View File

@ -67,4 +67,6 @@ std::string PerfMonitor::GetPageUrl()
void PerfMonitor::SetAppForeground(bool isShow) {}
void PerfMonitor::SetAppStartStatus() {}
void PerfMonitor::SetPageName(const std::string& pageName) {}
void PerfMonitor::ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName) {}
} // namespace OHOS::Ace