From 71cd62bde14863425353e6832e7397ee93464526 Mon Sep 17 00:00:00 2001 From: liuchungang Date: Wed, 17 Jul 2024 15:30:43 +0800 Subject: [PATCH 1/7] Add fps offset for power mode Signed-off-by: liuchungang --- common/src/config_reader.cpp | 30 +++++++++++-------- services/include/concurrent_task_controller.h | 4 +-- services/src/concurrent_task_controller.cpp | 22 +++++++------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/common/src/config_reader.cpp b/common/src/config_reader.cpp index 26c46a6..bdc3e8a 100644 --- a/common/src/config_reader.cpp +++ b/common/src/config_reader.cpp @@ -36,6 +36,10 @@ namespace { const std::string XML_TAG_SWITCH = "switch"; const std::string XML_TAG_FPS = "fps"; const std::string XML_TAG_DEGRADATION_FPS = "degradationfps"; + const std::string XML_TAG_FPS_HIGH = "120"; + const std::string XML_TAG_FPS_MEDIUM = "90"; + const std::string XML_TAG_FPS_STANDARD = "60"; + constexpr int FPS_OFFSET = 10000; } bool ConfigReader::IsValidNode(const xmlNode* currNode) @@ -122,7 +126,7 @@ void ConfigReader::ParsePowerMode(const xmlNode* currNode) xmlNodePtr currNodePtr = currNode->xmlChildrenNode; for (; currNodePtr; currNodePtr = currNodePtr->next) { if (xmlStrcmp(currNodePtr->name, reinterpret_cast(XML_TAG_SWITCH.c_str())) == 0) { - char* switchValue = reinterpret_cast(xmlNodeGetContent(currNode)); + char* switchValue = reinterpret_cast(xmlNodeGetContent(currNodePtr)); if (!switchValue) { CONCUR_LOGE("ParsePowerMode:: switch is null!"); continue; @@ -140,18 +144,18 @@ void ConfigReader::ParsePowerMode(const xmlNode* currNode) if (xmlStrcmp(currNodePtr->name, reinterpret_cast(XML_TAG_DEGRADATION_FPS.c_str())) == 0) { char* fpsValue = reinterpret_cast(xmlGetProp(currNodePtr, reinterpret_cast(XML_TAG_FPS.c_str()))); - char* deFpsValue = reinterpret_cast(xmlNodeGetContent(currNode)); - if (!fpsValue || !deFpsValue) { - CONCUR_LOGE("ParsePowerMode:: fps is null!"); - continue; - } - if (IsValidFps(fpsValue) && IsPositiveInt(deFpsValue)) { + char* deFpsValue = reinterpret_cast(xmlNodeGetContent(currNodePtr)); + if (fpsValue && deFpsValue && IsValidFps(fpsValue) && IsPositiveInt(deFpsValue)) { degradationFpsMap_.insert(std::make_pair(atoi(fpsValue), atoi(deFpsValue))); } else { - CONCUR_LOGE("ParsePowerMode:: invalid fps value!"); + CONCUR_LOGE("ParsePowerMode:: fps is null or invalid!"); + } + if (fpsValue) { + xmlFree(fpsValue); + } + if (deFpsValue) { + xmlFree(deFpsValue); } - xmlFree(fpsValue); - xmlFree(deFpsValue); } } } @@ -234,18 +238,18 @@ int ConfigReader::GetDegratationFps(int fps) if (degradationFpsMap_.find(fps) == degradationFpsMap_.end()) { return fps; } - return degradationFpsMap_[fps]; + return degradationFpsMap_[fps] + FPS_OFFSET; } bool ConfigReader::IsValidFps(const std::string& fps) { - if (fps == "120" || fps == "90" || fps == "60") { + if (fps == XML_TAG_FPS_HIGH || fps == XML_TAG_FPS_MEDIUM || fps == XML_TAG_FPS_STANDARD) { return true; } return false; } -bool ConfigReader::IsPositiveInt(const std::string& intStr) +bool ConfigReader::IsPositiveInt(const std::string& intStr) { int num = 0; try { diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 4d6e2e6..5dadc7a 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -79,7 +79,7 @@ private: void SetAppRate(const Json::Value& payload); int FindRateFromInfo(int uiTid, const Json::Value& payload); void SetRenderServiceRate(const Json::Value& payload); - void SetAppAndRenderServicRate(int appRate, int rsRate); + void SetAppAndRenderServiceRate(int appRate, int rsRate); bool CheckJsonValid(const Json::Value& payload); void SetFrameRate(int rtgId, int rate); std::list::iterator GetRecordOfPid(int pid); @@ -119,7 +119,7 @@ private: int executorNum_ = 0; std::map appBundleName; std::unique_ptr configReader_ = nullptr; - std::unordered_map appTypeCache_; + std::unordered_map appTypeCache_; const std::string RENDER_SERVICE_PROCESS_NAME = "render_service"; const std::string RESOURCE_SCHEDULE_PROCESS_NAME = "resource_schedule_service"; diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 9d6f030..d1cb67a 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -551,7 +551,7 @@ void TaskController::NewForeground(int uid, int pid) void TaskController::NewForegroundAppRecord(int pid, int uiTid, bool ddlEnabled) { - auto appRecord = foregroundApp_.emplace_back(pid, uiTid, pid != curGamePid_); + ForegroundAppRecord& appRecord = foregroundApp_.emplace_back(pid, uiTid, pid != curGamePid_); if (foregroundApp_.size() <= 0 || appRecord.GetPid() != pid) { CONCUR_LOGE("pid %{public}d create app record failed", pid); return; @@ -607,7 +607,7 @@ void TaskController::NewAppStart(int uid, int pid, const std::string& bundleName authApps_.push_back(pid); appBundleName[pid] = bundleName; if (ddlSceneSchedSwitch_ && appType != APP_TYPE_INVALID) { - appTypeCache_[bundleName] = appType; + appTypeCache_[pid] = appType; } } @@ -635,6 +635,9 @@ void TaskController::AppKilled(int uid, int pid) } } appBundleName.erase(pid); + if (ddlSceneSchedSwitch_) { + appTypeCache_.erase(pid); + } } int TaskController::AuthSystemProcess(int pid) @@ -708,7 +711,7 @@ void TaskController::DeadlinePerfMode() { if (ddlPowerModeEnable_) { StartTrace(HITRACE_TAG_ACE, "Deadline perf mode"); - SetAppAndRenderServicRate(uniAppRate_, systemRate_); + SetAppAndRenderServiceRate(uniAppRate_, systemRate_); ddlPowerModeEnable_ = false; CONCUR_LOGI("Deadline switch to perf mode"); FinishTrace(HITRACE_TAG_ACE); @@ -725,7 +728,7 @@ void TaskController::DeadlinePowerMode() appRate = configReader_->GetDegratationFps(appRate); rsRate = configReader_->GetDegratationFps(rsRate); } - SetAppAndRenderServicRate(appRate, rsRate); + SetAppAndRenderServiceRate(appRate, rsRate); ddlPowerModeEnable_ = true; CONCUR_LOGI("Deadline switch to power mode"); FinishTrace(HITRACE_TAG_ACE); @@ -912,7 +915,7 @@ void TaskController::SetRenderServiceRate(const Json::Value& payload) } } -void TaskController::SetAppAndRenderServicRate(int appRate, int rsRate) +void TaskController::SetAppAndRenderServiceRate(int appRate, int rsRate) { bool ret = OHOS::system::SetParameter(INTERVAL_APP_RATE, std::to_string(appRate)); if (ret == false) { @@ -1004,13 +1007,12 @@ int TaskController::ParseAppType(const Json::Value& payload) bool TaskController::IsVideoApp(int pid) { - if (!ddlSceneSchedSwitch_ || appBundleName.find(pid) == appBundleName.end()) { + if (!ddlSceneSchedSwitch_) { return false; } - std::string bundleName = appBundleName[pid]; - if (appTypeCache_.find(bundleName) != appTypeCache_.end()) { - return appTypeCache_[bundleName] == APP_TYPE_VIDEO || - appTypeCache_[bundleName]== APP_TYPE_VIDEO_CLIP; + if (appTypeCache_.find(pid) != appTypeCache_.end()) { + return appTypeCache_[pid] == APP_TYPE_VIDEO || + appTypeCache_[pid]== APP_TYPE_VIDEO_CLIP; } return false; } -- Gitee From 0bd8b3e2ee62f139f046656cfc54998580dcfe83 Mon Sep 17 00:00:00 2001 From: liuchungang Date: Mon, 12 Aug 2024 21:39:02 +0800 Subject: [PATCH 2/7] clean code Signed-off-by: liuchungang --- common/src/config_reader.cpp | 4 ++-- services/src/concurrent_task_controller.cpp | 10 +++++----- services/src/qos_interface.cpp | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/common/src/config_reader.cpp b/common/src/config_reader.cpp index bdc3e8a..92d4261 100644 --- a/common/src/config_reader.cpp +++ b/common/src/config_reader.cpp @@ -131,9 +131,9 @@ void ConfigReader::ParsePowerMode(const xmlNode* currNode) CONCUR_LOGE("ParsePowerMode:: switch is null!"); continue; } - if (strcmp(switchValue, "1") == 0) { + if (strncmp(switchValue, "1", 1) == 0) { powerModeSchedSwitch_ = true; - } else if (strcmp(switchValue, "0") == 0) { + } else if (strncmp(switchValue, "0", 1) == 0) { powerModeSchedSwitch_ = false; } else { CONCUR_LOGE("ParsePowerMode:: invalid switch value!"); diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index d1cb67a..1596465 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -724,7 +724,7 @@ void TaskController::DeadlinePowerMode() StartTrace(HITRACE_TAG_ACE, "Deadline power mode"); int appRate = uniAppRate_; int rsRate = systemRate_; - if (configReader_) { + if (configEnable_ && configReader_) { appRate = configReader_->GetDegratationFps(appRate); rsRate = configReader_->GetDegratationFps(rsRate); } @@ -800,7 +800,7 @@ int TaskController::GetGamePid(const std::string &gameMsg) const return -1; } int ret = sscanf_s(gameMsg.substr(0, pos).c_str(), "{\"gamePid\":\"%d\"", &gamePid); - if (ret == -1) { + if (ret <= 0) { CONCUR_LOGE("[MSG_GAME]message parsing failed, ret is %{public}d", ret); } else { CONCUR_LOGI("[MSG_GAME]message parsing success"); @@ -848,7 +848,7 @@ void TaskController::SetAppRate(const Json::Value& payload) if (appRate > 0 && appRate != uniAppRate_) { CONCUR_LOGD("set unified app rate %{public}d", appRate); uniAppRate_ = appRate; - if (ddlSceneSchedSwitch_ && ddlPowerModeEnable_ && configReader_) { + if (ddlSceneSchedSwitch_ && ddlPowerModeEnable_ && configEnable_ && configReader_) { appRate = configReader_->GetDegratationFps(appRate); } bool ret = OHOS::system::SetParameter(INTERVAL_APP_RATE, std::to_string(appRate)); @@ -902,7 +902,7 @@ void TaskController::SetRenderServiceRate(const Json::Value& payload) rsRate, renderServiceMainGrpId_, systemRate_); SetFrameRate(renderServiceMainGrpId_, rsRate); systemRate_ = rsRate; - if (ddlSceneSchedSwitch_ && ddlPowerModeEnable_ && configReader_) { + if (ddlSceneSchedSwitch_ && ddlPowerModeEnable_ && configEnable_ && configReader_) { rsRate = configReader_->GetDegratationFps(rsRate); } bool ret = OHOS::system::SetParameter(INTERVAL_RS_RATE, std::to_string(rsRate)); @@ -982,7 +982,7 @@ int TaskController::CreateNewRtgGrp(int prioType, int rtNum) } grp_data.rtg_cmd = CMD_CREATE_RTG_GRP; ret = ioctl(fd, CMD_ID_SET_RTG, &grp_data); - if (ret < 0) { + if (ret <= 0) { CONCUR_LOGE("create rtg grp failed, errno = %{public}d (%{public}s)", errno, strerror(errno)); } else { CONCUR_LOGI("create rtg grp success, get rtg id %{public}d.", ret); diff --git a/services/src/qos_interface.cpp b/services/src/qos_interface.cpp index 4bc270e..0003b17 100644 --- a/services/src/qos_interface.cpp +++ b/services/src/qos_interface.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "qos_interface.h" -- Gitee From b3a7967bdd965424e69a5f04dfe8ea2a69fedd22 Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Mon, 19 Aug 2024 12:00:22 +0800 Subject: [PATCH 3/7] qos_manager code check Bugfix Signed-off-by: liuyuxiu --- services/include/concurrent_task_controller.h | 2 +- services/src/concurrent_task_controller.cpp | 29 ++++++++++--------- services/src/qos_interface.cpp | 1 + 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 5dadc7a..25e211a 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -82,7 +82,7 @@ private: void SetAppAndRenderServiceRate(int appRate, int rsRate); bool CheckJsonValid(const Json::Value& payload); void SetFrameRate(int rtgId, int rate); - std::list::iterator GetRecordOfPid(int pid); + ForegroundAppRecord* GetRecordOfPid(int pid); void PrintInfo(); bool ParsePayload(const Json::Value& payload, int& uid, int& pid, std::string& bundleName); std::string GetProcessNameByToken(); diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 1596465..33dd1b5 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -149,12 +149,12 @@ std::string TaskController::GetProcessNameByToken() void TaskController::QueryUi(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - auto iter = GetRecordOfPid(pid); - if (iter == foregroundApp_.end()) { + ForegroundAppRecord* record = GetRecordOfPid(pid); + if (!record) { CONCUR_LOGD("Query ui with pid %{public}d failed", pid); return; } - int grpId = iter->GetGrpId(); + int grpId = record->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query ui with none grpid", pid); queryRs.rtgId = -1; @@ -167,12 +167,12 @@ void TaskController::QueryUi(int uid, IntervalReply& queryRs) void TaskController::QueryRender(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - auto iter = GetRecordOfPid(pid); - if (iter == foregroundApp_.end()) { + ForegroundAppRecord* record = GetRecordOfPid(pid); + if (!record) { CONCUR_LOGD("Query render with pid %{public}d failed", pid); return; } - int grpId = iter->GetGrpId(); + int grpId = record->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query render with none grpid", pid); queryRs.rtgId = -1; @@ -312,12 +312,12 @@ void TaskController::QueryExecutorStart(int uid, int pid, IntervalReply& queryRs void TaskController::QueryHwc(int uid, IntervalReply& queryRs) { pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - auto iter = GetRecordOfPid(pid); - if (iter == foregroundApp_.end()) { + ForegroundAppRecord* record = GetRecordOfPid(pid); + if (!record) { CONCUR_LOGD("Query ipc thread with pid %{public}d failed", pid); return; } - int grpId = iter->GetGrpId(); + int grpId = record->GetGrpId(); if (grpId <= 0) { CONCUR_LOGI("%{public}d Query ipc thread with none grpid", pid); queryRs.rtgId = -1; @@ -498,15 +498,15 @@ void TaskController::DealSystemRequest(int requestType, const Json::Value& paylo } } -std::list::iterator TaskController::GetRecordOfPid(int pid) +ForegroundAppRecord* TaskController::GetRecordOfPid(int pid) { std::lock_guard lock(appInfoLock_); for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { if (iter->GetPid() == pid) { - return iter; + return &*iter; } } - return foregroundApp_.end(); + return nullptr; } void TaskController::NewForeground(int uid, int pid) @@ -519,6 +519,7 @@ void TaskController::NewForeground(int uid, int pid) } int ret = AuthGet(pid); if (ret != static_cast(AuthStatus::AUTH_STATUS_FOCUS)) { + CONCUR_LOGI("pid %{public}d change to foreground.", pid); unsigned int pidParam = static_cast(pid); unsigned int uaFlag = AF_RTG_ALL; unsigned int status = static_cast(AuthStatus::AUTH_STATUS_FOREGROUND); @@ -528,7 +529,6 @@ void TaskController::NewForeground(int uid, int pid) } else { CONCUR_LOGE("auth_enable %{public}d fail with ret %{public}d", pid, ret); } - CONCUR_LOGI("pid %{public}d change to foreground.", pid); } else { CONCUR_LOGI("pid %{public}d is already focus", pid); } @@ -542,6 +542,7 @@ void TaskController::NewForeground(int uid, int pid) iter->AddKeyThread(uiTid, PRIO_RT); } iter->BeginScene(); + break; } } if (!found) { @@ -624,7 +625,7 @@ void TaskController::AppKilled(int uid, int pid) std::lock_guard lock(appInfoLock_); for (auto iter = foregroundApp_.begin(); iter != foregroundApp_.end(); iter++) { if (iter->GetPid() == pid) { - foregroundApp_.erase(iter++); + foregroundApp_.erase(iter); break; } } diff --git a/services/src/qos_interface.cpp b/services/src/qos_interface.cpp index 0003b17..b970b4b 100644 --- a/services/src/qos_interface.cpp +++ b/services/src/qos_interface.cpp @@ -203,6 +203,7 @@ int AuthGet(unsigned int pid) ret = ioctl(fd, BASIC_AUTH_CTRL_OPERATION, &data); if (ret < 0) { + close(fd); return ret; } close(fd); -- Gitee From 4c32d7d48bff97d32da42d2392b8f4a7cdf37a05 Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Mon, 19 Aug 2024 12:03:24 +0800 Subject: [PATCH 4/7] qos_manager Signed-off-by: liuyuxiu --- services/src/concurrent_task_controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 33dd1b5..dc4ad7a 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -883,7 +883,7 @@ int TaskController::FindRateFromInfo(int uiTid, const Json::Value& payload) { int appRate = 0; if (payload[std::to_string(uiTid)].isNull()) { - CONCUR_LOGI("FindRateFromInfo tid %{public}d is null", uiTid); + CONCUR_LOGD("FindRateFromInfo tid %{public}d is null", uiTid); return appRate; } try { -- Gitee From a5b6088870a7c9559cf31aac2a38321496cf38ab Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Tue, 20 Aug 2024 14:07:57 +0800 Subject: [PATCH 5/7] qos_manager add fuzz test Signed-off-by: liuyuxiu --- .../concurrent_fuzzer/concurrent_fuzzer.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/fuzztest/concurrent_fuzzer/concurrent_fuzzer.cpp b/test/fuzztest/concurrent_fuzzer/concurrent_fuzzer.cpp index 75d4c25..6d06a61 100644 --- a/test/fuzztest/concurrent_fuzzer/concurrent_fuzzer.cpp +++ b/test/fuzztest/concurrent_fuzzer/concurrent_fuzzer.cpp @@ -956,6 +956,19 @@ bool FuzzTaskControllerCheckJsonValid(const uint8_t* data, size_t size) } return true; } + +bool FuzzQosControllerGetThreadQosForOtherThread(const uint8_t* data, size_t size) +{ + g_baseFuzzData = data; + g_baseFuzzSize = size; + g_baseFuzzPos = 0; + if (size > sizeof(int)) { + enum QosLevel level; + int32_t tid = GetData(); + QosController::GetInstance().GetThreadQosForOtherThread(level, tid); + } + return true; +} } // namespace OHOS static void TaskControllerFuzzTestSuit(const uint8_t *data, size_t size) @@ -977,6 +990,7 @@ static void TaskControllerFuzzTestSuit(const uint8_t *data, size_t size) OHOS::FuzzTaskControllerModifySystemRate(data, size); OHOS::FuzzTaskControllerSetRenderServiceRate(data, size); OHOS::FuzzTaskControllerCheckJsonValid(data, size); + OHOS::FuzzQosControllerGetThreadQosForOtherThread(data, size); } /* Fuzzer entry point */ -- Gitee From 7fdab02fd894d8aafce5d0197fb391e3832e54e6 Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Mon, 26 Aug 2024 14:47:25 +0800 Subject: [PATCH 6/7] reduce DDL auth Signed-off-by: liuyuxiu --- services/include/qos_interface.h | 1 + services/src/concurrent_task_controller.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/services/include/qos_interface.h b/services/include/qos_interface.h index 42d8987..855b5d2 100644 --- a/services/include/qos_interface.h +++ b/services/include/qos_interface.h @@ -163,6 +163,7 @@ enum QosCtrlCmdid { */ #define AF_RTG_ALL 0x1fff #define AF_RTG_DELEGATED 0x1fff +#define AF_RTG_APP 0x10b8 struct RtgEnableData { int enable; diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index dc4ad7a..24cddd6 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -521,7 +521,7 @@ void TaskController::NewForeground(int uid, int pid) if (ret != static_cast(AuthStatus::AUTH_STATUS_FOCUS)) { CONCUR_LOGI("pid %{public}d change to foreground.", pid); unsigned int pidParam = static_cast(pid); - unsigned int uaFlag = AF_RTG_ALL; + unsigned int uaFlag = AF_RTG_APP; unsigned int status = static_cast(AuthStatus::AUTH_STATUS_FOREGROUND); int ret = AuthEnable(pidParam, uaFlag, status); if (ret == 0) { @@ -594,7 +594,7 @@ void TaskController::NewAppStart(int uid, int pid, const std::string& bundleName { CONCUR_LOGI("pid %{public}d start.", pid); unsigned int pidParam = static_cast(pid); - unsigned int uaFlag = AF_RTG_ALL; + unsigned int uaFlag = AF_RTG_APP; unsigned int status = static_cast(AuthStatus::AUTH_STATUS_DEFAULT); int ret = AuthEnable(pidParam, uaFlag, status); @@ -671,7 +671,7 @@ void TaskController::ContinuousTaskProcess(int uid, int pid, int status) void TaskController::FocusStatusProcess(int uid, int pid, int status) { int ret = -1; - unsigned int rtgFlag = AF_RTG_ALL; + unsigned int rtgFlag = AF_RTG_APP; unsigned int qosFlag = AF_QOS_DELEGATED; if (status == static_cast(MSG_GET_FOCUS)) { ret = AuthSwitch(pid, rtgFlag, qosFlag, static_cast(AuthStatus::AUTH_STATUS_FOCUS)); -- Gitee From 44ad6cd5ba31c080fb8a3334464f20695265f0b0 Mon Sep 17 00:00:00 2001 From: liuchungang Date: Mon, 2 Sep 2024 11:01:56 +0800 Subject: [PATCH 7/7] fix rs auth failed Signed-off-by: liuchungang --- services/include/concurrent_task_controller.h | 2 +- services/src/concurrent_task_controller.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 25e211a..3eb2243 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -111,7 +111,7 @@ private: int uniAppRate_ = 0; bool rtgEnabled_ = false; bool configEnable_ = false; - bool rsAuthed_ = false; + int authedRSPid_ = 0; bool ddlSceneSchedSwitch_ = false; bool ddlPowerModeEnable_ = false; bool isVideoApp_ = false; diff --git a/services/src/concurrent_task_controller.cpp b/services/src/concurrent_task_controller.cpp index 24cddd6..9d9d73b 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -216,14 +216,14 @@ void TaskController::QueryRenderService(int uid, IntervalReply& queryRs) void TaskController::QueryRenderServiceMain(int uid, int pid, IntervalReply& queryRs) { - if (GetProcessNameByToken() != RENDER_SERVICE_PROCESS_NAME) { + if (uid != RS_UID) { return; } - if (!rsAuthed_) { + if (authedRSPid_ != pid) { if (AuthSystemProcess(pid) != 0) { return; } - rsAuthed_ = true; + authedRSPid_ = pid; } if (renderServiceMainGrpId_ <= 0) { TryCreateRSMainGrp(); @@ -246,7 +246,7 @@ void TaskController::QueryRenderServiceMain(int uid, int pid, IntervalReply& que void TaskController::QueryRenderServiceRender(int uid, int pid, IntervalReply& queryRs) { - if (GetProcessNameByToken() != RENDER_SERVICE_PROCESS_NAME) { + if (uid != RS_UID) { return; } if (renderServiceRenderGrpId_ <= 0) { -- Gitee