diff --git a/README.md b/README_ZH.md similarity index 85% rename from README.md rename to README_ZH.md index bb1e6aa..4b81512 100644 --- a/README.md +++ b/README_ZH.md @@ -8,6 +8,19 @@ SOC统一调频服务作为资源调度子系统的子模块,主要功能是 **图1** 统一调频部件架构图 ![架构图](figures/resource_schedule_socperf_architecture_ZH_1.png) + + + 架构说明: + + 1、应用调用系统服务,触发系统事件。 + + 2、在系统事件回调中通过统一调频提供的内部接口插入调频事件桩点。 + + 3、在资源调度服务中感知系统事件,转发给统一调频插件。 + + 4、在统一调频服务中根据系统事件查找配置,找到与其对应的调频配置,经过调频仲裁后得到最终的调频策略。 + + 5、统一调频模块将调频策略参数传递给内核完成调频。 ## 目录 ``` @@ -23,11 +36,11 @@ SOC统一调频服务作为资源调度子系统的子模块,主要功能是 │ └── server # SocPerf服务端代码,用于接受客户端发送的调频请求 ``` ## 编译构建 -编译32位ARM系统soc_perf部件 +编译32位ARM系统soc_perf部件: ``` ./build.sh --product-name {product_name} --ccache --build-target soc_perf ``` -编译64位ARM系统soc_perf部件 +编译64位ARM系统soc_perf部件: ``` ./build.sh --product-name {product_name} --ccache --target-cpu arm64 --build-target soc_perf ``` @@ -74,15 +87,15 @@ socperf_boost_config.xml使用的cmdID不能重复。 要实现点击场景的提频,分为点击事件插桩、事件上报给资源调度框架、框架给插件分发事件、生效调频服务四个步骤。 第一步, -ACE子系统仓内实现了对资源调度框架提供的可动态加载接口ReportData的封装,路径为/framework/base/ressched/ressched_report.h -并在/framework/core/gestures/click_recognizer.cpp增加了打点作为手势识别中对点击事件的判定 +ArkUI框架子系统仓内实现了对资源调度框架提供的可动态加载接口ReportData的封装,路径为/framework/base/ressched/ressched_report.h +并在/framework/core/gestures/click_recognizer.cpp增加了打点作为手势识别中对点击事件的判定。 第二步, -通过动态加载libressched_client.z.so,调用资源调度框架提供的接口ReportData,ACE子系统将点击事件上报给全局资源调度子系统 +通过动态加载libressched_client.z.so,调用资源调度框架提供的接口ReportData,ACE子系统将点击事件上报给全局资源调度子系统。 第三步, 在资源调度框架里,点击事件类型定义在/ressched/interfaces/innerkits/ressched_client/include/res_type.h内,为RES_TYPE_CLICK_RECOGNIZE -由于调频插件socperf_plugin在初始化过程中已完成了对该点击事件的订阅,因此框架会在接受到事件通知时将点击事件分发给调频插件 +由于调频插件socperf_plugin在初始化过程中已完成了对该点击事件的订阅,因此框架会在接受到事件通知时将点击事件分发给调频插件。 第四步, 调频插件socperf_plugin对于点击事件分配了cmdID:PERF_REQUEST_CMD_ID_EVENT_CLICK,路径在/ressched/plugins/socperf_plugin/src/socperf_plugin.cpp下 diff --git a/bundle.json b/bundle.json index 8525dfb..a164d05 100644 --- a/bundle.json +++ b/bundle.json @@ -15,8 +15,6 @@ "syscap": [], "features": [], "adapted_system_type": [ - "mini", - "small", "standard" ], "rom": "2048KB", diff --git a/figures/resource_schedule_socperf_architecture_ZH_1.png b/figures/resource_schedule_socperf_architecture_ZH_1.png index ade045f..9218825 100644 Binary files a/figures/resource_schedule_socperf_architecture_ZH_1.png and b/figures/resource_schedule_socperf_architecture_ZH_1.png differ diff --git a/patches/patches.json b/patches/patches.json new file mode 100644 index 0000000..2f446a2 --- /dev/null +++ b/patches/patches.json @@ -0,0 +1,9 @@ +{ + "patches": [ + { + "project":"resourceschedule_resource_schedule_service", + "patch_file":"resourceschedule_resource_schedule_service.patch", + "path":"foundation/resourceschedule/resource_schedule_service" + } + ] +} \ No newline at end of file diff --git a/patches/resourceschedule_resource_schedule_service.patch b/patches/resourceschedule_resource_schedule_service.patch new file mode 100644 index 0000000..79874af --- /dev/null +++ b/patches/resourceschedule_resource_schedule_service.patch @@ -0,0 +1,4804 @@ +diff --git a/soc_perf/bundle.json b/soc_perf/bundle.json +deleted file mode 100644 +index 2226fca..0000000 +--- a/soc_perf/bundle.json ++++ /dev/null +@@ -1,72 +0,0 @@ +-{ +- "name": "@ohos/soc_perf", +- "description": "resource schedule service", +- "version": "3.1", +- "license": "Apache License 2.0", +- "publishAs": "code-segment", +- "segment": { +- "destPath": "foundation/resourceschedule/resource_schedule_service/soc_perf" +- }, +- "dirs": {}, +- "scripts": {}, +- "component": { +- "name": "soc_perf", +- "subsystem": "resourceschedule", +- "syscap": [], +- "features": [], +- "adapted_system_type": [ +- "mini", +- "small", +- "standard" +- ], +- "rom": "2048KB", +- "ram": "10240KB", +- "deps": { +- "components": [ +- "c_utils", +- "config_policy", +- "eventhandler", +- "hitrace_native", +- "hiviewdfx_hilog_native", +- "ipc", +- "libxml2", +- "safwk", +- "samgr" +- ], +- "third_party": [] +- }, +- "build": { +- "group_type": { +- "base_group" : [ +- "//foundation/resourceschedule/resource_schedule_service/soc_perf/profile:socperf_config" +- ], +- "fwk_group" : [ +- "//foundation/resourceschedule/resource_schedule_service/soc_perf/interfaces/inner_api/socperf_client:socperf_client" +- ], +- "service_group" : [ +- "//foundation/resourceschedule/resource_schedule_service/soc_perf/sa_profile:socperf_sa_profile", +- "//foundation/resourceschedule/resource_schedule_service/soc_perf/services:socperf_server" +- ] +- }, +- "inner_kits": [ +- { +- "header": { +- "header_base": "//foundation/resourceschedule/resource_schedule_service/soc_perf/interfaces/inner_api/socperf_client/include", +- "header_files": [ +- "i_socperf_service.h", +- "socperf_action_type.h", +- "socperf_client.h", +- "socperf_proxy.h" +- ] +- }, +- "name": "//foundation/resourceschedule/resource_schedule_service/soc_perf/interfaces/inner_api/socperf_client:socperf_client" +- } +- ], +- "test": [ +- "//foundation/resourceschedule/resource_schedule_service/soc_perf/test/unittest:unittest", +- "//foundation/resourceschedule/resource_schedule_service/soc_perf/test/fuzztest:fuzztest", +- "//foundation/resourceschedule/resource_schedule_service/soc_perf/test/testutil:socperf_test" +- ] +- } +- } +-} +\ No newline at end of file +diff --git a/soc_perf/common/include/socperf_log.h b/soc_perf/common/include/socperf_log.h +deleted file mode 100644 +index 0723b1e..0000000 +--- a/soc_perf/common/include/socperf_log.h ++++ /dev/null +@@ -1,75 +0,0 @@ +-/* +- * Copyright (c) 2023 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 SOC_PERF_COMMON_INCLUDE_SOCPERF_LOG_H +-#define SOC_PERF_COMMON_INCLUDE_SOCPERF_LOG_H +- +-#include "hilog/log.h" +- +-namespace OHOS { +-namespace SOCPERF { +-#ifndef LOG_TAG_SOC_PERF +-#define LOG_TAG_SOC_PERF "socperf" +-#endif +- +-#ifndef LOG_TAG_DOMAIN_ID_SOC_PERF +-#define LOG_TAG_DOMAIN_ID_SOC_PERF 0xD001703 +-#endif +- +-static constexpr OHOS::HiviewDFX::HiLogLabel SOC_PERF_LOG_LABEL = { +- LOG_CORE, +- LOG_TAG_DOMAIN_ID_SOC_PERF, +- LOG_TAG_SOC_PERF +-}; +- +-class SocPerfLog { +-public: +- SocPerfLog() = delete; +- ~SocPerfLog() = delete; +- +- static bool IsDebugLogEnabled() +- { +- return isDebugLogEnabled_; +- } +- +- static void EnableDebugLog() +- { +- isDebugLogEnabled_ = true; +- } +- +- static void DisableDebugLog() +- { +- isDebugLogEnabled_ = false; +- } +- +-private: +- static bool isDebugLogEnabled_; +-}; +- +-#define SOC_PERF_PRINT_LOG(Level, fmt, ...) \ +- OHOS::HiviewDFX::HiLog::Level(SOC_PERF_LOG_LABEL, "[%{public}s]: " fmt, __FUNCTION__, ##__VA_ARGS__) +- +-#define SOC_PERF_LOGD(fmt, ...) \ +- if (SocPerfLog::IsDebugLogEnabled()) \ +- SOC_PERF_PRINT_LOG(Debug, fmt, ##__VA_ARGS__) +- +-#define SOC_PERF_LOGI(fmt, ...) SOC_PERF_PRINT_LOG(Info, fmt, ##__VA_ARGS__) +-#define SOC_PERF_LOGW(fmt, ...) SOC_PERF_PRINT_LOG(Warn, fmt, ##__VA_ARGS__) +-#define SOC_PERF_LOGE(fmt, ...) SOC_PERF_PRINT_LOG(Error, fmt, ##__VA_ARGS__) +-#define SOC_PERF_LOGF(fmt, ...) SOC_PERF_PRINT_LOG(Fatal, fmt, ##__VA_ARGS__) +-} // namespace SOCPERF +-} // namespace OHOS +- +-#endif // SOC_PERF_COMMON_INCLUDE_SOCPERF_LOG_H +diff --git a/soc_perf/common/src/socperf_log.cpp b/soc_perf/common/src/socperf_log.cpp +deleted file mode 100644 +index 90c819d..0000000 +--- a/soc_perf/common/src/socperf_log.cpp ++++ /dev/null +@@ -1,22 +0,0 @@ +-/* +- * Copyright (c) 2023 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 "socperf_log.h" +- +-namespace OHOS { +-namespace SOCPERF { +-bool SocPerfLog::isDebugLogEnabled_ = HiLogIsLoggable(LOG_TAG_DOMAIN_ID_SOC_PERF, LOG_TAG_SOC_PERF, LOG_DEBUG); +-} // namespace SOCPERF +-} // namespace OHOS +diff --git a/soc_perf/interfaces/inner_api/socperf_client/BUILD.gn b/soc_perf/interfaces/inner_api/socperf_client/BUILD.gn +deleted file mode 100644 +index 09b4d7b..0000000 +--- a/soc_perf/interfaces/inner_api/socperf_client/BUILD.gn ++++ /dev/null +@@ -1,45 +0,0 @@ +-# Copyright (c) 2022-2023 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") +-import("../../../soc_perf.gni") +- +-config("socperf_client_public_config") { +- include_dirs = [ +- "include", +- "${socperf_common}/include", +- ] +-} +- +-ohos_shared_library("socperf_client") { +- sources = [ +- "${socperf_common}/src/socperf_log.cpp", +- "src/socperf_client.cpp", +- "src/socperf_proxy.cpp", +- ] +- +- public_configs = [ ":socperf_client_public_config" ] +- +- external_deps = [ +- "c_utils:utils", +- "hiviewdfx_hilog_native:libhilog", +- "ipc:ipc_single", +- "safwk:system_ability_fwk", +- "samgr:samgr_proxy", +- ] +- +- innerapi_tags = [ "platformsdk" ] +- version_script = "libsocperf_client.versionscript" +- part_name = "soc_perf" +- subsystem_name = "resourceschedule" +-} +diff --git a/soc_perf/interfaces/inner_api/socperf_client/include/i_socperf_service.h b/soc_perf/interfaces/inner_api/socperf_client/include/i_socperf_service.h +deleted file mode 100644 +index abbafb5..0000000 +--- a/soc_perf/interfaces/inner_api/socperf_client/include/i_socperf_service.h ++++ /dev/null +@@ -1,93 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_I_SOCPERF_SERVICE_H +-#define SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_I_SOCPERF_SERVICE_H +- +-#include +-#include "iremote_broker.h" +-#include "iremote_stub.h" +-#include "iremote_proxy.h" +-#include "iremote_object.h" +-#include "system_ability.h" +-#include "system_ability_definition.h" +-#include "if_system_ability_manager.h" +-#include "iservice_registry.h" +-#include "socperf_action_type.h" +- +-namespace OHOS { +-namespace SOCPERF { +-class ISocPerfService : public IRemoteBroker { +-public: +- /** +- * @brief Sending a performance request. +- * +- * @param cmdId scene id defined in config file. +- * @param msg Additional string info, which is used for other extensions. +- */ +- virtual void PerfRequest(int32_t cmdId, const std::string& msg) = 0; +- +- /** +- * @brief Sending a performance request. +- * +- * @param cmdId Scene id defined in config file. +- * @param onOffTag Indicates the start of end of a long-term frequency increase event. +- * @param msg Additional string info, which is used for other extensions. +- */ +- virtual void PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg) = 0; +- +- /** +- * @brief Sending a power limit boost request. +- * +- * @param onOffTag Indicates the start of end of a power limit boost event. +- * @param msg Additional string info, which is used for other extensions. +- */ +- virtual void PowerLimitBoost(bool onOffTag, const std::string& msg) = 0; +- +- /** +- * @brief Sending a thermal limit boost request. +- * +- * @param onOffTag Indicates the start of end of a thermal limit boost event. +- * @param msg Additional string info, which is used for other extensions. +- */ +- virtual void ThermalLimitBoost(bool onOffTag, const std::string& msg) = 0; +- +- /** +- * @brief Sending a limit request. +- * +- * @param clientId Used to indentify the caller of frequency limiting, such as +- * the thermal module or power consumption module. +- * @param configs Indicates the specific value to be limited. +- * @param msg Additional string info, which is used for other extensions. +- */ +- virtual void LimitRequest(int32_t clientId, +- const std::vector& tags, const std::vector& configs, const std::string& msg) = 0; +- +-public: +- enum { +- TRANS_IPC_ID_PERF_REQUEST = 0x0001, +- TRANS_IPC_ID_PERF_REQUEST_EX = 0x0002, +- TRANS_IPC_ID_POWER_LIMIT_BOOST_FREQ = 0x0005, +- TRANS_IPC_ID_THERMAL_LIMIT_BOOST_FREQ = 0x0008, +- TRANS_IPC_ID_LIMIT_REQUEST = 0x0009, +- }; +- +-public: +- DECLARE_INTERFACE_DESCRIPTOR(u"Resourceschedule.ISocPerfService"); +-}; +-} // namespace SOCPERF +-} // namespace OHOS +- +-#endif // SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_I_SOCPERF_SERVICE_H +diff --git a/soc_perf/interfaces/inner_api/socperf_client/include/socperf_action_type.h b/soc_perf/interfaces/inner_api/socperf_client/include/socperf_action_type.h +deleted file mode 100644 +index d7a8a42..0000000 +--- a/soc_perf/interfaces/inner_api/socperf_client/include/socperf_action_type.h ++++ /dev/null +@@ -1,32 +0,0 @@ +-/* +- * Copyright (c) 2023 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 SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_ACTION_TYPE_H +-#define SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_ACTION_TYPE_H +- +-#include +- +-namespace OHOS { +-namespace SOCPERF { +-enum ActionType : uint32_t { +- ACTION_TYPE_PERF, +- ACTION_TYPE_POWER, +- ACTION_TYPE_THERMAL, +- ACTION_TYPE_MAX +-}; +-} // namespace SOCPERF +-} // namespace OHOS +- +-#endif // SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_ACTION_TYPE_H +diff --git a/soc_perf/interfaces/inner_api/socperf_client/include/socperf_client.h b/soc_perf/interfaces/inner_api/socperf_client/include/socperf_client.h +deleted file mode 100644 +index a638e48..0000000 +--- a/soc_perf/interfaces/inner_api/socperf_client/include/socperf_client.h ++++ /dev/null +@@ -1,114 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_CLIENT_H +-#define SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_CLIENT_H +- +-#include // for int32_t +-#include // for string +-#include // for vector +-#include "i_socperf_service.h" // for ISocPerfService +- +-namespace OHOS { +-namespace SOCPERF { +-class SocPerfClient { +-public: +- /** +- * @brief Get the Instance object +- * +- * @return SocPerfClient& +- */ +- static SocPerfClient& GetInstance(); +- +- /** +- * @brief Sending a performance request. +- * +- * @param cmdId Scene id defined in config file. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void PerfRequest(int32_t cmdId, const std::string& msg); +- +- /** +- * @brief Sending a performance request. +- * +- * @param cmdId Scene id defined in config file. +- * @param onOffTag Indicates the start of end of a long-term frequency increase event. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg); +- +- /** +- * @brief Sending a power limit boost request. +- * +- * @param onOffTag Indicates the start of end of a power limit boost event. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void PowerLimitBoost(bool onOffTag, const std::string& msg); +- +- /** +- * @brief Sending a thermal limit boost request. +- * +- * @param onOffTag Indicates the start of end of a thermal limit boost event. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void ThermalLimitBoost(bool onOffTag, const std::string& msg); +- +- /** +- * @brief Sending a limit request. +- * +- * @param clientId Used to indentify the caller of frequency limiting, such as +- * the thermal module or power consumption module. +- * @param configs Indicates the specific value to be limited. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void LimitRequest(int32_t clientId, +- const std::vector& tags, const std::vector& configs, const std::string& msg); +- +- /** +- * @brief Reset SocperfClient +- * +- */ +- void ResetClient(); +- +-private: +- SocPerfClient() {} +- ~SocPerfClient() {} +- +-private: +- bool CheckClientValid(); +- std::string AddPidAndTidInfo(const std::string& msg); +- +-private: +- class SocPerfDeathRecipient : public IRemoteObject::DeathRecipient { +- public: +- explicit SocPerfDeathRecipient(SocPerfClient &socPerfClient); +- +- ~SocPerfDeathRecipient(); +- +- void OnRemoteDied(const wptr &object) override; +- +- private: +- SocPerfClient &socPerfClient_; +- }; +- +-private: +- std::mutex mutex_; +- sptr client; +- sptr recipient_; +-}; +-} // namespace SOCPERF +-} // namespace OHOS +- +-#endif // SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_CLIENT_H +diff --git a/soc_perf/interfaces/inner_api/socperf_client/include/socperf_proxy.h b/soc_perf/interfaces/inner_api/socperf_client/include/socperf_proxy.h +deleted file mode 100644 +index 67f3faa..0000000 +--- a/soc_perf/interfaces/inner_api/socperf_client/include/socperf_proxy.h ++++ /dev/null +@@ -1,90 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_PROXY_H +-#define SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_PROXY_H +- +-#include "i_socperf_service.h" +- +-namespace OHOS { +-namespace SOCPERF { +-class SocPerfProxy : public IRemoteProxy { +-public: +- /** +- * @brief Sending a performance request. +- * +- * @param cmdId Scene id defined in config file. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void PerfRequest(int32_t cmdId, const std::string& msg) override; +- +- /** +- * @brief Sending a performance request. +- * +- * @param cmdId Scene id defined in config file. +- * @param onOffTag Indicates the start of end of a long-term frequency increase event. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg) override; +- +- /** +- * @brief Sending a power limit boost request. +- * +- * @param onOffTag Indicates the start of end of a power limit boost event. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void PowerLimitBoost(bool onOffTag, const std::string& msg) override; +- +- /** +- * @brief Sending a thermal limit boost request. +- * +- * @param onOffTag Indicates the start of end of a thermal limit boost event. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void ThermalLimitBoost(bool onOffTag, const std::string& msg) override; +- +- /** +- * @brief Sending a limit request. +- * +- * @param clientId Used to indentify the caller of frequency limiting, such as +- * the thermal module or power consumption module. +- * @param configs Indicates the specific value to be limited. +- * @param msg Additional string info, which is used for other extensions. +- */ +- void LimitRequest(int32_t clientId, +- const std::vector& tags, const std::vector& configs, const std::string& msg) override; +- +-public: +- /** +- * @brief Construct a new SocPerfProxy object. +- * +- * @param impl RemoteObject. +- */ +- explicit SocPerfProxy(const sptr &impl) +- : IRemoteProxy(impl) {} +- +- /** +- * @brief Destroy the SocPerfProxy object. +- * +- */ +- virtual ~SocPerfProxy() {} +- +-private: +- static inline BrokerDelegator delegator_; +-}; +-} // namespace SOCPERF +-} // namespace OHOS +- +-#endif // SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_PROXY_H +diff --git a/soc_perf/interfaces/inner_api/socperf_client/libsocperf_client.versionscript b/soc_perf/interfaces/inner_api/socperf_client/libsocperf_client.versionscript +deleted file mode 100644 +index d870698..0000000 +--- a/soc_perf/interfaces/inner_api/socperf_client/libsocperf_client.versionscript ++++ /dev/null +@@ -1,27 +0,0 @@ +-# Copyright (c) 2023 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. +- +-1.0 { +- global: +- *ISocPerfService*; +- *SocPerfClient*GetInstance*; +- *SocPerfClient*PerfRequest*; +- *SocPerfClient*PerfRequestEx*; +- *SocPerfClient*PowerLimitBoost*; +- *SocPerfClient*ThermalLimitBoost*; +- *SocPerfClient*LimitRequest*; +- *SocPerfClient*ResetClient*; +- *SocPerfProxy*; +- local: +- *; +-}; +diff --git a/soc_perf/interfaces/inner_api/socperf_client/src/socperf_client.cpp b/soc_perf/interfaces/inner_api/socperf_client/src/socperf_client.cpp +deleted file mode 100644 +index d70f7f2..0000000 +--- a/soc_perf/interfaces/inner_api/socperf_client/src/socperf_client.cpp ++++ /dev/null +@@ -1,141 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 "socperf_client.h" +-#include // for basic_string, to_string +-#include // for getpid, gettid +-#include "socperf_log.h" +- +-namespace OHOS { +-namespace SOCPERF { +-SocPerfClient& SocPerfClient::GetInstance() +-{ +- static SocPerfClient instance; +- return instance; +-} +- +-bool SocPerfClient::CheckClientValid() +-{ +- std::lock_guard lock(mutex_); +- if (client) { +- return true; +- } +- +- sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); +- if (!samgr) { +- SOC_PERF_LOGE("Failed to get SystemAbilityManager."); +- return false; +- } +- +- sptr object = samgr->CheckSystemAbility(SOC_PERF_SERVICE_SA_ID); +- if (!object) { +- SOC_PERF_LOGE("Failed to get SystemAbility[1906]."); +- return false; +- } +- +- client = iface_cast(object); +- if (!client || !client->AsObject()) { +- SOC_PERF_LOGE("Failed to get SocPerfClient."); +- return false; +- } +- +- recipient_ = new (std::nothrow) SocPerfDeathRecipient(*this); +- if (!recipient_) { +- return false; +- } +- client->AsObject()->AddDeathRecipient(recipient_); +- +- return true; +-} +- +-void SocPerfClient::ResetClient() +-{ +- std::lock_guard lock(mutex_); +- if (client && client->AsObject()) { +- client->AsObject()->RemoveDeathRecipient(recipient_); +- } +- client = nullptr; +-} +- +-SocPerfClient::SocPerfDeathRecipient::SocPerfDeathRecipient(SocPerfClient &socPerfClient) +- : socPerfClient_(socPerfClient) {} +- +-SocPerfClient::SocPerfDeathRecipient::~SocPerfDeathRecipient() {} +- +-void SocPerfClient::SocPerfDeathRecipient::OnRemoteDied(const wptr &remote) +-{ +- socPerfClient_.ResetClient(); +-} +- +-std::string SocPerfClient::AddPidAndTidInfo(const std::string& msg) +-{ +- std::string str; +- int32_t pid = getpid(); +- int32_t tid = gettid(); +- str.append("pid=").append(std::to_string(pid)).append("|"); +- str.append("tid=").append(std::to_string(tid)); +- if (msg.size() > 0) { +- str.append("|").append(msg); +- } +- return str; +-} +- +-void SocPerfClient::PerfRequest(int32_t cmdId, const std::string& msg) +-{ +- if (!CheckClientValid()) { +- return; +- } +- std::string newMsg = AddPidAndTidInfo(msg); +- client->PerfRequest(cmdId, newMsg); +-} +- +-void SocPerfClient::PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg) +-{ +- if (!CheckClientValid()) { +- return; +- } +- std::string newMsg = AddPidAndTidInfo(msg); +- client->PerfRequestEx(cmdId, onOffTag, newMsg); +-} +- +-void SocPerfClient::PowerLimitBoost(bool onOffTag, const std::string& msg) +-{ +- if (!CheckClientValid()) { +- return; +- } +- std::string newMsg = AddPidAndTidInfo(msg); +- client->PowerLimitBoost(onOffTag, newMsg); +-} +- +-void SocPerfClient::ThermalLimitBoost(bool onOffTag, const std::string& msg) +-{ +- if (!CheckClientValid()) { +- return; +- } +- std::string newMsg = AddPidAndTidInfo(msg); +- client->ThermalLimitBoost(onOffTag, newMsg); +-} +- +-void SocPerfClient::LimitRequest(int32_t clientId, +- const std::vector& tags, const std::vector& configs, const std::string& msg) +-{ +- if (!CheckClientValid()) { +- return; +- } +- std::string newMsg = AddPidAndTidInfo(msg); +- client->LimitRequest(clientId, tags, configs, newMsg); +-} +-} // namespace SOCPERF +-} // namespace OHOS +diff --git a/soc_perf/interfaces/inner_api/socperf_client/src/socperf_proxy.cpp b/soc_perf/interfaces/inner_api/socperf_client/src/socperf_proxy.cpp +deleted file mode 100644 +index afb44dd..0000000 +--- a/soc_perf/interfaces/inner_api/socperf_client/src/socperf_proxy.cpp ++++ /dev/null +@@ -1,89 +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. +- */ +- +-#include "socperf_proxy.h" +- +-namespace OHOS { +-namespace SOCPERF { +-void SocPerfProxy::PerfRequest(int32_t cmdId, const std::string& msg) +-{ +- MessageParcel data; +- MessageParcel reply; +- MessageOption option = { MessageOption::TF_ASYNC }; +- if (!data.WriteInterfaceToken(GetDescriptor())) { +- return; +- } +- data.WriteInt32(cmdId); +- data.WriteString(msg); +- Remote()->SendRequest(TRANS_IPC_ID_PERF_REQUEST, data, reply, option); +-} +- +-void SocPerfProxy::PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg) +-{ +- MessageParcel data; +- MessageParcel reply; +- MessageOption option = { MessageOption::TF_ASYNC }; +- if (!data.WriteInterfaceToken(GetDescriptor())) { +- return; +- } +- data.WriteInt32(cmdId); +- data.WriteBool(onOffTag); +- data.WriteString(msg); +- Remote()->SendRequest(TRANS_IPC_ID_PERF_REQUEST_EX, data, reply, option); +-} +- +-void SocPerfProxy::PowerLimitBoost(bool onOffTag, const std::string& msg) +-{ +- MessageParcel data; +- MessageParcel reply; +- MessageOption option = { MessageOption::TF_ASYNC }; +- if (!data.WriteInterfaceToken(GetDescriptor())) { +- return; +- } +- data.WriteBool(onOffTag); +- data.WriteString(msg); +- Remote()->SendRequest(TRANS_IPC_ID_POWER_LIMIT_BOOST_FREQ, data, reply, option); +-} +- +-void SocPerfProxy::ThermalLimitBoost(bool onOffTag, const std::string& msg) +-{ +- MessageParcel data; +- MessageParcel reply; +- MessageOption option = { MessageOption::TF_ASYNC }; +- if (!data.WriteInterfaceToken(GetDescriptor())) { +- return; +- } +- data.WriteBool(onOffTag); +- data.WriteString(msg); +- Remote()->SendRequest(TRANS_IPC_ID_THERMAL_LIMIT_BOOST_FREQ, data, reply, option); +-} +- +-void SocPerfProxy::LimitRequest(int32_t clientId, +- const std::vector& tags, const std::vector& configs, const std::string& msg) +-{ +- MessageParcel data; +- MessageParcel reply; +- MessageOption option = { MessageOption::TF_ASYNC }; +- if (!data.WriteInterfaceToken(GetDescriptor())) { +- return; +- } +- data.WriteInt32(clientId); +- data.WriteInt32Vector(tags); +- data.WriteInt64Vector(configs); +- data.WriteString(msg); +- Remote()->SendRequest(TRANS_IPC_ID_LIMIT_REQUEST, data, reply, option); +-} +-} // namespace SOCPERF +-} // namespace OHOS +diff --git a/soc_perf/profile/BUILD.gn b/soc_perf/profile/BUILD.gn +deleted file mode 100644 +index d5b9789..0000000 +--- a/soc_perf/profile/BUILD.gn ++++ /dev/null +@@ -1,36 +0,0 @@ +-# Copyright (c) 2023 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("socperf_resource_config") { +- source = "socperf_resource_config.xml" +- install_enable = true +- module_install_dir = "etc/soc_perf" +- part_name = "soc_perf" +- subsystem_name = "resourceschedule" +-} +-ohos_prebuilt_etc("socperf_boost_config") { +- source = "socperf_boost_config.xml" +- install_enable = true +- module_install_dir = "etc/soc_perf" +- part_name = "soc_perf" +- subsystem_name = "resourceschedule" +-} +- +-group("socperf_config") { +- deps = [ +- ":socperf_boost_config", +- ":socperf_resource_config", +- ] +-} +diff --git a/soc_perf/profile/socperf_boost_config.xml b/soc_perf/profile/socperf_boost_config.xml +deleted file mode 100644 +index 4fdf3be..0000000 +--- a/soc_perf/profile/socperf_boost_config.xml ++++ /dev/null +@@ -1,17 +0,0 @@ +- +- +- +- +\ No newline at end of file +diff --git a/soc_perf/profile/socperf_resource_config.xml b/soc_perf/profile/socperf_resource_config.xml +deleted file mode 100644 +index 4fdf3be..0000000 +--- a/soc_perf/profile/socperf_resource_config.xml ++++ /dev/null +@@ -1,17 +0,0 @@ +- +- +- +- +\ No newline at end of file +diff --git a/soc_perf/sa_profile/1906.json b/soc_perf/sa_profile/1906.json +deleted file mode 100644 +index 12cf53a..0000000 +--- a/soc_perf/sa_profile/1906.json ++++ /dev/null +@@ -1,12 +0,0 @@ +-{ +- "process": "resource_schedule_service", +- "systemability": [ +- { +- "name": 1906, +- "libpath": "libsocperf_server.z.so", +- "run-on-create": true, +- "distributed": false, +- "dump_level": 1 +- } +- ] +-} +\ No newline at end of file +diff --git a/soc_perf/sa_profile/BUILD.gn b/soc_perf/sa_profile/BUILD.gn +deleted file mode 100644 +index ef1bab8..0000000 +--- a/soc_perf/sa_profile/BUILD.gn ++++ /dev/null +@@ -1,19 +0,0 @@ +-# Copyright (c) 2023 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/sa_profile/sa_profile.gni") +- +-ohos_sa_profile("socperf_sa_profile") { +- sources = [ "1906.json" ] +- part_name = "soc_perf" +-} +diff --git a/soc_perf/services/BUILD.gn b/soc_perf/services/BUILD.gn +deleted file mode 100644 +index 934b1ab..0000000 +--- a/soc_perf/services/BUILD.gn ++++ /dev/null +@@ -1,91 +0,0 @@ +-# Copyright (c) 2022-2023 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") +-import("../soc_perf.gni") +- +-config("socperf_server_config") { +- include_dirs = [ +- "core/include", +- "server/include", +- "${socperf_common}/include", +- "${socperf_interfaces}/inner_api/socperf_client/include", +- ] +-} +- +-ohos_shared_library("socperf_server") { +- configs = [ ":socperf_server_config" ] +- +- sources = [ +- "${socperf_common}/src/socperf_log.cpp", +- "core/src/socperf.cpp", +- "core/src/socperf_handler.cpp", +- "server/src/socperf_server.cpp", +- "server/src/socperf_stub.cpp", +- ] +- +- deps = [ "//third_party/libxml2:xml2" ] +- +- external_deps = [ +- "c_utils:utils", +- "eventhandler:libeventhandler", +- "hitrace_native:hitrace_meter", +- "hiviewdfx_hilog_native:libhilog", +- "ipc:ipc_single", +- "safwk:system_ability_fwk", +- "samgr:samgr_proxy", +- ] +- +- defines = [] +- if (customization_config_policy_enable) { +- external_deps += [ "config_policy:configpolicy_util" ] +- defines += [ "CUSTOMIZATION_CONFIG_POLICY_ENABLE" ] +- } +- +- shlib_type = "sa" +- part_name = "soc_perf" +- subsystem_name = "resourceschedule" +-} +- +-ohos_static_library("socperf_server_static") { +- configs = [ ":socperf_server_config" ] +- +- sources = [ +- "${socperf_common}/src/socperf_log.cpp", +- "core/src/socperf.cpp", +- "core/src/socperf_handler.cpp", +- "server/src/socperf_server.cpp", +- "server/src/socperf_stub.cpp", +- ] +- +- deps = [ "//third_party/libxml2:xml2" ] +- +- external_deps = [ +- "c_utils:utils", +- "eventhandler:libeventhandler", +- "hitrace_native:hitrace_meter", +- "hiviewdfx_hilog_native:libhilog", +- "ipc:ipc_single", +- "safwk:system_ability_fwk", +- "samgr:samgr_proxy", +- ] +- +- defines = [] +- if (customization_config_policy_enable) { +- external_deps += [ "config_policy:configpolicy_util" ] +- defines += [ "CUSTOMIZATION_CONFIG_POLICY_ENABLE" ] +- } +- +- part_name = "soc_perf" +- subsystem_name = "resourceschedule" +-} +diff --git a/soc_perf/services/core/include/socperf.h b/soc_perf/services/core/include/socperf.h +deleted file mode 100644 +index f36070c..0000000 +--- a/soc_perf/services/core/include/socperf.h ++++ /dev/null +@@ -1,85 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_H +-#define SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_H +- +-#include +-#include +-#include +-#include +-#include "libxml/parser.h" +-#include "libxml/tree.h" +-#include "socperf_common.h" +-#include "socperf_handler.h" +- +-namespace OHOS { +-namespace SOCPERF { +-class SocPerf { +-public: +- bool Init(); +- void PerfRequest(int32_t cmdId, const std::string& msg); +- void PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg); +- void PowerLimitBoost(bool onOffTag, const std::string& msg); +- void ThermalLimitBoost(bool onOffTag, const std::string& msg); +- void LimitRequest(int32_t clientId, +- const std::vector& tags, const std::vector& configs, const std::string& msg); +- +-public: +- SocPerf(); +- ~SocPerf(); +- +-private: +- std::unordered_map> perfActionsInfo; +- std::vector> handlers; +- bool handlerSwitch[MAX_HANDLER_THREADS] = { false }; +- bool enabled = false; +- +- std::unordered_map> resNodeInfo; +- std::unordered_map> govResNodeInfo; +- std::unordered_map resStrToIdInfo; +- std::vector> limitRequest; +- +-private: +- std::mutex mutex_; +- std::string GetRealConfigPath(const std::string configFile); +- std::shared_ptr GetHandlerByResId(int32_t resId); +- bool LoadConfigXmlFile(std::string configFile); +- bool CreateHandlers(); +- void InitHandlerThreads(); +- bool LoadResource(xmlNode* rootNode, std::string configFile); +- bool LoadGovResource(xmlNode* rootNode, std::string configFile); +- bool LoadCmd(xmlNode* rootNode, std::string configFile); +- bool CheckResourceTag(char* id, char* name, char* pair, char* mode, std::string configFile); +- bool CheckResourceTag(char* def, char* path, std::string configFile); +- bool LoadResourceAvailable(std::shared_ptr resNode, char* node); +- bool CheckPairResIdValid(); +- bool CheckResDefValid(); +- bool CheckGovResourceTag(char* id, char* name, std::string configFile); +- bool LoadGovResourceAvailable(std::shared_ptr govResNode, char* level, char* node); +- bool CheckGovResDefValid(); +- bool CheckCmdTag(char* id, char* name, std::string configFile); +- bool CheckActionResIdAndValueValid(std::string configFile); +- void DoFreqActions(std::shared_ptr actions, int32_t onOff, int32_t actionType); +- void PrintCachedInfo(); +- void SendLimitRequestEvent(int32_t clientId, int32_t resId, int64_t resValue); +- void SendLimitRequestEventOff(std::shared_ptr handler, +- int32_t clientId, int32_t resId, int32_t eventId); +- void SendLimitRequestEventOn(std::shared_ptr handler, +- int32_t clientId, int32_t resId, int64_t resValue, int32_t eventId); +-}; +-} // namespace SOCPERF +-} // namespace OHOS +-#endif // SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_H +diff --git a/soc_perf/services/core/include/socperf_common.h b/soc_perf/services/core/include/socperf_common.h +deleted file mode 100644 +index 74b6598..0000000 +--- a/soc_perf/services/core/include/socperf_common.h ++++ /dev/null +@@ -1,367 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_COMMON_H +-#define SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_COMMON_H +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include "socperf_log.h" +-#include "socperf_action_type.h" +- +-namespace OHOS { +-namespace SOCPERF { +-enum EventType { +- EVENT_INVALID = -1, +- EVENT_OFF, +- EVENT_ON +-}; +- +-const std::string SOCPERF_RESOURCE_CONFIG_XML = "etc/soc_perf/socperf_resource_config.xml"; +-const std::string SOCPERF_BOOST_CONFIG_XML = "etc/soc_perf/socperf_boost_config.xml"; +-const int64_t MAX_INT_VALUE = 0x7FFFFFFFFFFFFFFF; +-const int64_t MIN_INT_VALUE = 0x8000000000000000; +-const int32_t INVALID_VALUE = INT_MIN; +-const int32_t RESET_VALUE = -1; +-/* +- * Divide all resource id into five sections, resource of each section is processed in an individual handler thread. +- * handlerId = resourceId / RES_ID_NUMS_PER_TYPE - 1 +- * Resource section: [1000, 1999] [2000, 2999] [3000, 3999] [4000, 4999] [5000, 5999] +- * Handler Thread: handlers[0] handlers[1] handlers[2] handlers[3] handlers[4] +- */ +-const int32_t MAX_HANDLER_THREADS = 5; +-const int32_t MIN_RESOURCE_ID = 1000; +-const int32_t MAX_RESOURCE_ID = 5999; +-const int32_t RES_ID_ADDITION = 10000; +-const int32_t RES_ID_AND_VALUE_PAIR = 2; +-const int32_t RES_ID_NUMS_PER_TYPE = 1000; +- +-class ResNode { +-public: +- int32_t id; +- std::string name; +- int64_t def; +- std::string path; +- int32_t mode; +- int32_t pair; +- std::unordered_set available; +- +-public: +- ResNode(int32_t resId, std::string resName, int32_t resMode, int32_t resPair) +- { +- id = resId; +- name = resName; +- mode = resMode; +- pair = resPair; +- def = INVALID_VALUE; +- } +- ~ResNode() {} +- +- void PrintString() +- { +- SOC_PERF_LOGD("resNode-> id: [%{public}d], name: [%{public}s]", id, name.c_str()); +- SOC_PERF_LOGD(" path: [%{public}s]", path.c_str()); +- SOC_PERF_LOGD(" def: [%{public}lld], mode: [%{public}d], pair: [%{public}d]", +- (long long)def, mode, pair); +- std::string str; +- str.append("available(").append(std::to_string((int32_t)available.size())).append("): "); +- str.append("["); +- for (auto validValue : available) { +- str.append(std::to_string(validValue)).append(","); +- } +- if (!available.empty()) { +- str.pop_back(); +- } +- str.append("]"); +- SOC_PERF_LOGD(" %{public}s", str.c_str()); +- } +-}; +- +-class GovResNode { +-public: +- int32_t id; +- std::string name; +- int64_t def; +- std::vector paths; +- std::unordered_set available; +- std::unordered_map> levelToStr; +- +-public: +- GovResNode(int32_t govResId, std::string govResName) +- { +- id = govResId; +- name = govResName; +- def = INVALID_VALUE; +- } +- ~GovResNode() {} +- +- void PrintString() +- { +- SOC_PERF_LOGD("govResNode-> id: [%{public}d], name: [%{public}s]", id, name.c_str()); +- SOC_PERF_LOGD(" def: [%{public}lld]", (long long)def); +- for (auto path : paths) { +- SOC_PERF_LOGD(" path: [%{public}s]", path.c_str()); +- } +- std::string str; +- str.append("available(").append(std::to_string((int32_t)available.size())).append("): "); +- str.append("["); +- for (auto validValue : available) { +- str.append(std::to_string(validValue)).append(","); +- } +- if (!available.empty()) { +- str.pop_back(); +- } +- str.append("]"); +- SOC_PERF_LOGD(" %{public}s", str.c_str()); +- for (auto iter = levelToStr.begin(); iter != levelToStr.end(); ++iter) { +- std::string str2; +- int64_t level = iter->first; +- std::vector result = iter->second; +- for (int32_t i = 0; i < (int32_t)result.size(); i++) { +- str2.append(result[i]).append(","); +- } +- if (!result.empty()) { +- str2.pop_back(); +- } +- SOC_PERF_LOGD(" %{public}lld: [%{public}s]", (long long)level, str2.c_str()); +- } +- } +-}; +- +-class Action { +-public: +- int32_t duration; +- std::vector variable; +- +-public: +- Action() {} +- ~Action() {} +-}; +- +-class Actions { +-public: +- int32_t id; +- std::string name; +- std::list> actionList; +- +-public: +- Actions(int32_t cmdId, std::string cmdName) +- { +- id = cmdId; +- name = cmdName; +- } +- ~Actions() {} +- +- void PrintString() +- { +- SOC_PERF_LOGD("Actions-> id: [%{public}d], name: [%{public}s]", id, name.c_str()); +- for (auto iter = actionList.begin(); iter != actionList.end(); iter++) { +- std::shared_ptr action = *iter; +- std::string str; +- str.append("variable(").append(std::to_string((int32_t)action->variable.size())).append("): ["); +- for (int32_t i = 0; i < (int32_t)action->variable.size(); i++) { +- str.append(std::to_string(action->variable[i])).append(","); +- } +- if (!action->variable.empty()) { +- str.pop_back(); +- } +- str.append("]"); +- SOC_PERF_LOGD(" duration: [%{public}d], %{public}s", action->duration, str.c_str()); +- } +- } +-}; +- +-class ResAction { +-public: +- int64_t value; +- int32_t duration; +- int32_t type; +- int32_t onOff; +- +-public: +- ResAction(int64_t resActionValue, int32_t resActionDuration, int32_t resActionType, int32_t resActionOnOff) +- { +- value = resActionValue; +- duration = resActionDuration; +- type = resActionType; +- onOff = resActionOnOff; +- } +- ~ResAction() {} +- +- bool TotalSame(std::shared_ptr resAction) +- { +- if (value == resAction->value +- && duration == resAction->duration +- && type == resAction->type +- && onOff == resAction->onOff) { +- return true; +- } +- return false; +- } +- +- bool PartSame(std::shared_ptr resAction) +- { +- if (value == resAction->value +- && duration == resAction->duration +- && type == resAction->type) { +- return true; +- } +- return false; +- } +-}; +- +-class ResActionItem { +-public: +- ResActionItem(int32_t id) +- { +- resId = id; +- } +- +- ~ResActionItem() = default; +- +- int32_t resId; +- std::shared_ptr resAction = nullptr; +- std::shared_ptr next = nullptr; +-}; +- +-class ResStatus { +-public: +- std::vector>> resActionList; +- std::vector candidates; +- int64_t candidate; +- int64_t current; +- +-public: +- explicit ResStatus(int64_t val) +- { +- resActionList = std::vector>>(ACTION_TYPE_MAX); +- candidates = std::vector(ACTION_TYPE_MAX); +- candidates[ACTION_TYPE_PERF] = INVALID_VALUE; +- candidates[ACTION_TYPE_POWER] = INVALID_VALUE; +- candidates[ACTION_TYPE_THERMAL] = INVALID_VALUE; +- candidate = val; +- current = val; +- } +- ~ResStatus() {} +- +- std::string ToString() +- { +- std::string str; +- str.append("perf:["); +- for (auto iter = resActionList[ACTION_TYPE_PERF].begin(); +- iter != resActionList[ACTION_TYPE_PERF].end(); ++iter) { +- str.append(std::to_string((*iter)->value)).append(","); +- } +- if (!resActionList[ACTION_TYPE_PERF].empty()) { +- str.pop_back(); +- } +- str.append("]power:["); +- for (auto iter = resActionList[ACTION_TYPE_POWER].begin(); +- iter != resActionList[ACTION_TYPE_POWER].end(); ++iter) { +- str.append(std::to_string((*iter)->value)).append(","); +- } +- if (!resActionList[ACTION_TYPE_POWER].empty()) { +- str.pop_back(); +- } +- str.append("]thermal:["); +- for (auto iter = resActionList[ACTION_TYPE_THERMAL].begin(); +- iter != resActionList[ACTION_TYPE_THERMAL].end(); ++iter) { +- str.append(std::to_string((*iter)->value)).append(","); +- } +- if (!resActionList[ACTION_TYPE_THERMAL].empty()) { +- str.pop_back(); +- } +- str.append("]candidates["); +- for (auto iter = candidates.begin(); iter != candidates.end(); ++iter) { +- str.append(std::to_string(*iter)).append(","); +- } +- str.pop_back(); +- str.append("]candidate[").append(std::to_string(candidate)); +- str.append("]current[").append(std::to_string(current)).append("]"); +- return str; +- } +-}; +- +-static inline int64_t Max(int64_t num1, int64_t num2) +-{ +- if (num1 >= num2) { +- return num1; +- } +- return num2; +-} +- +-static inline int64_t Max(int64_t num1, int64_t num2, int64_t num3) +-{ +- return Max(Max(num1, num2), num3); +-} +- +-static inline int64_t Min(int64_t num1, int64_t num2) +-{ +- if (num1 <= num2) { +- return num1; +- } +- return num2; +-} +- +-static inline int64_t Min(int64_t num1, int64_t num2, int64_t num3) +-{ +- return Min(Min(num1, num2), num3); +-} +- +-static inline bool IsNumber(std::string str) +-{ +- for (int32_t i = 0; i < (int32_t)str.size(); i++) { +- if (i == 0 && str.at(i) == '-') { +- continue; +- } +- if (str.at(i) < '0' || str.at(i) > '9') { +- return false; +- } +- } +- return true; +-} +- +-static inline bool IsValidResId(int32_t id) +-{ +- if (id < MIN_RESOURCE_ID || id > MAX_RESOURCE_ID) { +- return false; +- } +- return true; +-} +- +-static inline std::vector Split(std::string str, std::string pattern) +-{ +- int32_t position; +- std::vector result; +- str += pattern; +- int32_t length = (int32_t)str.size(); +- for (int32_t i = 0; i < length; i++) { +- position = (int32_t)str.find(pattern, i); +- if (position < length) { +- std::string tmp = str.substr(i, position - i); +- result.push_back(tmp); +- i = position + (int32_t)pattern.size() - 1; +- } +- } +- return result; +-} +-} // namespace SOCPERF +-} // namespace OHOS +- +-#endif // SOC_PERF_SERVICES_CORE_INCLUDE_COMMON_H +diff --git a/soc_perf/services/core/include/socperf_handler.h b/soc_perf/services/core/include/socperf_handler.h +deleted file mode 100644 +index 414e02e..0000000 +--- a/soc_perf/services/core/include/socperf_handler.h ++++ /dev/null +@@ -1,79 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_HANDLER_H +-#define SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_HANDLER_H +- +- +-#include // for shared_ptr +-#include // for string +-#include // for unordered_map +-#include // for uint32_t +-#include "event_handler.h" // for EventHandler +-#include "event_runner.h" +-#include "inner_event.h" // for InnerEvent, InnerEvent::Pointer +-namespace OHOS { namespace SOCPERF { class GovResNode; } } +-namespace OHOS { namespace SOCPERF { class ResAction; } } +-namespace OHOS { namespace SOCPERF { class ResNode; } } +-namespace OHOS { namespace SOCPERF { class ResStatus; } } +- +-namespace OHOS { +-namespace SOCPERF { +-enum SocPerfInnerEvent : uint32_t { +- INNER_EVENT_ID_INIT_RES_NODE_INFO = 0, +- INNER_EVENT_ID_INIT_GOV_RES_NODE_INFO, +- INNER_EVENT_ID_DO_FREQ_ACTION, +- INNER_EVENT_ID_DO_FREQ_ACTION_PACK, +- INNER_EVENT_ID_DO_FREQ_ACTION_DELAYED, +- INNER_EVENT_ID_POWER_LIMIT_BOOST_FREQ, +- INNER_EVENT_ID_THERMAL_LIMIT_BOOST_FREQ, +- INNER_EVENT_ID_DO_FREQ_ACTION_LEVEL, +-}; +- +-class SocPerfHandler : public AppExecFwk::EventHandler { +-public: +- explicit SocPerfHandler(const std::shared_ptr& runner); +- ~SocPerfHandler() override; +- void ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event) override; +- +-private: +- std::unordered_map> resNodeInfo; +- std::unordered_map> govResNodeInfo; +- std::unordered_map> resStatusInfo; +- std::unordered_map fdInfo; +- bool powerLimitBoost = false; +- bool thermalLimitBoost = false; +- +-private: +- void HandleDoFreqActionLevel(int32_t resId, std::shared_ptr resAction); +- bool GetResValueByLevel(int32_t resId, int32_t level, int64_t& resValue); +- void UpdateResActionList(int32_t resId, std::shared_ptr resAction, bool delayed); +- void UpdateCandidatesValue(int32_t resId, int32_t type); +- void ArbitrateCandidate(int32_t resId); +- void ArbitratePairRes(int32_t resId); +- void UpdatePairResValue(int32_t minResId, int64_t minResValue, int32_t maxResId, int64_t maxResValue); +- void UpdateCurrentValue(int32_t resId, int64_t value); +- void WriteNode(std::string path, std::string value); +- bool ExistNoCandidate( +- int32_t resId, std::shared_ptr resStatus, int64_t perf, int64_t power, int64_t thermal); +- bool IsGovResId(int32_t resId); +- bool IsResId(int32_t resId); +- bool IsValidResId(int32_t resId); +- int32_t GetFdForFilePath(std::string filePath); +-}; +-} // namespace SOCPERF +-} // namespace OHOS +- +-#endif // SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_HANDLER_H +diff --git a/soc_perf/services/core/src/socperf.cpp b/soc_perf/services/core/src/socperf.cpp +deleted file mode 100644 +index 03f006c..0000000 +--- a/soc_perf/services/core/src/socperf.cpp ++++ /dev/null +@@ -1,752 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 "socperf.h" +- +-#ifdef CUSTOMIZATION_CONFIG_POLICY_ENABLE +-#include "config_policy_utils.h" +-#endif // CUSTOMIZATION_CONFIG_POLICY_ENABLE +- +-#include "hitrace_meter.h" +- +-namespace OHOS { +-namespace SOCPERF { +-SocPerf::SocPerf() +-{ +-} +- +-SocPerf::~SocPerf() +-{ +-} +- +-bool SocPerf::Init() +-{ +-#ifdef CUSTOMIZATION_CONFIG_POLICY_ENABLE +- if (!LoadConfigXmlFile(SOCPERF_RESOURCE_CONFIG_XML)) { +- SOC_PERF_LOGE("Failed to load %{public}s", SOCPERF_RESOURCE_CONFIG_XML.c_str()); +- return false; +- } +- +- if (!LoadConfigXmlFile(SOCPERF_BOOST_CONFIG_XML)) { +- SOC_PERF_LOGE("Failed to load %{public}s", SOCPERF_BOOST_CONFIG_XML.c_str()); +- return false; +- } +-#endif // CUSTOMIZATION_CONFIG_POLICY_ENABLE +- +- PrintCachedInfo(); +- +- if (!CreateHandlers()) { +- SOC_PERF_LOGE("Failed to create handler threads"); +- return false; +- } +- +- InitHandlerThreads(); +- +- resNodeInfo.clear(); +- govResNodeInfo.clear(); +- resStrToIdInfo.clear(); +- limitRequest = std::vector>(ACTION_TYPE_MAX); +- +- enabled = true; +- +- SOC_PERF_LOGD("SocPerf Init SUCCESS!"); +- +- return true; +-} +- +-void SocPerf::PerfRequest(int32_t cmdId, const std::string& msg) +-{ +- if (!enabled) { +- SOC_PERF_LOGE("SocPerf disabled!"); +- return; +- } +- if (perfActionsInfo.find(cmdId) == perfActionsInfo.end()) { +- SOC_PERF_LOGE("Invalid PerfRequest cmdId[%{public}d]", cmdId); +- return; +- } +- SOC_PERF_LOGD("cmdId[%{public}d]msg[%{public}s]", cmdId, msg.c_str()); +- +- std::string trace_str(__func__); +- trace_str.append(",cmdId[").append(std::to_string(cmdId)).append("]"); +- trace_str.append(",msg[").append(msg).append("]"); +- StartTrace(HITRACE_TAG_OHOS, trace_str, -1); +- DoFreqActions(perfActionsInfo[cmdId], EVENT_INVALID, ACTION_TYPE_PERF); +- FinishTrace(HITRACE_TAG_OHOS); +-} +- +-void SocPerf::PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg) +-{ +- if (!enabled) { +- SOC_PERF_LOGE("SocPerf disabled!"); +- return; +- } +- if (perfActionsInfo.find(cmdId) == perfActionsInfo.end()) { +- SOC_PERF_LOGE("Invalid PerfRequestEx cmdId[%{public}d]", cmdId); +- return; +- } +- SOC_PERF_LOGD("cmdId[%{public}d]onOffTag[%{public}d]msg[%{public}s]", +- cmdId, onOffTag, msg.c_str()); +- +- std::string trace_str(__func__); +- trace_str.append(",cmdId[").append(std::to_string(cmdId)).append("]"); +- trace_str.append(",onOff[").append(std::to_string(onOffTag)).append("]"); +- trace_str.append(",msg[").append(msg).append("]"); +- StartTrace(HITRACE_TAG_OHOS, trace_str, -1); +- DoFreqActions(perfActionsInfo[cmdId], onOffTag ? EVENT_ON : EVENT_OFF, ACTION_TYPE_PERF); +- FinishTrace(HITRACE_TAG_OHOS); +-} +- +-void SocPerf::PowerLimitBoost(bool onOffTag, const std::string& msg) +-{ +- if (!enabled) { +- SOC_PERF_LOGE("SocPerf disabled!"); +- return; +- } +- SOC_PERF_LOGD("onOffTag[%{public}d]msg[%{public}s]", onOffTag, msg.c_str()); +- +- std::string trace_str(__func__); +- trace_str.append(",onOff[").append(std::to_string(onOffTag)).append("]"); +- trace_str.append(",msg[").append(msg).append("]"); +- StartTrace(HITRACE_TAG_OHOS, trace_str, -1); +- for (auto handler : handlers) { +- if (handler) { +- auto event = AppExecFwk::InnerEvent::Get(INNER_EVENT_ID_POWER_LIMIT_BOOST_FREQ, onOffTag ? 1 : 0); +- handler->SendEvent(event); +- } +- } +- FinishTrace(HITRACE_TAG_OHOS); +-} +- +-void SocPerf::ThermalLimitBoost(bool onOffTag, const std::string& msg) +-{ +- if (!enabled) { +- SOC_PERF_LOGE("SocPerf disabled!"); +- return; +- } +- SOC_PERF_LOGD("onOffTag[%{public}d]msg[%{public}s]", onOffTag, msg.c_str()); +- std::string trace_str(__func__); +- trace_str.append(",onOff[").append(std::to_string(onOffTag)).append("]"); +- trace_str.append(",msg[").append(msg).append("]"); +- StartTrace(HITRACE_TAG_OHOS, trace_str, -1); +- for (auto handler : handlers) { +- if (handler) { +- auto event = AppExecFwk::InnerEvent::Get(INNER_EVENT_ID_THERMAL_LIMIT_BOOST_FREQ, onOffTag ? 1 : 0); +- handler->SendEvent(event); +- } +- } +- FinishTrace(HITRACE_TAG_OHOS); +-} +- +-void SocPerf::SendLimitRequestEventOff(std::shared_ptr handler, +- int32_t clientId, int32_t resId, int32_t eventId) +-{ +- auto iter = limitRequest[clientId].find(resId); +- if (iter != limitRequest[clientId].end() +- && limitRequest[clientId][resId] != INVALID_VALUE) { +- auto resAction = std::make_shared( +- limitRequest[clientId][resId], 0, clientId, EVENT_OFF); +- auto event = AppExecFwk::InnerEvent::Get(eventId, resAction, resId); +- handler->SendEvent(event); +- limitRequest[clientId].erase(iter); +- } +-} +- +-void SocPerf::SendLimitRequestEventOn(std::shared_ptr handler, +- int32_t clientId, int32_t resId, int64_t resValue, int32_t eventId) +-{ +- if (resValue != INVALID_VALUE && resValue != RESET_VALUE) { +- auto resAction = std::make_shared(resValue, 0, clientId, EVENT_ON); +- auto event = AppExecFwk::InnerEvent::Get(eventId, resAction, resId); +- handler->SendEvent(event); +- limitRequest[clientId].insert(std::pair(resId, resValue)); +- } +-} +- +-void SocPerf::SendLimitRequestEvent(int32_t clientId, int32_t resId, int64_t resValue) +-{ +- int32_t eventId, realResId, levelResId; +- if (resId > RES_ID_ADDITION) { +- realResId = resId - RES_ID_ADDITION; +- levelResId = resId; +- eventId = INNER_EVENT_ID_DO_FREQ_ACTION_LEVEL; +- } else { +- realResId = resId; +- levelResId = resId + RES_ID_ADDITION; +- eventId = INNER_EVENT_ID_DO_FREQ_ACTION; +- } +- +- auto handler = GetHandlerByResId(realResId); +- if (!handler) { +- return; +- } +- std::lock_guard lock(mutex_); +- SendLimitRequestEventOff(handler, clientId, realResId, INNER_EVENT_ID_DO_FREQ_ACTION); +- SendLimitRequestEventOff(handler, clientId, levelResId, INNER_EVENT_ID_DO_FREQ_ACTION_LEVEL); +- SendLimitRequestEventOn(handler, clientId, resId, resValue, eventId); +-} +- +-void SocPerf::LimitRequest(int32_t clientId, +- const std::vector& tags, const std::vector& configs, const std::string& msg) +-{ +- if (!enabled) { +- SOC_PERF_LOGE("SocPerf disabled!"); +- return; +- } +- if (tags.size() != configs.size()) { +- SOC_PERF_LOGE("tags'size and configs' size must be the same!"); +- return; +- } +- if (clientId <= (int32_t)ACTION_TYPE_PERF || clientId >= (int32_t)ACTION_TYPE_MAX) { +- SOC_PERF_LOGE("clientId must be between ACTION_TYPE_PERF and ACTION_TYPE_MAX!"); +- return; +- } +- for (int32_t i = 0; i < (int32_t)tags.size(); i++) { +- SOC_PERF_LOGD("clientId[%{public}d],tags[%{public}d],configs[%{public}lld],msg[%{public}s]", +- clientId, tags[i], (long long)configs[i], msg.c_str()); +- SendLimitRequestEvent(clientId, tags[i], configs[i]); +- } +-} +- +-void SocPerf::DoFreqActions(std::shared_ptr actions, int32_t onOff, int32_t actionType) +-{ +- std::shared_ptr header[MAX_HANDLER_THREADS] = { nullptr }; +- std::shared_ptr curItem[MAX_HANDLER_THREADS] = { nullptr }; +- for (auto iter = actions->actionList.begin(); iter != actions->actionList.end(); iter++) { +- std::shared_ptr action = *iter; +- for (int32_t i = 0; i < (int32_t)action->variable.size() - 1; i += RES_ID_AND_VALUE_PAIR) { +- if (!IsValidResId(action->variable[i])) { +- continue; +- } +- auto resActionItem = std::make_shared(action->variable[i]); +- resActionItem->resAction = +- std::make_shared(action->variable[i + 1], action->duration, actionType, onOff); +- int32_t id = action->variable[i] / RES_ID_NUMS_PER_TYPE - 1; +- if (curItem[id]) { +- curItem[id]->next = resActionItem; +- } else { +- header[id] = resActionItem; +- } +- curItem[id] = resActionItem; +- } +- } +- for (int32_t i = 0; i < MAX_HANDLER_THREADS; ++i) { +- if (!handlers[i] || !header[i]) { +- continue; +- } +- auto event = AppExecFwk::InnerEvent::Get(INNER_EVENT_ID_DO_FREQ_ACTION_PACK, header[i]); +- handlers[i]->SendEvent(event); +- } +-} +- +-#ifdef CUSTOMIZATION_CONFIG_POLICY_ENABLE +-std::string SocPerf::GetRealConfigPath(const std::string configFile) +-{ +- char buf[PATH_MAX + 1]; +- char* configFilePath = GetOneCfgFile(configFile.c_str(), buf, PATH_MAX + 1); +- char tmpPath[PATH_MAX + 1] = {0}; +- if (!configFilePath || strlen(configFilePath) == 0 || strlen(configFilePath) > PATH_MAX || +- !realpath(configFilePath, tmpPath)) { +- SOC_PERF_LOGE("load %{public}s file fail", configFile.c_str()); +- return ""; +- } +- return std::string(tmpPath); +-} +-#endif // CUSTOMIZATION_CONFIG_POLICY_ENABLE +- +-std::shared_ptr SocPerf::GetHandlerByResId(int32_t resId) +-{ +- if (!IsValidResId(resId)) { +- return nullptr; +- } +- return handlers[resId / RES_ID_NUMS_PER_TYPE - 1]; +-} +- +-#ifdef CUSTOMIZATION_CONFIG_POLICY_ENABLE +-bool SocPerf::LoadConfigXmlFile(std::string configFile) +-{ +- std::string realConfigFile = GetRealConfigPath(configFile); +- if (realConfigFile.size() <= 0) { +- return false; +- } +- xmlKeepBlanksDefault(0); +- xmlDoc* file = xmlReadFile(realConfigFile.c_str(), nullptr, XML_PARSE_NOERROR | XML_PARSE_NOWARNING); +- if (!file) { +- SOC_PERF_LOGE("Failed to open xml file"); +- return false; +- } +- xmlNode* rootNode = xmlDocGetRootElement(file); +- if (!rootNode) { +- SOC_PERF_LOGE("Failed to get xml file's RootNode"); +- xmlFreeDoc(file); +- return false; +- } +- if (!xmlStrcmp(rootNode->name, reinterpret_cast("Configs"))) { +- if (realConfigFile.find(SOCPERF_RESOURCE_CONFIG_XML) != std::string::npos) { +- xmlNode* child = rootNode->children; +- for (; child; child = child->next) { +- if (!xmlStrcmp(child->name, reinterpret_cast("Resource"))) { +- if (!LoadResource(child, realConfigFile)) { +- xmlFreeDoc(file); +- return false; +- } +- } else if (!xmlStrcmp(child->name, reinterpret_cast("GovResource"))) { +- if (!LoadGovResource(child, realConfigFile)) { +- xmlFreeDoc(file); +- return false; +- } +- } +- } +- } else { +- if (!LoadCmd(rootNode, realConfigFile)) { +- xmlFreeDoc(file); +- return false; +- } +- } +- } else { +- SOC_PERF_LOGE("Wrong format for xml file"); +- xmlFreeDoc(file); +- return false; +- } +- xmlFreeDoc(file); +- SOC_PERF_LOGD("Success to Load %{public}s", configFile.c_str()); +- return true; +-} +-#endif // CUSTOMIZATION_CONFIG_POLICY_ENABLE +- +-bool SocPerf::CreateHandlers() +-{ +- handlers = std::vector>(MAX_HANDLER_THREADS); +- std::string threadName = "socperf#"; +- for (int32_t i = 0; i < (int32_t)handlers.size(); i++) { +- if (!handlerSwitch[i]) { +- handlers[i] = nullptr; +- continue; +- } +- auto runner = AppExecFwk::EventRunner::Create(threadName + std::to_string(i)); +- if (!runner) { +- SOC_PERF_LOGE("Failed to Create EventRunner"); +- return false; +- } +- handlers[i] = std::make_shared(runner); +- } +- SOC_PERF_LOGD("Success to Create All Handler threads"); +- return true; +-} +- +-void SocPerf::InitHandlerThreads() +-{ +- for (auto iter = resNodeInfo.begin(); iter != resNodeInfo.end(); ++iter) { +- std::shared_ptr resNode = iter->second; +- auto handler = GetHandlerByResId(resNode->id); +- if (!handler) { +- continue; +- } +- auto event = AppExecFwk::InnerEvent::Get(INNER_EVENT_ID_INIT_RES_NODE_INFO, resNode); +- handler->SendEvent(event); +- } +- for (auto iter = govResNodeInfo.begin(); iter != govResNodeInfo.end(); ++iter) { +- std::shared_ptr govResNode = iter->second; +- auto handler = GetHandlerByResId(govResNode->id); +- if (!handler) { +- continue; +- } +- auto event = AppExecFwk::InnerEvent::Get(INNER_EVENT_ID_INIT_GOV_RES_NODE_INFO, govResNode); +- handler->SendEvent(event); +- } +-} +- +-bool SocPerf::LoadResource(xmlNode* child, std::string configFile) +-{ +- xmlNode* grandson = child->children; +- for (; grandson; grandson = grandson->next) { +- if (!xmlStrcmp(grandson->name, reinterpret_cast("res"))) { +- char* id = reinterpret_cast(xmlGetProp(grandson, reinterpret_cast("id"))); +- char* name = reinterpret_cast(xmlGetProp(grandson, reinterpret_cast("name"))); +- char* pair = reinterpret_cast(xmlGetProp(grandson, reinterpret_cast("pair"))); +- char* mode = reinterpret_cast(xmlGetProp(grandson, reinterpret_cast("mode"))); +- if (!CheckResourceTag(id, name, pair, mode, configFile)) { +- xmlFree(id); +- xmlFree(name); +- xmlFree(pair); +- xmlFree(mode); +- return false; +- } +- xmlNode* greatGrandson = grandson->children; +- std::shared_ptr resNode = std::make_shared( +- atoi(id), name, mode ? atoi(mode) : 0, pair ? atoi(pair) : INVALID_VALUE); +- xmlFree(id); +- xmlFree(name); +- xmlFree(pair); +- xmlFree(mode); +- char *def = nullptr; +- char *path = nullptr; +- char *node = nullptr; +- for (; greatGrandson; greatGrandson = greatGrandson->next) { +- if (!xmlStrcmp(greatGrandson->name, reinterpret_cast("default"))) { +- xmlFree(def); +- def = reinterpret_cast(xmlNodeGetContent(greatGrandson)); +- } else if (!xmlStrcmp(greatGrandson->name, reinterpret_cast("path"))) { +- xmlFree(path); +- path = reinterpret_cast(xmlNodeGetContent(greatGrandson)); +- } else if (!xmlStrcmp(greatGrandson->name, reinterpret_cast("node"))) { +- xmlFree(node); +- node = reinterpret_cast(xmlNodeGetContent(greatGrandson)); +- } +- } +- if (!CheckResourceTag(def, path, configFile)) { +- xmlFree(def); +- xmlFree(path); +- xmlFree(node); +- return false; +- } +- resNode->def = atoll(def); +- resNode->path = path; +- xmlFree(def); +- xmlFree(path); +- if (node && !LoadResourceAvailable(resNode, node)) { +- SOC_PERF_LOGE("Invalid resource node for %{public}s", configFile.c_str()); +- xmlFree(node); +- return false; +- } +- xmlFree(node); +- +- resStrToIdInfo.insert(std::pair(resNode->name, resNode->id)); +- resNodeInfo.insert(std::pair>(resNode->id, resNode)); +- handlerSwitch[resNode->id / RES_ID_NUMS_PER_TYPE - 1] = true; +- } +- } +- +- if (!CheckPairResIdValid() || !CheckResDefValid()) { +- return false; +- } +- +- return true; +-} +- +-bool SocPerf::LoadGovResource(xmlNode* child, std::string configFile) +-{ +- xmlNode* grandson = child->children; +- for (; grandson; grandson = grandson->next) { +- if (xmlStrcmp(grandson->name, reinterpret_cast("res"))) { +- continue; +- } +- char* id = reinterpret_cast(xmlGetProp(grandson, reinterpret_cast("id"))); +- char* name = reinterpret_cast(xmlGetProp(grandson, reinterpret_cast("name"))); +- if (!CheckGovResourceTag(id, name, configFile)) { +- xmlFree(id); +- xmlFree(name); +- return false; +- } +- xmlNode* greatGrandson = grandson->children; +- std::shared_ptr govResNode = std::make_shared(atoi(id), name); +- xmlFree(id); +- xmlFree(name); +- handlerSwitch[govResNode->id / RES_ID_NUMS_PER_TYPE - 1] = true; +- for (; greatGrandson; greatGrandson = greatGrandson->next) { +- if (!xmlStrcmp(greatGrandson->name, reinterpret_cast("default"))) { +- char* def = reinterpret_cast(xmlNodeGetContent(greatGrandson)); +- if (!def || !IsNumber(def)) { +- SOC_PERF_LOGE("Invalid governor resource default for %{public}s", configFile.c_str()); +- xmlFree(def); +- return false; +- } +- govResNode->def = atoll(def); +- xmlFree(def); +- } else if (!xmlStrcmp(greatGrandson->name, reinterpret_cast("path"))) { +- char* path = reinterpret_cast(xmlNodeGetContent(greatGrandson)); +- if (!path) { +- SOC_PERF_LOGE("Invalid governor resource path for %{public}s", configFile.c_str()); +- return false; +- } +- govResNode->paths.push_back(path); +- xmlFree(path); +- } else if (!xmlStrcmp(greatGrandson->name, reinterpret_cast("node"))) { +- char* level = reinterpret_cast( +- xmlGetProp(greatGrandson, reinterpret_cast("level"))); +- char* node = reinterpret_cast(xmlNodeGetContent(greatGrandson)); +- if (!level || !IsNumber(level) || !node +- || !LoadGovResourceAvailable(govResNode, level, node)) { +- SOC_PERF_LOGE("Invalid governor resource node for %{public}s", configFile.c_str()); +- xmlFree(level); +- xmlFree(node); +- return false; +- } +- xmlFree(level); +- xmlFree(node); +- } +- } +- +- resStrToIdInfo.insert(std::pair(govResNode->name, govResNode->id)); +- govResNodeInfo.insert(std::pair>(govResNode->id, govResNode)); +- } +- +- if (!CheckGovResDefValid()) { +- return false; +- } +- +- return true; +-} +- +-bool SocPerf::LoadCmd(xmlNode* rootNode, std::string configFile) +-{ +- xmlNode* child = rootNode->children; +- for (; child; child = child->next) { // Iterate all cmdID +- if (xmlStrcmp(child->name, reinterpret_cast("cmd"))) { +- continue; +- } +- char* id = reinterpret_cast(xmlGetProp(child, reinterpret_cast("id"))); +- char* name = reinterpret_cast(xmlGetProp(child, reinterpret_cast("name"))); +- if (!CheckCmdTag(id, name, configFile)) { +- xmlFree(id); +- xmlFree(name); +- return false; +- } +- xmlNode* grandson = child->children; +- std::shared_ptr actions = std::make_shared(atoi(id), name); +- xmlFree(id); +- xmlFree(name); +- for (; grandson; grandson = grandson->next) { // Iterate all Action +- std::shared_ptr action = std::make_shared(); +- xmlNode* greatGrandson = grandson->children; +- for (; greatGrandson; greatGrandson = greatGrandson->next) { // Iterate duration and all res +- if (!xmlStrcmp(greatGrandson->name, reinterpret_cast("duration"))) { +- char* duration = reinterpret_cast(xmlNodeGetContent(greatGrandson)); +- if (!duration || !IsNumber(duration)) { +- SOC_PERF_LOGE("Invalid cmd duration for %{public}s", configFile.c_str()); +- xmlFree(duration); +- return false; +- } +- action->duration = atoi(duration); +- xmlFree(duration); +- } else { +- char* resStr = reinterpret_cast(const_cast(greatGrandson->name)); +- char* resValue = reinterpret_cast(xmlNodeGetContent(greatGrandson)); +- if (!resStr || resStrToIdInfo.find(resStr) == resStrToIdInfo.end() +- || !resValue || !IsNumber(resValue)) { +- SOC_PERF_LOGE("Invalid cmd resource(%{public}s) for %{public}s", resStr, configFile.c_str()); +- xmlFree(resValue); +- return false; +- } +- action->variable.push_back(resStrToIdInfo[resStr]); +- action->variable.push_back(atoll(resValue)); +- xmlFree(resValue); +- } +- } +- actions->actionList.push_back(action); +- } +- +- if (configFile.find(SOCPERF_BOOST_CONFIG_XML) != std::string::npos) { +- perfActionsInfo.insert(std::pair>(actions->id, actions)); +- } +- } +- +- if (!CheckActionResIdAndValueValid(configFile)) { +- return false; +- } +- +- return true; +-} +- +-bool SocPerf::CheckResourceTag(char* id, char* name, char* pair, char* mode, std::string configFile) +-{ +- if (!id || !IsNumber(id) || !IsValidResId(atoi(id))) { +- SOC_PERF_LOGE("Invalid resource id for %{public}s", configFile.c_str()); +- return false; +- } +- if (!name) { +- SOC_PERF_LOGE("Invalid resource name for %{public}s", configFile.c_str()); +- return false; +- } +- if (pair && (!IsNumber(pair) || !IsValidResId(atoi(pair)))) { +- SOC_PERF_LOGE("Invalid resource pair for %{public}s", configFile.c_str()); +- return false; +- } +- if (mode && !IsNumber(mode)) { +- SOC_PERF_LOGE("Invalid resource mode for %{public}s", configFile.c_str()); +- return false; +- } +- return true; +-} +- +-bool SocPerf::CheckResourceTag(char* def, char* path, std::string configFile) +-{ +- if (!def || !IsNumber(def)) { +- SOC_PERF_LOGE("Invalid resource default for %{public}s", configFile.c_str()); +- return false; +- } +- if (!path) { +- SOC_PERF_LOGE("Invalid resource path for %{public}s", configFile.c_str()); +- return false; +- } +- return true; +-} +- +-bool SocPerf::LoadResourceAvailable(std::shared_ptr resNode, char* node) +-{ +- std::string nodeStr = node; +- std::vector result = Split(nodeStr, " "); +- for (auto str : result) { +- if (IsNumber(str)) { +- resNode->available.insert(stoll(str)); +- } else { +- return false; +- } +- } +- return true; +-} +- +-bool SocPerf::CheckPairResIdValid() +-{ +- for (auto iter = resNodeInfo.begin(); iter != resNodeInfo.end(); ++iter) { +- int32_t resId = iter->first; +- std::shared_ptr resNode = iter->second; +- int32_t pairResId = resNode->pair; +- if (pairResId != INVALID_VALUE && resNodeInfo.find(pairResId) == resNodeInfo.end()) { +- SOC_PERF_LOGE("resId[%{public}d]'s pairResId[%{public}d] is not valid", resId, pairResId); +- return false; +- } +- } +- return true; +-} +- +-bool SocPerf::CheckResDefValid() +-{ +- for (auto iter = resNodeInfo.begin(); iter != resNodeInfo.end(); ++iter) { +- int32_t resId = iter->first; +- std::shared_ptr resNode = iter->second; +- int64_t def = resNode->def; +- if (!resNode->available.empty() && resNode->available.find(def) == resNode->available.end()) { +- SOC_PERF_LOGE("resId[%{public}d]'s def[%{public}lld] is not valid", resId, (long long)def); +- return false; +- } +- } +- return true; +-} +- +-bool SocPerf::CheckGovResourceTag(char* id, char* name, std::string configFile) +-{ +- if (!id || !IsNumber(id) || !IsValidResId(atoi(id))) { +- SOC_PERF_LOGE("Invalid governor resource id for %{public}s", configFile.c_str()); +- return false; +- } +- if (!name) { +- SOC_PERF_LOGE("Invalid governor resource name for %{public}s", configFile.c_str()); +- return false; +- } +- return true; +-} +- +-bool SocPerf::LoadGovResourceAvailable(std::shared_ptr govResNode, char* level, char* node) +-{ +- govResNode->available.insert(atoll(level)); +- std::string nodeStr = node; +- std::vector result = Split(nodeStr, "|"); +- if (result.size() != govResNode->paths.size()) { +- SOC_PERF_LOGE("Invalid governor resource node matches paths"); +- return false; +- } +- govResNode->levelToStr.insert(std::pair>(atoll(level), result)); +- return true; +-} +- +-bool SocPerf::CheckGovResDefValid() +-{ +- for (auto iter = govResNodeInfo.begin(); iter != govResNodeInfo.end(); ++iter) { +- int32_t govResId = iter->first; +- std::shared_ptr govResNode = iter->second; +- int32_t def = govResNode->def; +- if (govResNode->available.find(def) == govResNode->available.end()) { +- SOC_PERF_LOGE("govResId[%{public}d]'s def[%{public}d] is not valid", govResId, def); +- return false; +- } +- } +- return true; +-} +- +-bool SocPerf::CheckCmdTag(char* id, char* name, std::string configFile) +-{ +- if (!id || !IsNumber(id)) { +- SOC_PERF_LOGE("Invalid cmd id for %{public}s", configFile.c_str()); +- return false; +- } +- if (!name) { +- SOC_PERF_LOGE("Invalid cmd name for %{public}s", configFile.c_str()); +- return false; +- } +- return true; +-} +- +-bool SocPerf::CheckActionResIdAndValueValid(std::string configFile) +-{ +- std::unordered_map> actionsInfo; +- if (configFile.find(SOCPERF_BOOST_CONFIG_XML) != std::string::npos) { +- actionsInfo = perfActionsInfo; +- } +- for (auto actionsIter = actionsInfo.begin(); actionsIter != actionsInfo.end(); ++actionsIter) { +- int32_t actionId = actionsIter->first; +- std::shared_ptr actions = actionsIter->second; +- for (auto actionIter = actions->actionList.begin(); actionIter != actions->actionList.end(); ++actionIter) { +- std::shared_ptr action = *actionIter; +- for (int32_t i = 0; i < (int32_t)action->variable.size() - 1; i += RES_ID_AND_VALUE_PAIR) { +- int32_t resId = action->variable[i]; +- int64_t resValue = action->variable[i + 1]; +- if (resNodeInfo.find(resId) != resNodeInfo.end()) { +- if (!resNodeInfo[resId]->available.empty() +- && resNodeInfo[resId]->available.find(resValue) == resNodeInfo[resId]->available.end()) { +- SOC_PERF_LOGE("action[%{public}d]'s resValue[%{public}lld] is not valid", +- actionId, (long long)resValue); +- return false; +- } +- } else if (govResNodeInfo.find(resId) != govResNodeInfo.end()) { +- if (govResNodeInfo[resId]->available.find(resValue) == govResNodeInfo[resId]->available.end()) { +- SOC_PERF_LOGE("action[%{public}d]'s resValue[%{public}lld] is not valid", +- actionId, (long long)resValue); +- return false; +- } +- } else { +- SOC_PERF_LOGE("action[%{public}d]'s resId[%{public}d] is not valid", actionId, resId); +- return false; +- } +- } +- } +- } +- return true; +-} +- +-void SocPerf::PrintCachedInfo() +-{ +- SOC_PERF_LOGD("------------------------------------"); +- SOC_PERF_LOGD("resNodeInfo(%{public}d)", (int32_t)resNodeInfo.size()); +- for (auto iter = resNodeInfo.begin(); iter != resNodeInfo.end(); ++iter) { +- std::shared_ptr resNode = iter->second; +- resNode->PrintString(); +- } +- SOC_PERF_LOGD("------------------------------------"); +- SOC_PERF_LOGD("govResNodeInfo(%{public}d)", (int32_t)govResNodeInfo.size()); +- for (auto iter = govResNodeInfo.begin(); iter != govResNodeInfo.end(); ++iter) { +- std::shared_ptr govResNode = iter->second; +- govResNode->PrintString(); +- } +- SOC_PERF_LOGD("------------------------------------"); +- SOC_PERF_LOGD("perfActionsInfo(%{public}d)", (int32_t)perfActionsInfo.size()); +- for (auto iter = perfActionsInfo.begin(); iter != perfActionsInfo.end(); ++iter) { +- std::shared_ptr actions = iter->second; +- actions->PrintString(); +- } +- SOC_PERF_LOGD("------------------------------------"); +-} +-} // namespace SOCPERF +-} // namespace OHOS +diff --git a/soc_perf/services/core/src/socperf_handler.cpp b/soc_perf/services/core/src/socperf_handler.cpp +deleted file mode 100644 +index a63e94e..0000000 +--- a/soc_perf/services/core/src/socperf_handler.cpp ++++ /dev/null +@@ -1,431 +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. +- */ +-#include "socperf_handler.h" +-#include // for FILE +-#include // for int32_t +-#include // for PATH_MAX +-#include // for list, __list_iterator, operator!= +-#include // for operator delete, operator new +-#include // for realpath +-#include // for set +-#include // for basic_string, to_string +-#include // for unordered_map, operator==, operator!= +-#include // for pair +-#include // for vector +-#include // for open, write +-#include // for O_RDWR, O_CLOEXEC +-#include "socperf_common.h" // for ResStatus, ResAction, ResNode, INVALID_V... +- +-namespace OHOS { +-namespace SOCPERF { +-SocPerfHandler::SocPerfHandler( +- const std::shared_ptr& runner) : AppExecFwk::EventHandler(runner) +-{ +-} +- +-SocPerfHandler::~SocPerfHandler() +-{ +-} +- +-void SocPerfHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) +-{ +- if (event == nullptr) { +- return; +- } +- switch (event->GetInnerEventId()) { +- case INNER_EVENT_ID_INIT_RES_NODE_INFO: { +- auto resNode = event->GetSharedObject(); +- if (resNode != nullptr) { +- resNodeInfo.insert(std::pair>(resNode->id, resNode)); +- WriteNode(resNode->path, std::to_string(resNode->def)); +- auto resStatus = std::make_shared(resNode->def); +- resStatusInfo.insert(std::pair>(resNode->id, resStatus)); +- } +- break; +- } +- case INNER_EVENT_ID_INIT_GOV_RES_NODE_INFO: { +- auto govResNode = event->GetSharedObject(); +- if (govResNode != nullptr) { +- govResNodeInfo.insert(std::pair>(govResNode->id, govResNode)); +- for (int32_t i = 0; i < (int32_t)govResNode->paths.size(); i++) { +- WriteNode(govResNode->paths[i], govResNode->levelToStr[govResNode->def][i]); +- } +- auto resStatus = std::make_shared(govResNode->def); +- resStatusInfo.insert(std::pair>(govResNode->id, resStatus)); +- } +- break; +- } +- case INNER_EVENT_ID_DO_FREQ_ACTION: { +- int32_t resId = event->GetParam(); +- if (!IsValidResId(resId)) { +- return; +- } +- std::shared_ptr resAction = event->GetSharedObject(); +- if (resAction != nullptr) { +- UpdateResActionList(resId, resAction, false); +- } +- break; +- } +- case INNER_EVENT_ID_DO_FREQ_ACTION_PACK: { +- std::shared_ptr head = event->GetSharedObject(); +- while (head) { +- if (IsValidResId(head->resId)) { +- UpdateResActionList(head->resId, head->resAction, false); +- } +- auto temp = head->next; +- head->next = nullptr; +- head = temp; +- } +- break; +- } +- case INNER_EVENT_ID_DO_FREQ_ACTION_DELAYED: { +- int32_t resId = event->GetParam(); +- if (!IsValidResId(resId)) { +- return; +- } +- std::shared_ptr resAction = event->GetSharedObject(); +- if (resAction != nullptr) { +- UpdateResActionList(resId, resAction, true); +- } +- break; +- } +- case INNER_EVENT_ID_POWER_LIMIT_BOOST_FREQ: { +- powerLimitBoost = event->GetParam() == 1; +- for (auto iter = resStatusInfo.begin(); iter != resStatusInfo.end(); ++iter) { +- ArbitrateCandidate(iter->first); +- } +- break; +- } +- case INNER_EVENT_ID_THERMAL_LIMIT_BOOST_FREQ: { +- thermalLimitBoost = event->GetParam() == 1; +- for (auto iter = resStatusInfo.begin(); iter != resStatusInfo.end(); ++iter) { +- ArbitrateCandidate(iter->first); +- } +- break; +- } +- case INNER_EVENT_ID_DO_FREQ_ACTION_LEVEL: { +- HandleDoFreqActionLevel(event->GetParam(), event->GetSharedObject()); +- break; +- } +- default: { +- break; +- } +- } +-} +- +-void SocPerfHandler::HandleDoFreqActionLevel(int32_t resId, std::shared_ptr resAction) +-{ +- int32_t realResId = resId - RES_ID_ADDITION; +- if (!IsValidResId(realResId) || !resAction) { +- return; +- } +- int32_t level = (int32_t)resAction->value; +- if (!GetResValueByLevel(realResId, level, resAction->value)) { +- return; +- } +- UpdateResActionList(realResId, resAction, false); +-} +- +-bool SocPerfHandler::GetResValueByLevel(int32_t resId, int32_t level, int64_t& resValue) +-{ +- if (resNodeInfo.find(resId) == resNodeInfo.end() +- || resNodeInfo[resId]->available.empty()) { +- SOC_PERF_LOGE("resId[%{public}d] is not valid.", resId); +- return false; +- } +- if (level < 0) { +- return false; +- } +- +- std::set available; +- for (auto a : resNodeInfo[resId]->available) { +- available.insert(a); +- } +- int32_t len = (int32_t)available.size(); +- auto iter = available.begin(); +- if (level < len) { +- std::advance(iter, len - 1 - level); +- } +- resValue = *iter; +- return true; +-} +- +-void SocPerfHandler::UpdateResActionList(int32_t resId, std::shared_ptr resAction, bool delayed) +-{ +- std::shared_ptr resStatus = resStatusInfo[resId]; +- int32_t type = resAction->type; +- +- if (delayed) { +- for (auto iter = resStatus->resActionList[type].begin(); +- iter != resStatus->resActionList[type].end(); ++iter) { +- if (resAction == *iter) { +- resStatus->resActionList[type].erase(iter); +- UpdateCandidatesValue(resId, type); +- break; +- } +- } +- } else { +- switch (resAction->onOff) { +- case EVENT_INVALID: { +- resStatus->resActionList[type].push_back(resAction); +- UpdateCandidatesValue(resId, type); +- auto event = AppExecFwk::InnerEvent::Get( +- INNER_EVENT_ID_DO_FREQ_ACTION_DELAYED, resAction, resId); +- this->SendEvent(event, resAction->duration); +- break; +- } +- case EVENT_ON: { +- if (resAction->duration == 0) { +- for (auto iter = resStatus->resActionList[type].begin(); +- iter != resStatus->resActionList[type].end(); ++iter) { +- if (resAction->TotalSame(*iter)) { +- resStatus->resActionList[type].erase(iter); +- break; +- } +- } +- resStatus->resActionList[type].push_back(resAction); +- UpdateCandidatesValue(resId, type); +- } else { +- resStatus->resActionList[type].push_back(resAction); +- UpdateCandidatesValue(resId, type); +- auto event = AppExecFwk::InnerEvent::Get( +- INNER_EVENT_ID_DO_FREQ_ACTION_DELAYED, resAction, resId); +- this->SendEvent(event, resAction->duration); +- } +- break; +- } +- case EVENT_OFF: { +- for (auto iter = resStatus->resActionList[type].begin(); +- iter != resStatus->resActionList[type].end(); ++iter) { +- if (resAction->PartSame(*iter) && (*iter)->onOff == EVENT_ON) { +- resStatus->resActionList[type].erase(iter); +- UpdateCandidatesValue(resId, type); +- break; +- } +- } +- break; +- } +- default: { +- break; +- } +- } +- } +-} +- +-void SocPerfHandler::UpdateCandidatesValue(int32_t resId, int32_t type) +-{ +- std::shared_ptr resStatus = resStatusInfo[resId]; +- int64_t prev = resStatus->candidates[type]; +- +- if (resStatus->resActionList[type].empty()) { +- resStatus->candidates[type] = INVALID_VALUE; +- } else { +- if (type == ACTION_TYPE_PERF) { +- int64_t res = MIN_INT_VALUE; +- for (auto iter = resStatus->resActionList[type].begin(); +- iter != resStatus->resActionList[type].end(); ++iter) { +- res = Max(res, (*iter)->value); +- } +- resStatus->candidates[type] = res; +- } else { +- int64_t res = MAX_INT_VALUE; +- for (auto iter = resStatus->resActionList[type].begin(); +- iter != resStatus->resActionList[type].end(); ++iter) { +- res = Min(res, (*iter)->value); +- } +- resStatus->candidates[type] = res; +- } +- } +- +- if (resStatus->candidates[type] != prev) { +- ArbitrateCandidate(resId); +- } +-} +- +-void SocPerfHandler::ArbitrateCandidate(int32_t resId) +-{ +- std::shared_ptr resStatus = resStatusInfo[resId]; +- int64_t candidatePerf = resStatus->candidates[ACTION_TYPE_PERF]; +- int64_t candidatePower = resStatus->candidates[ACTION_TYPE_POWER]; +- int64_t candidateThermal = resStatus->candidates[ACTION_TYPE_THERMAL]; +- +- if (ExistNoCandidate(resId, resStatus, candidatePerf, candidatePower, candidateThermal)) { +- return; +- } +- +- if (!powerLimitBoost && !thermalLimitBoost) { +- if (candidatePerf != INVALID_VALUE) { +- resStatus->candidate = Max(candidatePerf, candidatePower, candidateThermal); +- } else { +- resStatus->candidate = +- (candidatePower == INVALID_VALUE) ? candidateThermal : +- ((candidateThermal == INVALID_VALUE) ? candidatePower : Min(candidatePower, candidateThermal)); +- } +- } else if (!powerLimitBoost && thermalLimitBoost) { +- resStatus->candidate = +- (candidateThermal != INVALID_VALUE) ? candidateThermal : Max(candidatePerf, candidatePower); +- } else if (powerLimitBoost && !thermalLimitBoost) { +- resStatus->candidate = +- (candidatePower != INVALID_VALUE) ? candidatePower : Max(candidatePerf, candidateThermal); +- } else { +- if (candidatePower == INVALID_VALUE && candidateThermal == INVALID_VALUE) { +- resStatus->candidate = candidatePerf; +- } else { +- resStatus->candidate = +- (candidatePower == INVALID_VALUE) ? candidateThermal : +- ((candidateThermal == INVALID_VALUE) ? candidatePower : Min(candidatePower, candidateThermal)); +- } +- } +- +- ArbitratePairRes(resId); +-} +- +-void SocPerfHandler::ArbitratePairRes(int32_t resId) +-{ +- if (IsGovResId(resId)) { +- UpdateCurrentValue(resId, resStatusInfo[resId]->candidate); +- return; +- } +- +- int32_t pairResId = resNodeInfo[resId]->pair; +- if (pairResId == INVALID_VALUE) { +- UpdateCurrentValue(resId, resStatusInfo[resId]->candidate); +- return; +- } +- +- if (resNodeInfo[resId]->mode == 1) { +- if (resStatusInfo[resId]->candidate < resStatusInfo[pairResId]->candidate) { +- if (powerLimitBoost || thermalLimitBoost) { +- UpdatePairResValue(pairResId, +- resStatusInfo[resId]->candidate, resId, resStatusInfo[resId]->candidate); +- } else { +- UpdatePairResValue(pairResId, +- resStatusInfo[pairResId]->candidate, resId, resStatusInfo[pairResId]->candidate); +- } +- } else { +- UpdatePairResValue(pairResId, +- resStatusInfo[pairResId]->candidate, resId, resStatusInfo[resId]->candidate); +- } +- } else { +- if (resStatusInfo[resId]->candidate > resStatusInfo[pairResId]->candidate) { +- if (powerLimitBoost || thermalLimitBoost) { +- UpdatePairResValue(resId, +- resStatusInfo[pairResId]->candidate, pairResId, resStatusInfo[pairResId]->candidate); +- } else { +- UpdatePairResValue(resId, +- resStatusInfo[resId]->candidate, pairResId, resStatusInfo[resId]->candidate); +- } +- } else { +- UpdatePairResValue(resId, +- resStatusInfo[resId]->candidate, pairResId, resStatusInfo[pairResId]->candidate); +- } +- } +-} +- +-void SocPerfHandler::UpdatePairResValue(int32_t minResId, int64_t minResValue, int32_t maxResId, int64_t maxResValue) +-{ +- WriteNode(resNodeInfo[minResId]->path, std::to_string(resNodeInfo[minResId]->def)); +- WriteNode(resNodeInfo[maxResId]->path, std::to_string(resNodeInfo[maxResId]->def)); +- UpdateCurrentValue(minResId, minResValue); +- UpdateCurrentValue(maxResId, maxResValue); +-} +- +-void SocPerfHandler::UpdateCurrentValue(int32_t resId, int64_t currValue) +-{ +- resStatusInfo[resId]->current = currValue; +- if (IsGovResId(resId)) { +- if (govResNodeInfo[resId]->levelToStr.find(currValue) != govResNodeInfo[resId]->levelToStr.end()) { +- std::vector targetStrs = govResNodeInfo[resId]->levelToStr[resStatusInfo[resId]->current]; +- for (int32_t i = 0; i < (int32_t)govResNodeInfo[resId]->paths.size(); i++) { +- WriteNode(govResNodeInfo[resId]->paths[i], targetStrs[i]); +- } +- } +- } else if (IsResId(resId)) { +- WriteNode(resNodeInfo[resId]->path, std::to_string(resStatusInfo[resId]->current)); +- } +-} +- +-void SocPerfHandler::WriteNode(std::string filePath, std::string value) +-{ +- int32_t fd = GetFdForFilePath(filePath); +- if (fd < 0) { +- return; +- } +- write(fd, value.c_str(), value.size()); +-} +- +-int32_t SocPerfHandler::GetFdForFilePath(std::string filePath) +-{ +- if (fdInfo.find(filePath) != fdInfo.end()) { +- return fdInfo[filePath]; +- } +- char path[PATH_MAX + 1] = {0}; +- if (filePath.size() == 0 || filePath.size() > PATH_MAX || !realpath(filePath.c_str(), path)) { +- return -1; +- } +- int32_t fd = open(path, O_RDWR | O_CLOEXEC); +- if (fd < 0) { +- return fd; +- } +- fdInfo.insert(std::pair(filePath, fd)); +- return fdInfo[filePath]; +-} +- +-bool SocPerfHandler::ExistNoCandidate( +- int32_t resId, std::shared_ptr resStatus, int64_t perf, int64_t power, int64_t thermal) +-{ +- if (perf == INVALID_VALUE && power == INVALID_VALUE && thermal == INVALID_VALUE) { +- if (IsGovResId(resId)) { +- resStatus->candidate = govResNodeInfo[resId]->def; +- } else if (IsResId(resId)) { +- resStatus->candidate = resNodeInfo[resId]->def; +- } +- ArbitratePairRes(resId); +- return true; +- } +- return false; +-} +- +-bool SocPerfHandler::IsGovResId(int32_t resId) +-{ +- if (resNodeInfo.find(resId) == resNodeInfo.end() +- && govResNodeInfo.find(resId) != govResNodeInfo.end()) { +- return true; +- } +- return false; +-} +- +-bool SocPerfHandler::IsResId(int32_t resId) +-{ +- if (govResNodeInfo.find(resId) == govResNodeInfo.end() +- && resNodeInfo.find(resId) != resNodeInfo.end()) { +- return true; +- } +- return false; +-} +- +-bool SocPerfHandler::IsValidResId(int32_t resId) +-{ +- if (resNodeInfo.find(resId) == resNodeInfo.end() +- && govResNodeInfo.find(resId) == govResNodeInfo.end()) { +- return false; +- } +- if (resStatusInfo.find(resId) == resStatusInfo.end()) { +- return false; +- } +- return true; +-} +-} // namespace SOCPERF +-} // namespace OHOS +diff --git a/soc_perf/services/server/include/socperf_server.h b/soc_perf/services/server/include/socperf_server.h +deleted file mode 100644 +index 7af60a2..0000000 +--- a/soc_perf/services/server/include/socperf_server.h ++++ /dev/null +@@ -1,56 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_SERVER_H +-#define SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_SERVER_H +- +-#include +-#include +-#include "i_socperf_service.h" +-#include "singleton.h" +-#include "socperf_stub.h" +-#include "socperf.h" +- +-namespace OHOS { +-namespace SOCPERF { +-class SocPerfServer : public SystemAbility, public SocPerfStub, +- public std::enable_shared_from_this { +-DISALLOW_COPY_AND_MOVE(SocPerfServer); +-DECLARE_SYSTEM_ABILITY(SocPerfServer); +-DECLARE_DELAYED_SINGLETON(SocPerfServer); +- +-public: +- void PerfRequest(int32_t cmdId, const std::string& msg) override; +- void PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg) override; +- void PowerLimitBoost(bool onOffTag, const std::string& msg) override; +- void ThermalLimitBoost(bool onOffTag, const std::string& msg) override; +- void LimitRequest(int32_t clientId, +- const std::vector& tags, const std::vector& configs, const std::string& msg) override; +- int32_t Dump(int32_t fd, const std::vector& args) override; +- +-public: +- SocPerfServer(int32_t systemAbilityId, bool runOnCreate); +- +-protected: +- void OnStart() override; +- void OnStop() override; +- +-private: +- SocPerf socPerf; +-}; +-} // namespace SOCPERF +-} // namespace OHOS +- +-#endif // SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_SERVER_H +diff --git a/soc_perf/services/server/include/socperf_stub.h b/soc_perf/services/server/include/socperf_stub.h +deleted file mode 100644 +index cf1e10d..0000000 +--- a/soc_perf/services/server/include/socperf_stub.h ++++ /dev/null +@@ -1,36 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_STUB_H +-#define SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_STUB_H +- +-#include // for int32_t, uint32_t +-#include "i_socperf_service.h" +- +-namespace OHOS { +-namespace SOCPERF { +-class SocPerfStub : public IRemoteStub { +-public: +- SocPerfStub() = default; +- ~SocPerfStub() override = default; +- DISALLOW_COPY_AND_MOVE(SocPerfStub); +- +- int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, +- MessageParcel &reply, MessageOption &option) override; +-}; +-} // namespace SOCPERF +-} // namespace OHOS +- +-#endif // SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_STUB_H +diff --git a/soc_perf/services/server/src/socperf_server.cpp b/soc_perf/services/server/src/socperf_server.cpp +deleted file mode 100644 +index 6f5aa78..0000000 +--- a/soc_perf/services/server/src/socperf_server.cpp ++++ /dev/null +@@ -1,93 +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. +- */ +- +-#include "socperf_server.h" +- +-namespace OHOS { +-namespace SOCPERF { +-const bool REGISTER_RESULT = +- SystemAbility::MakeAndRegisterAbility(DelayedSingleton::GetInstance().get()); +- +-SocPerfServer::SocPerfServer() : SystemAbility(SOC_PERF_SERVICE_SA_ID, true) +-{ +-} +- +-SocPerfServer::~SocPerfServer() +-{ +-} +- +-void SocPerfServer::OnStart() +-{ +- if (!Publish(DelayedSingleton::GetInstance().get())) { +- SOC_PERF_LOGE("Register SystemAbility for SocPerf FAILED."); +- return; +- } +- if (!socPerf.Init()) { +- SOC_PERF_LOGE("SocPerf Init FAILED"); +- return; +- } +-} +- +-void SocPerfServer::OnStop() +-{ +-} +- +-int32_t SocPerfServer::Dump(int32_t fd, const std::vector& args) +-{ +- std::vector argsInStr; +- std::transform(args.begin(), args.end(), std::back_inserter(argsInStr), +- [](const std::u16string &arg) { +- return Str16ToStr8(arg); +- }); +- std::string result; +- result.append("usage: soc_perf service dump []\n") +- .append(" 1. PerfRequest(cmdId, msg)\n") +- .append(" 2. PerfRequestEx(cmdId, onOffTag, msg)\n") +- .append(" 3. LimitRequest(clientId, tags, configs, msg)\n") +- .append(" -h: show the help.\n") +- .append(" -a: show all info.\n"); +- if (!SaveStringToFd(fd, result)) { +- SOC_PERF_LOGE("Dump FAILED"); +- } +- return ERR_OK; +-} +- +-void SocPerfServer::PerfRequest(int32_t cmdId, const std::string& msg) +-{ +- socPerf.PerfRequest(cmdId, msg); +-} +- +-void SocPerfServer::PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg) +-{ +- socPerf.PerfRequestEx(cmdId, onOffTag, msg); +-} +- +-void SocPerfServer::PowerLimitBoost(bool onOffTag, const std::string& msg) +-{ +- socPerf.PowerLimitBoost(onOffTag, msg); +-} +- +-void SocPerfServer::ThermalLimitBoost(bool onOffTag, const std::string& msg) +-{ +- socPerf.ThermalLimitBoost(onOffTag, msg); +-} +- +-void SocPerfServer::LimitRequest(int32_t clientId, +- const std::vector& tags, const std::vector& configs, const std::string& msg) +-{ +- socPerf.LimitRequest(clientId, tags, configs, msg); +-} +-} // namespace SOCPERF +-} // namespace OHOS +diff --git a/soc_perf/services/server/src/socperf_stub.cpp b/soc_perf/services/server/src/socperf_stub.cpp +deleted file mode 100644 +index 413f6ae..0000000 +--- a/soc_perf/services/server/src/socperf_stub.cpp ++++ /dev/null +@@ -1,73 +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. +- */ +- +-#include "socperf_stub.h" +-#include // for int32_t +-#include // for string +-#include // for basic_string, operator!=, u16string +-#include // for vector +- +- +-namespace OHOS { +-namespace SOCPERF { +-int32_t SocPerfStub::OnRemoteRequest(uint32_t code, MessageParcel &data, +- MessageParcel &reply, MessageOption &option) +-{ +- auto remoteDescriptor = data.ReadInterfaceToken(); +- if (GetDescriptor() != remoteDescriptor) { +- return ERR_INVALID_STATE; +- } +- switch (code) { +- case TRANS_IPC_ID_PERF_REQUEST: { +- int32_t cmdId = data.ReadInt32(); +- std::string msg = data.ReadString(); +- PerfRequest(cmdId, msg); +- return 0; +- } +- case TRANS_IPC_ID_PERF_REQUEST_EX: { +- int32_t cmdId = data.ReadInt32(); +- bool onOffTag = data.ReadBool(); +- std::string msg = data.ReadString(); +- PerfRequestEx(cmdId, onOffTag, msg); +- return 0; +- } +- case TRANS_IPC_ID_POWER_LIMIT_BOOST_FREQ: { +- bool onOffTag = data.ReadBool(); +- std::string msg = data.ReadString(); +- PowerLimitBoost(onOffTag, msg); +- return 0; +- } +- case TRANS_IPC_ID_THERMAL_LIMIT_BOOST_FREQ: { +- bool onOffTag = data.ReadBool(); +- std::string msg = data.ReadString(); +- ThermalLimitBoost(onOffTag, msg); +- return 0; +- } +- case TRANS_IPC_ID_LIMIT_REQUEST: { +- int32_t clientId = data.ReadInt32(); +- std::vector tags; +- data.ReadInt32Vector(&tags); +- std::vector configs; +- data.ReadInt64Vector(&configs); +- std::string msg = data.ReadString(); +- LimitRequest(clientId, tags, configs, msg); +- return 0; +- } +- default: +- return IPCObjectStub::OnRemoteRequest(code, data, reply, option); +- } +-} +-} // namespace SOCPERF +-} // namespace OHOS +diff --git a/soc_perf/soc_perf.gni b/soc_perf/soc_perf.gni +deleted file mode 100644 +index 9bd7ce5..0000000 +--- a/soc_perf/soc_perf.gni ++++ /dev/null +@@ -1,31 +0,0 @@ +-# Copyright (C) 2023 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. +- +-socperf_path = +- "//foundation/resourceschedule/resource_schedule_service/soc_perf" +- +-socperf_services = "${socperf_path}/services" +- +-socperf_common = "${socperf_path}/common" +- +-socperf_interfaces = "${socperf_path}/interfaces" +- +-socperf_test = "${socperf_path}/test" +- +-declare_args() { +- customization_config_policy_enable = true +- if (defined(global_parts_info) && +- !defined(global_parts_info.customization_config_policy)) { +- customization_config_policy_enable = false +- } +-} +diff --git a/soc_perf/test/fuzztest/BUILD.gn b/soc_perf/test/fuzztest/BUILD.gn +deleted file mode 100644 +index e857064..0000000 +--- a/soc_perf/test/fuzztest/BUILD.gn ++++ /dev/null +@@ -1,22 +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. +- +-group("fuzztest") { +- testonly = true +- +- deps = [ +- "loadconfigxmlfile_fuzzer:fuzztest", +- "perfrequest_fuzzer:fuzztest", +- "socperf_fuzzer:fuzztest", +- ] +-} +diff --git a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/BUILD.gn b/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/BUILD.gn +deleted file mode 100644 +index c93ebb2..0000000 +--- a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/BUILD.gn ++++ /dev/null +@@ -1,60 +0,0 @@ +-# Copyright (c) 2022-2023 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. +- +-#####################hydra-fuzz################### +-import("//build/config/features.gni") +-import("//build/test.gni") +-import("../../../soc_perf.gni") +-module_output_path = "resource_schedule_service/soc_perf" +- +-##############################fuzztest########################################## +-config("module_private_config") { +- include_dirs = [ +- "${socperf_common}/include", +- "${socperf_interfaces}/inner_api/socperf_client/include", +- "${socperf_services}/core/include", +- "${socperf_services}/server/include", +- ] +-} +- +-ohos_fuzztest("LoadConfigXmlFileFuzzTest") { +- module_out_path = module_output_path +- fuzz_config_file = "${socperf_test}/fuzztest/loadconfigxmlfile_fuzzer" +- configs = [ ":module_private_config" ] +- +- cflags = [ +- "-g", +- "-O0", +- "-Wno-unused-variable", +- "-fno-omit-frame-pointer", +- ] +- +- sources = [ "loadconfigxmlfile_fuzzer.cpp" ] +- +- deps = [ "${socperf_services}:socperf_server_static" ] +- +- external_deps = [ +- "c_utils:utils", +- "hiviewdfx_hilog_native:libhilog", +- ] +-} +- +-############################################################################### +-group("fuzztest") { +- testonly = true +- deps = [ +- # deps file +- ":LoadConfigXmlFileFuzzTest", +- ] +-} +-############################################################################### +diff --git a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/corpus/init b/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/corpus/init +deleted file mode 100644 +index 415fc33..0000000 +--- a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/corpus/init ++++ /dev/null +@@ -1,28 +0,0 @@ +- +- +- +- +- +- 408000 +- /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq +- 408000 600000 816000 1104000 1416000 1608000 1800000 1992000 +- +- +- 1992000 +- /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq +- 408000 600000 816000 1104000 1416000 1608000 1800000 1992000 +- +- +- +\ No newline at end of file +diff --git a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/loadconfigxmlfile_fuzzer.cpp b/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/loadconfigxmlfile_fuzzer.cpp +deleted file mode 100644 +index 933451d..0000000 +--- a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/loadconfigxmlfile_fuzzer.cpp ++++ /dev/null +@@ -1,70 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 "loadconfigxmlfile_fuzzer.h" +- +-#define private public +-#include "socperf.h" +- +-namespace OHOS { +-namespace SOCPERF { +- const std::string fuzzedFile = "myFuzzed.xml"; +- const int32_t FILE_RETURN_SUCCESS = 1; +- std::mutex mutexLock; +- std::unique_ptr socPerf = nullptr; +- +- bool DoInit() +- { +- std::lock_guard lock(mutexLock); +- if (socPerf) { +- return true; +- } +- socPerf = std::make_unique(); +- return socPerf != nullptr; +- } +- +- void DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +- { +- if (!DoInit()) { +- return; +- } +- +- // generate fuzzed xml +- FILE *pFile = fopen(fuzzedFile.c_str(), "wb"); +- if (!pFile) { +- return; +- } +- +- int32_t retCode = fwrite(reinterpret_cast(data), size, 1, pFile); // 1 means count=1 +- if (retCode < FILE_RETURN_SUCCESS) { +- (void)fclose(pFile); +- pFile = nullptr; +- return; +- } +- +- (void)fclose(pFile); +- pFile = nullptr; +- socPerf->LoadConfigXmlFile(fuzzedFile); +- } +-} // namespace SOCPERF +-} // namespace OHOS +- +-/* Fuzzer entry point */ +-extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +-{ +- /* Run your code on data */ +- OHOS::SOCPERF::DoSomethingInterestingWithMyAPI(data, size); +- return 0; +-} +diff --git a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/loadconfigxmlfile_fuzzer.h b/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/loadconfigxmlfile_fuzzer.h +deleted file mode 100644 +index 9f20ca2..0000000 +--- a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/loadconfigxmlfile_fuzzer.h ++++ /dev/null +@@ -1,21 +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 TEST_FUZZTEST_LOADCONFIGXMLFILE_FUZZER_H +-#define TEST_FUZZTEST_LOADCONFIGXMLFILE_FUZZER_H +- +-#define FUZZ_PROJECT_NAME "loadconfigxmlfile_fuzzer" +- +-#endif +\ No newline at end of file +diff --git a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/project.xml b/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/project.xml +deleted file mode 100644 +index c2b6907..0000000 +--- a/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer/project.xml ++++ /dev/null +@@ -1,24 +0,0 @@ +- +- +- +- +- +- 1000 +- +- 300 +- +- 4096 +- +- +diff --git a/soc_perf/test/fuzztest/perfrequest_fuzzer/BUILD.gn b/soc_perf/test/fuzztest/perfrequest_fuzzer/BUILD.gn +deleted file mode 100644 +index 87ec5dd..0000000 +--- a/soc_perf/test/fuzztest/perfrequest_fuzzer/BUILD.gn ++++ /dev/null +@@ -1,60 +0,0 @@ +-# Copyright (c) 2022-2023 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. +- +-#####################hydra-fuzz################### +-import("//build/config/features.gni") +-import("//build/test.gni") +-import("../../../soc_perf.gni") +- +-##############################fuzztest########################################## +-ohos_fuzztest("PerfRequestFuzzTest") { +- module_out_path = "soc_perf/socperftest" +- fuzz_config_file = "${socperf_test}/fuzztest/perfrequest_fuzzer" +- +- include_dirs = [ +- "${socperf_common}/include", +- "${socperf_interfaces}/inner_api/socperf_client:socperf_client", +- "${socperf_services}/core/include", +- ] +- +- cflags = [ +- "-g", +- "-O0", +- "-Wno-unused-variable", +- "-fno-omit-frame-pointer", +- ] +- +- sources = [ "perfrequest_fuzzer.cpp" ] +- +- deps = [ "${socperf_interfaces}/inner_api/socperf_client:socperf_client" ] +- +- external_deps = [ +- "c_utils:utils", +- "eventhandler:libeventhandler", +- "hiviewdfx_hilog_native:libhilog", +- "ipc:ipc_single", +- "safwk:system_ability_fwk", +- "samgr:samgr_proxy", +- ] +-} +- +-############################################################################### +-group("fuzztest") { +- testonly = true +- deps = [] +- deps += [ +- # deps file +- ":PerfRequestFuzzTest", +- ] +-} +-############################################################################### +diff --git a/soc_perf/test/fuzztest/perfrequest_fuzzer/corpus/init b/soc_perf/test/fuzztest/perfrequest_fuzzer/corpus/init +deleted file mode 100644 +index f812823..0000000 +--- a/soc_perf/test/fuzztest/perfrequest_fuzzer/corpus/init ++++ /dev/null +@@ -1,14 +0,0 @@ +-# Copyright (c) 2023 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. +- +-FUZZ +\ No newline at end of file +diff --git a/soc_perf/test/fuzztest/perfrequest_fuzzer/perfrequest_fuzzer.cpp b/soc_perf/test/fuzztest/perfrequest_fuzzer/perfrequest_fuzzer.cpp +deleted file mode 100644 +index 896269d..0000000 +--- a/soc_perf/test/fuzztest/perfrequest_fuzzer/perfrequest_fuzzer.cpp ++++ /dev/null +@@ -1,198 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 "perfrequest_fuzzer.h" +-#include "socperf_client.h" +- +-#include +-#include +-#include +-#include +- +-#ifndef errno_t +-typedef int errno_t; +-#endif +- +-#ifndef EOK +-#define EOK 0 +-#endif +- +-namespace OHOS { +-namespace SOCPERF { +- const uint8_t* g_data = nullptr; +- size_t g_size = 0; +- size_t g_pos; +- +- /* +- * describe: get data from outside untrusted data(g_data) which size is according to sizeof(T) +- * tips: only support basic type +- */ +- template +- T GetData() +- { +- T object {}; +- size_t objectSize = sizeof(object); +- if (g_data == nullptr || objectSize > g_size - g_pos) { +- return object; +- } +- errno_t ret = memcpy_s(&object, objectSize, g_data + g_pos, objectSize); +- if (ret != EOK) { +- return {}; +- } +- g_pos += objectSize; +- return object; +- } +- +- /* +- * get a string from g_data +- */ +- std::string GetStringFromData(int strlen) +- { +- if (strlen <= 0) { +- return ""; +- } +- char cstr[strlen]; +- cstr[strlen - 1] = '\0'; +- for (int i = 0; i < strlen - 1; i++) { +- char tmp = GetData(); +- if (tmp == '\0') { +- tmp = '1'; +- } +- cstr[i] = tmp; +- } +- std::string str(cstr); +- return str; +- } +- +- bool PerfRequestFuzzTest(const uint8_t* data, size_t size) +- { +- if (data == nullptr) { +- return false; +- } +- +- // initialize +- g_data = data; +- g_size = size; +- g_pos = 0; +- +- // getdata +- std::string msg; +- int32_t cmdId = GetData(); +- msg = GetStringFromData(int(size) - sizeof(int32_t)); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(cmdId, msg); +- +- return true; +- } +- +- bool PerfRequestExFuzzTest(const uint8_t* data, size_t size) +- { +- if (data == nullptr) { +- return false; +- } +- +- // initialize +- g_data = data; +- g_size = size; +- g_pos = 0; +- +- // getdata +- std::string msg; +- int32_t cmdId = GetData(); +- bool onOffTag = GetData(); +- msg = GetStringFromData(int(size) - sizeof(int32_t) - sizeof(bool)); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(cmdId, onOffTag, msg); +- +- return true; +- } +- +- bool PowerLimitBoostFuzzTest(const uint8_t* data, size_t size) +- { +- if (data == nullptr) { +- return false; +- } +- +- // initialize +- g_data = data; +- g_size = size; +- g_pos = 0; +- +- // getdata +- std::string msg; +- bool onOffTag = GetData(); +- msg = GetStringFromData(int(size) - sizeof(bool)); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(onOffTag, msg); +- +- return true; +- } +- +- bool ThermalLimitBoostFuzzTest(const uint8_t* data, size_t size) +- { +- if (data == nullptr) { +- return false; +- } +- +- // initialize +- g_data = data; +- g_size = size; +- g_pos = 0; +- +- // getdata +- std::string msg; +- bool onOffTag = GetData(); +- msg = GetStringFromData(int(size) - sizeof(bool)); +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(onOffTag, msg); +- +- return true; +- } +- +- bool LimitRequestFuzzTest(const uint8_t* data, size_t size) +- { +- if (data == nullptr) { +- return false; +- } +- +- // initialize +- g_data = data; +- g_size = size; +- g_pos = 0; +- +- // getdata +- std::vector tags; +- std::vector configs; +- std::string msg; +- int32_t tagsNumber = GetData(); +- int64_t configsNumber = GetData(); +- int32_t clientId = GetData(); +- tags.push_back(tagsNumber); +- configs.push_back(configsNumber); +- msg = GetStringFromData(int(size) - sizeof(int32_t) - sizeof(int32_t) - sizeof(int64_t)); +- OHOS::SOCPERF::SocPerfClient::GetInstance().LimitRequest(clientId, tags, configs, msg); +- +- return true; +- } +-} // namespace SOCPERF +-} // namespace OHOS +- +-/* Fuzzer entry point */ +-extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +-{ +- /* Run your code on data */ +- OHOS::SOCPERF::PerfRequestFuzzTest(data, size); +- OHOS::SOCPERF::PerfRequestExFuzzTest(data, size); +- OHOS::SOCPERF::PowerLimitBoostFuzzTest(data, size); +- OHOS::SOCPERF::ThermalLimitBoostFuzzTest(data, size); +- OHOS::SOCPERF::LimitRequestFuzzTest(data, size); +- return 0; +-} +\ No newline at end of file +diff --git a/soc_perf/test/fuzztest/perfrequest_fuzzer/perfrequest_fuzzer.h b/soc_perf/test/fuzztest/perfrequest_fuzzer/perfrequest_fuzzer.h +deleted file mode 100644 +index 5343b90..0000000 +--- a/soc_perf/test/fuzztest/perfrequest_fuzzer/perfrequest_fuzzer.h ++++ /dev/null +@@ -1,28 +0,0 @@ +-/* +- * Copyright (c) 2023 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 PERFREQUEST_FUZZER_H +-#define PERFREQUEST_FUZZER_H +- +-#include +-#include +-#include +-#include +-#include +-#include +- +-#define FUZZ_PROJECT_NAME "perfrequest_fuzzer" +- +-#endif +\ No newline at end of file +diff --git a/soc_perf/test/fuzztest/perfrequest_fuzzer/project.xml b/soc_perf/test/fuzztest/perfrequest_fuzzer/project.xml +deleted file mode 100644 +index f881f69..0000000 +--- a/soc_perf/test/fuzztest/perfrequest_fuzzer/project.xml ++++ /dev/null +@@ -1,24 +0,0 @@ +- +- +- +- +- +- 1000 +- +- 300 +- +- 4096 +- +- +diff --git a/soc_perf/test/fuzztest/socperf_fuzzer/BUILD.gn b/soc_perf/test/fuzztest/socperf_fuzzer/BUILD.gn +deleted file mode 100644 +index 70e73e6..0000000 +--- a/soc_perf/test/fuzztest/socperf_fuzzer/BUILD.gn ++++ /dev/null +@@ -1,55 +0,0 @@ +-# Copyright (c) 2022-2023 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. +- +-#####################hydra-fuzz################### +-import("//build/config/features.gni") +-import("//build/test.gni") +-import("../../../soc_perf.gni") +-module_output_path = "resource_schedule_service/soc_perf" +- +-##############################fuzztest########################################## +-ohos_fuzztest("SocPerfFuzzTest") { +- module_out_path = module_output_path +- fuzz_config_file = "${socperf_test}/fuzztest/socperf_fuzzer" +- include_dirs = [] +- +- cflags = [ +- "-g", +- "-O0", +- "-Wno-unused-variable", +- "-fno-omit-frame-pointer", +- ] +- +- sources = [ "socperf_fuzzer.cpp" ] +- +- deps = [ "${socperf_interfaces}/inner_api/socperf_client:socperf_client" ] +- +- external_deps = [ +- "c_utils:utils", +- "hiviewdfx_hilog_native:libhilog", +- "ipc:ipc_single", +- "safwk:system_ability_fwk", +- "samgr:samgr_proxy", +- ] +-} +- +-############################################################################### +-group("fuzztest") { +- testonly = true +- deps = [] +- deps += [ +- # deps file +- ":SocPerfFuzzTest", +- ] +-} +-############################################################################### +diff --git a/soc_perf/test/fuzztest/socperf_fuzzer/corpus/init b/soc_perf/test/fuzztest/socperf_fuzzer/corpus/init +deleted file mode 100644 +index bc977bd..0000000 +--- a/soc_perf/test/fuzztest/socperf_fuzzer/corpus/init ++++ /dev/null +@@ -1,14 +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. +- +-FUZZ +\ No newline at end of file +diff --git a/soc_perf/test/fuzztest/socperf_fuzzer/project.xml b/soc_perf/test/fuzztest/socperf_fuzzer/project.xml +deleted file mode 100644 +index c2b6907..0000000 +--- a/soc_perf/test/fuzztest/socperf_fuzzer/project.xml ++++ /dev/null +@@ -1,24 +0,0 @@ +- +- +- +- +- +- 1000 +- +- 300 +- +- 4096 +- +- +diff --git a/soc_perf/test/fuzztest/socperf_fuzzer/socperf_fuzzer.cpp b/soc_perf/test/fuzztest/socperf_fuzzer/socperf_fuzzer.cpp +deleted file mode 100644 +index 8c05f42..0000000 +--- a/soc_perf/test/fuzztest/socperf_fuzzer/socperf_fuzzer.cpp ++++ /dev/null +@@ -1,87 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 "socperf_fuzzer.h" +- +-#include "iservice_registry.h" +-#include "system_ability_definition.h" +- +-#include "i_socperf_service.h" +-#include "socperf_log.h" +- +-namespace OHOS { +-namespace SOCPERF { +- constexpr int32_t MIN_LEN = 4; +- std::mutex mutexLock; +- sptr remoteObj = nullptr; +- +- bool DoInit() +- { +- std::lock_guard lock(mutexLock); +- if (remoteObj) { +- return true; +- } +- auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); +- if (!samgr) { +- return false; +- } +- remoteObj = samgr->GetSystemAbility(SOC_PERF_SERVICE_SA_ID); +- if (!remoteObj) { +- return false; +- } +- return true; +- } +- +- int32_t onRemoteRequest(uint32_t code, MessageParcel& data) +- { +- if (!DoInit()) { +- return -1; +- } +- MessageParcel reply; +- MessageOption option; +- return remoteObj->SendRequest(code, data, reply, option); +- } +- +- bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +- { +- if (size <= MIN_LEN) { +- return false; +- } +- +- MessageParcel dataMessageParcel; +- if (!dataMessageParcel.WriteInterfaceToken(IRemoteStub::GetDescriptor())) { +- return false; +- } +- +- uint32_t code = *(reinterpret_cast(data)); +- size -= sizeof(uint32_t); +- +- dataMessageParcel.WriteBuffer(data + sizeof(uint32_t), size); +- dataMessageParcel.RewindRead(0); +- +- onRemoteRequest(code, dataMessageParcel); +- return true; +- } +-} // namespace SOCPERF +-} // namespace OHOS +- +-/* Fuzzer entry point */ +-extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +-{ +- /* Run your code on data */ +- OHOS::SOCPERF::DoSomethingInterestingWithMyAPI(data, size); +- return 0; +-} +- +diff --git a/soc_perf/test/fuzztest/socperf_fuzzer/socperf_fuzzer.h b/soc_perf/test/fuzztest/socperf_fuzzer/socperf_fuzzer.h +deleted file mode 100644 +index cfd3fb6..0000000 +--- a/soc_perf/test/fuzztest/socperf_fuzzer/socperf_fuzzer.h ++++ /dev/null +@@ -1,21 +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 TEST_FUZZTEST_SOCPERF_FUZZER_H +-#define TEST_FUZZTEST_SOCPERF_FUZZER_H +- +-#define FUZZ_PROJECT_NAME "socperf_fuzzer" +- +-#endif +\ No newline at end of file +diff --git a/soc_perf/test/testutil/BUILD.gn b/soc_perf/test/testutil/BUILD.gn +deleted file mode 100644 +index a5c9041..0000000 +--- a/soc_perf/test/testutil/BUILD.gn ++++ /dev/null +@@ -1,33 +0,0 @@ +-# Copyright (c) 2022-2023 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/test.gni") +-import("../../soc_perf.gni") +- +-ohos_executable("socperf_test") { +- sources = [ "socperf_test.cpp" ] +- +- deps = [ "${socperf_interfaces}/inner_api/socperf_client:socperf_client" ] +- +- external_deps = [ +- "c_utils:utils", +- "eventhandler:libeventhandler", +- "hiviewdfx_hilog_native:libhilog", +- "ipc:ipc_single", +- "safwk:system_ability_fwk", +- "samgr:samgr_proxy", +- ] +- +- part_name = "soc_perf" +- subsystem_name = "resourceschedule" +-} +diff --git a/soc_perf/test/testutil/socperf_test.cpp b/soc_perf/test/testutil/socperf_test.cpp +deleted file mode 100644 +index 2ea5559..0000000 +--- a/soc_perf/test/testutil/socperf_test.cpp ++++ /dev/null +@@ -1,110 +0,0 @@ +-/* +- * Copyright (c) 2022-2023 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 // for int32_t +-#include // for atoi +-#include // for vector +-#include // for strcmp +-#include "socperf_client.h" // for SocPerfClient +- +-const static int32_t PARAMETERS_NUM_MIN = 2; +-const static int32_t PARAMETERS_NUM_WITHOUT_EX = 3; +-const static int32_t PARAMETERS_NUM_WITH_EX = 4; +-const static int32_t PARAMETERS_NUM_LIMIT = 5; +- +-static void PerfRequest(int32_t argc, char *argv[]) +-{ +- if (argc == PARAMETERS_NUM_WITHOUT_EX) { +- char* cmdId = argv[2]; +- if (cmdId) { +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(atoi(cmdId), ""); +- } +- } +-} +- +-static void PerfRequestEx(int32_t argc, char *argv[]) +-{ +- if (argc == PARAMETERS_NUM_WITH_EX) { +- char* cmdId = argv[2]; +- char* onOffTag = argv[3]; +- if (cmdId && onOffTag) { +- if (strcmp(onOffTag, "true") == 0) { +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(atoi(cmdId), true, ""); +- } else if (strcmp(onOffTag, "false") == 0) { +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(atoi(cmdId), false, ""); +- } +- } +- } +-} +- +-static void PowerLimitBoost(int32_t argc, char *argv[]) +-{ +- if (argc == PARAMETERS_NUM_WITHOUT_EX) { +- char* onOffTag = argv[2]; +- if (onOffTag) { +- if (strcmp(onOffTag, "true") == 0) { +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(true, ""); +- } else if (strcmp(onOffTag, "false") == 0) { +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(false, ""); +- } +- } +- } +-} +- +-static void ThermalLimitBoost(int32_t argc, char *argv[]) +-{ +- if (argc == PARAMETERS_NUM_WITHOUT_EX) { +- char* onOffTag = argv[2]; +- if (onOffTag) { +- if (strcmp(onOffTag, "true") == 0) { +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(true, ""); +- } else if (strcmp(onOffTag, "false") == 0) { +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(false, ""); +- } +- } +- } +-} +- +-static void LimitRequest(int32_t argc, char *argv[]) +-{ +- if (argc == PARAMETERS_NUM_LIMIT) { +- char* clientId = argv[2]; +- char* tags = argv[3]; +- char* configs = argv[4]; +- std::vector tagsVector = { atoi(tags) }; +- std::vector configsVector = { atoll(configs) }; +- OHOS::SOCPERF::SocPerfClient::GetInstance().LimitRequest(atoi(clientId), tagsVector, configsVector, ""); +- } +-} +- +-int32_t main(int32_t argc, char *argv[]) +-{ +- if (argc >= PARAMETERS_NUM_MIN && argv) { +- char* function = argv[1]; +- if (strcmp(function, "PerfRequest") == 0) { +- PerfRequest(argc, argv); +- } else if (strcmp(function, "PerfRequestEx") == 0) { +- PerfRequestEx(argc, argv); +- } else if (strcmp(function, "PowerLimitBoost") == 0) { +- PowerLimitBoost(argc, argv); +- } else if (strcmp(function, "ThermalLimitBoost") == 0) { +- ThermalLimitBoost(argc, argv); +- } else if (strcmp(function, "LimitRequest") == 0) { +- LimitRequest(argc, argv); +- } +- } +- return 0; +-} +diff --git a/soc_perf/test/unittest/BUILD.gn b/soc_perf/test/unittest/BUILD.gn +deleted file mode 100644 +index 6540071..0000000 +--- a/soc_perf/test/unittest/BUILD.gn ++++ /dev/null +@@ -1,84 +0,0 @@ +-# Copyright (c) 2022-2023 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/test.gni") +-import("../../soc_perf.gni") +- +-module_output_path = "soc_perf/socperftest" +- +-config("module_private_config") { +- visibility = [ ":*" ] +- +- include_dirs = [ +- "${socperf_common}/include", +- "${socperf_interfaces}/inner_api/socperf_client/include", +- "${socperf_services}/core/include", +- ] +-} +- +-ohos_unittest("SocPerfSubTest") { +- module_out_path = module_output_path +- +- sources = [ "socperf_sub_test.cpp" ] +- +- configs = [ ":module_private_config" ] +- +- deps = [ +- "${socperf_interfaces}/inner_api/socperf_client:socperf_client", +- "//third_party/googletest:gtest_main", +- "//third_party/libxml2:xml2", +- ] +- +- external_deps = [ +- "c_utils:utils", +- "eventhandler:libeventhandler", +- "hiviewdfx_hilog_native:libhilog", +- "ipc:ipc_single", +- "safwk:system_ability_fwk", +- "samgr:samgr_proxy", +- ] +-} +- +-ohos_unittest("SocPerfSubMockTest") { +- module_out_path = module_output_path +- +- sources = [ +- "mock/mock_socperf_client.cpp", +- "socperf_sub_mock_test.cpp", +- ] +- +- configs = [ ":module_private_config" ] +- +- deps = [ +- "${socperf_interfaces}/inner_api/socperf_client:socperf_client", +- "//third_party/googletest:gtest_main", +- "//third_party/libxml2:xml2", +- ] +- +- external_deps = [ +- "c_utils:utils", +- "eventhandler:libeventhandler", +- "hiviewdfx_hilog_native:libhilog", +- "ipc:ipc_single", +- "safwk:system_ability_fwk", +- "samgr:samgr_proxy", +- ] +-} +- +-group("unittest") { +- testonly = true +- deps = [ +- ":SocPerfSubMockTest", +- ":SocPerfSubTest", +- ] +-} +diff --git a/soc_perf/test/unittest/mock/mock_socperf_client.cpp b/soc_perf/test/unittest/mock/mock_socperf_client.cpp +deleted file mode 100644 +index 4081bc9..0000000 +--- a/soc_perf/test/unittest/mock/mock_socperf_client.cpp ++++ /dev/null +@@ -1,25 +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. +- */ +- +-#define private public +-#include "socperf_client.h" +-namespace OHOS { +-namespace SOCPERF { +-bool SocPerfClient::CheckClientValid() +-{ +- return false; +-} +-} // namespace SOCPERF +-} // namespace OHOS +\ No newline at end of file +diff --git a/soc_perf/test/unittest/socperf_sub_mock_test.cpp b/soc_perf/test/unittest/socperf_sub_mock_test.cpp +deleted file mode 100644 +index 1da0c75..0000000 +--- a/soc_perf/test/unittest/socperf_sub_mock_test.cpp ++++ /dev/null +@@ -1,139 +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. +- */ +- +-#define private public +-#define protected public +-#undef private +-#undef protected +- +-#include +-#include "socperf_client.h" +-#include "socperf.h" +-#include "iservice_registry.h" +-#include "system_ability_definition.h" +- +-using namespace testing::ext; +- +-namespace OHOS { +-namespace SOCPERF { +-class SocPerfSubTest : public testing::Test { +-public: +- static void SetUpTestCase(void); +- static void TearDownTestCase(void); +- void SetUp(); +- void TearDown(); +-}; +- +-void SocPerfSubTest::SetUpTestCase(void) +-{ +-} +- +-void SocPerfSubTest::TearDownTestCase(void) +-{ +-} +- +-void SocPerfSubTest::SetUp(void) +-{ +-} +- +-void SocPerfSubTest::TearDown(void) +-{ +-} +- +-/* +- * @tc.name: SocPerfSubTest_PerfRequest_001 +- * @tc.desc: PerfRequest +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PerfRequest_001, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(10000, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(10000, "123"); +-} +- +-/* +- * @tc.name: SocPerfSubTest_PerfRequest_002 +- * @tc.desc: PerfRequestEx ON +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PerfRequest_002, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10000, true, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10000, true, "123"); +-} +- +-/* +- * @tc.name: SocPerfSubTest_PerfRequest_003 +- * @tc.desc: PerfRequestEx OFF +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PerfRequest_003, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10000, false, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10000, false, "123"); +-} +- +-/* +- * @tc.name: SocPerfSubTest_PowerLimitBoost_001 +- * @tc.desc: PowerLimitBoost ON +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PowerLimitBoost_001, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(true, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(true, "123"); +-} +- +-/* +- * @tc.name: SocPerfSubTest_PowerLimitBoost_001 +- * @tc.desc: PowerLimitBoost OFF +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PowerLimitBoost_002, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(false, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(false, "123"); +-} +- +-/* +- * @tc.name: SocPerfSubTest_ThermalLimitBoost_001 +- * @tc.desc: ThermalLimitBoost ON +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_ThermalLimitBoost_001, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(true, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(true, "123"); +-} +- +-/* +- * @tc.name: SocPerfSubTest_ThermalLimitBoost_002 +- * @tc.desc: ThermalLimitBoost OFF +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_ThermalLimitBoost_002, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(false, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(false, "123"); +-} +-} // namespace SOCPERF +-} // namespace OHOS +\ No newline at end of file +diff --git a/soc_perf/test/unittest/socperf_sub_test.cpp b/soc_perf/test/unittest/socperf_sub_test.cpp +deleted file mode 100644 +index 9312e64..0000000 +--- a/soc_perf/test/unittest/socperf_sub_test.cpp ++++ /dev/null +@@ -1,361 +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. +- */ +- +-#define private public +-#define protected public +-#undef private +-#undef protected +- +-#include +-#include "socperf_client.h" +-#include "socperf.h" +-#include "iservice_registry.h" +-#include "system_ability_definition.h" +- +-using namespace testing::ext; +- +-namespace OHOS { +-namespace SOCPERF { +-class SocPerfSubTest : public testing::Test { +-public: +- static void SetUpTestCase(void); +- static void TearDownTestCase(void); +- void SetUp(); +- void TearDown(); +-}; +- +-void SocPerfSubTest::SetUpTestCase(void) +-{ +-} +- +-void SocPerfSubTest::TearDownTestCase(void) +-{ +-} +- +-void SocPerfSubTest::SetUp(void) +-{ +-} +- +-void SocPerfSubTest::TearDown(void) +-{ +-} +- +-/* +- * @tc.name: SocPerfSubTest_ActionType_001 +- * @tc.desc: action type perf +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_ActionType_001, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(OHOS::SOCPERF::ActionType::ACTION_TYPE_PERF, 0); +-} +- +-/* +- * @tc.name: SocPerfSubTest_ActionType_002 +- * @tc.desc: action type power +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_ActionType_002, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(OHOS::SOCPERF::ActionType::ACTION_TYPE_POWER, 1); +-} +- +-/* +- * @tc.name: SocPerfSubTest_ActionType_003 +- * @tc.desc: action type THERMAL +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_ActionType_003, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(OHOS::SOCPERF::ActionType::ACTION_TYPE_THERMAL, 2); +-} +- +-/* +- * @tc.name: SocPerfSubTest_ActionType_004 +- * @tc.desc: action type max +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_ActionType_004, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(OHOS::SOCPERF::ActionType::ACTION_TYPE_MAX, 3); +-} +- +-/* +- * @tc.name: SocPerfSubTest_EventType_001 +- * @tc.desc: event type off +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_EventType_001, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(OHOS::SOCPERF::EventType::EVENT_OFF, 0); +-} +- +-/* +- * @tc.name: SocPerfSubTest_EventType_002 +- * @tc.desc: event type on +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_EventType_002, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(OHOS::SOCPERF::EventType::EVENT_ON, 1); +-} +- +-/* +- * @tc.name: SocPerfSubTest_EventType_003 +- * @tc.desc: event type invalid +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_EventType_003, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(OHOS::SOCPERF::EventType::EVENT_INVALID, -1); +-} +- +-/* +- * @tc.name: SocPerfSubTest_InnerEventId_001 +- * @tc.desc: init res node info +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_InnerEventId_001, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(INNER_EVENT_ID_INIT_RES_NODE_INFO, 0); +-} +- +-/* +- * @tc.name: SocPerfSubTest_InnerEventId_002 +- * @tc.desc: init gov res node info +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_InnerEventId_002, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(INNER_EVENT_ID_INIT_GOV_RES_NODE_INFO, 1); +-} +- +-/* +- * @tc.name: SocPerfSubTest_InnerEventId_003 +- * @tc.desc: do freq action +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_InnerEventId_003, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(INNER_EVENT_ID_DO_FREQ_ACTION, 2); +-} +- +-/* +- * @tc.name: SocPerfSubTest_InnerEventId_004 +- * @tc.desc: do freq action delayed +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_InnerEventId_004, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(INNER_EVENT_ID_DO_FREQ_ACTION_DELAYED, 4); +-} +- +-/* +- * @tc.name: SocPerfSubTest_InnerEventId_005 +- * @tc.desc: power limit boost freq +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_InnerEventId_005, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(INNER_EVENT_ID_POWER_LIMIT_BOOST_FREQ, 5); +-} +- +-/* +- * @tc.name: SocPerfSubTest_InnerEventId_006 +- * @tc.desc: thermal limit boost freq +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_InnerEventId_006, Function | MediumTest | Level0) +-{ +- EXPECT_EQ(INNER_EVENT_ID_THERMAL_LIMIT_BOOST_FREQ, 6); +-} +- +-/* +- * @tc.name: SocPerfSubTest_GetService_001 +- * @tc.desc: get socperf service +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_GetService_001, Function | MediumTest | Level0) +-{ +- sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); +- EXPECT_NE(samgr, nullptr); +- +- sptr object = samgr->GetSystemAbility(SOC_PERF_SERVICE_SA_ID); +- EXPECT_NE(object, nullptr); +-} +- +-/* +- * @tc.name: SocPerfSubTest_GetService_002 +- * @tc.desc: get socperf service +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_GetService_002, Function | MediumTest | Level0) +-{ +- sptr samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); +- EXPECT_NE(samgr, nullptr); +- +- sptr object = samgr->GetSystemAbility(RES_SCHED_SYS_ABILITY_ID); +- EXPECT_NE(object, nullptr); +-} +- +-/* +- * @tc.name: SocPerfSubTest_PerfRequest_001 +- * @tc.desc: PerfRequest +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PerfRequest_001, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(10000, ""); +-} +- +-/* +- * @tc.name: SocPerfSubTest_PerfRequest_002 +- * @tc.desc: PerfRequestEx ON +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PerfRequest_002, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10000, true, ""); +-} +- +-/* +- * @tc.name: SocPerfSubTest_PerfRequest_003 +- * @tc.desc: PerfRequestEx OFF +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PerfRequest_003, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10000, false, ""); +-} +- +-/* +- * @tc.name: SocPerfSubTest_PowerLimitBoost_001 +- * @tc.desc: PowerLimitBoost ON +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PowerLimitBoost_001, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(true, ""); +-} +- +-/* +- * @tc.name: SocPerfSubTest_PowerLimitBoost_001 +- * @tc.desc: PowerLimitBoost OFF +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_PowerLimitBoost_002, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(false, ""); +-} +- +-/* +- * @tc.name: SocPerfSubTest_ThermalLimitBoost_001 +- * @tc.desc: ThermalLimitBoost ON +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_ThermalLimitBoost_001, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(true, ""); +-} +- +-/* +- * @tc.name: SocPerfSubTest_ThermalLimitBoost_002 +- * @tc.desc: ThermalLimitBoost OFF +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_ThermalLimitBoost_002, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(false, ""); +-} +- +-/* +- * @tc.name: SocPerfSubTest_LimitRequest_001 +- * @tc.desc: LimitRequest thermal +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_LimitRequest_001, Function | MediumTest | Level0) +-{ +- int32_t clientId_power = ACTION_TYPE_POWER; +- std::vector tags; +- tags.push_back(1001); +- std::vector configs; +- EXPECT_NE(tags.size(), configs.size()); +- configs.push_back(1608000); +- EXPECT_EQ(tags.size(), configs.size()); +- OHOS::SOCPERF::SocPerfClient::GetInstance().LimitRequest(clientId_power, tags, configs, ""); +-} +- +-/* +- * @tc.name: SocPerfSubTest_LimitRequest_002 +- * @tc.desc: LimitRequest thermal +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_LimitRequest_002, Function | MediumTest | Level0) +-{ +- int32_t clientId_thermal = ACTION_TYPE_THERMAL; +- std::vector tags; +- tags.push_back(1000); +- tags.push_back(1001); +- std::vector configs; +- EXPECT_NE(tags.size(), configs.size()); +- configs.push_back(1800000); +- configs.push_back(1992000); +- EXPECT_EQ(tags.size(), configs.size()); +- OHOS::SOCPERF::SocPerfClient::GetInstance().LimitRequest(clientId_thermal, tags, configs, ""); +-} +- +-/* +- * @tc.name: SocPerfSubTest_ResetClient_001 +- * @tc.desc: ResetClient +- * @tc.type FUNC +- * @tc.require: issueI78T3V +- */ +-HWTEST_F(SocPerfSubTest, SocPerfSubTest_ResetClient_001, Function | MediumTest | Level0) +-{ +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(10000, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10000, true, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequestEx(10000, false, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(true, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().PowerLimitBoost(false, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(true, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().ThermalLimitBoost(false, ""); +- OHOS::SOCPERF::SocPerfClient::GetInstance().ResetClient(); +-} +-} // namespace SOCPERF +-} // namespace OHOS