diff --git a/frameworks/core/frame_aware_policy/include/app_info.h b/frameworks/core/frame_aware_policy/include/app_info.h index 8af5afce0d863f1f2de47cedcb470ba09da59578..06919d5bc2390cd08872ecf7cbe1b0221002cd22 100644 --- a/frameworks/core/frame_aware_policy/include/app_info.h +++ b/frameworks/core/frame_aware_policy/include/app_info.h @@ -43,7 +43,7 @@ enum class CgroupPolicy { class AppInfo { public: - AppInfo(int pid); + AppInfo(int pid, int uid); ~AppInfo() = default; void SetRenderTid(const int tid); @@ -57,11 +57,13 @@ public: int GetFocusState(); void SetAppPid(const int pid); int GetAppPid(); + int GetAppUid(); void SetRtgrp(const int grpNum); int GetRtgrp(); private: std::string m_appName; int m_pid; + int m_uid; int m_uiTid; int m_renderTid; int m_isFocus; diff --git a/frameworks/core/frame_aware_policy/include/intellisense_server.h b/frameworks/core/frame_aware_policy/include/intellisense_server.h index 48e6a3e523460cc0b33f49bc511623166bd850f9..7b34b8f75a2705b259db230f4be592f9c8e880bb 100644 --- a/frameworks/core/frame_aware_policy/include/intellisense_server.h +++ b/frameworks/core/frame_aware_policy/include/intellisense_server.h @@ -44,10 +44,10 @@ public: void SetPara(const int32_t currentFps, const int32_t currentRenderType); private: - void NewForeground(int pid); + void NewForeground(int pid, int uid); void NewBackground(int pid); void NewDiedProcess(int pid); - void NewAppRecord(int pid); + void NewAppRecord(int pid, int uid); void AuthAppKilled(int uid); void AuthForeground(int uid); void AuthBackground(int uid); diff --git a/frameworks/core/frame_aware_policy/src/app_info.cpp b/frameworks/core/frame_aware_policy/src/app_info.cpp index 322f846843ca2469235ab849e2c1dbfb9c7e8274..474d83eaec98886eafbfc0f2ae5ba150e9fc5797 100644 --- a/frameworks/core/frame_aware_policy/src/app_info.cpp +++ b/frameworks/core/frame_aware_policy/src/app_info.cpp @@ -17,9 +17,10 @@ namespace OHOS { namespace RME { -AppInfo::AppInfo(int pid) +AppInfo::AppInfo(int pid, int uid) : m_appName(""), m_pid(pid), + m_uid(uid), m_uiTid(0), m_renderTid(0), m_isFocus(0), @@ -77,6 +78,11 @@ int AppInfo::GetAppPid() return m_pid; } +int AppInfo::GetAppUid() +{ + return m_uid; +} + AppState AppInfo::GetAppState() { return m_appState; diff --git a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp index fa17b79049592c6e71cc84f9e25904eebfe1e054..6ca24c269c19920de2c0ff43b88522d1d3aaeb81 100644 --- a/frameworks/core/frame_aware_policy/src/intellisense_server.cpp +++ b/frameworks/core/frame_aware_policy/src/intellisense_server.cpp @@ -30,6 +30,8 @@ namespace OHOS { namespace RME { namespace { static std::string configFilePath = "/system/etc/frame_aware_sched/hwrme.xml"; // need To check the exact file path. + constexpr int WEB_BASE_UID = 1000001; + constexpr int WEB_END_UID = 1099999; } using namespace std; using namespace QosCommon; @@ -83,12 +85,12 @@ bool IntelliSenseServer::ReadXml() return false; } -void IntelliSenseServer::NewForeground(int pid) +void IntelliSenseServer::NewForeground(int pid, int uid) { HITRACE_METER(HITRACE_TAG_ACE); int newCreatedRtg = 0; for (auto iter = m_historyApp.begin(); iter != m_historyApp.end(); iter++) { - if (iter->GetAppPid() == pid) { + if (iter->GetAppUid() == uid) { RME_LOGI("[ReportMessage]pid %{public}d change to foreground.", pid); if (iter->GetAppState() != AppState::APP_FOREGROUND) { iter->SetUiTid(pid); @@ -145,15 +147,15 @@ void IntelliSenseServer::NewBackground(int pid) } } -void IntelliSenseServer::NewAppRecord(int pid) +void IntelliSenseServer::NewAppRecord(int pid, int uid) { for (auto iter = m_historyApp.begin(); iter != m_historyApp.end(); iter++) { - if (iter->GetAppPid() == pid) { + if (iter->GetAppUid() == uid) { RME_LOGI("[NewAppRecord]pid %{public}d already exist.", pid); return; } } - AppInfo tempRecord(pid); + AppInfo tempRecord(pid, uid); tempRecord.SetAppState(AppState::APP_FOREGROUND_WITHOUT_RTG); m_historyApp.push_back(tempRecord); } @@ -188,6 +190,9 @@ std::list::iterator IntelliSenseServer::GetRecordOfPid(int pid) void IntelliSenseServer::ReportRenderThread(const int pid, const int uid, int renderTid) { + if (uid >= WEB_BASE_UID && uid <= WEB_END_UID) { + return; + } if (!m_switch) { return; } @@ -201,6 +206,7 @@ void IntelliSenseServer::ReportRenderThread(const int pid, const int uid, int re int grpId = record->GetRtgrp(); if (grpId >= 0 && record->GetAppState() == AppState::APP_FOREGROUND) { int ret = AddThreadToRtg(renderTid, grpId, 0); // add render thread + RME_LOGE("web test ReportRenderThread uid is %{public}d", uid); if (ret != 0) { RME_LOGE("[OnFore]:add render thread fail! pid:%{public}d,rtg:%{public}d!ret:%{publid}d", renderTid, grpId, ret); @@ -235,6 +241,9 @@ inline CgroupPolicy IntelliSenseServer::CheckCgroupState(CgroupPolicy cgroup) void IntelliSenseServer::ReportCgroupChange(const int pid, const int uid, const int oldGroup, const int newGroup) { + if (uid >= WEB_BASE_UID && uid <= WEB_END_UID) { + return; + } if (!m_switch) { return; } @@ -249,8 +258,8 @@ void IntelliSenseServer::ReportCgroupChange(const int pid, const int uid, const NewBackground(pid); AuthBackground(uid); } else if (newState == CgroupPolicy::SP_FOREGROUND) { - RME_LOGI("CgroupChange NewForeground"); - NewForeground(pid); + RME_LOGI("web test CgroupChange NewForeground uid is %{public}d", uid); + NewForeground(pid, uid); AuthForeground(uid); } } @@ -270,6 +279,9 @@ void IntelliSenseServer::ReportAppInfo(const int pid, const int uid, const std:: void IntelliSenseServer::ReportProcessInfo(const int pid, const int uid, const std::string bundleName, ThreadState state) { + if (uid >= WEB_BASE_UID && uid <= WEB_END_UID) { + return; + } if (!m_switch) { return; } @@ -285,7 +297,7 @@ void IntelliSenseServer::ReportProcessInfo(const int pid, break; case ThreadState::CREATE: RME_LOGI("ProcessInfo NewAppRecord"); - NewAppRecord(pid); + NewAppRecord(pid, uid); break; default: RME_LOGI("unknown state : %{public}d", static_cast(state)); diff --git a/interfaces/inner_api/qos.h b/interfaces/inner_api/qos.h index 98a82b86d9695b9009c6eac6db7097be5733fdfb..28553f7c03b1eb0639b0c88afb4854e46d3de732 100644 --- a/interfaces/inner_api/qos.h +++ b/interfaces/inner_api/qos.h @@ -22,7 +22,9 @@ enum class QosLevel { qos_background = 1, qos_utility, qos_default, - qos_user_initiated = 4, + qos_user_initiated, + qos_deadline_request, + qos_user_interactive, }; class QosController { diff --git a/qos_manager/src/qos_manager.cpp b/qos_manager/src/qos_manager.cpp index ec30133bf4bb10e73c98a9a30e26722dddb9075c..22ede23c864009fe20565a7174295c7b80800c7a 100644 --- a/qos_manager/src/qos_manager.cpp +++ b/qos_manager/src/qos_manager.cpp @@ -127,7 +127,7 @@ int QosController::SetPolicy() int QosController::SetThreadQosForOtherThread(enum QosLevel level, int tid) { int qos = static_cast(level); - if (level < QosLevel::qos_background || level > QosLevel::qos_user_initiated) { + if (level < QosLevel::qos_background || level > QosLevel::qos_user_interactive) { RME_LOGE("invalid qos level %{public}d", qos); return ERROR_NUM; } @@ -176,4 +176,4 @@ int ResetQosForOtherThread(int tid) } } // namespace QOS -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/test/unittest/phone/qos_manager_test.cpp b/test/unittest/phone/qos_manager_test.cpp index ce4d8e6178b30e479f1f9b128a810d5f3d96e583..b0e7e1b521566ad6094d892921e6718b28f307cb 100644 --- a/test/unittest/phone/qos_manager_test.cpp +++ b/test/unittest/phone/qos_manager_test.cpp @@ -61,6 +61,10 @@ HWTEST_F(QosManagerTest, SetThreadQosTest1, TestSize.Level1) EXPECT_EQ(ret, 0); ret = SetThreadQos(QosLevel::qos_background); EXPECT_EQ(ret, 0); + ret = SetThreadQos(QosLevel::qos_deadline_request); + EXPECT_EQ(ret, 0); + ret = SetThreadQos(QosLevel::qos_user_interactive); + EXPECT_EQ(ret, 0); } HWTEST_F(QosManagerTest, SetThreadQosTest3, TestSize.Level1) @@ -73,6 +77,10 @@ HWTEST_F(QosManagerTest, SetThreadQosTest3, TestSize.Level1) EXPECT_EQ(ret, 0); ret = SetQosForOtherThread(QosLevel::qos_background, gettid()); EXPECT_EQ(ret, 0); + ret = SetQosForOtherThread(QosLevel::qos_deadline_request, gettid()); + EXPECT_EQ(ret, 0); + ret = SetQosForOtherThread(QosLevel::qos_user_interactive, gettid()); + EXPECT_EQ(ret, 0); } HWTEST_F(QosManagerTest, ResetThreadQosTest1, TestSize.Level1)