From c88be1182172579d85dbfd2e0db8e727467ba638 Mon Sep 17 00:00:00 2001 From: rongkunshi Date: Thu, 24 Feb 2022 11:49:43 +0800 Subject: [PATCH 1/7] frame_aware_sched:Prepare for scheme open ohos inclusion category:feature issue:NA CVE:NA ------------------------------------- 1.fix rtg node path 2.policy-part: bug fix 3.collector-part: bug fix & add interface for dynamic load. 4.msg test fix 5.total switch by rtgEnable Signed-off-by: rongkunshi --- common/include/rtg_interface.h | 6 +- .../include/rme_core_sched.h | 6 +- .../src/frame_msg_mgr.cpp | 6 +- .../src/rme_core_sched.cpp | 69 ++++--- .../src/rme_scene_sched.cpp | 4 +- .../frame_aware_policy/include/app_info.h | 2 +- .../frame_aware_policy/include/app_info_mgr.h | 6 +- .../core/frame_aware_policy/src/app_info.cpp | 9 +- .../frame_aware_policy/src/app_info_mgr.cpp | 143 +++++++------- .../src/intellisense_server.cpp | 33 ++-- .../frame_aware_policy/src/rtg_msg_mgr.cpp | 8 +- .../innerkits/frameintf/frame_ui_intf.cpp | 75 +++++++- .../innerkits/frameintf/rtg_interface.cpp | 32 +++- profiles/hwrme.xml | 2 +- test/unittest/phone/frame_msg_intf_test.cpp | 176 +++++++++++++----- 15 files changed, 395 insertions(+), 182 deletions(-) diff --git a/common/include/rtg_interface.h b/common/include/rtg_interface.h index f6e07d8..12e14ab 100644 --- a/common/include/rtg_interface.h +++ b/common/include/rtg_interface.h @@ -83,6 +83,7 @@ enum rtg_sched_cmdid { LIST_RTG, LIST_RTG_THREAD, SEARCH_RTG, + GET_ENABLE, RTG_CTRL_MAX_NR, }; @@ -98,13 +99,14 @@ extern "C"{ int SetFrameRateAndPrioType(int rtgId, int rate, int rtgType); int SetMaxVipRtgs(int rtframe); int BeginFrameFreq(int grpId, int stateParam); - int EndFrameFreq(int grpId, int stateParam); - int EndScene(int rtgId); + int EndFrameFreq(int grpId); + int EndScene(int grpId); int SetMinUtil(int grpId, int stateParam); int SetMargin(int grpId, int stateParam); int ListRtgThread(int grpId, vector *rs); // list all tasks of grpId; int ListRtgGroup(vector *rs); int SearchRtgForTid(int stateParam); + int GetRtgEnable(); } } // namespace RME diff --git a/frameworks/core/frame_aware_collector/include/rme_core_sched.h b/frameworks/core/frame_aware_collector/include/rme_core_sched.h index 7355f3c..e21bb39 100644 --- a/frameworks/core/frame_aware_collector/include/rme_core_sched.h +++ b/frameworks/core/frame_aware_collector/include/rme_core_sched.h @@ -27,7 +27,7 @@ public: RmeCoreSched(); ~RmeCoreSched(); - void Init(); + bool Init(); void BeginFlushAnimation(); void EndFlushAnimation(); @@ -49,6 +49,10 @@ public: RmeCoreSched(const RmeCoreSched &) = delete; RmeCoreSched &operator=(const RmeCoreSched &) = delete; +private: + int m_currentPid = -1; + int m_currentRtg = -1; + bool isRenderAdd = false; }; } // namespace RME diff --git a/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp b/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp index 787fdf4..e3e8526 100644 --- a/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp +++ b/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp @@ -40,7 +40,7 @@ bool FrameMsgMgr::Init() } if (!rmeScene->Init()) { - RME_LOGE("[Init]:inited success!"); + RME_LOGE("[Init]:inited failed!"); return false; } RME_LOGI("[Init]:inited success!"); @@ -53,9 +53,6 @@ void FrameMsgMgr::EventUpdate(FrameEvent event, EventState value) case FrameEvent::EVENT_SET_PARAM: SetSchedParam(); break; - case FrameEvent::EVENT_RTG_ENABLE: - RME_LOGI("[EventUpdate]:rtg enable!"); - break; default: HandleDefaultEvent(event, value); break; @@ -68,7 +65,6 @@ void FrameMsgMgr::UpdateScene(SceneEvent scene) if (scene < SceneEvent::SCENE_INVALID || scene >= SceneEvent::SCENE_MAX) { scene = SceneEvent::SCENE_INVALID; } - sceneType = scene; } diff --git a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp index 80a7729..569085e 100644 --- a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp +++ b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp @@ -28,27 +28,36 @@ RmeCoreSched::RmeCoreSched() RmeCoreSched::~RmeCoreSched() { + EnableRtg(false); return; } -void RmeCoreSched::Init() +bool RmeCoreSched::Init() { - int ret = EnableRtg(true); - if (ret < 0) { - RME_LOGE("[Init]: enableRtg failed!"); + int ret = GetRtgEnable(); + if (ret) { + RME_LOGE("[Init]: rtgEnabled! scheme Open!ret: %{public}d", ret); + } else { + RME_LOGE("[Init]: do not enabled!ret: %{public}d", ret); } - return; + return ret; } void RmeCoreSched::BeginFlushAnimation() { + m_currentPid = getpid(); int tid = gettid(); - int rtGrp = SearchRtgForTid(tid); - if (rtGrp < 0) { - RME_LOGE("[BeginFlushAnimation]: search rtg for tid failed!"); - } - int ret = BeginFrameFreq(rtGrp, 0); - RME_LOGI("[BeginFlushAnimation]: set BeginFrameFreq(2, 0), ret: %{public}d!",ret); + if (m_currentRtg == -1) { + m_currentRtg = SearchRtgForTid(m_currentPid); + if (m_currentRtg <= 0) { + RME_LOGE("[BeginFlushAnimation]:Search rtg for pid %{public}d failed! m_currentRtg: %{public}d", m_currentPid, m_currentRtg); + return; + } else { + RME_LOGI("[BeginFlushAnimation]:Search rtg sucess m_currentRtg, val:%{public}d", m_currentRtg); + } + } + int ret = BeginFrameFreq(m_currentRtg, 0); + RME_LOGI("[BeginFlushAnimation]: set BeginFrameFreq, currentRtg:%{public}d, currentPid:%{public}d, tid:%{public}d, ret:%{public}d!", m_currentRtg, m_currentPid, tid, ret); return; } @@ -58,6 +67,7 @@ void RmeCoreSched::EndFlushAnimation() void RmeCoreSched::BeginFlushBuild() { + SetMargin(m_currentRtg, -3); } void RmeCoreSched::EndFlushBuild() @@ -74,6 +84,7 @@ void RmeCoreSched::EndFlushLayout() void RmeCoreSched::BeginFlushRender() { + SetMargin(m_currentRtg, -5); } void RmeCoreSched::EndFlushRender() @@ -90,30 +101,40 @@ void RmeCoreSched::ProcessCommandsStart() void RmeCoreSched::AnimateStart() { + if (isRenderAdd) { + return; + } + if (m_currentRtg <= 0) { + RME_LOGE("[AnimateStart]: search rtgGrp->m_currentRtg error! m_currentRtg:%{public}d, m_currentPid:%{public}d", m_currentRtg, m_currentPid); + return; + } int rendertid = gettid(); - int uitid = getpid(); // ui tid equals pid now. - int rtGrp = SearchRtgForTid(uitid); - if (rtGrp < 0) { - RME_LOGE("[AnimateStart]: search rtg for tid failed! uitid:%{public}d", uitid); + int pid = getpid(); // ui tid equals pid now. + int ret = AddThreadToRtg(rendertid, m_currentRtg); + if (ret) { // 1 means false. + RME_LOGE("[AnimateStart]:add rtg grp failed!, ret: %{public}d, rtGrp: %{public}d, rendertid: \ + %{public}d, m_currentPid:%{public}d, pid: %{public}d", ret, m_currentRtg, rendertid, m_currentPid, pid); + } else { + isRenderAdd = true; + RME_LOGI("[AnimateStart]:add rtg grp SUCESS! rendertid: \ + %{public}d, pid: %{public}d, rtGrp: %{public}d, m_currentPid:%{public}d", rendertid, pid, m_currentRtg, m_currentPid); } - int ret = AddThreadToRtg(rendertid, rtGrp); - RME_LOGE("[AnimateStart]:add rtg grp failed! ret: %{public}d, rendertid: \ - %{public}d, rtGrp: %{public}d", ret, rendertid, rtGrp); } void RmeCoreSched::RenderStart() { + SetMargin(m_currentRtg, -7); } void RmeCoreSched::SendCommandsStart() { - int tid = gettid(); - int rtGrp = SearchRtgForTid(tid); - if (rtGrp < 0) { - RME_LOGE("[BeginFlushAnimation]: search rtg for tid failed!"); + int pid = getpid(); + if (m_currentRtg <= 0) { + RME_LOGE("[SendCommandStart]: m_currentRtg error! rtGrp:%{public}d, m_currentPid:%{public}d, pid:%{public}d!", m_currentRtg, m_currentPid, pid); + return; } - int ret = EndFrameFreq(rtGrp, 16); - RME_LOGI("[SendCommandsStart]: set EndFrameFreq(2, 16), ret: %{public}d!", ret); + int ret = EndFrameFreq(m_currentRtg); + RME_LOGI("[SendCommandsStart]: set EndFrameFreq, ret: %{public}d, m_currentPid:%{publid}d, pid:%{public}d!", ret, m_currentPid, pid); } } // namespace RME diff --git a/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp b/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp index e6be973..ec8d502 100644 --- a/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp +++ b/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp @@ -42,8 +42,8 @@ bool RmeSceneSched::Init() if (rmeCoreSched == nullptr) { return false; } - RME_LOGI("[Init]:RmeSceneSched init success!"); - return true; + bool ret = rmeCoreSched->Init(); + return ret; } void RmeSceneSched::BeginFlushAnimation() diff --git a/frameworks/core/frame_aware_policy/include/app_info.h b/frameworks/core/frame_aware_policy/include/app_info.h index c7eee02..d34182e 100644 --- a/frameworks/core/frame_aware_policy/include/app_info.h +++ b/frameworks/core/frame_aware_policy/include/app_info.h @@ -54,7 +54,7 @@ private: int m_uiTid; int m_renderTid; int m_isFocus; - int m_rtgrp; + int m_rtGrp; AppState m_appState; }; diff --git a/frameworks/core/frame_aware_policy/include/app_info_mgr.h b/frameworks/core/frame_aware_policy/include/app_info_mgr.h index 25b8778..db2331a 100644 --- a/frameworks/core/frame_aware_policy/include/app_info_mgr.h +++ b/frameworks/core/frame_aware_policy/include/app_info_mgr.h @@ -17,6 +17,8 @@ #define APP_INFO_MGR_H #include +#include +#include #include "app_info.h" #include "rme_log_domain.h" @@ -34,11 +36,9 @@ public: void OnBackgroundChanged(const int pid, const std::string appName); void OnAppTerminateChanged(const int pid, const std::string appName); void OnWindowFocus(const int pid, bool isFocus); - void OnUiProcessStart(const int pid, const int tid); - void OnRenderProcessStart(const int pid, const int tid); bool OnProcessDied(const int pid, const int tid); std::shared_ptr GetFocusApp() const; - void SetFocusApp(const int pid); + void SetFocusApp(const int pid, bool isFocus); int GetAppRtgrp(const int pid); private: diff --git a/frameworks/core/frame_aware_policy/src/app_info.cpp b/frameworks/core/frame_aware_policy/src/app_info.cpp index 864d6a6..826f81f 100644 --- a/frameworks/core/frame_aware_policy/src/app_info.cpp +++ b/frameworks/core/frame_aware_policy/src/app_info.cpp @@ -18,12 +18,17 @@ namespace OHOS { namespace RME { +namespace { +const int RTG_GRP_INIT = -1; +} + AppInfo::AppInfo(std::string appName, int pid, int uiTid, int renderTid, int isFocus, AppState state) : m_appName(appName), m_pid(pid), m_uiTid(uiTid), m_renderTid(renderTid), m_isFocus(isFocus), + m_rtGrp(RTG_GRP_INIT), m_appState(state) {} @@ -84,12 +89,12 @@ AppState AppInfo::GetAppState() void AppInfo::SetRtgrp(const int grpNum) { - this->m_rtgrp = grpNum; + this->m_rtGrp = grpNum; } int AppInfo::GetRtgrp() { - return m_rtgrp; + return m_rtGrp; } diff --git a/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp b/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp index d40270e..a0c322b 100644 --- a/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp +++ b/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp @@ -22,123 +22,132 @@ DEFINE_RMELOG_SERVICE("ueaServer-AppInfoMgr"); namespace { constexpr int INIT_VAL = -1; + std::mutex mMutex; } IMPLEMENT_SINGLE_INSTANCE(AppInfoMgr); void AppInfoMgr::OnForegroundChanged(const int pid, const std::string appName, const int rtGrp) { - RME_LOGI("[OnForegroundChanged]:pid %{public}d, appname:%{public}s", pid, appName.c_str()); - std::map>::iterator it = mForegroundAppList.find(pid); - if (it != mForegroundAppList.end()) { - mForegroundAppList[pid]->SetAppName(appName); - mForegroundAppList[pid]->SetAppState(AppState::APP_FOREGROUND); + if (mBackgroundAppList.count(pid)) { + RME_LOGE("[OnForegroundChanged]: back yes!pid:%{public}d", pid); + mBackgroundAppList[pid]->SetAppName(appName); + mBackgroundAppList[pid]->SetAppState(AppState::APP_FOREGROUND); + mForegroundAppList[pid] = mBackgroundAppList[pid]; + mBackgroundAppList.erase(pid); } else { - std::map>::iterator itB = mBackgroundAppList.find(pid); - if (itB != mBackgroundAppList.end()) { - mBackgroundAppList[pid]->SetAppName(appName); - mBackgroundAppList[pid]->SetAppState(AppState::APP_FOREGROUND); - mForegroundAppList[pid] = mBackgroundAppList[pid]; - mBackgroundAppList.erase(pid); - } else { - auto appInfo = std::make_shared(appName, pid, INIT_VAL, INIT_VAL, INIT_VAL, AppState::APP_FOREGROUND); - mForegroundAppList[pid] = appInfo; - } + RME_LOGE("[OnForegroundChanged]: back No!pid:%{public}d", pid); + auto appInfo = std::make_shared(appName, pid, INIT_VAL, INIT_VAL, INIT_VAL, AppState::APP_FOREGROUND); + mForegroundAppList[pid] = appInfo; } mForegroundAppList[pid]->SetRtgrp(rtGrp); - RME_LOGI("[OnForegroundChanged]rtgrp:%{public}d:", rtGrp); + + int isExistFore = mForegroundAppList.count(pid); + int isExistBack = mBackgroundAppList.count(pid); + RME_LOGE("[OnForegroundChanged]:isExistFore: %{public}d, size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, mForegroundAppList.size(), isExistBack, mBackgroundAppList.size()); + + RME_LOGE("[OnForegroundChanged]:pid:%{public}d, rtgrp:%{public}d, \ + app_state: %{public}d", pid, rtGrp, static_cast(mForegroundAppList[pid]->GetAppState())); } void AppInfoMgr::OnBackgroundChanged(const int pid, const std::string appName) { - RME_LOGI("[OnBackgroundChanged]:pid:%{public}d, appName:%{public}s", pid, appName.c_str()); std::map>::iterator it = mForegroundAppList.find(pid); if (it != mForegroundAppList.end()) { mForegroundAppList[pid]->SetAppState(AppState::APP_BACKGROUND); + mForegroundAppList[pid]->SetRtgrp(INIT_VAL); mBackgroundAppList[pid] = mForegroundAppList[pid]; mForegroundAppList.erase(pid); } else { - RME_LOGE("[OnBackgroundChanged]:unfind appName in foreground app when go to background!"); + RME_LOGE("[OnBackgroundChanged]:unfind app in foreground app when go to background! pid:%{public}d", pid); } + mBackgroundAppList[pid]->SetRtgrp(INIT_VAL); + int isExistFore = mForegroundAppList.count(pid); + int isExistBack = mBackgroundAppList.count(pid); + RME_LOGE("[OnBackgroundChanged]:isExistFore: %{public}d,size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, mForegroundAppList.size(), isExistBack, mBackgroundAppList.size()); + + RME_LOGE("[OnBackgroundChanged]:pid:%{public}d, appName:%{public}s", pid, appName.c_str()); } void AppInfoMgr::OnAppTerminateChanged(const int pid, const std::string appName) { - RME_LOGI("[OnAppTerminatedChanged]: pid: %{public}d, appName: %{public}s:", pid, appName.c_str()); mForegroundAppList.erase(pid); mBackgroundAppList.erase(pid); + + int isExistFore = mForegroundAppList.count(pid); + int isExistBack = mBackgroundAppList.count(pid); + RME_LOGE("[OnAppTerminatedChanged]:isExistFore: %{public}d,size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, isExistBack, mForegroundAppList.size(), mBackgroundAppList.size()); + + RME_LOGE("[OnAppTerminatedChanged]: pid: %{public}d, appName: %{public}s, \ + ", pid, appName.c_str()); } void AppInfoMgr::OnWindowFocus(const int pid, bool isFocus) { - RME_LOGI("[OnAppFocus]: pid:%{public}d, isFocus:%{public}d", pid, isFocus); + // isFocus: 0:focused, 1:unfocused. std::shared_ptr appInfo = nullptr; - if (mForegroundAppList.find(pid) != mForegroundAppList.end()) { + if (!isFocus) { appInfo = mForegroundAppList[pid]; - mForegroundAppList.erase(pid); - } else if (mBackgroundAppList.find(pid) != mBackgroundAppList.end()) { - appInfo = mBackgroundAppList[pid]; - mBackgroundAppList.erase(pid); + if (appInfo == nullptr) { + RME_LOGE("[OnAppFocus]:not found pid %{public}d in fore map", pid); + return; + } + } else { - appInfo = std::make_shared("", pid, INIT_VAL, INIT_VAL, isFocus, AppState::APP_FOREGROUND); + appInfo = mBackgroundAppList[pid]; + if (appInfo == nullptr) { + RME_LOGE("[OnAppFocus]:not found pid %{public}d in back map", pid); + return; + } } + SetFocusApp(pid, isFocus); appInfo->SetFocusState(isFocus); - if (isFocus) { - mForegroundAppList[pid] = appInfo; - SetFocusApp(pid); - } else { - mBackgroundAppList[pid] = appInfo; - } -} + int isExistFore = mForegroundAppList.count(pid); + int isExistBack = mBackgroundAppList.count(pid); + RME_LOGE("[OnAppFocus]:isExistFore:isExistFore: %{public}d,size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, mForegroundAppList.size(), isExistBack, mBackgroundAppList.size()); -void AppInfoMgr::OnUiProcessStart(const int pid, const int tid) -{ - RME_LOGI("[OnUiProcessStart]:pid:%{public}d, uitid:%{public}d.\n", pid, tid); - std::shared_ptr appInfo = nullptr; - if (mForegroundAppList.find(pid) != mForegroundAppList.end()) { - appInfo = mForegroundAppList[pid]; - mForegroundAppList.erase(pid); - } else if (mBackgroundAppList.find(pid) != mBackgroundAppList.end()) { - appInfo = mBackgroundAppList[pid]; - mBackgroundAppList.erase(pid); - } else { - appInfo = std::make_shared("", pid, tid, INIT_VAL, INIT_VAL, AppState::APP_UNKNOWN); - } - appInfo->SetUiTid(tid); + RME_LOGE("[OnAppFocus]: pid:%{public}d, isFocus:%{public}d, \ + ", pid, isFocus); } bool AppInfoMgr::OnProcessDied(const int pid, const int tid) { + // TO DO: need to add tid set mgr. now has process then erase. bool deleted = false; + bool isUi = pid == tid ? true : false; if (mForegroundAppList.count(pid)) { - mForegroundAppList.erase(pid); + if (isUi) { + mForegroundAppList.erase(pid); + } else { + // TO DO: if render died, do not need process. + mForegroundAppList[pid]->SetRenderTid(INIT_VAL); + } deleted = true; } else if (mBackgroundAppList.count(pid)) { - mBackgroundAppList.erase(pid); + if (isUi) { + mBackgroundAppList.erase(pid); + } else { + // TO DO: if render died, do not need process. + mBackgroundAppList[pid]->SetRenderTid(INIT_VAL); + } } - RME_LOGI("[OnProcessDied]: pid: %{public}d, tid:%{public}d, deleted:%{public}d.\n", pid, tid, deleted); + int isExistFore = mForegroundAppList.count(pid); + int isExistBack = mBackgroundAppList.count(pid); + RME_LOGE("[OnProcessDied]:isExistFore: %{public}d,size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, isExistBack, mForegroundAppList.size(), mBackgroundAppList.size()); + + RME_LOGE("[OnProcessDied]: pid: %{public}d, tid:%{public}d, deleted:%{public}d, isExist:foreground:%{public}d, \ + background:%{public}d.", pid, tid, deleted, mForegroundAppList.count(pid), mBackgroundAppList.count(pid)); return deleted; } -void AppInfoMgr::OnRenderProcessStart(const int pid, const int tid) +void AppInfoMgr::SetFocusApp(const int pid, bool isFocus) { - RME_LOGI("[OnRenderProcessStart]:pid:%{public}d, tid:%{public}d.\n", pid, tid); - std::shared_ptr appInfo = nullptr; - if (mForegroundAppList.find(pid) != mForegroundAppList.end()) { - appInfo = mForegroundAppList[pid]; - mForegroundAppList.erase(pid); - } else if (mBackgroundAppList.find(pid) != mBackgroundAppList.end()) { - appInfo = mBackgroundAppList[pid]; - mBackgroundAppList.erase(pid); + if (!isFocus) { + mFocusApp = mForegroundAppList[pid]; } else { - appInfo = std::make_shared("", pid, INIT_VAL, tid, INIT_VAL, AppState::APP_UNKNOWN); + mFocusApp = nullptr; } - appInfo->SetUiTid(tid); -} - -void AppInfoMgr::SetFocusApp(const int pid) -{ - mFocusApp = mForegroundAppList[pid]; + RME_LOGE("[SetFocusApp]:pid: %{public}d, isFocus%{public}d", pid, isFocus); } std::shared_ptr AppInfoMgr::GetFocusApp() const @@ -154,7 +163,7 @@ int AppInfoMgr::GetAppRtgrp(const int pid) } else if (mBackgroundAppList.count(pid) != 0) { rtGrp = mBackgroundAppList[pid]->GetRtgrp(); } else { - RME_LOGI("[GetAppRtgrp]: do not have this pid, please add!"); + RME_LOGE("[GetAppRtgrp]: do not have this pid, please add!"); } return rtGrp; } diff --git a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp index c99d615..a266239 100644 --- a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp +++ b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp @@ -65,19 +65,25 @@ void IntelliSenseServer::ReportMessage(std::string appName, std::string processN int rtGrp = AppInfoMgr::GetInstance().GetAppRtgrp(pid); switch (reason) { case AppStateUpdateReason::APP_FOREGROUND: - rtGrp = RtgMsgMgr::GetInstance().OnForeground(appName, pid); - AppInfoMgr::GetInstance().OnForegroundChanged(pid, appName, rtGrp); - RME_LOGI("[ReportMessage]: App_foreground!"); + { + rtGrp = RtgMsgMgr::GetInstance().OnForeground(appName, pid); + AppInfoMgr::GetInstance().OnForegroundChanged(pid, appName, rtGrp); + RME_LOGI("[ReportMessage]: App_foreground! rtGrp: %{public}d", rtGrp); + } break; case AppStateUpdateReason::APP_BACKGROUND: - RtgMsgMgr::GetInstance().OnBackground(appName, pid, rtGrp); - AppInfoMgr::GetInstance().OnBackgroundChanged(pid, appName); - RME_LOGI("[ReportMessage]: App_background!"); + { + RtgMsgMgr::GetInstance().OnBackground(appName, pid, rtGrp); + AppInfoMgr::GetInstance().OnBackgroundChanged(pid, appName); + RME_LOGI("[ReportMessage]: App_background! rtGrp: %{public}d", rtGrp); + } break; case AppStateUpdateReason::APP_TERMINATED: - RtgMsgMgr::GetInstance().ProcessDied(pid, -1); - AppInfoMgr::GetInstance().OnAppTerminateChanged(pid, appName); - RME_LOGI("[ReportMessage]: App terminated!"); + { + RtgMsgMgr::GetInstance().ProcessDied(pid, -1); + AppInfoMgr::GetInstance().OnAppTerminateChanged(pid, appName); + RME_LOGI("[ReportMessage]: App terminated! rtGrp: %{public}d", rtGrp); + } break; default: RME_LOGI("[ReportMessage]: get unuse app state msg!"); @@ -90,22 +96,23 @@ void IntelliSenseServer::ReportWindowFocus(const int pid, int isFocus) { int rtGrp = AppInfoMgr::GetInstance().GetAppRtgrp(pid); switch (isFocus) { - case static_cast(WindowState::FOCUS_YES): + case static_cast(WindowState::FOCUS_YES): // isFocus: 0 { rtGrp = RtgMsgMgr::GetInstance().OnForeground("", pid); AppInfoMgr::GetInstance().OnForegroundChanged(pid, "", rtGrp); - RME_LOGI("[ReportWindowFocus]: Focus yes!"); + RME_LOGI("[ReportWindowFocus]: Focus yes!rtGrp: %{public}d", rtGrp); } break; - case static_cast(WindowState::FOCUS_NO): + case static_cast(WindowState::FOCUS_NO): // isFocus: 1 { RtgMsgMgr::GetInstance().OnBackground("", pid, rtGrp); AppInfoMgr::GetInstance().OnBackgroundChanged(pid, ""); - RME_LOGI("[ReportWindowFocus]: Focus No!"); + RME_LOGI("[ReportWindowFocus]: Focus No!rtGrp: %{public}d", rtGrp); } break; default: RME_LOGI("[ReportWindowFocus]:unknown msg!"); + break; } AppInfoMgr::GetInstance().OnWindowFocus(pid, isFocus); RtgMsgMgr::GetInstance().FocusChanged(pid, isFocus); diff --git a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp index b8392cf..643297b 100644 --- a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp +++ b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp @@ -39,12 +39,14 @@ int RtgMsgMgr::OnForeground(const std::string appName, const int pid) RME_LOGI("[OnForeground]:pid:%{public}d:", pid); int rtGrp = CreateNewRtgGrp(PRIO_TYPE, RT_NUM); RME_LOGI("[OnForeground]: createNewRtgGroup begin! rtGrp:%{public}d, pid: %{public}d", rtGrp, pid); - if (rtGrp < 0) { + if (rtGrp <= 0) { RME_LOGI("[OnForeground]: createNewRtgGroup failed! rtGrp:%{public}d, pid: %{public}d", rtGrp, pid); - rtGrp = -1; return rtGrp; } - AddThreadToRtg(pid, rtGrp); // add ui thread + int ret = AddThreadToRtg(pid, rtGrp); // add ui thread + if (ret != 0) { + RME_LOGI("[OnForeground]: add thread pid: %{public}d to rtgGrp: %{public}d failed! ret: %{publid}d", pid, rtGrp, ret); + } return rtGrp; } diff --git a/interfaces/innerkits/frameintf/frame_ui_intf.cpp b/interfaces/innerkits/frameintf/frame_ui_intf.cpp index b9ca253..76a011a 100644 --- a/interfaces/innerkits/frameintf/frame_ui_intf.cpp +++ b/interfaces/innerkits/frameintf/frame_ui_intf.cpp @@ -51,7 +51,6 @@ int FrameUiIntf::GetSenseSchedEnable() if (!inited) { return static_cast(ErrorCode::FAIL); } - FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::EVENT_RTG_ENABLE, EventState::ENABLE); return static_cast(ErrorCode::SUCC); } @@ -164,5 +163,79 @@ void FrameUiIntf::SendCommandsStart() RME_LOGI("[SendCommandsStart]:success"); } +extern "C" void Init() +{ + FrameUiIntf::GetInstance().Init(); +} + +extern "C" int GetSenseSchedEnable() +{ + return FrameUiIntf::GetInstance().GetSenseSchedEnable(); +} + +extern "C" void BeginFlushAnimation() +{ + FrameUiIntf::GetInstance().BeginFlushAnimation(); +} + +extern "C" void EndFlushAnimation() +{ + FrameUiIntf::GetInstance().EndFlushAnimation(); +} + +extern "C" void BeginFlushBuild() +{ + FrameUiIntf::GetInstance().BeginFlushBuild(); +} + +extern "C" void EndFlushBuild() +{ + FrameUiIntf::GetInstance().EndFlushBuild(); +} + +extern "C" void BeginFlushLayout() +{ + FrameUiIntf::GetInstance().BeginFlushLayout(); +} + +extern "C" void EndFlushLayout() +{ + FrameUiIntf::GetInstance().EndFlushLayout(); +} + +extern "C" void BeginFlushRender() +{ + FrameUiIntf::GetInstance().BeginFlushRender(); +} + +extern "C" void EndFlushRender() +{ + FrameUiIntf::GetInstance().EndFlushRender(); +} + +extern "C" void BeginProcessPostFlush() +{ + FrameUiIntf::GetInstance().BeginProcessPostFlush(); +} + +extern "C" void ProcessCommandsStart() +{ + FrameUiIntf::GetInstance().ProcessCommandsStart(); +} + +extern "C" void AnimateStart() +{ + FrameUiIntf::GetInstance().AnimateStart(); +} + +extern "C" void RenderStart() +{ + FrameUiIntf::GetInstance().RenderStart(); +} + +extern "C" void SendCommandsStart() +{ + FrameUiIntf::GetInstance().SendCommandsStart(); +} } // namespace RME } // namespace OHOS diff --git a/interfaces/innerkits/frameintf/rtg_interface.cpp b/interfaces/innerkits/frameintf/rtg_interface.cpp index 5eaca08..6c6c13e 100644 --- a/interfaces/innerkits/frameintf/rtg_interface.cpp +++ b/interfaces/innerkits/frameintf/rtg_interface.cpp @@ -62,10 +62,12 @@ DEFINE_RMELOG_INTELLISENSE("rtg_interface"); _IOWR(RTG_SCHED_IPC_MAGIC, LIST_RTG_THREAD, struct rtg_grp_data) #define CMD_ID_SEARCH_RTG \ _IOWR(RTG_SCHED_IPC_MAGIC, SEARCH_RTG, struct proc_state_data) +#define CMD_ID_GET_ENABLE \ + _IOWR(RTG_SCHED_IPC_MAGIC, GET_ENABLE, struct rtg_enable_data) int BasicOpenRtgNode() { - char fileName[] = "/proc/rtg_ctrl"; + char fileName[] = "/dev/sched_rtg_ctrl"; int fd = open(fileName, O_RDWR); if (fd < 0) { RME_LOGE("Open fail, errno = %{public}d(%{public}s), dev = %{public}s", errno, strerror(errno), fileName); @@ -143,10 +145,10 @@ int AddThreadToRtg(int tid, int grpId) grp_data.grp_id = grpId; grp_data.rtg_cmd = CMD_ADD_RTG_THREAD; ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data); - if ( ret < 0) { - RME_LOGE("add rtg grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno)); - } else { + if (ret == 0) { RME_LOGI("add rtg grp success"); + } else { + RME_LOGE("add tid %d to grp %d fail with ret %d", tid, grpId, ret); } close(fd); return ret; @@ -178,8 +180,10 @@ int AddThreadsToRtg(vector tids, int grpId) ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data); if ( ret < 0) { RME_LOGE("add rtg grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno)); - } else { + } else if (ret == 0) { RME_LOGI("add rtg grp success"); + } else { + RME_LOGI("add rtg grp failed with %d threads", ret); } close(fd); return ret; @@ -317,12 +321,12 @@ int BeginFrameFreq(int grpId, int stateParam) return ret; } -int EndFrameFreq(int grpId, int stateParam) +int EndFrameFreq(int grpId) { int ret = 0; struct proc_state_data state_data; state_data.grp_id = grpId; - state_data.state_param = stateParam; + state_data.state_param = 0; int fd = BasicOpenRtgNode(); if (fd < 0) { @@ -339,11 +343,11 @@ int EndFrameFreq(int grpId, int stateParam) return ret; } -int EndScene(int rtgId) +int EndScene(int grpId) { int ret = 0; struct proc_state_data state_data; - state_data.grp_id = rtgId; + state_data.grp_id = grpId; int fd = BasicOpenRtgNode(); if (fd < 0) { @@ -481,5 +485,15 @@ int SearchRtgForTid(int tid) return ret; } +int GetRtgEnable() +{ + struct rtg_enable_data enableData; + int fd = BasicOpenRtgNode(); + if (fd < 0) { + return fd; + } + return ioctl(fd, CMD_ID_GET_ENABLE, &enableData); +} + } // namespace RME } // namespace OHOS diff --git a/profiles/hwrme.xml b/profiles/hwrme.xml index 49c6c78..a41326e 100644 --- a/profiles/hwrme.xml +++ b/profiles/hwrme.xml @@ -14,7 +14,7 @@ --> 1.0 - -1 + 0 1 990 1 diff --git a/test/unittest/phone/frame_msg_intf_test.cpp b/test/unittest/phone/frame_msg_intf_test.cpp index 2161920..f89c2be 100644 --- a/test/unittest/phone/frame_msg_intf_test.cpp +++ b/test/unittest/phone/frame_msg_intf_test.cpp @@ -20,6 +20,8 @@ #include "frame_msg_intf.h" #include "app_info_mgr.h" #include "app_info.h" +#include +#include #undef private #undef protected @@ -46,98 +48,176 @@ void FrameMsgIntfTest::TearDownTestCase() void FrameMsgIntfTest::SetUp() { + bool ret = FrameMsgIntf::GetInstance().Init(); + EXPECT_EQ(ret, true); } void FrameMsgIntfTest::TearDown() { + FrameMsgIntf::GetInstance().Stop(); + std::shared_ptr thread = FrameMsgIntf::GetInstance().threadHandler_; + EXPECT_TRUE(thread == nullptr); } -HWTEST_F(FrameMsgIntfTest, FrameMsgIntfInit, TestSize.Level1) +HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoColdStart, TestSize.Level1) { - bool ret = FrameMsgIntf::GetInstance().Init(); - EXPECT_EQ(ret, true); + int pid_1 = 1001; + std::string appName_1 = "com.ohos.frameaware.testColdStart"; + + // app foreground + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); + sleep(1); + std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); + bool isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1); + std::cout << "cold start: size:" << mapList.size() << " count:" << mapList.count(pid_1) << " isAppPidExist:" << isAppPidExist << std::endl; + EXPECT_TRUE(isAppPidExist); // should be true } -HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfo, TestSize.Level1) +HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoWarmStart, TestSize.Level1) { - int pid_1 = 12315; - std::string appName_1 = "com.ohos.frameaware.test1"; - int pid_2 = 12366; - std::string appName_2 = "com.ohos.frameaware.test2"; + int pid_1 = 1002; + std::string appName_1 = "com.ohos.frameaware.testWarmStart"; + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); + + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_BACKGROUND); + + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); + sleep(1); + + std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); + bool isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1); + std::cout << "warm start: size:" << mapList.size() << " count:" << mapList.count(pid_1) << " isAppPidExist:" << isAppPidExist << std::endl; + EXPECT_TRUE(isAppPidExist); // should be true +} + +HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoTerminated, TestSize.Level1) +{ + int pid_1 = 1003; + std::string appName_1 = "com.ohos.frameaware.testAppDied"; + // start + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); + // terminated + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_TERMINATED); + sleep(1); + + std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); + bool isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1); + std::cout << "app terminated: size:" << mapList.size() << " count:" << mapList.count(pid_1) << " isAppPidExist:" << isAppPidExist << std::endl; + EXPECT_FALSE(isAppPidExist); +} + +HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoSwitch, TestSize.Level1) +{ + int pid_1 = 1004; + std::string appName_1 = "com.ohos.frameaware.testAppSwitch1"; + int pid_2 = 10041; + std::string appName_2 = "com.ohos.frameaware.testAppSwitch2"; + // app foreground FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); + FrameMsgIntf::GetInstance().ReportAppInfo(appName_2, appName_2, pid_2, AppStateUpdateReason::APP_FOREGROUND); + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_BACKGROUND); - // app background FrameMsgIntf::GetInstance().ReportAppInfo(appName_2, appName_2, pid_2, AppStateUpdateReason::APP_BACKGROUND); + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); + sleep(1); - + std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); + std::cout << "size:" << mapList.size() << " count:" << mapList.count(pid_1) << std::endl; bool isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1); bool isAppPidExist2 = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_2); - - EXPECT_EQ(isAppPidExist, true); - EXPECT_EQ(isAppPidExist2, false); - // app terminated - FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_TERMINATED); - isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1); - EXPECT_EQ(isAppPidExist, false); + std::cout << "app switch: size:" << mapList.size() << " count:" << mapList.count(pid_1) << " isAppPidExist:" << isAppPidExist << std::endl; + + EXPECT_TRUE(isAppPidExist); // should be true + EXPECT_FALSE(isAppPidExist2); // should be false } HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportWindowFocus, TestSize.Level1) { - int pid_1 = 12234; - int pid_2 = 23134; - int pid_3 = 8912; + int pid_1 = 1005; - std::string appName_1 = "com.ohos.frameaware.test1"; - std::string appName_2 = "com.ohos.frameaware.test2"; - std::string appName_3 = "com.ohos.frameaware.test3"; + std::string appName_1 = "com.ohos.frameaware.testWindowFocus"; // app focus FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); - FrameMsgIntf::GetInstance().ReportAppInfo(appName_2, appName_2, pid_2, AppStateUpdateReason::APP_FOREGROUND); - FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 1); - - // app Unfocus - FrameMsgIntf::GetInstance().ReportAppInfo(appName_3, appName_3, pid_3, AppStateUpdateReason::APP_FOREGROUND); - FrameMsgIntf::GetInstance().ReportWindowFocus(pid_3, 0); + FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 0); + sleep(1); std::shared_ptr app_1 = AppInfoMgr::GetInstance().GetFocusApp(); bool focusSta_1 = app_1->GetFocusState(); - std::shared_ptr app_2 = AppInfoMgr::GetInstance().GetFocusApp(); - bool focusSta_2 = app_2->GetFocusState(); - EXPECT_EQ(focusSta_1, true); - EXPECT_EQ(focusSta_2, false); + EXPECT_EQ(focusSta_1, false); // 0 means focus } -HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportProcessInfo, TestSize.Level1) +HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportWindowUnFocus, TestSize.Level1) { - //process died - int pid_1 = 12435; - int pid_2 = 12436; - int ui_tid = 12435; - int render_tid = 13332; + int pid_1 = 1006; + + std::string appName_1 = "com.ohos.frameaware.testWindowUnfocus"; + + // app focus + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); + FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_BACKGROUND); + FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 0); FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 1); - FrameMsgIntf::GetInstance().ReportWindowFocus(pid_2, 1); + sleep(1); + + std::shared_ptr app_1 = AppInfoMgr::GetInstance().GetFocusApp(); + + EXPECT_EQ(app_1 == nullptr, true); // 1 means unfocus +} + +HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportProcessInfoUiDiedFore, TestSize.Level1) +{ + //process died + int pid_1 = 1007; + int ui_tid = pid_1; + + // foreground ui died + FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 0); + sleep(1); + std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); + EXPECT_EQ(mapList.count(pid_1), 1); FrameMsgIntf::GetInstance().ReportProcessInfo(pid_1, ui_tid, ThreadState::DIED); - FrameMsgIntf::GetInstance().ReportProcessInfo(pid_1, render_tid, ThreadState::DIED); + sleep(1); + std::map> mapList1 = AppInfoMgr::GetInstance().GetForegroundApp(); + EXPECT_EQ(mapList1.count(pid_1), 0); +} - std::shared_ptr app_1 = AppInfoMgr::GetInstance().mForegroundAppList[pid_1]; - EXPECT_EQ(app_1->GetUiTid(), ui_tid); - EXPECT_EQ(app_1->GetRenderTid(), render_tid); +HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportProcessInfoUiDiedBack, TestSize.Level1) +{ + int pid_1 = 1008; + int ui_tid = pid_1; + //background ui died + FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 0); + FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 1); + FrameMsgIntf::GetInstance().ReportProcessInfo(pid_1, ui_tid, ThreadState::DIED); + sleep(1); + std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); + EXPECT_EQ(mapList.count(pid_1), 0); } -HWTEST_F(FrameMsgIntfTest, FrameMsgIntfStop, TestSize.Level1) +HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportProcessInfoRenderDiedFore, TestSize.Level1) { - FrameMsgIntf::GetInstance().Stop(); - std::shared_ptr thread = FrameMsgIntf::GetInstance().threadHandler_; - EXPECT_TRUE(thread == nullptr); + int pid_2 = 1009; + int render_tid = 10091; + + // foreground render died + FrameMsgIntf::GetInstance().ReportWindowFocus(pid_2, 0); + sleep(1); + std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); + EXPECT_EQ(mapList.count(pid_2), 1); + + FrameMsgIntf::GetInstance().ReportProcessInfo(pid_2, render_tid, ThreadState::DIED); + sleep(1); + std::map> mapList2 = AppInfoMgr::GetInstance().GetForegroundApp(); + EXPECT_EQ(mapList2.count(pid_2), 1); } } // namespace RME -- Gitee From dc13e52aacbd872c957b94be26d6952105666a18 Mon Sep 17 00:00:00 2001 From: rongkunshi Date: Thu, 24 Feb 2022 18:31:59 +0800 Subject: [PATCH 2/7] add ace interface-BeginFlushRenderFinish Signed-off-by: rongkunshi --- .../include/frame_scene_sched.h | 6 +-- .../include/rme_core_sched.h | 4 +- .../include/rme_scene_sched.h | 9 ++--- .../src/frame_msg_mgr.cpp | 8 +++- .../src/rme_core_sched.cpp | 40 ++++++++----------- .../src/rme_scene_sched.cpp | 15 ++++++- .../innerkits/frameintf/frame_ui_intf.cpp | 26 ++++++++++++ .../innerkits/frameintf/frame_ui_intf.h | 3 ++ 8 files changed, 74 insertions(+), 37 deletions(-) diff --git a/frameworks/core/frame_aware_collector/include/frame_scene_sched.h b/frameworks/core/frame_aware_collector/include/frame_scene_sched.h index 03398e3..eae6950 100644 --- a/frameworks/core/frame_aware_collector/include/frame_scene_sched.h +++ b/frameworks/core/frame_aware_collector/include/frame_scene_sched.h @@ -26,7 +26,6 @@ public: FrameSceneSched() {}; virtual ~FrameSceneSched() = default; -// virtual void UpdateBufferCount(int count); virtual void BeginFlushAnimation() = 0; virtual void EndFlushAnimation() = 0; virtual void BeginFlushBuild() = 0; @@ -35,16 +34,15 @@ public: virtual void EndFlushLayout() = 0; virtual void BeginFlushRender() = 0; virtual void EndFlushRender() = 0; + virtual void BeginFlushRenderFinish() = 0; + virtual void EndFlushRenderFinish() = 0; virtual void BeginProcessPostFlush() = 0; virtual void ProcessCommandsStart() = 0; virtual void AnimateStart() = 0; virtual void RenderStart() = 0; virtual void SendCommandsStart() = 0; - }; - } // namespace RME - } // namespace OHOS #endif diff --git a/frameworks/core/frame_aware_collector/include/rme_core_sched.h b/frameworks/core/frame_aware_collector/include/rme_core_sched.h index e21bb39..03f2b83 100644 --- a/frameworks/core/frame_aware_collector/include/rme_core_sched.h +++ b/frameworks/core/frame_aware_collector/include/rme_core_sched.h @@ -41,6 +41,9 @@ public: void BeginFlushRender(); void EndFlushRender(); + void BeginFlushRenderFinish(); + void EndFlushRenderFinish(); + void BeginProcessPostFlush(); void ProcessCommandsStart(); void AnimateStart(); @@ -54,7 +57,6 @@ private: int m_currentRtg = -1; bool isRenderAdd = false; }; - } // namespace RME } // namespace OHOS #endif diff --git a/frameworks/core/frame_aware_collector/include/rme_scene_sched.h b/frameworks/core/frame_aware_collector/include/rme_scene_sched.h index 4a301f0..89d8e22 100644 --- a/frameworks/core/frame_aware_collector/include/rme_scene_sched.h +++ b/frameworks/core/frame_aware_collector/include/rme_scene_sched.h @@ -29,6 +29,7 @@ public: RmeSceneSched(); ~RmeSceneSched() override; + bool Init(); void BeginFlushAnimation() override; void EndFlushAnimation() override; @@ -41,20 +42,18 @@ public: void BeginFlushRender() override; void EndFlushRender() override; + void BeginFlushRenderFinish() override; + void EndFlushRenderFinish() override; + void BeginProcessPostFlush() override; void ProcessCommandsStart() override; void AnimateStart() override; void RenderStart() override; void SendCommandsStart() override; - - bool Init(); - private: int curWorkingStatus; RmeCoreSched *rmeCoreSched; }; - - } // namespace RME } // namespace OHOS #endif diff --git a/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp b/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp index e3e8526..6bfd9c2 100644 --- a/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp +++ b/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp @@ -105,6 +105,12 @@ void FrameMsgMgr::HandleDefaultEvent(FrameEvent event, EventState value) scene->EndFlushRender(); } break; + case FrameEvent::FLUSH_RENDER_FINISH: + if (value == EventState::EVENT_ENTER) { + scene->BeginFlushRenderFinish(); + } else { + scene->EndFlushRenderFinish(); + } case FrameEvent::PROCESS_POST_FLUSH: scene->BeginProcessPostFlush(); break; @@ -141,7 +147,5 @@ FrameSceneSched *FrameMsgMgr::GetSceneHandler() const } return rmeScene; } - - } // namespace RME } // namespace OHOS diff --git a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp index 569085e..ca402e8 100644 --- a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp +++ b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp @@ -21,10 +21,7 @@ namespace RME { DEFINE_RMELOG_INTELLISENSE("ueaClient-RmeCoreSched"); -RmeCoreSched::RmeCoreSched() -{ - return; -} +RmeCoreSched::RmeCoreSched() {} RmeCoreSched::~RmeCoreSched() { @@ -57,7 +54,8 @@ void RmeCoreSched::BeginFlushAnimation() } } int ret = BeginFrameFreq(m_currentRtg, 0); - RME_LOGI("[BeginFlushAnimation]: set BeginFrameFreq, currentRtg:%{public}d, currentPid:%{public}d, tid:%{public}d, ret:%{public}d!", m_currentRtg, m_currentPid, tid, ret); + RME_LOGI("[BeginFlushAnimation]: set BeginFrameFreq, currentRtg:%{public}d, currentPid:%{public}d, \ + tid:%{public}d, ret:%{public}d!", m_currentRtg, m_currentPid, tid, ret); return; } @@ -70,34 +68,29 @@ void RmeCoreSched::BeginFlushBuild() SetMargin(m_currentRtg, -3); } -void RmeCoreSched::EndFlushBuild() -{ -} +void RmeCoreSched::EndFlushBuild() {} -void RmeCoreSched::BeginFlushLayout() -{ -} +void RmeCoreSched::BeginFlushLayout() {} -void RmeCoreSched::EndFlushLayout() -{ -} +void RmeCoreSched::EndFlushLayout() {} void RmeCoreSched::BeginFlushRender() { SetMargin(m_currentRtg, -5); } -void RmeCoreSched::EndFlushRender() -{ -} +void RmeCoreSched::EndFlushRender() {} -void RmeCoreSched::BeginProcessPostFlush() +void RmeCoreSched::BeginFlushRenderFinish() { + SetMargin(m_currentRtg, -7); } -void RmeCoreSched::ProcessCommandsStart() -{ -} +void RmeCoreSched::EndFlushRenderFinish() {} + +void RmeCoreSched::BeginProcessPostFlush() {} + +void RmeCoreSched::ProcessCommandsStart() {} void RmeCoreSched::AnimateStart() { @@ -105,7 +98,7 @@ void RmeCoreSched::AnimateStart() return; } if (m_currentRtg <= 0) { - RME_LOGE("[AnimateStart]: search rtgGrp->m_currentRtg error! m_currentRtg:%{public}d, m_currentPid:%{public}d", m_currentRtg, m_currentPid); + RME_LOGE("[AnimateStart]: search rtg error! m_currentRtg:%{public}d, m_currentPid:%{public}d", m_currentRtg, m_currentPid); return; } int rendertid = gettid(); @@ -123,7 +116,7 @@ void RmeCoreSched::AnimateStart() void RmeCoreSched::RenderStart() { - SetMargin(m_currentRtg, -7); + SetMargin(m_currentRtg, -3); } void RmeCoreSched::SendCommandsStart() @@ -136,6 +129,5 @@ void RmeCoreSched::SendCommandsStart() int ret = EndFrameFreq(m_currentRtg); RME_LOGI("[SendCommandsStart]: set EndFrameFreq, ret: %{public}d, m_currentPid:%{publid}d, pid:%{public}d!", ret, m_currentPid, pid); } - } // namespace RME } // OHOS diff --git a/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp b/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp index ec8d502..cd322d3 100644 --- a/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp +++ b/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp @@ -106,6 +106,20 @@ void RmeSceneSched::EndFlushRender() } } +void RmeSceneSched::BeginFlushRenderFinish() +{ + if (curWorkingStatus == 1) { + rmeCoreSched->BeginFlushRenderFinish(); + } +} + +void RmeSceneSched::EndFlushRenderFinish() +{ + if (curWorkingStatus == 1) { + rmeCoreSched->EndFlushRenderFinish(); + } +} + void RmeSceneSched::BeginProcessPostFlush() { if (curWorkingStatus == 1) { @@ -141,6 +155,5 @@ void RmeSceneSched::SendCommandsStart() RME_LOGI("[SendCommandsStart]:RmeSceneSched send msg success!"); } } - } // namespace RME } // namespace OHOS diff --git a/interfaces/innerkits/frameintf/frame_ui_intf.cpp b/interfaces/innerkits/frameintf/frame_ui_intf.cpp index 76a011a..d0faac1 100644 --- a/interfaces/innerkits/frameintf/frame_ui_intf.cpp +++ b/interfaces/innerkits/frameintf/frame_ui_intf.cpp @@ -121,6 +121,22 @@ void FrameUiIntf::EndFlushRender() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_RENDER, EventState::EVENT_EXIT); } +void FrameUiIntf::BeginFlushRenderFinish() +{ + if (!inited) { + return; + } + FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_RENDER_FINISH, EventState::EVENT_ENTER); +} + +void FrameUiIntf::EndFlushRenderFinish() +{ + if (!inited) { + return; + } + FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_RENDER_FINISH, EventState::EVENT_EXIT); +} + void FrameUiIntf::BeginProcessPostFlush() { if (!inited) { @@ -213,6 +229,16 @@ extern "C" void EndFlushRender() FrameUiIntf::GetInstance().EndFlushRender(); } +extern "C" void BeginFlushRenderFinish() +{ + FrameUiIntf::GetInstance().BeginFlushRenderFinish(); +} + +extern "C" void EndFlushRenderFinish() +{ + FrameUiIntf::GetInstance().EndFlushRenderFinish(); +} + extern "C" void BeginProcessPostFlush() { FrameUiIntf::GetInstance().BeginProcessPostFlush(); diff --git a/interfaces/innerkits/frameintf/frame_ui_intf.h b/interfaces/innerkits/frameintf/frame_ui_intf.h index 284d8f1..2bfaba7 100644 --- a/interfaces/innerkits/frameintf/frame_ui_intf.h +++ b/interfaces/innerkits/frameintf/frame_ui_intf.h @@ -35,6 +35,9 @@ public: void BeginFlushRender(); void EndFlushRender(); + void BeginFlushRenderFinish(); + void EndFlushRenderFinish(); + void BeginProcessPostFlush(); void ProcessCommandsStart(); void AnimateStart(); -- Gitee From ce2eb3d79f2bcad4a03444819a49c19a94f0add8 Mon Sep 17 00:00:00 2001 From: rongkunshi Date: Thu, 24 Feb 2022 22:29:30 +0800 Subject: [PATCH 3/7] frame aware sched csec fix 1.0 Signed-off-by: rongkunshi --- common/include/frame_info_const.h | 2 - common/include/rme_constants.h | 3 - common/include/rme_log_domain.h | 13 +- common/include/rtg_interface.h | 115 +++++++++--------- common/include/single_instance.h | 4 +- .../include/frame_msg_mgr.h | 7 -- .../include/frame_scene_sched.h | 2 - .../include/frame_window_mgr.h | 1 - .../include/intelli_sense_sched.h | 41 ------- .../include/rme_core_sched.h | 6 - .../include/rme_scene_sched.h | 1 - .../src/frame_msg_mgr.cpp | 7 +- .../src/frame_window_mgr.cpp | 4 +- .../src/rme_core_sched.cpp | 37 +++--- .../src/rme_scene_sched.cpp | 4 +- .../frame_aware_policy/include/app_info.h | 7 +- .../frame_aware_policy/include/app_info_mgr.h | 4 - .../include/intellisense_server.h | 5 +- .../frame_aware_policy/include/para_config.h | 10 +- .../core/frame_aware_policy/src/app_info.cpp | 5 +- .../frame_aware_policy/src/app_info_mgr.cpp | 46 ++----- .../src/intellisense_server.cpp | 9 +- .../frame_aware_policy/src/para_config.cpp | 40 +++--- .../frame_aware_policy/src/rtg_msg_mgr.cpp | 25 ++-- interfaces/innerkits/frameintf/BUILD.gn | 7 +- .../innerkits/frameintf/frame_msg_intf.cpp | 3 - .../innerkits/frameintf/frame_ui_intf.cpp | 39 +++--- .../innerkits/frameintf/frame_ui_intf.h | 44 ++++--- .../innerkits/frameintf/rtg_interface.cpp | 75 ++++++------ test/unittest/phone/frame_msg_intf_test.cpp | 25 +--- test/unittest/phone/rtg_interface_test.cpp | 9 +- 31 files changed, 216 insertions(+), 384 deletions(-) delete mode 100644 frameworks/core/frame_aware_collector/include/intelli_sense_sched.h diff --git a/common/include/frame_info_const.h b/common/include/frame_info_const.h index 2b941e6..d1e4bf4 100644 --- a/common/include/frame_info_const.h +++ b/common/include/frame_info_const.h @@ -18,7 +18,6 @@ namespace OHOS { namespace RME { - enum class FrameEvent { FLUSH_ANIMATION, FLUSH_BUILD, @@ -52,7 +51,6 @@ enum class SceneEvent { CLICK, SCENE_MAX, }; - } // namespace RME } // namespace OHOS diff --git a/common/include/rme_constants.h b/common/include/rme_constants.h index d35086b..f11c8ce 100644 --- a/common/include/rme_constants.h +++ b/common/include/rme_constants.h @@ -18,7 +18,6 @@ namespace OHOS { namespace RME { - enum class AppStateUpdateReason { APP_FOREGROUND, APP_BACKGROUND, @@ -49,8 +48,6 @@ enum class ErrorCode { FAIL, SUCC, }; - } // namespace RME } // namespace OHOS - #endif diff --git a/common/include/rme_log_domain.h b/common/include/rme_log_domain.h index 09b78d0..e29af38 100644 --- a/common/include/rme_log_domain.h +++ b/common/include/rme_log_domain.h @@ -21,7 +21,6 @@ namespace OHOS { namespace RmeLogDomain { - constexpr uint32_t COMMON = 0xD006600; constexpr uint32_t RME_SERVICE = 0xD006601; constexpr uint32_t RME_TEST = 0xD006602; @@ -50,23 +49,19 @@ constexpr uint32_t RME_INTELLISENSE = 0xD006604; */ #define DEFINE_RMELOG_LABEL(name) \ - static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::COMMON, name}; + static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::COMMON, name} #define DEFINE_RMELOG_INTELLISENSE(name) \ - static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::RME_INTELLISENSE, name}; + static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::RME_INTELLISENSE, name} #define DEFINE_RMELOG_SERVICE(name) \ - static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::RME_SERVICE, name}; + static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::RME_SERVICE, name} #define DEFINE_RMELOG_TEST(name) \ - static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::RME_TEST, name}; - + static constexpr OHOS::HiviewDFX::HiLogLabel RME_LOG_LABEL = {LOG_CORE, OHOS::RmeLogDomain::RME_TEST, name} #define RME_LOGF(...) (void)OHOS::HiviewDFX::HiLog::Fatal(RME_LOG_LABEL, ##__VA_ARGS__) #define RME_LOGE(...) (void)OHOS::HiviewDFX::HiLog::Error(RME_LOG_LABEL, ##__VA_ARGS__) #define RME_LOGW(...) (void)OHOS::HiviewDFX::HiLog::Warn(RME_LOG_LABEL, ##__VA_ARGS__) #define RME_LOGI(...) (void)OHOS::HiviewDFX::HiLog::Info(RME_LOG_LABEL, ##__VA_ARGS__) #define RME_LOGD(...) (void)OHOS::HiviewDFX::HiLog::Debug(RME_LOG_LABEL, ##__VA_ARGS__) - - } // namespace RmeLogDomain } // namespace OHOS - #endif // RME_LOG_DOMAIN_H diff --git a/common/include/rtg_interface.h b/common/include/rtg_interface.h index 12e14ab..2a38b35 100644 --- a/common/include/rtg_interface.h +++ b/common/include/rtg_interface.h @@ -16,99 +16,96 @@ #ifndef OHOS_FRAME_AWARE_SCHED_COMMON_INCLUDE_RTG_INTERFACE_H #define OHOS_FRAME_AWARE_SCHED_COMMON_INCLUDE_RTG_INTERFACE_H - #include #include namespace OHOS { namespace RME { - using namespace std; #define MAX_TID_NUM 5 #define MAX_SUBPROCESS_NUM 8 -#define MULTI_FRAME_NUM 5 +#define MULTI_FRAME_NUM 5 typedef int pid_t; struct rtg_enable_data { - int enable; - int len; - char *data; + int enable; + int len; + char *data; }; struct rtg_str_data { - int type; - int len; - char *data; + int type; + int len; + char *data; }; struct proc_state_data { - int grp_id; - int state_param; + int grp_id; + int state_param; }; enum grp_ctrl_cmd { - CMD_CREATE_RTG_GRP, - CMD_ADD_RTG_THREAD, - CMD_REMOVE_RTG_THREAD, - CMD_CLEAR_RTG_GRP, - CMD_DESTROY_RTG_GRP + CMD_CREATE_RTG_GRP, + CMD_ADD_RTG_THREAD, + CMD_REMOVE_RTG_THREAD, + CMD_CLEAR_RTG_GRP, + CMD_DESTROY_RTG_GRP }; struct rtg_grp_data { - int rtg_cmd; - int grp_id; - int prio_type; - int rt_cnt; - int tid_num; - int tids[MAX_TID_NUM]; + int rtg_cmd; + int grp_id; + int prio_type; + int rt_cnt; + int tid_num; + int tids[MAX_TID_NUM]; }; struct rtg_info { - int rtg_num; - int rtgs[MULTI_FRAME_NUM]; + int rtg_num; + int rtgs[MULTI_FRAME_NUM]; }; enum rtg_sched_cmdid { - SET_ENABLE = 1, - SET_RTG, - SET_CONFIG, - SET_RTG_ATTR, - BEGIN_FRAME_FREQ = 5, - END_FRAME_FREQ, - END_SCENE, - SET_MIN_UTIL, - SET_MARGIN, - LIST_RTG, - LIST_RTG_THREAD, - SEARCH_RTG, - GET_ENABLE, - RTG_CTRL_MAX_NR, + SET_ENABLE = 1, + SET_RTG, + SET_CONFIG, + SET_RTG_ATTR, + BEGIN_FRAME_FREQ = 5, + END_FRAME_FREQ, + END_SCENE, + SET_MIN_UTIL, + SET_MARGIN, + LIST_RTG, + LIST_RTG_THREAD, + SEARCH_RTG, + GET_ENABLE, + RTG_CTRL_MAX_NR, }; -extern "C"{ - int EnableRtg(bool flag); - //-----for frame rtg-----// - int CreateNewRtgGrp(int prioType = 0, int rtNum = 0); // Return GrpId if success - int AddThreadToRtg(int tid, int grpId); - int AddThreadsToRtg(vector tids, int grpId); - int RemoveRtgThread(int tid); - int ClearRtgGrp(int grpId); - int DestroyRtgGrp(int grpId); - int SetFrameRateAndPrioType(int rtgId, int rate, int rtgType); - int SetMaxVipRtgs(int rtframe); - int BeginFrameFreq(int grpId, int stateParam); - int EndFrameFreq(int grpId); - int EndScene(int grpId); - int SetMinUtil(int grpId, int stateParam); - int SetMargin(int grpId, int stateParam); - int ListRtgThread(int grpId, vector *rs); // list all tasks of grpId; - int ListRtgGroup(vector *rs); - int SearchRtgForTid(int stateParam); - int GetRtgEnable(); +extern "C"{ + int EnableRtg(bool flag); + //-----for frame rtg-----// + int CreateNewRtgGrp(int prioType = 0, int rtNum = 0); // Return GrpId if success + int AddThreadToRtg(int tid, int grpId); + int AddThreadsToRtg(vector tids, int grpId); + int RemoveRtgThread(int tid); + int ClearRtgGrp(int grpId); + int DestroyRtgGrp(int grpId); + int SetFrameRateAndPrioType(int rtgId, int rate, int rtgType); + int SetMaxVipRtgs(int rtframe); + int BeginFrameFreq(int grpId, int stateParam); + int EndFrameFreq(int grpId); + int EndScene(int grpId); + int SetMinUtil(int grpId, int stateParam); + int SetMargin(int grpId, int stateParam); + int ListRtgThread(int grpId, vector *rs); // list all tasks of grpId; + int ListRtgGroup(vector *rs); + int SearchRtgForTid(int stateParam); + int GetRtgEnable(); } - } // namespace RME } // namespace OHOS #endif // OHOS_FRAME_AWARE_SCHED_COMMON_INCLUDE_RTG_INTERFACE_H \ No newline at end of file diff --git a/common/include/single_instance.h b/common/include/single_instance.h index 37d765f..087f4a2 100644 --- a/common/include/single_instance.h +++ b/common/include/single_instance.h @@ -41,9 +41,7 @@ className& className::GetInstance() \ { \ static auto instance = new className(); \ return *instance; \ -} - +} } // namespace RME } // namespace OHOS - #endif // SINGLE_INSTANCE_H diff --git a/frameworks/core/frame_aware_collector/include/frame_msg_mgr.h b/frameworks/core/frame_aware_collector/include/frame_msg_mgr.h index 4d51e30..dfcaef3 100644 --- a/frameworks/core/frame_aware_collector/include/frame_msg_mgr.h +++ b/frameworks/core/frame_aware_collector/include/frame_msg_mgr.h @@ -24,7 +24,6 @@ namespace OHOS { namespace RME { - class RmeSceneSched; class FrameMsgMgr { @@ -34,20 +33,14 @@ public: ~FrameMsgMgr(); bool Init(); void EventUpdate(FrameEvent eventType, EventState state); - private: void UpdateScene(SceneEvent scene); - void HandleDefaultEvent(FrameEvent event, EventState state); void SetSchedParam(); FrameSceneSched *GetSceneHandler() const; - SceneEvent sceneType; RmeSceneSched *rmeScene; - }; - - } // namespace RME } // namespace OHOS #endif diff --git a/frameworks/core/frame_aware_collector/include/frame_scene_sched.h b/frameworks/core/frame_aware_collector/include/frame_scene_sched.h index eae6950..66ae8f4 100644 --- a/frameworks/core/frame_aware_collector/include/frame_scene_sched.h +++ b/frameworks/core/frame_aware_collector/include/frame_scene_sched.h @@ -20,7 +20,6 @@ namespace OHOS { namespace RME { - class FrameSceneSched { public: FrameSceneSched() {}; @@ -44,5 +43,4 @@ public: }; } // namespace RME } // namespace OHOS - #endif diff --git a/frameworks/core/frame_aware_collector/include/frame_window_mgr.h b/frameworks/core/frame_aware_collector/include/frame_window_mgr.h index 9ef373c..5e112c9 100644 --- a/frameworks/core/frame_aware_collector/include/frame_window_mgr.h +++ b/frameworks/core/frame_aware_collector/include/frame_window_mgr.h @@ -22,7 +22,6 @@ namespace OHOS { namespace RME { - class FrameWindowMgr { DECLARE_SINGLE_INSTANCE(FrameWindowMgr); public: diff --git a/frameworks/core/frame_aware_collector/include/intelli_sense_sched.h b/frameworks/core/frame_aware_collector/include/intelli_sense_sched.h deleted file mode 100644 index a2cb0b4..0000000 --- a/frameworks/core/frame_aware_collector/include/intelli_sense_sched.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef INTELLI_SENSE_SCHED_H -#define INTELLI_SENSE_SCHED_H - -#include -#include - - -namespace OHOS { - -namespace RME { - -class IntelliSenseSched { -public: - IntelliSenseSched(); - ~IntelliSenseSched(); - - static IntelliSenseSched &GetInstance(); - static bool IsSoLoaded(); - - -} - - -} // namespace RME -} // namespace OHOS -#endif diff --git a/frameworks/core/frame_aware_collector/include/rme_core_sched.h b/frameworks/core/frame_aware_collector/include/rme_core_sched.h index 03f2b83..bf05fd8 100644 --- a/frameworks/core/frame_aware_collector/include/rme_core_sched.h +++ b/frameworks/core/frame_aware_collector/include/rme_core_sched.h @@ -21,26 +21,20 @@ namespace OHOS { namespace RME { - class RmeCoreSched { public: RmeCoreSched(); ~RmeCoreSched(); bool Init(); - void BeginFlushAnimation(); void EndFlushAnimation(); - void BeginFlushBuild(); void EndFlushBuild(); - void BeginFlushLayout(); void EndFlushLayout(); - void BeginFlushRender(); void EndFlushRender(); - void BeginFlushRenderFinish(); void EndFlushRenderFinish(); diff --git a/frameworks/core/frame_aware_collector/include/rme_scene_sched.h b/frameworks/core/frame_aware_collector/include/rme_scene_sched.h index 89d8e22..2fccfbe 100644 --- a/frameworks/core/frame_aware_collector/include/rme_scene_sched.h +++ b/frameworks/core/frame_aware_collector/include/rme_scene_sched.h @@ -23,7 +23,6 @@ namespace OHOS { namespace RME { - class RmeSceneSched : public FrameSceneSched { public: RmeSceneSched(); diff --git a/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp b/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp index 6bfd9c2..3096491 100644 --- a/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp +++ b/frameworks/core/frame_aware_collector/src/frame_msg_mgr.cpp @@ -17,14 +17,12 @@ namespace OHOS { namespace RME { - DEFINE_RMELOG_INTELLISENSE("ueaClient-FrameMsgMgr"); IMPLEMENT_SINGLE_INSTANCE(FrameMsgMgr); FrameMsgMgr::FrameMsgMgr() : sceneType(SceneEvent::SLIDE), rmeScene(nullptr) -{ -} +{} FrameMsgMgr::~FrameMsgMgr() { @@ -38,7 +36,6 @@ bool FrameMsgMgr::Init() if (rmeScene == nullptr) { rmeScene = new RmeSceneSched(); } - if (!rmeScene->Init()) { RME_LOGE("[Init]:inited failed!"); return false; @@ -75,7 +72,6 @@ void FrameMsgMgr::HandleDefaultEvent(FrameEvent event, EventState value) RME_LOGE("[HandleDefaultEvent]:scene nullptr"); return; } - switch (event) { case FrameEvent::FLUSH_ANIMATION: if (value == EventState::EVENT_ENTER) { @@ -140,7 +136,6 @@ void FrameMsgMgr::SetSchedParam() FrameSceneSched *FrameMsgMgr::GetSceneHandler() const { - if (sceneType == SceneEvent::SCENE_INVALID) { RME_LOGE("[GetSceneHandler]:get nullptr sceneType %{public}d,", static_cast(sceneType)); return nullptr; diff --git a/frameworks/core/frame_aware_collector/src/frame_window_mgr.cpp b/frameworks/core/frame_aware_collector/src/frame_window_mgr.cpp index 7ae52be..7b10003 100644 --- a/frameworks/core/frame_aware_collector/src/frame_window_mgr.cpp +++ b/frameworks/core/frame_aware_collector/src/frame_window_mgr.cpp @@ -18,8 +18,7 @@ namespace OHOS { namespace RME { namespace { - -const std::string SCHEME_SWITCH_PROP = ""; // to add prop + const std::string SCHEME_SWITCH_PROP = ""; // to add prop } IMPLEMENT_SINGLE_INSTANCE(FrameWindowMgr); @@ -43,6 +42,5 @@ bool FrameWindowMgr::GetStartFlag() { return m_startFlag; } - } // namespace RME } // namespace OHOS diff --git a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp index ca402e8..7578ed9 100644 --- a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp +++ b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp @@ -18,9 +18,12 @@ namespace OHOS { namespace RME { - +namespace { + constexpr int CPU_MARGIN_THREE = -3; + constexpr int CPU_MARGIN_FIVE = -5; + constexpr int CPU_MARGIN_SEVEN = -7; +} DEFINE_RMELOG_INTELLISENSE("ueaClient-RmeCoreSched"); - RmeCoreSched::RmeCoreSched() {} RmeCoreSched::~RmeCoreSched() @@ -47,7 +50,8 @@ void RmeCoreSched::BeginFlushAnimation() if (m_currentRtg == -1) { m_currentRtg = SearchRtgForTid(m_currentPid); if (m_currentRtg <= 0) { - RME_LOGE("[BeginFlushAnimation]:Search rtg for pid %{public}d failed! m_currentRtg: %{public}d", m_currentPid, m_currentRtg); + RME_LOGE("[BeginFlushAnimation]:Search rtg for pid %{public}d failed! \ + m_currentRtg: %{public}d", m_currentPid, m_currentRtg); return; } else { RME_LOGI("[BeginFlushAnimation]:Search rtg sucess m_currentRtg, val:%{public}d", m_currentRtg); @@ -59,13 +63,11 @@ void RmeCoreSched::BeginFlushAnimation() return; } -void RmeCoreSched::EndFlushAnimation() -{ -} +void RmeCoreSched::EndFlushAnimation() {} void RmeCoreSched::BeginFlushBuild() { - SetMargin(m_currentRtg, -3); + SetMargin(m_currentRtg, CPU_MARGIN_THREE); } void RmeCoreSched::EndFlushBuild() {} @@ -76,14 +78,14 @@ void RmeCoreSched::EndFlushLayout() {} void RmeCoreSched::BeginFlushRender() { - SetMargin(m_currentRtg, -5); + SetMargin(m_currentRtg, CPU_MARGIN_FIVE); } void RmeCoreSched::EndFlushRender() {} void RmeCoreSched::BeginFlushRenderFinish() { - SetMargin(m_currentRtg, -7); + SetMargin(m_currentRtg, CPU_MARGIN_SEVEN); } void RmeCoreSched::EndFlushRenderFinish() {} @@ -98,7 +100,8 @@ void RmeCoreSched::AnimateStart() return; } if (m_currentRtg <= 0) { - RME_LOGE("[AnimateStart]: search rtg error! m_currentRtg:%{public}d, m_currentPid:%{public}d", m_currentRtg, m_currentPid); + RME_LOGE("[AnimateStart]: search rtg error! m_currentRtg:%{public}d, \ + m_currentPid:%{public}d", m_currentRtg, m_currentPid); return; } int rendertid = gettid(); @@ -109,25 +112,27 @@ void RmeCoreSched::AnimateStart() %{public}d, m_currentPid:%{public}d, pid: %{public}d", ret, m_currentRtg, rendertid, m_currentPid, pid); } else { isRenderAdd = true; - RME_LOGI("[AnimateStart]:add rtg grp SUCESS! rendertid: \ - %{public}d, pid: %{public}d, rtGrp: %{public}d, m_currentPid:%{public}d", rendertid, pid, m_currentRtg, m_currentPid); + RME_LOGI("[AnimateStart]:add rtg grp SUCESS! rendertid: %{public}d, pid: %{public}d,\ + rtGrp: %{public}d, m_currentPid:%{public}d", rendertid, pid, m_currentRtg, m_currentPid); } } void RmeCoreSched::RenderStart() { - SetMargin(m_currentRtg, -3); + SetMargin(m_currentRtg, CPU_MARGIN_THREE); } void RmeCoreSched::SendCommandsStart() { int pid = getpid(); if (m_currentRtg <= 0) { - RME_LOGE("[SendCommandStart]: m_currentRtg error! rtGrp:%{public}d, m_currentPid:%{public}d, pid:%{public}d!", m_currentRtg, m_currentPid, pid); + RME_LOGE("[SendCommandStart]: m_currentRtg error! rtGrp:%{public}d, \ + m_currentPid:%{public}d, pid:%{public}d!", m_currentRtg, m_currentPid, pid); return; } int ret = EndFrameFreq(m_currentRtg); - RME_LOGI("[SendCommandsStart]: set EndFrameFreq, ret: %{public}d, m_currentPid:%{publid}d, pid:%{public}d!", ret, m_currentPid, pid); + RME_LOGI("[SendCommandsStart]: set EndFrameFreq, ret: %{public}d, m_currentPid:\ + %{publid}d, pid:%{public}d!", ret, m_currentPid, pid); } } // namespace RME -} // OHOS +} // OHOS \ No newline at end of file diff --git a/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp b/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp index cd322d3..cd3188d 100644 --- a/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp +++ b/frameworks/core/frame_aware_collector/src/rme_scene_sched.cpp @@ -17,13 +17,11 @@ namespace OHOS { namespace RME { - DEFINE_RMELOG_INTELLISENSE("ueaClient-RmeSceneSched"); RmeSceneSched::RmeSceneSched() :curWorkingStatus(0), rmeCoreSched(nullptr) -{ -} +{} RmeSceneSched::~RmeSceneSched() { diff --git a/frameworks/core/frame_aware_policy/include/app_info.h b/frameworks/core/frame_aware_policy/include/app_info.h index d34182e..06c97a0 100644 --- a/frameworks/core/frame_aware_policy/include/app_info.h +++ b/frameworks/core/frame_aware_policy/include/app_info.h @@ -20,7 +20,6 @@ namespace OHOS { namespace RME { - enum class AppState { APP_FOREGROUND, APP_BACKGROUND, @@ -28,7 +27,6 @@ enum class AppState { APP_UNKNOWN, }; - class AppInfo { public: AppInfo(std::string appName, int pid, int uiTid, int renderTid, int isFocus, AppState state); @@ -47,18 +45,15 @@ public: int GetAppPid(); void SetRtgrp(const int grpNum); int GetRtgrp(); - private: std::string m_appName; int m_pid; int m_uiTid; - int m_renderTid; + int m_renderTid; int m_isFocus; int m_rtGrp; AppState m_appState; }; - - } // RME } // OHOS #endif diff --git a/frameworks/core/frame_aware_policy/include/app_info_mgr.h b/frameworks/core/frame_aware_policy/include/app_info_mgr.h index db2331a..1da4985 100644 --- a/frameworks/core/frame_aware_policy/include/app_info_mgr.h +++ b/frameworks/core/frame_aware_policy/include/app_info_mgr.h @@ -26,7 +26,6 @@ namespace OHOS { namespace RME { - class AppInfoMgr { DECLARE_SINGLE_INSTANCE(AppInfoMgr); @@ -40,14 +39,11 @@ public: std::shared_ptr GetFocusApp() const; void SetFocusApp(const int pid, bool isFocus); int GetAppRtgrp(const int pid); - private: std::map> mForegroundAppList; std::map> mBackgroundAppList; std::shared_ptr mFocusApp; }; - - } // namespace RME } // namespace OHOS #endif diff --git a/frameworks/core/frame_aware_policy/include/intellisense_server.h b/frameworks/core/frame_aware_policy/include/intellisense_server.h index 2b0fa24..6d55c0f 100644 --- a/frameworks/core/frame_aware_policy/include/intellisense_server.h +++ b/frameworks/core/frame_aware_policy/include/intellisense_server.h @@ -28,14 +28,13 @@ namespace OHOS { namespace RME { - using namespace std; class IntelliSenseServer { DECLARE_SINGLE_INSTANCE(IntelliSenseServer); public: void Init(); - void ReportMessage(std::string appName, std::string processName, int pid, + void ReportMessage(std::string appName, std::string processName, int pid, AppStateUpdateReason reason); void ReportWindowFocus(const int pid, int isFocus); void ReportProcessInfo(const int pid, const int tid, ThreadState state); @@ -47,11 +46,9 @@ private: std::map> m_subEventPara {}; std::vector m_fpsList {}; std::vector m_renderTypeList {}; - bool m_readXmlSuc = false; bool m_needReadXml = true; }; - } // namespace RME } // namesapce OHOS #endif diff --git a/frameworks/core/frame_aware_policy/include/para_config.h b/frameworks/core/frame_aware_policy/include/para_config.h index a2e7aa6..52a410b 100644 --- a/frameworks/core/frame_aware_policy/include/para_config.h +++ b/frameworks/core/frame_aware_policy/include/para_config.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include "third_party/libxml2/include/libxml/parser.h" #include "third_party/libxml2/include/libxml/tree.h" @@ -31,7 +31,6 @@ namespace OHOS { namespace RME { - class ParaConfig { public: ParaConfig(); @@ -47,14 +46,11 @@ public: static std::map> GetSubEventConfig(); static std::vector GetFpsList(); static std::vector GetRenderTypeList(); -// static bool GetSwitchEnable(); - private: static std::map m_generalConfig; static std::map> m_subEventConfig; static std::vector m_fpsList; static std::vector m_renderTypeList; -// static bool m_switchEnable; static void ReadAttr(xmlNodePtr& root, const std::string& attrName, std::string& res); static void ReadFrameConfig(const xmlNodePtr& root); @@ -64,11 +60,7 @@ private: static void SplitString(const std::string& context, const std::string& character, std::vector &mList, const int maxVal, const std::string& attrName); static bool IsValidNode(const xmlNode& currNode); - }; - - } // namespace RME - } // namespace OHOS #endif diff --git a/frameworks/core/frame_aware_policy/src/app_info.cpp b/frameworks/core/frame_aware_policy/src/app_info.cpp index 826f81f..38efcce 100644 --- a/frameworks/core/frame_aware_policy/src/app_info.cpp +++ b/frameworks/core/frame_aware_policy/src/app_info.cpp @@ -17,9 +17,8 @@ namespace OHOS { namespace RME { - namespace { -const int RTG_GRP_INIT = -1; + constexpr int RTG_GRP_INIT = -1; } AppInfo::AppInfo(std::string appName, int pid, int uiTid, int renderTid, int isFocus, AppState state) @@ -96,7 +95,5 @@ int AppInfo::GetRtgrp() { return m_rtGrp; } - - } // namespace RME } // namespace OHOS diff --git a/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp b/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp index a0c322b..ab215d5 100644 --- a/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp +++ b/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp @@ -17,36 +17,27 @@ namespace OHOS { namespace RME { - -DEFINE_RMELOG_SERVICE("ueaServer-AppInfoMgr"); - namespace { constexpr int INIT_VAL = -1; - std::mutex mMutex; } - +DEFINE_RMELOG_SERVICE("ueaServer-AppInfoMgr"); IMPLEMENT_SINGLE_INSTANCE(AppInfoMgr); void AppInfoMgr::OnForegroundChanged(const int pid, const std::string appName, const int rtGrp) { if (mBackgroundAppList.count(pid)) { - RME_LOGE("[OnForegroundChanged]: back yes!pid:%{public}d", pid); + RME_LOGI("[OnForegroundChanged]: back yes!pid:%{public}d", pid); mBackgroundAppList[pid]->SetAppName(appName); mBackgroundAppList[pid]->SetAppState(AppState::APP_FOREGROUND); mForegroundAppList[pid] = mBackgroundAppList[pid]; mBackgroundAppList.erase(pid); } else { - RME_LOGE("[OnForegroundChanged]: back No!pid:%{public}d", pid); + RME_LOGI("[OnForegroundChanged]: back No!pid:%{public}d", pid); auto appInfo = std::make_shared(appName, pid, INIT_VAL, INIT_VAL, INIT_VAL, AppState::APP_FOREGROUND); mForegroundAppList[pid] = appInfo; } mForegroundAppList[pid]->SetRtgrp(rtGrp); - - int isExistFore = mForegroundAppList.count(pid); - int isExistBack = mBackgroundAppList.count(pid); - RME_LOGE("[OnForegroundChanged]:isExistFore: %{public}d, size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, mForegroundAppList.size(), isExistBack, mBackgroundAppList.size()); - - RME_LOGE("[OnForegroundChanged]:pid:%{public}d, rtgrp:%{public}d, \ + RME_LOGI("[OnForegroundChanged]:pid:%{public}d, rtgrp:%{public}d, \ app_state: %{public}d", pid, rtGrp, static_cast(mForegroundAppList[pid]->GetAppState())); } @@ -62,23 +53,14 @@ void AppInfoMgr::OnBackgroundChanged(const int pid, const std::string appName) RME_LOGE("[OnBackgroundChanged]:unfind app in foreground app when go to background! pid:%{public}d", pid); } mBackgroundAppList[pid]->SetRtgrp(INIT_VAL); - int isExistFore = mForegroundAppList.count(pid); - int isExistBack = mBackgroundAppList.count(pid); - RME_LOGE("[OnBackgroundChanged]:isExistFore: %{public}d,size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, mForegroundAppList.size(), isExistBack, mBackgroundAppList.size()); - - RME_LOGE("[OnBackgroundChanged]:pid:%{public}d, appName:%{public}s", pid, appName.c_str()); + RME_LOGI("[OnBackgroundChanged]:pid:%{public}d, appName:%{public}s", pid, appName.c_str()); } void AppInfoMgr::OnAppTerminateChanged(const int pid, const std::string appName) { mForegroundAppList.erase(pid); mBackgroundAppList.erase(pid); - - int isExistFore = mForegroundAppList.count(pid); - int isExistBack = mBackgroundAppList.count(pid); - RME_LOGE("[OnAppTerminatedChanged]:isExistFore: %{public}d,size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, isExistBack, mForegroundAppList.size(), mBackgroundAppList.size()); - - RME_LOGE("[OnAppTerminatedChanged]: pid: %{public}d, appName: %{public}s, \ + RME_LOGI("[OnAppTerminatedChanged]: pid: %{public}d, appName: %{public}s, \ ", pid, appName.c_str()); } @@ -92,7 +74,6 @@ void AppInfoMgr::OnWindowFocus(const int pid, bool isFocus) RME_LOGE("[OnAppFocus]:not found pid %{public}d in fore map", pid); return; } - } else { appInfo = mBackgroundAppList[pid]; if (appInfo == nullptr) { @@ -102,11 +83,7 @@ void AppInfoMgr::OnWindowFocus(const int pid, bool isFocus) } SetFocusApp(pid, isFocus); appInfo->SetFocusState(isFocus); - int isExistFore = mForegroundAppList.count(pid); - int isExistBack = mBackgroundAppList.count(pid); - RME_LOGE("[OnAppFocus]:isExistFore:isExistFore: %{public}d,size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, mForegroundAppList.size(), isExistBack, mBackgroundAppList.size()); - - RME_LOGE("[OnAppFocus]: pid:%{public}d, isFocus:%{public}d, \ + RME_LOGI("[OnAppFocus]: pid:%{public}d, isFocus:%{public}d, \ ", pid, isFocus); } @@ -131,11 +108,7 @@ bool AppInfoMgr::OnProcessDied(const int pid, const int tid) mBackgroundAppList[pid]->SetRenderTid(INIT_VAL); } } - int isExistFore = mForegroundAppList.count(pid); - int isExistBack = mBackgroundAppList.count(pid); - RME_LOGE("[OnProcessDied]:isExistFore: %{public}d,size:%{public}d, isExistBack: %{public}d, size:%{public}d", isExistFore, isExistBack, mForegroundAppList.size(), mBackgroundAppList.size()); - - RME_LOGE("[OnProcessDied]: pid: %{public}d, tid:%{public}d, deleted:%{public}d, isExist:foreground:%{public}d, \ + RME_LOGI("[OnProcessDied]: pid: %{public}d, tid:%{public}d, deleted:%{public}d, isExist:foreground:%{public}d, \ background:%{public}d.", pid, tid, deleted, mForegroundAppList.count(pid), mBackgroundAppList.count(pid)); return deleted; } @@ -147,7 +120,7 @@ void AppInfoMgr::SetFocusApp(const int pid, bool isFocus) } else { mFocusApp = nullptr; } - RME_LOGE("[SetFocusApp]:pid: %{public}d, isFocus%{public}d", pid, isFocus); + RME_LOGI("[SetFocusApp]:pid: %{public}d, isFocus%{public}d", pid, isFocus); } std::shared_ptr AppInfoMgr::GetFocusApp() const @@ -172,6 +145,5 @@ std::map> AppInfoMgr::GetForegroundApp() const { return mForegroundAppList; } - } // namespace RME } // namespace OHOS diff --git a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp index a266239..846b933 100644 --- a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp +++ b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp @@ -24,13 +24,12 @@ namespace OHOS { namespace RME { - +namespace { + static std::string configFilePath = "/system/etc/frame_aware_sched/hwrme.xml"; // need To check the exact file path. +} using namespace std; -static std::string configFilePath = "/system/etc/frame_aware_sched/hwrme.xml"; // need To check the exact file path. - DEFINE_RMELOG_INTELLISENSE("ueaServer-IntelliSenseServer"); - IMPLEMENT_SINGLE_INSTANCE(IntelliSenseServer); void IntelliSenseServer::Init() @@ -151,7 +150,5 @@ void IntelliSenseServer::SetPara(const int32_t currentFps, const int32_t current map tempMap = m_subEventPara[key]; RME_LOGI("[SetPara]:subEventPara map size: %{public}d", tempMap.size()); } - - } // namespace RME } // namesapce OHOS diff --git a/frameworks/core/frame_aware_policy/src/para_config.cpp b/frameworks/core/frame_aware_policy/src/para_config.cpp index 4e2fdf3..06f14f8 100644 --- a/frameworks/core/frame_aware_policy/src/para_config.cpp +++ b/frameworks/core/frame_aware_policy/src/para_config.cpp @@ -15,12 +15,11 @@ #include "para_config.h" -namespace OHOS { +namespace OHOS { namespace RME { - namespace { -constexpr int FPS_MAX_VALUE = 120; -constexpr int RENDER_TYPE_MAX_VALUE = 2; + constexpr int FPS_MAX_VALUE = 120; + constexpr int RENDER_TYPE_MAX_VALUE = 2; } DEFINE_RMELOG_INTELLISENSE("ueaServer-ParaConfig"); @@ -33,27 +32,25 @@ std::vector ParaConfig::m_renderTypeList; bool ParaConfig::IsXmlPrepared(const std::string& filePath) { RME_LOGI("[IsXmlPrepared]:begin!"); - xmlDocPtr docPtr; - docPtr = xmlReadFile(filePath.c_str(), nullptr, XML_PARSE_NOBLANKS); + xmlDocPtr docPtr = xmlReadFile(filePath.c_str(), nullptr, XML_PARSE_NOBLANKS); RME_LOGI("[IsXmlPrepared]:filePath:%{public}s", filePath.c_str()); if (docPtr == nullptr) { RME_LOGE("[IsXmlPrepared]:load xml error!"); - return false; + return false; } - xmlNodePtr rootPtr; - rootPtr = xmlDocGetRootElement(docPtr); + xmlNodePtr rootPtr = xmlDocGetRootElement(docPtr); if (rootPtr == nullptr || rootPtr->name == nullptr) { RME_LOGE("[IsXmlPrepared]: get root element failed!"); xmlFreeDoc(docPtr); - return false; + return false; } for (xmlNodePtr curNodePtr = rootPtr->xmlChildrenNode; curNodePtr != nullptr; curNodePtr = curNodePtr->next) { if (IsValidNode(*curNodePtr)) { RME_LOGE("[IsXmlPrepared]: invalid node!"); continue; } - auto nodeName = curNodePtr->name; // char* to string + auto nodeName = curNodePtr->name; // char* to string if (!xmlStrcmp(nodeName, reinterpret_cast("log_open")) || !xmlStrcmp(nodeName, reinterpret_cast("enable")) || !xmlStrcmp(nodeName, reinterpret_cast("SOC")) || @@ -90,8 +87,8 @@ void ParaConfig::ReadConfigInfo(const xmlNodePtr& root) { xmlChar* context = xmlNodeGetContent(root); if (context == nullptr) { - RME_LOGE("[GetConfigInfo]:read xml node error: nodeName:(%{public}s)", root->name); - return; + RME_LOGE("[GetConfigInfo]:read xml node error: nodeName:(%{public}s)", root->name); + return; } std::string nodeName = reinterpret_cast(root->name); m_generalConfig[nodeName] = std::string(reinterpret_cast(context)); @@ -103,7 +100,7 @@ void ParaConfig::ReadFpsConfig(const xmlNodePtr& root) xmlChar* context = xmlNodeGetContent(root); if (context == nullptr) { RME_LOGE("[GetFpsConfig]: fps read failed!"); - return; + return; } SplitString(std::string(reinterpret_cast(context)), " ", m_fpsList, FPS_MAX_VALUE, "fpsList"); @@ -133,21 +130,21 @@ void ParaConfig::SplitString(const std::string& context, const std::string& char while (pos != toSplitStr.npos) { int curVal = atoi(toSplitStr.substr(0, pos).c_str()); - if (curVal <= 0 && curVal > maxVal) { + if (curVal <= 0 && curVal > maxVal) { RME_LOGI("[SplitString]:get data error! attr name:%{public}s", attrName.c_str()); - return; - } - mList.push_back(curVal); + return; + } + mList.push_back(curVal); - toSplitStr = toSplitStr.substr(pos + 1,toSplitStr.size()); - pos = toSplitStr.find(character); + toSplitStr = toSplitStr.substr(pos + 1,toSplitStr.size()); + pos = toSplitStr.find(character); } RME_LOGI("[SplitString]:get data success!attr name:%{public}s", attrName.c_str()); } void ParaConfig::ReadFrameConfig(const xmlNodePtr& root) { - // TODO: need abnormal process! what if the xml has problem when traversal? + // to need abnormal process! what if the xml has problem when traversal? for (xmlNodePtr curNode = root->xmlChildrenNode; curNode != nullptr; curNode = curNode->next) { if (IsValidNode(*curNode)) { RME_LOGE("[IsXmlPrepared]: invalid node!"); @@ -208,6 +205,5 @@ std::vector ParaConfig::GetRenderTypeList() { return m_renderTypeList; } - } // namespace RME } // namespace OHOS diff --git a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp index 643297b..abd25b2 100644 --- a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp +++ b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp @@ -18,12 +18,10 @@ namespace OHOS { namespace RME { namespace { -const int PRIO_TYPE = 0; -const int RT_NUM = 0; + constexpr int PRIO_TYPE = 0; + constexpr int RT_NUM = 0; } - DEFINE_RMELOG_INTELLISENSE("ueaServer-RtgMsgMgr"); - IMPLEMENT_SINGLE_INSTANCE(RtgMsgMgr); void RtgMsgMgr::Init() @@ -35,12 +33,11 @@ void RtgMsgMgr::Init() } int RtgMsgMgr::OnForeground(const std::string appName, const int pid) -{ // for multiwindow - RME_LOGI("[OnForeground]:pid:%{public}d:", pid); +{ + // for multiwindow int rtGrp = CreateNewRtgGrp(PRIO_TYPE, RT_NUM); - RME_LOGI("[OnForeground]: createNewRtgGroup begin! rtGrp:%{public}d, pid: %{public}d", rtGrp, pid); if (rtGrp <= 0) { - RME_LOGI("[OnForeground]: createNewRtgGroup failed! rtGrp:%{public}d, pid: %{public}d", rtGrp, pid); + RME_LOGE("[OnForeground]: createNewRtgGroup failed! rtGrp:%{public}d, pid: %{public}d", rtGrp, pid); return rtGrp; } int ret = AddThreadToRtg(pid, rtGrp); // add ui thread @@ -52,9 +49,8 @@ int RtgMsgMgr::OnForeground(const std::string appName, const int pid) void RtgMsgMgr::OnBackground(const std::string appName, const int pid, const int grpId) { - RME_LOGI("[OnBackground]:pid:%{public}d", pid); if (grpId <= 0) { - RME_LOGI("[OnBackground]:do not find grpid, pid:%{public}d, grpId:%{public}d", pid, grpId); + RME_LOGE("[OnBackground]:do not find grpid, pid:%{public}d, grpId:%{public}d", pid, grpId); return; } DestroyRtgGrp(grpId); @@ -63,7 +59,7 @@ void RtgMsgMgr::OnBackground(const std::string appName, const int pid, const int void RtgMsgMgr::ProcessStart(const int tid, const int grpId) { if (grpId <= 0) { - RME_LOGI("[ProcessStart]:do not find grpid, tid:%{public}d, grpId:%{public}d", tid, grpId); + RME_LOGE("[ProcessStart]:do not find grpid, tid:%{public}d, grpId:%{public}d", tid, grpId); return; } AddThreadToRtg(tid, grpId); @@ -79,9 +75,11 @@ void RtgMsgMgr::ProcessDied(const int pid, const int tid) } int ret = RemoveRtgThread(removeTid); if (ret < 0) { - RME_LOGI("[ProcessDied]: removeRtgGroup failed!pid:%{public}d, tid:%{public}d", pid, tid); + RME_LOGE("[ProcessDied]: removeRtgGroup failed!pid:%{public}d, tid:%{public}d", pid, tid); + } else { + RME_LOGI("[ProcessDied]: removeRtgGroup success! pid:%{public}d, tid:%{public}d:tid", pid, tid); } - RME_LOGI("[ProcessDied]: removeRtgGroup success! pid:%{public}d, tid:%{public}d:tid", pid, tid); + } void RtgMsgMgr::FpsChanged() @@ -93,6 +91,5 @@ void RtgMsgMgr::FocusChanged(const int pid, bool isFocus) { RME_LOGI("[FocusChanged]: need to change prio for rtggrp"); } - } // RME } // OHOS diff --git a/interfaces/innerkits/frameintf/BUILD.gn b/interfaces/innerkits/frameintf/BUILD.gn index 2d4d191..ef12a2e 100644 --- a/interfaces/innerkits/frameintf/BUILD.gn +++ b/interfaces/innerkits/frameintf/BUILD.gn @@ -104,7 +104,12 @@ ohos_shared_library("frame_msg_intf") { ohos_shared_library("rtg_interface") { sources = [ "rtg_interface.cpp" ] - include_dirs = [ "${frame_aware_path}/common/include" ] + include_dirs = [ + "${frame_aware_path}/common/include", + "//utils/native/base/include", + ] + + deps = [ "//utils/native/base:utilsecurec" ] external_deps = [ "hiviewdfx_hilog_native:libhilog" ] diff --git a/interfaces/innerkits/frameintf/frame_msg_intf.cpp b/interfaces/innerkits/frameintf/frame_msg_intf.cpp index 4b7df62..b827b83 100644 --- a/interfaces/innerkits/frameintf/frame_msg_intf.cpp +++ b/interfaces/innerkits/frameintf/frame_msg_intf.cpp @@ -20,7 +20,6 @@ namespace OHOS { namespace RME { - DEFINE_RMELOG_INTELLISENSE("ueaServer-FrameMsgIntf"); FrameMsgIntf& FrameMsgIntf::GetInstance() @@ -79,7 +78,6 @@ void FrameMsgIntf::ReportWindowFocus(const int pid, const int isFocus) void FrameMsgIntf::ReportProcessInfo(const int pid, const int tid, ThreadState state) { - if (threadHandler_ == nullptr) { RME_LOGI("[ReportWindowFocus]:threandHandler none!"); return; @@ -97,7 +95,6 @@ void FrameMsgIntf::Stop() } RME_LOGI("stop eventRunner success!"); } - } // namespace RME } // namespace OHOS diff --git a/interfaces/innerkits/frameintf/frame_ui_intf.cpp b/interfaces/innerkits/frameintf/frame_ui_intf.cpp index d0faac1..f01980b 100644 --- a/interfaces/innerkits/frameintf/frame_ui_intf.cpp +++ b/interfaces/innerkits/frameintf/frame_ui_intf.cpp @@ -21,11 +21,8 @@ namespace OHOS { namespace RME { - DEFINE_RMELOG_INTELLISENSE("ueaCleint-FrameUiIntf"); -//TO DO: need to check the init logic. - FrameUiIntf& FrameUiIntf::GetInstance() { static FrameUiIntf instance; @@ -54,9 +51,8 @@ int FrameUiIntf::GetSenseSchedEnable() return static_cast(ErrorCode::SUCC); } -void FrameUiIntf::BeginFlushAnimation() +void FrameUiIntf::BeginFlushAnimation() const { - RME_LOGI("[BeginFlushAnimation]:start"); if (!inited) { return; @@ -64,7 +60,7 @@ void FrameUiIntf::BeginFlushAnimation() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_ANIMATION, EventState::EVENT_ENTER); } -void FrameUiIntf::EndFlushAnimation() +void FrameUiIntf::EndFlushAnimation() const { if (!inited) { return; @@ -72,16 +68,15 @@ void FrameUiIntf::EndFlushAnimation() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_BUILD, EventState::EVENT_EXIT); } -void FrameUiIntf::BeginFlushBuild() +void FrameUiIntf::BeginFlushBuild() const { if (!inited) { return; } FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_BUILD, EventState::EVENT_ENTER); - RME_LOGI("[BeginFlushBuild]:success"); } -void FrameUiIntf::EndFlushBuild() +void FrameUiIntf::EndFlushBuild() const { if (!inited) { return; @@ -89,15 +84,15 @@ void FrameUiIntf::EndFlushBuild() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_BUILD, EventState::EVENT_EXIT); } -void FrameUiIntf::BeginFlushLayout() -{ +void FrameUiIntf::BeginFlushLayout() const +{ if (!inited) { return; } FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_LAYOUT, EventState::EVENT_ENTER); } -void FrameUiIntf::EndFlushLayout() +void FrameUiIntf::EndFlushLayout() const { if (!inited) { return; @@ -105,7 +100,7 @@ void FrameUiIntf::EndFlushLayout() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_LAYOUT, EventState::EVENT_EXIT); } -void FrameUiIntf::BeginFlushRender() +void FrameUiIntf::BeginFlushRender() const { if (!inited) { return; @@ -113,7 +108,7 @@ void FrameUiIntf::BeginFlushRender() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_RENDER, EventState::EVENT_ENTER); } -void FrameUiIntf::EndFlushRender() +void FrameUiIntf::EndFlushRender() const { if (!inited) { return; @@ -121,7 +116,7 @@ void FrameUiIntf::EndFlushRender() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_RENDER, EventState::EVENT_EXIT); } -void FrameUiIntf::BeginFlushRenderFinish() +void FrameUiIntf::BeginFlushRenderFinish() const { if (!inited) { return; @@ -129,7 +124,7 @@ void FrameUiIntf::BeginFlushRenderFinish() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_RENDER_FINISH, EventState::EVENT_ENTER); } -void FrameUiIntf::EndFlushRenderFinish() +void FrameUiIntf::EndFlushRenderFinish() const { if (!inited) { return; @@ -137,7 +132,7 @@ void FrameUiIntf::EndFlushRenderFinish() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::FLUSH_RENDER_FINISH, EventState::EVENT_EXIT); } -void FrameUiIntf::BeginProcessPostFlush() +void FrameUiIntf::BeginProcessPostFlush() const { if (!inited) { return; @@ -145,7 +140,7 @@ void FrameUiIntf::BeginProcessPostFlush() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::PROCESS_POST_FLUSH, EventState::EVENT_ENTER); } -void FrameUiIntf::ProcessCommandsStart() +void FrameUiIntf::ProcessCommandsStart() const { if (!inited) { return; @@ -153,7 +148,7 @@ void FrameUiIntf::ProcessCommandsStart() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::PROCESS_COMMANDS, EventState::EVENT_ENTER); } -void FrameUiIntf::AnimateStart() +void FrameUiIntf::AnimateStart() const { if (!inited) { return; @@ -161,7 +156,7 @@ void FrameUiIntf::AnimateStart() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::ANIMATE, EventState::EVENT_ENTER); } -void FrameUiIntf::RenderStart() +void FrameUiIntf::RenderStart() const { if (!inited) { return; @@ -169,7 +164,7 @@ void FrameUiIntf::RenderStart() FrameMsgMgr::GetInstance().EventUpdate(FrameEvent::RENDER, EventState::EVENT_ENTER); } -void FrameUiIntf::SendCommandsStart() +void FrameUiIntf::SendCommandsStart() const { RME_LOGI("[SendCommandsStart]:start"); if (!inited) { @@ -187,7 +182,7 @@ extern "C" void Init() extern "C" int GetSenseSchedEnable() { return FrameUiIntf::GetInstance().GetSenseSchedEnable(); -} +} extern "C" void BeginFlushAnimation() { diff --git a/interfaces/innerkits/frameintf/frame_ui_intf.h b/interfaces/innerkits/frameintf/frame_ui_intf.h index 2bfaba7..2801fbd 100644 --- a/interfaces/innerkits/frameintf/frame_ui_intf.h +++ b/interfaces/innerkits/frameintf/frame_ui_intf.h @@ -18,35 +18,33 @@ namespace OHOS { namespace RME { - class FrameUiIntf { public: static FrameUiIntf& GetInstance(); void Init(); int GetSenseSchedEnable(); - void BeginFlushAnimation(); - void EndFlushAnimation(); - - void BeginFlushBuild(); - void EndFlushBuild(); - void BeginFlushLayout(); - void EndFlushLayout(); - - void BeginFlushRender(); - void EndFlushRender(); - - void BeginFlushRenderFinish(); - void EndFlushRenderFinish(); - - void BeginProcessPostFlush(); - void ProcessCommandsStart(); - void AnimateStart(); - void RenderStart(); - void SendCommandsStart(); - - bool inited = false; + void BeginFlushAnimation() const; + void EndFlushAnimation() const; + + void BeginFlushBuild() const; + void EndFlushBuild() const; + void BeginFlushLayout() const; + void EndFlushLayout() const; + + void BeginFlushRender() const; + void EndFlushRender() const; + + void BeginFlushRenderFinish() const; + void EndFlushRenderFinish() const; + + void BeginProcessPostFlush() const; + void ProcessCommandsStart() const; + void AnimateStart() const; + void RenderStart() const; + void SendCommandsStart() const; +private: + bool inited = false; }; - } // namespace RME } // namespace OHOS #endif diff --git a/interfaces/innerkits/frameintf/rtg_interface.cpp b/interfaces/innerkits/frameintf/rtg_interface.cpp index 6c6c13e..9f0094c 100644 --- a/interfaces/innerkits/frameintf/rtg_interface.cpp +++ b/interfaces/innerkits/frameintf/rtg_interface.cpp @@ -17,11 +17,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -29,7 +29,6 @@ namespace OHOS { namespace RME { - DEFINE_RMELOG_INTELLISENSE("rtg_interface"); #define MAX_LENGTH 100 @@ -39,27 +38,27 @@ DEFINE_RMELOG_INTELLISENSE("rtg_interface"); #define RTG_SCHED_IPC_MAGIC 0xAB #define CMD_ID_SET_ENABLE \ - _IOWR(RTG_SCHED_IPC_MAGIC, SET_ENABLE, struct rtg_enable_data) + _IOWR(RTG_SCHED_IPC_MAGIC, SET_ENABLE, struct rtg_enable_data) #define CMD_ID_SET_RTG \ - _IOWR(RTG_SCHED_IPC_MAGIC, SET_RTG, struct rtg_str_data) + _IOWR(RTG_SCHED_IPC_MAGIC, SET_RTG, struct rtg_str_data) #define CMD_ID_SET_CONFIG \ - _IOWR(RTG_SCHED_IPC_MAGIC, SET_CONFIG, struct rtg_str_data) + _IOWR(RTG_SCHED_IPC_MAGIC, SET_CONFIG, struct rtg_str_data) #define CMD_ID_SET_RTG_ATTR \ - _IOWR(RTG_SCHED_IPC_MAGIC, SET_RTG_ATTR, struct rtg_str_data) + _IOWR(RTG_SCHED_IPC_MAGIC, SET_RTG_ATTR, struct rtg_str_data) #define CMD_ID_BEGIN_FRAME_FREQ \ - _IOWR(RTG_SCHED_IPC_MAGIC, BEGIN_FRAME_FREQ, struct proc_state_data) + _IOWR(RTG_SCHED_IPC_MAGIC, BEGIN_FRAME_FREQ, struct proc_state_data) #define CMD_ID_END_FRAME_FREQ \ - _IOWR(RTG_SCHED_IPC_MAGIC, END_FRAME_FREQ, struct proc_state_data) + _IOWR(RTG_SCHED_IPC_MAGIC, END_FRAME_FREQ, struct proc_state_data) #define CMD_ID_END_SCENE \ - _IOWR(RTG_SCHED_IPC_MAGIC, END_SCENE, struct proc_state_data) + _IOWR(RTG_SCHED_IPC_MAGIC, END_SCENE, struct proc_state_data) #define CMD_ID_SET_MIN_UTIL \ - _IOWR(RTG_SCHED_IPC_MAGIC, SET_MIN_UTIL, struct proc_state_data) + _IOWR(RTG_SCHED_IPC_MAGIC, SET_MIN_UTIL, struct proc_state_data) #define CMD_ID_SET_MARGIN \ - _IOWR(RTG_SCHED_IPC_MAGIC, SET_MARGIN, struct proc_state_data) + _IOWR(RTG_SCHED_IPC_MAGIC, SET_MARGIN, struct proc_state_data) #define CMD_ID_LIST_RTG \ - _IOWR(RTG_SCHED_IPC_MAGIC, LIST_RTG, struct rtg_info) + _IOWR(RTG_SCHED_IPC_MAGIC, LIST_RTG, struct rtg_info) #define CMD_ID_LIST_RTG_THREAD \ - _IOWR(RTG_SCHED_IPC_MAGIC, LIST_RTG_THREAD, struct rtg_grp_data) + _IOWR(RTG_SCHED_IPC_MAGIC, LIST_RTG_THREAD, struct rtg_grp_data) #define CMD_ID_SEARCH_RTG \ _IOWR(RTG_SCHED_IPC_MAGIC, SEARCH_RTG, struct proc_state_data) #define CMD_ID_GET_ENABLE \ @@ -76,11 +75,10 @@ int BasicOpenRtgNode() } enum rtg_type { - VIP = 0, - TOP_TASK_KEY, - TOP_TASK, - NORMAL_TASK, - RTG_TYPE_MAX, + VIP = 0, + TOP_TASK_KEY, + NORMAL_TASK, + RTG_TYPE_MAX, }; int EnableRtg(bool flag) @@ -112,7 +110,7 @@ int CreateNewRtgGrp(int prioType, int rtNum) if (fd < 0) { return fd; } - memset(&grp_data, 0, sizeof(struct rtg_grp_data)); + memset_s(&grp_data, sizeof(struct rtg_grp_data), 0, sizeof(struct rtg_grp_data)); if ((prioType > 0) && (prioType < RTG_TYPE_MAX)) { grp_data.prio_type = prioType; } @@ -139,11 +137,11 @@ int AddThreadToRtg(int tid, int grpId) RME_LOGE("open node failed."); return fd; } - memset(&grp_data, 0, sizeof(struct rtg_grp_data)); + memset_s(&grp_data, sizeof(struct rtg_grp_data), 0, sizeof(struct rtg_grp_data)); grp_data.tid_num = 1; grp_data.tids[0] = tid; grp_data.grp_id = grpId; - grp_data.rtg_cmd = CMD_ADD_RTG_THREAD; + grp_data.rtg_cmd = CMD_ADD_RTG_THREAD; ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data); if (ret == 0) { RME_LOGI("add rtg grp success"); @@ -162,7 +160,7 @@ int AddThreadsToRtg(vector tids, int grpId) if (fd < 0) { return fd; } - memset(&grp_data, 0, sizeof(struct rtg_grp_data)); + memset_s(&grp_data, sizeof(struct rtg_grp_data), 0, sizeof(struct rtg_grp_data)); int num = tids.size(); if (num > MAX_TID_NUM) { return -1; @@ -197,10 +195,10 @@ int RemoveRtgThread(int tid) if (fd < 0) { return fd; } - memset(&grp_data, 0, sizeof(struct rtg_grp_data)); + memset_s(&grp_data, sizeof(struct rtg_grp_data), 0, sizeof(struct rtg_grp_data)); grp_data.tid_num = 1; grp_data.tids[0] = tid; - grp_data.rtg_cmd = CMD_REMOVE_RTG_THREAD; + grp_data.rtg_cmd = CMD_REMOVE_RTG_THREAD; ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data); if ( ret < 0) { RME_LOGE("remove grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno)); @@ -219,8 +217,8 @@ int ClearRtgGrp(int GrpId) if (fd < 0) { return fd; } - memset(&grp_data, 0, sizeof(struct rtg_grp_data)); - grp_data.rtg_cmd = CMD_CLEAR_RTG_GRP; + memset_s(&grp_data, sizeof(struct rtg_grp_data), 0, sizeof(struct rtg_grp_data)); + grp_data.rtg_cmd = CMD_CLEAR_RTG_GRP; grp_data.grp_id = GrpId; ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data); if ( ret < 0) { @@ -240,8 +238,8 @@ int DestroyRtgGrp(int GrpId) if (fd < 0) { return fd; } - memset(&grp_data, 0, sizeof(struct rtg_grp_data)); - grp_data.rtg_cmd = CMD_DESTROY_RTG_GRP; + memset_s(&grp_data, sizeof(struct rtg_grp_data), 0, sizeof(struct rtg_grp_data)); + grp_data.rtg_cmd = CMD_DESTROY_RTG_GRP; grp_data.grp_id = GrpId; ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data); if ( ret < 0) { @@ -258,7 +256,7 @@ int SetMaxVipRtgs(int rtframe) { int ret = 0; char str_data[MAX_STR_LEN] = {}; - snprintf(str_data, MAX_STR_LEN, "rtframe:%d", rtframe); + (void)snprintf_s(str_data, MAX_STR_LEN, MAX_STR_LEN - 1, "rtframe:%d", rtframe); struct rtg_str_data strData; strData.len = strlen(str_data); strData.data = str_data; @@ -281,7 +279,7 @@ int SetFrameRateAndPrioType(int rtgId, int rate, int rtgType) { int ret = 0; char str_data[MAX_LENGTH] = {}; - snprintf(str_data, MAX_LENGTH, "rtgId:%d;rate:%d;type:%d", rtgId, rate, rtgType); + (void)snprintf_s(str_data, MAX_LENGTH, MAX_LENGTH - 1, "rtgId:%d;rate:%d;type:%d", rtgId, rate, rtgType); struct rtg_str_data strData; strData.len = strlen(str_data); strData.data = str_data; @@ -369,7 +367,7 @@ int SetMinUtil(int grpId, int stateParam) int ret = 0; struct proc_state_data state_data; state_data.grp_id = grpId; - state_data.state_param = stateParam; + state_data.state_param = stateParam; int fd = BasicOpenRtgNode(); if (fd < 0) { @@ -419,7 +417,7 @@ int ListRtgGroup(vector *rs) if (!rs) { return -1; } - memset(&rtg_info, 0, sizeof(struct rtg_info)); + memset_s(&rtg_info, sizeof(struct rtg_info), 0, sizeof(struct rtg_info)); ret = ioctl(fd, CMD_ID_LIST_RTG, &rtg_info); if ( ret < 0) { RME_LOGE("list rtg group failed, errno = %{public}d (%{public}s)", errno, strerror(errno)); @@ -445,7 +443,7 @@ int ListRtgThread(int grpId, vector *rs) if (!rs) { return -1; } - memset(&grp_data, 0, sizeof(struct rtg_grp_data)); + memset_s(&grp_data, sizeof(struct rtg_grp_data), 0, sizeof(struct rtg_grp_data)); grp_data.grp_id = grpId; ret = ioctl(fd, CMD_ID_LIST_RTG_THREAD, &grp_data); if ( ret < 0) { @@ -473,7 +471,7 @@ int SearchRtgForTid(int tid) RME_LOGI("Search tid err: invalid tid."); return -1; } - memset(&search_data, 0, sizeof(struct proc_state_data)); + memset_s(&search_data, sizeof(struct proc_state_data), 0, sizeof(struct proc_state_data)); search_data.state_param = tid; ret = ioctl(fd, CMD_ID_SEARCH_RTG, &search_data); if ( ret < 0) { @@ -494,6 +492,5 @@ int GetRtgEnable() } return ioctl(fd, CMD_ID_GET_ENABLE, &enableData); } - } // namespace RME } // namespace OHOS diff --git a/test/unittest/phone/frame_msg_intf_test.cpp b/test/unittest/phone/frame_msg_intf_test.cpp index f89c2be..c63bc23 100644 --- a/test/unittest/phone/frame_msg_intf_test.cpp +++ b/test/unittest/phone/frame_msg_intf_test.cpp @@ -56,7 +56,7 @@ void FrameMsgIntfTest::TearDown() { FrameMsgIntf::GetInstance().Stop(); std::shared_ptr thread = FrameMsgIntf::GetInstance().threadHandler_; - EXPECT_TRUE(thread == nullptr); + EXPECT_TRUE(thread == nullptr); } HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoColdStart, TestSize.Level1) @@ -69,7 +69,6 @@ HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoColdStart, TestSize.Level1) sleep(1); std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); bool isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1); - std::cout << "cold start: size:" << mapList.size() << " count:" << mapList.count(pid_1) << " isAppPidExist:" << isAppPidExist << std::endl; EXPECT_TRUE(isAppPidExist); // should be true } @@ -86,7 +85,6 @@ HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoWarmStart, TestSize.Level1) std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); bool isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1); - std::cout << "warm start: size:" << mapList.size() << " count:" << mapList.count(pid_1) << " isAppPidExist:" << isAppPidExist << std::endl; EXPECT_TRUE(isAppPidExist); // should be true } @@ -103,7 +101,6 @@ HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoTerminated, TestSize.Level1) std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); bool isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1); - std::cout << "app terminated: size:" << mapList.size() << " count:" << mapList.count(pid_1) << " isAppPidExist:" << isAppPidExist << std::endl; EXPECT_FALSE(isAppPidExist); } @@ -114,7 +111,6 @@ HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoSwitch, TestSize.Level1) int pid_2 = 10041; std::string appName_2 = "com.ohos.frameaware.testAppSwitch2"; - // app foreground FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); FrameMsgIntf::GetInstance().ReportAppInfo(appName_2, appName_2, pid_2, AppStateUpdateReason::APP_FOREGROUND); @@ -125,60 +121,44 @@ HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportAppInfoSwitch, TestSize.Level1) sleep(1); std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); - std::cout << "size:" << mapList.size() << " count:" << mapList.count(pid_1) << std::endl; bool isAppPidExist = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_1); bool isAppPidExist2 = AppInfoMgr::GetInstance().GetForegroundApp().count(pid_2); - - std::cout << "app switch: size:" << mapList.size() << " count:" << mapList.count(pid_1) << " isAppPidExist:" << isAppPidExist << std::endl; - EXPECT_TRUE(isAppPidExist); // should be true EXPECT_FALSE(isAppPidExist2); // should be false } HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportWindowFocus, TestSize.Level1) { - int pid_1 = 1005; - std::string appName_1 = "com.ohos.frameaware.testWindowFocus"; - // app focus FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 0); sleep(1); - std::shared_ptr app_1 = AppInfoMgr::GetInstance().GetFocusApp(); bool focusSta_1 = app_1->GetFocusState(); - EXPECT_EQ(focusSta_1, false); // 0 means focus } HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportWindowUnFocus, TestSize.Level1) { - int pid_1 = 1006; - std::string appName_1 = "com.ohos.frameaware.testWindowUnfocus"; - // app focus FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_FOREGROUND); FrameMsgIntf::GetInstance().ReportAppInfo(appName_1, appName_1, pid_1, AppStateUpdateReason::APP_BACKGROUND); FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 0); FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 1); sleep(1); - std::shared_ptr app_1 = AppInfoMgr::GetInstance().GetFocusApp(); - EXPECT_EQ(app_1 == nullptr, true); // 1 means unfocus } HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportProcessInfoUiDiedFore, TestSize.Level1) { - //process died int pid_1 = 1007; int ui_tid = pid_1; - // foreground ui died FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 0); sleep(1); std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); @@ -194,7 +174,7 @@ HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportProcessInfoUiDiedBack, TestSize.Lev { int pid_1 = 1008; int ui_tid = pid_1; - //background ui died + FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 0); FrameMsgIntf::GetInstance().ReportWindowFocus(pid_1, 1); FrameMsgIntf::GetInstance().ReportProcessInfo(pid_1, ui_tid, ThreadState::DIED); @@ -208,7 +188,6 @@ HWTEST_F(FrameMsgIntfTest, FrameMsgIntfReportProcessInfoRenderDiedFore, TestSize int pid_2 = 1009; int render_tid = 10091; - // foreground render died FrameMsgIntf::GetInstance().ReportWindowFocus(pid_2, 0); sleep(1); std::map> mapList = AppInfoMgr::GetInstance().GetForegroundApp(); diff --git a/test/unittest/phone/rtg_interface_test.cpp b/test/unittest/phone/rtg_interface_test.cpp index d0e53cc..5fd7189 100644 --- a/test/unittest/phone/rtg_interface_test.cpp +++ b/test/unittest/phone/rtg_interface_test.cpp @@ -29,11 +29,10 @@ using namespace testing::ext; #define RTG_INTERFACE_SO_PATH "/system/lib/librtg_interface.z.so" enum rtg_type { - VIP = 0, - TOP_TASK_KEY, - TOP_TASK, - NORMAL_TASK, - RTG_TYPE_MAX, + VIP = 0, + TOP_TASK_KEY, + NORMAL_TASK, + RTG_TYPE_MAX, }; class RtgInterfaceTest : public testing::Test { -- Gitee From 1fc5c352301b1af7c35e86494b9e6d9b6a9d23fa Mon Sep 17 00:00:00 2001 From: rongkunshi Date: Fri, 25 Feb 2022 12:01:16 +0800 Subject: [PATCH 4/7] fix codex 2.0 for door Signed-off-by: rongkunshi --- .../src/rme_core_sched.cpp | 21 ++++++++++--------- .../frame_aware_policy/src/rtg_msg_mgr.cpp | 6 +++--- .../innerkits/frameintf/rtg_interface.cpp | 20 +++++++++--------- test/unittest/phone/frame_msg_intf_test.cpp | 4 ++-- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp index 7578ed9..ce51701 100644 --- a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp +++ b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp @@ -35,7 +35,7 @@ RmeCoreSched::~RmeCoreSched() bool RmeCoreSched::Init() { int ret = GetRtgEnable(); - if (ret) { + if (ret > 0) { RME_LOGE("[Init]: rtgEnabled! scheme Open!ret: %{public}d", ret); } else { RME_LOGE("[Init]: do not enabled!ret: %{public}d", ret); @@ -56,10 +56,10 @@ void RmeCoreSched::BeginFlushAnimation() } else { RME_LOGI("[BeginFlushAnimation]:Search rtg sucess m_currentRtg, val:%{public}d", m_currentRtg); } - } + } int ret = BeginFrameFreq(m_currentRtg, 0); RME_LOGI("[BeginFlushAnimation]: set BeginFrameFreq, currentRtg:%{public}d, currentPid:%{public}d, \ - tid:%{public}d, ret:%{public}d!", m_currentRtg, m_currentPid, tid, ret); + tid:%{public}d, ret:%{public}d!", m_currentRtg, m_currentPid, tid, ret); return; } @@ -112,8 +112,9 @@ void RmeCoreSched::AnimateStart() %{public}d, m_currentPid:%{public}d, pid: %{public}d", ret, m_currentRtg, rendertid, m_currentPid, pid); } else { isRenderAdd = true; - RME_LOGI("[AnimateStart]:add rtg grp SUCESS! rendertid: %{public}d, pid: %{public}d,\ - rtGrp: %{public}d, m_currentPid:%{public}d", rendertid, pid, m_currentRtg, m_currentPid); + RME_LOGI("[AnimateStart]:add rtg grp SUCESS! rendertid: \ + %{public}d, pid: %{public}d, rtGrp: %{public}d, m_currentPid:%{public}d", + rendertid, pid, m_currentRtg, m_currentPid); } } @@ -126,13 +127,13 @@ void RmeCoreSched::SendCommandsStart() { int pid = getpid(); if (m_currentRtg <= 0) { - RME_LOGE("[SendCommandStart]: m_currentRtg error! rtGrp:%{public}d, \ - m_currentPid:%{public}d, pid:%{public}d!", m_currentRtg, m_currentPid, pid); + RME_LOGE("[SendCommandStart]: m_currentRtg error! rtGrp:%{public}d, m_currentPid:%{public}d, pid:%{public}d!", + m_currentRtg, m_currentPid, pid); return; } int ret = EndFrameFreq(m_currentRtg); - RME_LOGI("[SendCommandsStart]: set EndFrameFreq, ret: %{public}d, m_currentPid:\ - %{publid}d, pid:%{public}d!", ret, m_currentPid, pid); + RME_LOGI("[SendCommandsStart]: set EndFrameFreq, ret: %{public}d, m_currentPid:%{publid}d, pid:%{public}d!", + ret, m_currentPid, pid); } } // namespace RME -} // OHOS \ No newline at end of file +} // OHOS diff --git a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp index abd25b2..894f8f9 100644 --- a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp +++ b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp @@ -33,7 +33,7 @@ void RtgMsgMgr::Init() } int RtgMsgMgr::OnForeground(const std::string appName, const int pid) -{ +{ // for multiwindow int rtGrp = CreateNewRtgGrp(PRIO_TYPE, RT_NUM); if (rtGrp <= 0) { @@ -42,7 +42,8 @@ int RtgMsgMgr::OnForeground(const std::string appName, const int pid) } int ret = AddThreadToRtg(pid, rtGrp); // add ui thread if (ret != 0) { - RME_LOGI("[OnForeground]: add thread pid: %{public}d to rtgGrp: %{public}d failed! ret: %{publid}d", pid, rtGrp, ret); + RME_LOGI("[OnForeground]: add thread pid: %{public}d to rtgGrp: %{public}d \ + failed! ret: %{publid}d", pid, rtGrp, ret); } return rtGrp; } @@ -79,7 +80,6 @@ void RtgMsgMgr::ProcessDied(const int pid, const int tid) } else { RME_LOGI("[ProcessDied]: removeRtgGroup success! pid:%{public}d, tid:%{public}d:tid", pid, tid); } - } void RtgMsgMgr::FpsChanged() diff --git a/interfaces/innerkits/frameintf/rtg_interface.cpp b/interfaces/innerkits/frameintf/rtg_interface.cpp index 9f0094c..d35127f 100644 --- a/interfaces/innerkits/frameintf/rtg_interface.cpp +++ b/interfaces/innerkits/frameintf/rtg_interface.cpp @@ -14,7 +14,6 @@ */ #include "rtg_interface.h" -#include #include #include #include @@ -24,17 +23,18 @@ #include #include #include +#include #include "rme_log_domain.h" namespace OHOS { namespace RME { +namespace { + constexpr int MAX_LENGTH = 100; + constexpr int MAX_STR_LEN = 100; +} DEFINE_RMELOG_INTELLISENSE("rtg_interface"); -#define MAX_LENGTH 100 -#define MAX_STR_LEN 100 -#define MAX_PATH_LEN 100 - #define RTG_SCHED_IPC_MAGIC 0xAB #define CMD_ID_SET_ENABLE \ @@ -322,9 +322,9 @@ int BeginFrameFreq(int grpId, int stateParam) int EndFrameFreq(int grpId) { int ret = 0; - struct proc_state_data state_data; + struct proc_state_data state_data; state_data.grp_id = grpId; - state_data.state_param = 0; + state_data.state_param = 0; int fd = BasicOpenRtgNode(); if (fd < 0) { @@ -344,7 +344,7 @@ int EndFrameFreq(int grpId) int EndScene(int grpId) { int ret = 0; - struct proc_state_data state_data; + struct proc_state_data state_data; state_data.grp_id = grpId; int fd = BasicOpenRtgNode(); @@ -387,9 +387,9 @@ int SetMinUtil(int grpId, int stateParam) int SetMargin(int grpId, int stateParam) { int ret = 0; - struct proc_state_data state_data; + struct proc_state_data state_data; state_data.grp_id = grpId; - state_data.state_param = stateParam; + state_data.state_param = stateParam; int fd = BasicOpenRtgNode(); if (fd < 0) { diff --git a/test/unittest/phone/frame_msg_intf_test.cpp b/test/unittest/phone/frame_msg_intf_test.cpp index c63bc23..115c403 100644 --- a/test/unittest/phone/frame_msg_intf_test.cpp +++ b/test/unittest/phone/frame_msg_intf_test.cpp @@ -17,11 +17,11 @@ #define private public #define protected public +#include +#include #include "frame_msg_intf.h" #include "app_info_mgr.h" #include "app_info.h" -#include -#include #undef private #undef protected -- Gitee From b4d64388866b6410c09e37cfe3725a1e52cebb9b Mon Sep 17 00:00:00 2001 From: rongkunshi Date: Fri, 25 Feb 2022 12:16:54 +0800 Subject: [PATCH 5/7] rtg_interface_test bug fix Signed-off-by: rongkunshi --- test/unittest/phone/rtg_interface_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unittest/phone/rtg_interface_test.cpp b/test/unittest/phone/rtg_interface_test.cpp index 5fd7189..133696e 100644 --- a/test/unittest/phone/rtg_interface_test.cpp +++ b/test/unittest/phone/rtg_interface_test.cpp @@ -232,7 +232,7 @@ HWTEST_F(RtgInterfaceTest, RtgInterfaceEndFrameFreq, TestSize.Level1) int grpId = 0; grpId = CreateNewRtgGrp(VIP, 0); EXPECT_GT(grpId, 0); - ret = EndFrameFreq(grpId, 0); + ret = EndFrameFreq(grpId); EXPECT_EQ(ret, 0); ret = DestroyRtgGrp(grpId); EXPECT_EQ(ret, 0); @@ -246,7 +246,7 @@ HWTEST_F(RtgInterfaceTest, RtgInterfaceEndFrameFreq, TestSize.Level1) HWTEST_F(RtgInterfaceTest, RtgInterfaceEndFrameFreqWithErrorGrp, TestSize.Level1) { int ret = 0; - ret = EndFrameFreq(-1, 0); + ret = EndFrameFreq(-1); EXPECT_NE(ret, 0); } -- Gitee From 114dd565e4124e6cc59ef1dd65c94c0bbc5333db Mon Sep 17 00:00:00 2001 From: rongkunshi Date: Fri, 25 Feb 2022 15:21:48 +0800 Subject: [PATCH 6/7] codex 3.0 and rtg interface test bugfix Signed-off-by: rongkunshi --- .../src/rme_core_sched.cpp | 22 ++++++++----------- .../frame_aware_policy/src/app_info_mgr.cpp | 6 ++--- .../frame_aware_policy/src/rtg_msg_mgr.cpp | 3 +-- .../innerkits/frameintf/rtg_interface.cpp | 12 +++------- test/unittest/phone/rtg_interface_test.cpp | 4 ++-- 5 files changed, 17 insertions(+), 30 deletions(-) diff --git a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp index ce51701..f4da518 100644 --- a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp +++ b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp @@ -50,16 +50,16 @@ void RmeCoreSched::BeginFlushAnimation() if (m_currentRtg == -1) { m_currentRtg = SearchRtgForTid(m_currentPid); if (m_currentRtg <= 0) { - RME_LOGE("[BeginFlushAnimation]:Search rtg for pid %{public}d failed! \ - m_currentRtg: %{public}d", m_currentPid, m_currentRtg); + RME_LOGE("[BeginFlushAnimation]:Search rtg failed!pid %{public}d,Rtg: %{public}d", + m_currentPid, m_currentRtg); return; } else { - RME_LOGI("[BeginFlushAnimation]:Search rtg sucess m_currentRtg, val:%{public}d", m_currentRtg); + RME_LOGI("[BeginFlushAnimation]:Search rtg sucess Rtg, val:%{public}d", m_currentRtg); } } int ret = BeginFrameFreq(m_currentRtg, 0); - RME_LOGI("[BeginFlushAnimation]: set BeginFrameFreq, currentRtg:%{public}d, currentPid:%{public}d, \ - tid:%{public}d, ret:%{public}d!", m_currentRtg, m_currentPid, tid, ret); + RME_LOGI("[BeginFlushAnimation]:BeginFrameFreq,Rtg:%{public}d,Pid:%{public}d,tid:%{public}d, ret:%{public}d!", + m_currentRtg, m_currentPid, tid, ret); return; } @@ -100,21 +100,17 @@ void RmeCoreSched::AnimateStart() return; } if (m_currentRtg <= 0) { - RME_LOGE("[AnimateStart]: search rtg error! m_currentRtg:%{public}d, \ - m_currentPid:%{public}d", m_currentRtg, m_currentPid); + RME_LOGE("[AnimateStart]: search rtg error! Rtg:%{public}d, Pid:%{public}d", m_currentRtg, m_currentPid); return; } int rendertid = gettid(); - int pid = getpid(); // ui tid equals pid now. int ret = AddThreadToRtg(rendertid, m_currentRtg); if (ret) { // 1 means false. - RME_LOGE("[AnimateStart]:add rtg grp failed!, ret: %{public}d, rtGrp: %{public}d, rendertid: \ - %{public}d, m_currentPid:%{public}d, pid: %{public}d", ret, m_currentRtg, rendertid, m_currentPid, pid); + RME_LOGE("[AnimateStart]:add rtg failed! rtGrp: %{public}d, rendertid: %{public}d, m_currentPid:%{public}d", + m_currentRtg, rendertid, m_currentPid); } else { isRenderAdd = true; - RME_LOGI("[AnimateStart]:add rtg grp SUCESS! rendertid: \ - %{public}d, pid: %{public}d, rtGrp: %{public}d, m_currentPid:%{public}d", - rendertid, pid, m_currentRtg, m_currentPid); + RME_LOGI("[AnimateStart]:add rtg SUCESS! rendertid:%{public}d, rtGrp:%{public}d",rendertid, m_currentRtg); } } diff --git a/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp b/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp index ab215d5..cd0821e 100644 --- a/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp +++ b/frameworks/core/frame_aware_policy/src/app_info_mgr.cpp @@ -37,8 +37,7 @@ void AppInfoMgr::OnForegroundChanged(const int pid, const std::string appName, c mForegroundAppList[pid] = appInfo; } mForegroundAppList[pid]->SetRtgrp(rtGrp); - RME_LOGI("[OnForegroundChanged]:pid:%{public}d, rtgrp:%{public}d, \ - app_state: %{public}d", pid, rtGrp, static_cast(mForegroundAppList[pid]->GetAppState())); + RME_LOGI("[OnForegroundChanged]:pid:%{public}d, rtgrp:%{public}d", pid, rtGrp); } void AppInfoMgr::OnBackgroundChanged(const int pid, const std::string appName) @@ -108,8 +107,7 @@ bool AppInfoMgr::OnProcessDied(const int pid, const int tid) mBackgroundAppList[pid]->SetRenderTid(INIT_VAL); } } - RME_LOGI("[OnProcessDied]: pid: %{public}d, tid:%{public}d, deleted:%{public}d, isExist:foreground:%{public}d, \ - background:%{public}d.", pid, tid, deleted, mForegroundAppList.count(pid), mBackgroundAppList.count(pid)); + RME_LOGI("[OnProcessDied]: pid: %{public}d, tid:%{public}d, deleted:%{public}d.", pid, tid, deleted); return deleted; } diff --git a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp index 894f8f9..45b1082 100644 --- a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp +++ b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp @@ -42,8 +42,7 @@ int RtgMsgMgr::OnForeground(const std::string appName, const int pid) } int ret = AddThreadToRtg(pid, rtGrp); // add ui thread if (ret != 0) { - RME_LOGI("[OnForeground]: add thread pid: %{public}d to rtgGrp: %{public}d \ - failed! ret: %{publid}d", pid, rtGrp, ret); + RME_LOGE("[OnFore]:add thread fail! pid:%{public}d,rtg:%{public}d!ret:%{publid}d",pid, rtGrp, ret); } return rtGrp; } diff --git a/interfaces/innerkits/frameintf/rtg_interface.cpp b/interfaces/innerkits/frameintf/rtg_interface.cpp index d35127f..72b88c0 100644 --- a/interfaces/innerkits/frameintf/rtg_interface.cpp +++ b/interfaces/innerkits/frameintf/rtg_interface.cpp @@ -30,8 +30,9 @@ namespace OHOS { namespace RME { namespace { - constexpr int MAX_LENGTH = 100; - constexpr int MAX_STR_LEN = 100; + constexpr size_t MAX_LENGTH = 100; + constexpr size_t MAX_STR_LEN = 100; + constexpr int RTG_TYPE_MAX = 3; } DEFINE_RMELOG_INTELLISENSE("rtg_interface"); @@ -74,13 +75,6 @@ int BasicOpenRtgNode() return fd; } -enum rtg_type { - VIP = 0, - TOP_TASK_KEY, - NORMAL_TASK, - RTG_TYPE_MAX, -}; - int EnableRtg(bool flag) { struct rtg_enable_data enableData; diff --git a/test/unittest/phone/rtg_interface_test.cpp b/test/unittest/phone/rtg_interface_test.cpp index 133696e..268d1ba 100644 --- a/test/unittest/phone/rtg_interface_test.cpp +++ b/test/unittest/phone/rtg_interface_test.cpp @@ -74,7 +74,7 @@ HWTEST_F(RtgInterfaceTest, RtgInterfaceCreateAndDestroy, TestSize.Level1) { int ret = 0; int grpId = 0; - grpId = CreateNewRtgGrp(VIP, 0); + grpId = CreateNewRtgGrp(NORMAL_TASK, 0); EXPECT_GT(grpId, 0); ret = DestroyRtgGrp(grpId); EXPECT_EQ(ret, 0); @@ -481,4 +481,4 @@ HWTEST_F(RtgInterfaceTest, RtgInterfaceSetLargeMaxVips, TestSize.Level1) } } // namespace RME -} // namespace OHOS \ No newline at end of file +} // namespace OHOS -- Gitee From 4827f34cfdd95410b2665869727a6636504250a3 Mon Sep 17 00:00:00 2001 From: rongkunshi Date: Fri, 25 Feb 2022 19:41:28 +0800 Subject: [PATCH 7/7] codex 4.0 Signed-off-by: rongkunshi --- frameworks/core/frame_aware_collector/src/rme_core_sched.cpp | 2 +- frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp | 2 +- interfaces/innerkits/frameintf/rtg_interface.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp index f4da518..f70380e 100644 --- a/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp +++ b/frameworks/core/frame_aware_collector/src/rme_core_sched.cpp @@ -110,7 +110,7 @@ void RmeCoreSched::AnimateStart() m_currentRtg, rendertid, m_currentPid); } else { isRenderAdd = true; - RME_LOGI("[AnimateStart]:add rtg SUCESS! rendertid:%{public}d, rtGrp:%{public}d",rendertid, m_currentRtg); + RME_LOGI("[AnimateStart]:add rtg SUCESS! rendertid:%{public}d, rtGrp:%{public}d", rendertid, m_currentRtg); } } diff --git a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp index 45b1082..212889a 100644 --- a/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp +++ b/frameworks/core/frame_aware_policy/src/rtg_msg_mgr.cpp @@ -42,7 +42,7 @@ int RtgMsgMgr::OnForeground(const std::string appName, const int pid) } int ret = AddThreadToRtg(pid, rtGrp); // add ui thread if (ret != 0) { - RME_LOGE("[OnFore]:add thread fail! pid:%{public}d,rtg:%{public}d!ret:%{publid}d",pid, rtGrp, ret); + RME_LOGE("[OnFore]:add thread fail! pid:%{public}d,rtg:%{public}d!ret:%{publid}d", pid, rtGrp, ret); } return rtGrp; } diff --git a/interfaces/innerkits/frameintf/rtg_interface.cpp b/interfaces/innerkits/frameintf/rtg_interface.cpp index 72b88c0..90ce408 100644 --- a/interfaces/innerkits/frameintf/rtg_interface.cpp +++ b/interfaces/innerkits/frameintf/rtg_interface.cpp @@ -250,7 +250,7 @@ int SetMaxVipRtgs(int rtframe) { int ret = 0; char str_data[MAX_STR_LEN] = {}; - (void)snprintf_s(str_data, MAX_STR_LEN, MAX_STR_LEN - 1, "rtframe:%d", rtframe); + snprintf(str_data, MAX_STR_LEN, "rtframe:%d", rtframe); struct rtg_str_data strData; strData.len = strlen(str_data); strData.data = str_data; @@ -273,7 +273,7 @@ int SetFrameRateAndPrioType(int rtgId, int rate, int rtgType) { int ret = 0; char str_data[MAX_LENGTH] = {}; - (void)snprintf_s(str_data, MAX_LENGTH, MAX_LENGTH - 1, "rtgId:%d;rate:%d;type:%d", rtgId, rate, rtgType); + snprintf(str_data, MAX_LENGTH, "rtgId:%d;rate:%d;type:%d", rtgId, rate, rtgType); struct rtg_str_data strData; strData.len = strlen(str_data); strData.data = str_data; -- Gitee