From 8ce1f83e78f9e40ee5510bd34117f29c766f15fc Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Tue, 28 May 2024 18:36:44 +0800 Subject: [PATCH 1/7] qos add xml Signed-off-by: liuyuxiu --- bundle.json | 5 +- common/include/config_reader.h | 40 +++++ common/src/config_reader.cpp | 142 ++++++++++++++++++ profiles/BUILD.gn | 22 +++ profiles/qos_manager_config.xml | 24 +++ services/BUILD.gn | 4 + services/include/concurrent_task_controller.h | 4 + services/src/concurrent_task_controller.cpp | 30 +++- 8 files changed, 268 insertions(+), 3 deletions(-) create mode 100644 common/include/config_reader.h create mode 100644 common/src/config_reader.cpp create mode 100644 profiles/BUILD.gn create mode 100644 profiles/qos_manager_config.xml diff --git a/bundle.json b/bundle.json index 0432c0f..f7413ac 100644 --- a/bundle.json +++ b/bundle.json @@ -24,6 +24,7 @@ "ability_base", "ability_runtime", "access_token", + "config_policy", "c_utils", "frame_aware_sched", "hilog", @@ -31,6 +32,7 @@ "init", "ipc", "jsoncpp", + "libxml2", "safwk", "samgr" ], @@ -45,7 +47,8 @@ "//foundation/resourceschedule/qos_manager/services:concurrentsvc", "//foundation/resourceschedule/qos_manager/frameworks/concurrent_task_client:concurrent_task_client", "//foundation/resourceschedule/qos_manager/qos:qos", - "//foundation/resourceschedule/qos_manager/frameworks/native:qos_ndk" + "//foundation/resourceschedule/qos_manager/frameworks/native:qos_ndk", + "//foundation/resourceschedule/qos_manager/profiles:qos_manager_config" ], "inner_kits": [ { diff --git a/common/include/config_reader.h b/common/include/config_reader.h new file mode 100644 index 0000000..729f712 --- /dev/null +++ b/common/include/config_reader.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 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 CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H +#define CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H + +#include +#include +#include +#include "libxml/parser.h" +#include "libxml/xpath.h" + +namespace OHOS { +namespace ConcurrentTask { +class ConfigReader { +public: + bool LoadFromConfigFile(const std::string& configFile); + void GetRealConfigPath(const char* configName, std::string& configPath); + std::unordered_set authProcUidConfigs_; + std::unordered_set authProcBundleNameConfigs_; +private: + static bool IsValidNode(const xmlNode* currNode); + bool FillinUidInfo(const xmlNode* currNode); + bool FillinBundleNameInfo(const xmlNode* currNode); + void ParseAuth(const xmlNode* currNode); +}; +} // namespace ConcurrentTask +} // namespace OHOS +#endif // CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H diff --git a/common/src/config_reader.cpp b/common/src/config_reader.cpp new file mode 100644 index 0000000..e199611 --- /dev/null +++ b/common/src/config_reader.cpp @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2024 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. + */ +#include +#include +#include +#include "config_reader.h" +#include "config_policy_utils.h" +#include "concurrent_task_log.h" + +using namespace std; + +namespace OHOS { +namespace ConcurrentTask { +namespace { + const std::string XML_TAG_QOS_CONFIG = "qosconfig"; + const std::string XML_TAG_QOS_AUTH = "auth"; + const std::string XML_TAG_UIDLIST = "uidlist"; + const std::string XML_TAG_UID = "uid"; + const std::string XML_TAG_BUNDLENAMELIST = "bundlenamelist"; + const std::string XML_TAG_BUNDLENAME = "bundlename"; +} + +bool ConfigReader::IsValidNode(const xmlNode* currNode) +{ + if (!currNode->name || currNode->type == XML_COMMENT_NODE) { + return false; + } + return true; +} + +bool ConfigReader::FillinUidInfo(const xmlNode* currNode) +{ + xmlNodePtr currNodePtr = currNode->xmlChildrenNode; + for (; currNodePtr; currNodePtr = currNodePtr->next) { + if (xmlStrcmp(currNodePtr->name, reinterpret_cast(XML_TAG_UID.c_str())) == 0) { + xmlChar *attrValue = xmlGetProp(currNodePtr, reinterpret_cast(XML_TAG_UID.c_str())); + if (!attrValue) { + CONCUR_LOGW("FillinUidInfo uid null!"); + return false; + } + int64_t uid = atoi(reinterpret_cast(attrValue)); + authProcUidConfigs_.insert(uid); + xmlFree(attrValue); + } + } + return true; +} + +bool ConfigReader::FillinBundleNameInfo(const xmlNode* currNode) +{ + xmlNodePtr currNodePtr = currNode->xmlChildrenNode; + for (; currNodePtr; currNodePtr = currNodePtr->next) { + if (xmlStrcmp(currNodePtr->name, reinterpret_cast(XML_TAG_BUNDLENAME.c_str())) == 0) { + xmlChar *attrValue = xmlGetProp(currNodePtr, reinterpret_cast(XML_TAG_BUNDLENAME.c_str())); + if (!attrValue) { + CONCUR_LOGW("FillinBundleNameInfo bundleName null!"); + return false; + } + std::string bundleName = reinterpret_cast(attrValue); + authProcBundleNameConfigs_.insert(bundleName); + xmlFree(attrValue); + } + } + return true; +} + +void ConfigReader::ParseAuth(const xmlNode* currNode) +{ + xmlNodePtr currNodePtr = currNode->xmlChildrenNode; + for (; currNodePtr; currNodePtr = currNodePtr->next) { + if (xmlStrcmp(currNodePtr->name, reinterpret_cast(XML_TAG_UIDLIST.c_str())) == 0) { + if (!FillinUidInfo(currNodePtr)) { + CONCUR_LOGE("uid fill in authProcUidConfigs_ error!"); + continue; + } + } + + if (xmlStrcmp(currNodePtr->name, reinterpret_cast(XML_TAG_BUNDLENAMELIST.c_str())) == 0) { + if (!FillinBundleNameInfo(currNodePtr)) { + CONCUR_LOGE("bundleName fill in authProcBundleNameConfigs_ error!"); + continue; + } + } + } +} + +bool ConfigReader::LoadFromConfigFile(const std::string& configFile) +{ + // skip the empty string, else you will get empty node + xmlDocPtr xmlDocPtr = xmlReadFile(configFile.c_str(), nullptr, + XML_PARSE_NOBLANKS | XML_PARSE_NOERROR | XML_PARSE_NOWARNING); + if (!xmlDocPtr) { + CONCUR_LOGE("xmlReadFile error!"); + return false; + } + xmlNodePtr rootNodePtr = xmlDocGetRootElement(xmlDocPtr); + if (!rootNodePtr || !rootNodePtr->name || + xmlStrcmp(rootNodePtr->name, reinterpret_cast(XML_TAG_QOS_CONFIG.c_str())) != 0) { + CONCUR_LOGE("root element tag error!"); + xmlFreeDoc(xmlDocPtr); + return false; + } + xmlNodePtr currNodePtr = rootNodePtr->xmlChildrenNode; + for (; currNodePtr; currNodePtr = currNodePtr->next) { + if (!IsValidNode(currNodePtr)) { + continue; + } + if (xmlStrcmp(currNodePtr->name, reinterpret_cast(XML_TAG_QOS_AUTH.c_str())) == 0) { + ParseAuth(currNodePtr); + } + } + xmlFreeDoc(xmlDocPtr); + return true; +} + +void ConfigReader::GetRealConfigPath(const char* configName, std::string& configPath) +{ + char buf[PATH_MAX + 1] = {0}; + char* configFilePath = GetOneCfgFile(configName, buf, PATH_MAX + 1); + char tmpPath[PATH_MAX + 1] = {0}; + if (!configFilePath || strlen(configFilePath) == 0 || strlen(configFilePath) > PATH_MAX || + !realpath(configFilePath, tmpPath)) { + CONCUR_LOGE("get config file path error!"); + configPath = ""; + return; + } + configPath = tmpPath; +} +} +} \ No newline at end of file diff --git a/profiles/BUILD.gn b/profiles/BUILD.gn new file mode 100644 index 0000000..b76467d --- /dev/null +++ b/profiles/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2024 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. + +import("//build/ohos.gni") + +ohos_prebuilt_etc("qos_manager_config") { + source = "qos_manager_config.xml" + install_enable = true + subsystem_name = "resourceschedule" + part_name = "qos_manager" + module_install_dir = "etc/qos_manager" +} \ No newline at end of file diff --git a/profiles/qos_manager_config.xml b/profiles/qos_manager_config.xml new file mode 100644 index 0000000..019882b --- /dev/null +++ b/profiles/qos_manager_config.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + diff --git a/services/BUILD.gn b/services/BUILD.gn index f37216f..79eb829 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -25,6 +25,7 @@ config("concurrent_task_config") { "../include", "../frameworks/concurrent_task_client/include/", "../interfaces/inner_api/", + "../common/include", ] } @@ -43,6 +44,7 @@ ohos_shared_library("concurrentsvc") { "src/concurrent_task_service_stub.cpp", "src/qos_interface.cpp", "src/qos_policy.cpp", + "../common/src/config_reader.cpp", ] deps = [ "../etc/param:ffrt_etc" ] @@ -55,9 +57,11 @@ ohos_shared_library("concurrentsvc") { external_deps = [ "access_token:libaccesstoken_sdk", "c_utils:utils", + "config_policy:configpolicy_util", "frame_aware_sched:rtg_interface", "hilog:libhilog", "hitrace:hitrace_meter", + "libxml2:libxml2", "init:libbegetutil", "ipc:ipc_single", "jsoncpp:jsoncpp", diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index 7f4c321..f65ffe8 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -24,6 +24,7 @@ #include #include "json/json.h" #include "concurrent_task_type.h" +#include "config_reader.h" #include "qos_policy.h" namespace OHOS { @@ -68,6 +69,7 @@ private: void ContinuousTaskProcess(int uid, int pid, int status); void FocusStatusProcess(int uid, int pid, int status); int AuthSystemProcess(int pid); + void ConfigReaderInit(); bool ModifySystemRate(const Json::Value& payload); void SetAppRate(const Json::Value& payload); int FindRateFromInfo(int uiTid, const Json::Value& payload); @@ -99,10 +101,12 @@ private: int hardwareTid_ = -1; int systemRate_ = 0; bool rtgEnabled_ = false; + bool configEnable_ = false; bool rsAuthed_ = false; std::atomic curGamePid_ = -1; int executorNum_ = 0; std::map appBundleName; + std::unique_ptr ConfigReader_ = nullptr; 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 3df8bb1..a1bf3c8 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -36,6 +36,7 @@ namespace { const std::string INTERVAL_DDL = "persist.ffrt.interval.renderthread"; const std::string INTERVAL_APP_RATE = "persist.ffrt.interval.appRate"; const std::string INTERVAL_RS_RATE = "persist.ffrt.interval.rsRate"; + const std::string CONFIG_FILE_NAME = "etc/qos_manager/qos_manager_config.xml"; constexpr int CURRENT_RATE = 120; constexpr int PARAM_TYPE = 1; constexpr int UNI_APP_RATE_ID = -1; @@ -56,9 +57,15 @@ TaskController& TaskController::GetInstance() void TaskController::RequestAuth(const Json::Value& payload) { + if (!configEnable_) { + ConfigReaderInit(); + } pid_t uid = IPCSkeleton::GetInstance().GetCallingUid(); - if (uid != HWF_SERVICE_UID) { - CONCUR_LOGE("Invalid uid %{public}d, only hwf service uid can call RequestAuth", uid); + auto uidIter = ConfigReader_->authProcUidConfigs_.find(uid); + auto bundleNameIter = ConfigReader_->authProcBundleNameConfigs_.find(GetProcessNameByToken()); + if (uidIter == ConfigReader_->authProcUidConfigs_.end() && + bundleNameIter == ConfigReader_->authProcBundleNameConfigs_.end()) { + CONCUR_LOGE("Invalid uid %{public}d, only hwf service uid and msdp can call RequestAuth", uid); return; } pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); @@ -320,6 +327,24 @@ void TaskController::Init() TypeMapInit(); qosPolicy_.Init(); TryCreateRsGroup(); + ConfigReaderInit(); +} + +void TaskController::ConfigReaderInit() +{ + ConfigReader_ = make_unique(); + if (!ConfigReader_) { + CONCUR_LOGE("ConfigReader_ initialize error!"); + return; + } + + std::string realPath; + ConfigReader_->GetRealConfigPath(CONFIG_FILE_NAME.c_str(), realPath); + if (realPath.empty() || !ConfigReader_->LoadFromConfigFile(realPath)) { + CONCUR_LOGE("config load failed!"); + return; + } + configEnable_ = true; } void TaskController::Release() @@ -333,6 +358,7 @@ void TaskController::Release() DestroyRtgGrp(renderServiceRenderGrpId_); renderServiceRenderGrpId_ = -1; } + ConfigReader_ = nullptr; } void TaskController::TypeMapInit() -- Gitee From 5b20aa1edc111659732740dd218bcb8a0a791e42 Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Wed, 29 May 2024 09:04:51 +0800 Subject: [PATCH 2/7] qos add xml Signed-off-by: liuyuxiu --- common/src/config_reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/config_reader.cpp b/common/src/config_reader.cpp index e199611..733156e 100644 --- a/common/src/config_reader.cpp +++ b/common/src/config_reader.cpp @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include "config_reader.h" #include "config_policy_utils.h" #include "concurrent_task_log.h" -- Gitee From 86b5f96c98ec64402b0898de95e8b8f06dfeeb32 Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Wed, 29 May 2024 09:08:33 +0800 Subject: [PATCH 3/7] qos add xml Signed-off-by: liuyuxiu --- common/include/config_reader.h | 1 - 1 file changed, 1 deletion(-) diff --git a/common/include/config_reader.h b/common/include/config_reader.h index 729f712..82372f2 100644 --- a/common/include/config_reader.h +++ b/common/include/config_reader.h @@ -15,7 +15,6 @@ #ifndef CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H #define CONCURRENT_TASK_SERVICES_COMMON_INCLUDE_CONFIG_READER_H -#include #include #include #include "libxml/parser.h" -- Gitee From 2c28e5e67ade68aa78b351769b1cef7f4e8e3baf Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Wed, 29 May 2024 11:28:04 +0800 Subject: [PATCH 4/7] qos add xml Signed-off-by: liuyuxiu --- common/src/config_reader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/config_reader.cpp b/common/src/config_reader.cpp index 733156e..946ca63 100644 --- a/common/src/config_reader.cpp +++ b/common/src/config_reader.cpp @@ -14,7 +14,7 @@ */ #include #include -#include +#include #include "config_reader.h" #include "config_policy_utils.h" #include "concurrent_task_log.h" -- Gitee From e95504803ebc8da71500171c37d3f262fe12c3c9 Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Wed, 29 May 2024 11:58:46 +0800 Subject: [PATCH 5/7] qos add xml Signed-off-by: liuyuxiu --- common/src/config_reader.cpp | 6 +++--- profiles/BUILD.gn | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/config_reader.cpp b/common/src/config_reader.cpp index 946ca63..35463c0 100644 --- a/common/src/config_reader.cpp +++ b/common/src/config_reader.cpp @@ -127,9 +127,9 @@ bool ConfigReader::LoadFromConfigFile(const std::string& configFile) void ConfigReader::GetRealConfigPath(const char* configName, std::string& configPath) { - char buf[PATH_MAX + 1] = {0}; - char* configFilePath = GetOneCfgFile(configName, buf, PATH_MAX + 1); - char tmpPath[PATH_MAX + 1] = {0}; + char buf[PATH_MAX] = {0}; + char* configFilePath = GetOneCfgFile(configName, buf, PATH_MAX); + char tmpPath[PATH_MAX] = {0}; if (!configFilePath || strlen(configFilePath) == 0 || strlen(configFilePath) > PATH_MAX || !realpath(configFilePath, tmpPath)) { CONCUR_LOGE("get config file path error!"); diff --git a/profiles/BUILD.gn b/profiles/BUILD.gn index b76467d..21dc555 100644 --- a/profiles/BUILD.gn +++ b/profiles/BUILD.gn @@ -19,4 +19,4 @@ ohos_prebuilt_etc("qos_manager_config") { subsystem_name = "resourceschedule" part_name = "qos_manager" module_install_dir = "etc/qos_manager" -} \ No newline at end of file +} -- Gitee From 31e4623b423b74a97e1a9507eb3c1f90bb58d6b3 Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Wed, 29 May 2024 13:51:03 +0800 Subject: [PATCH 6/7] qos add xml Signed-off-by: liuyuxiu --- services/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/BUILD.gn b/services/BUILD.gn index 79eb829..a1c0564 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -38,13 +38,13 @@ ohos_shared_library("concurrentsvc") { debug = false } sources = [ + "../common/src/config_reader.cpp", "src/concurrent_task_controller.cpp", "src/concurrent_task_service.cpp", "src/concurrent_task_service_ability.cpp", "src/concurrent_task_service_stub.cpp", "src/qos_interface.cpp", "src/qos_policy.cpp", - "../common/src/config_reader.cpp", ] deps = [ "../etc/param:ffrt_etc" ] @@ -61,10 +61,10 @@ ohos_shared_library("concurrentsvc") { "frame_aware_sched:rtg_interface", "hilog:libhilog", "hitrace:hitrace_meter", - "libxml2:libxml2", "init:libbegetutil", "ipc:ipc_single", "jsoncpp:jsoncpp", + "libxml2:libxml2", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] -- Gitee From c25804520e085efecc23259e4710fd0f421575a5 Mon Sep 17 00:00:00 2001 From: liuyuxiu Date: Wed, 29 May 2024 13:51:03 +0800 Subject: [PATCH 7/7] qos add xml Signed-off-by: liuyuxiu --- bundle.json | 3 +-- common/include/config_reader.h | 6 +++-- common/src/config_reader.cpp | 16 +++++++++++++ profiles/BUILD.gn | 22 ----------------- profiles/qos_manager_config.xml | 24 ------------------- services/BUILD.gn | 4 ++-- services/include/concurrent_task_controller.h | 2 +- services/src/concurrent_task_controller.cpp | 24 +++++++++---------- 8 files changed, 35 insertions(+), 66 deletions(-) delete mode 100644 profiles/BUILD.gn delete mode 100644 profiles/qos_manager_config.xml diff --git a/bundle.json b/bundle.json index f7413ac..6b2a023 100644 --- a/bundle.json +++ b/bundle.json @@ -47,8 +47,7 @@ "//foundation/resourceschedule/qos_manager/services:concurrentsvc", "//foundation/resourceschedule/qos_manager/frameworks/concurrent_task_client:concurrent_task_client", "//foundation/resourceschedule/qos_manager/qos:qos", - "//foundation/resourceschedule/qos_manager/frameworks/native:qos_ndk", - "//foundation/resourceschedule/qos_manager/profiles:qos_manager_config" + "//foundation/resourceschedule/qos_manager/frameworks/native:qos_ndk" ], "inner_kits": [ { diff --git a/common/include/config_reader.h b/common/include/config_reader.h index 82372f2..df65003 100644 --- a/common/include/config_reader.h +++ b/common/include/config_reader.h @@ -26,13 +26,15 @@ class ConfigReader { public: bool LoadFromConfigFile(const std::string& configFile); void GetRealConfigPath(const char* configName, std::string& configPath); - std::unordered_set authProcUidConfigs_; - std::unordered_set authProcBundleNameConfigs_; + bool IsUidAuth(pid_t uid); + bool IsBundleNameAuth(std::string& bundleName); private: static bool IsValidNode(const xmlNode* currNode); bool FillinUidInfo(const xmlNode* currNode); bool FillinBundleNameInfo(const xmlNode* currNode); void ParseAuth(const xmlNode* currNode); + std::unordered_set authProcUidConfigs_; + std::unordered_set authProcBundleNameConfigs_; }; } // namespace ConcurrentTask } // namespace OHOS diff --git a/common/src/config_reader.cpp b/common/src/config_reader.cpp index 35463c0..5219d9b 100644 --- a/common/src/config_reader.cpp +++ b/common/src/config_reader.cpp @@ -138,5 +138,21 @@ void ConfigReader::GetRealConfigPath(const char* configName, std::string& config } configPath = tmpPath; } + +bool ConfigReader::IsUidAuth(pid_t uid) +{ + if (authProcUidConfigs_.find(uid) != authProcUidConfigs_.end()) { + return true; + } + return false; +} + +bool ConfigReader::IsBundleNameAuth(std::string& bundleName) +{ + if (authProcBundleNameConfigs_.find(bundleName) != authProcBundleNameConfigs_.end()) { + return true; + } + return false; +} } } \ No newline at end of file diff --git a/profiles/BUILD.gn b/profiles/BUILD.gn deleted file mode 100644 index 21dc555..0000000 --- a/profiles/BUILD.gn +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (c) 2024 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. - -import("//build/ohos.gni") - -ohos_prebuilt_etc("qos_manager_config") { - source = "qos_manager_config.xml" - install_enable = true - subsystem_name = "resourceschedule" - part_name = "qos_manager" - module_install_dir = "etc/qos_manager" -} diff --git a/profiles/qos_manager_config.xml b/profiles/qos_manager_config.xml deleted file mode 100644 index 019882b..0000000 --- a/profiles/qos_manager_config.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - diff --git a/services/BUILD.gn b/services/BUILD.gn index 79eb829..a1c0564 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -38,13 +38,13 @@ ohos_shared_library("concurrentsvc") { debug = false } sources = [ + "../common/src/config_reader.cpp", "src/concurrent_task_controller.cpp", "src/concurrent_task_service.cpp", "src/concurrent_task_service_ability.cpp", "src/concurrent_task_service_stub.cpp", "src/qos_interface.cpp", "src/qos_policy.cpp", - "../common/src/config_reader.cpp", ] deps = [ "../etc/param:ffrt_etc" ] @@ -61,10 +61,10 @@ ohos_shared_library("concurrentsvc") { "frame_aware_sched:rtg_interface", "hilog:libhilog", "hitrace:hitrace_meter", - "libxml2:libxml2", "init:libbegetutil", "ipc:ipc_single", "jsoncpp:jsoncpp", + "libxml2:libxml2", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] diff --git a/services/include/concurrent_task_controller.h b/services/include/concurrent_task_controller.h index f65ffe8..2cfeea6 100644 --- a/services/include/concurrent_task_controller.h +++ b/services/include/concurrent_task_controller.h @@ -106,7 +106,7 @@ private: std::atomic curGamePid_ = -1; int executorNum_ = 0; std::map appBundleName; - std::unique_ptr ConfigReader_ = nullptr; + std::unique_ptr configReader_ = nullptr; 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 a1bf3c8..60837d1 100644 --- a/services/src/concurrent_task_controller.cpp +++ b/services/src/concurrent_task_controller.cpp @@ -61,15 +61,13 @@ void TaskController::RequestAuth(const Json::Value& payload) ConfigReaderInit(); } pid_t uid = IPCSkeleton::GetInstance().GetCallingUid(); - auto uidIter = ConfigReader_->authProcUidConfigs_.find(uid); - auto bundleNameIter = ConfigReader_->authProcBundleNameConfigs_.find(GetProcessNameByToken()); - if (uidIter == ConfigReader_->authProcUidConfigs_.end() && - bundleNameIter == ConfigReader_->authProcBundleNameConfigs_.end()) { - CONCUR_LOGE("Invalid uid %{public}d, only hwf service uid and msdp can call RequestAuth", uid); + auto bundleName = GetProcessNameByToken(); + if (configReader_->IsUidAuth(uid) || configReader_->IsBundleNameAuth(bundleName)) { + pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); + AuthSystemProcess(pid); return; } - pid_t pid = IPCSkeleton::GetInstance().GetCallingPid(); - AuthSystemProcess(pid); + CONCUR_LOGE("Invalid uid %{public}d, only hwf service uid and msdp can call RequestAuth", uid); } void TaskController::ReportData(uint32_t resType, int64_t value, const Json::Value& payload) @@ -332,15 +330,15 @@ void TaskController::Init() void TaskController::ConfigReaderInit() { - ConfigReader_ = make_unique(); - if (!ConfigReader_) { - CONCUR_LOGE("ConfigReader_ initialize error!"); + configReader_ = make_unique(); + if (!configReader_) { + CONCUR_LOGE("configReader_ initialize error!"); return; } std::string realPath; - ConfigReader_->GetRealConfigPath(CONFIG_FILE_NAME.c_str(), realPath); - if (realPath.empty() || !ConfigReader_->LoadFromConfigFile(realPath)) { + configReader_->GetRealConfigPath(CONFIG_FILE_NAME.c_str(), realPath); + if (realPath.empty() || !configReader_->LoadFromConfigFile(realPath)) { CONCUR_LOGE("config load failed!"); return; } @@ -358,7 +356,7 @@ void TaskController::Release() DestroyRtgGrp(renderServiceRenderGrpId_); renderServiceRenderGrpId_ = -1; } - ConfigReader_ = nullptr; + configReader_ = nullptr; } void TaskController::TypeMapInit() -- Gitee