mirror of
https://github.com/openharmony/resourceschedule_soc_perf.git
synced 2026-06-30 21:38:01 -04:00
fix: govern soc_perf inner_api.
Signed-off-by: wangxiaoding <wangxiaoding2@huawei.com>
This commit is contained in:
@@ -1,117 +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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//build/ohos/sa_profile/sa_profile.gni")
|
||||
|
||||
ohos_sa_profile("socperf_sa_profile") {
|
||||
sources = [ "sa_profile/1906.xml" ]
|
||||
part_name = "soc_perf"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("socperf_resource_config") {
|
||||
source = "configs/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 = "configs/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",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_shared_library("socperf_server") {
|
||||
sources = [
|
||||
"src/core/socperf.cpp",
|
||||
"src/core/socperf_handler.cpp",
|
||||
"src/server/socperf_server.cpp",
|
||||
"src/server/socperf_stub.cpp",
|
||||
]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"include/server",
|
||||
"include/core",
|
||||
"//base/customization/config_policy/interfaces/innerkits/include",
|
||||
]
|
||||
deps = [
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//third_party/libxml2:xml2",
|
||||
]
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"config_policy:configpolicy_util",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
]
|
||||
part_name = "soc_perf"
|
||||
subsystem_name = "resourceschedule"
|
||||
}
|
||||
|
||||
config("socperf_client_public_config") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"include/client",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_shared_library("socperf_client") {
|
||||
sources = [
|
||||
"src/client/socperf_client.cpp",
|
||||
"src/client/socperf_proxy.cpp",
|
||||
]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"include/client",
|
||||
"//foundation/systemabilitymgr/safwk/services/safwk/include",
|
||||
]
|
||||
public_configs = [ ":socperf_client_public_config" ]
|
||||
deps = [
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
]
|
||||
part_name = "soc_perf"
|
||||
subsystem_name = "resourceschedule"
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
ohos_executable("socperf_test") {
|
||||
sources = [ "test/unittest/socperf_test.cpp" ]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"include/client",
|
||||
]
|
||||
deps = [
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_client",
|
||||
"//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
]
|
||||
install_enable = true
|
||||
part_name = "soc_perf"
|
||||
subsystem_name = "resourceschedule"
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
}
|
||||
+11
-8
@@ -39,21 +39,24 @@
|
||||
},
|
||||
"build": {
|
||||
"sub_component": [
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_client",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_server",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_sa_profile",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_config",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_test"
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/profile:socperf_config",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/sa_profile:socperf_sa_profile",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/interfaces/inner_api/socperf_client:socperf_client",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/services:socperf_server",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/test/unittest:socperf_test"
|
||||
],
|
||||
"inner_kits": [
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/resourceschedule/resource_schedule_service/soc_perf/include/client",
|
||||
"header_base": "//foundation/resourceschedule/resource_schedule_service/soc_perf/interfaces/inner_api/socperf_client/include",
|
||||
"header_files": [
|
||||
"socperf_client.h"
|
||||
"i_socperf_service.h",
|
||||
"socperf_action_type.h",
|
||||
"socperf_client.h",
|
||||
"socperf_proxy.h"
|
||||
]
|
||||
},
|
||||
"name": "//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_client"
|
||||
"name": "//foundation/resourceschedule/resource_schedule_service/soc_perf/interfaces/inner_api/socperf_client:socperf_client"
|
||||
}
|
||||
],
|
||||
"test": [
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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, fmt, ##__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
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -1,43 +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 SOC_PERF_INCLUDE_CLIENT_SOCPERF_PROXY_H
|
||||
#define SOC_PERF_INCLUDE_CLIENT_SOCPERF_PROXY_H
|
||||
|
||||
#include "i_socperf_service.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace SOCPERF {
|
||||
class SocPerfProxy : public IRemoteProxy<ISocPerfService> {
|
||||
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<int32_t>& tags, const std::vector<int64_t>& configs, const std::string& msg) override;
|
||||
|
||||
public:
|
||||
explicit SocPerfProxy(const sptr<IRemoteObject> &impl)
|
||||
: IRemoteProxy<ISocPerfService>(impl) {}
|
||||
virtual ~SocPerfProxy() {}
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<SocPerfProxy> delegator_;
|
||||
};
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SOC_PERF_INCLUDE_CLIENT_SOCPERF_PROXY_H
|
||||
@@ -0,0 +1,45 @@
|
||||
# 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(
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/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" ]
|
||||
part_name = "soc_perf"
|
||||
subsystem_name = "resourceschedule"
|
||||
}
|
||||
+42
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOC_PERF_INCLUDE_I_SOCPERF_SERVICE_H
|
||||
#define SOC_PERF_INCLUDE_I_SOCPERF_SERVICE_H
|
||||
#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 <string>
|
||||
#include "iremote_broker.h"
|
||||
@@ -25,21 +25,53 @@
|
||||
#include "system_ability_definition.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "socperf_common.h"
|
||||
#include "socperf_action_type.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace SOCPERF {
|
||||
class ISocPerfService : public IRemoteBroker {
|
||||
public:
|
||||
ISocPerfService() = default;
|
||||
~ISocPerfService() override = default;
|
||||
DISALLOW_COPY_AND_MOVE(ISocPerfService);
|
||||
|
||||
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<int32_t>& tags, const std::vector<int64_t>& configs, const std::string& msg) = 0;
|
||||
|
||||
@@ -58,4 +90,4 @@ public:
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SOC_PERF_INCLUDE_I_SOCPERF_SERVICE_H
|
||||
#endif // SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_I_SOCPERF_SERVICE_H
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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_ACTION_TYPE_H
|
||||
#define SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_ACTION_TYPE_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
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
|
||||
+53
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOC_PERF_INCLUDE_CLIENT_SOCPERF_CLIENT_H
|
||||
#define SOC_PERF_INCLUDE_CLIENT_SOCPERF_CLIENT_H
|
||||
#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 <cstdint> // for int32_t
|
||||
#include <iosfwd> // for string
|
||||
@@ -25,13 +25,61 @@ 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<int32_t>& tags, const std::vector<int64_t>& configs, const std::string& msg);
|
||||
static SocPerfClient& GetInstance();
|
||||
|
||||
/**
|
||||
* @brief Reset SocperfClient
|
||||
*
|
||||
*/
|
||||
void ResetClient();
|
||||
|
||||
private:
|
||||
@@ -63,4 +111,4 @@ private:
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SOC_PERF_INCLUDE_CLIENT_SOCPERF_CLIENT_H
|
||||
#endif // SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_CLIENT_H
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* 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<ISocPerfService> {
|
||||
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<int32_t>& tags, const std::vector<int64_t>& configs, const std::string& msg) override;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new SocPerfProxy object.
|
||||
*
|
||||
* @param impl RemoteObject.
|
||||
*/
|
||||
explicit SocPerfProxy(const sptr<IRemoteObject> &impl)
|
||||
: IRemoteProxy<ISocPerfService>(impl) {}
|
||||
|
||||
/**
|
||||
* @brief Destroy the SocPerfProxy object.
|
||||
*
|
||||
*/
|
||||
virtual ~SocPerfProxy() {}
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<SocPerfProxy> delegator_;
|
||||
};
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SOC_PERF_INTERFACES_INNER_API_SOCPERF_CLIENT_INCLUDE_SOCPERF_PROXY_H
|
||||
@@ -0,0 +1,27 @@
|
||||
# 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:
|
||||
*;
|
||||
};
|
||||
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "socperf_client.h"
|
||||
#include <string> // for basic_string, to_string
|
||||
#include <unistd.h> // for getpid, gettid
|
||||
#include "socperf_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace SOCPERF {
|
||||
@@ -0,0 +1,36 @@
|
||||
# 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",
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
# 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.xml" ]
|
||||
part_name = "soc_perf"
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
# 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(
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/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",
|
||||
"config_policy:configpolicy_util",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
configs += [ "//build/config/gcc:symbol_visibility_hidden" ]
|
||||
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",
|
||||
"config_policy:configpolicy_util",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
part_name = "soc_perf"
|
||||
subsystem_name = "resourceschedule"
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOC_PERF_INCLUDE_CORE_SOCPERF_H
|
||||
#define SOC_PERF_INCLUDE_CORE_SOCPERF_H
|
||||
#ifndef SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_H
|
||||
#define SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <unistd.h>
|
||||
#include "libxml/parser.h"
|
||||
#include "libxml/tree.h"
|
||||
#include "i_socperf_service.h"
|
||||
#include "socperf_common.h"
|
||||
#include "socperf_handler.h"
|
||||
|
||||
@@ -46,7 +45,6 @@ private:
|
||||
std::unordered_map<int32_t, std::shared_ptr<Actions>> perfActionsInfo;
|
||||
std::vector<std::shared_ptr<SocPerfHandler>> handlers;
|
||||
bool enabled = false;
|
||||
bool debugLogEnabled = false;
|
||||
|
||||
std::unordered_map<int32_t, std::shared_ptr<ResNode>> resNodeInfo;
|
||||
std::unordered_map<int32_t, std::shared_ptr<GovResNode>> govResNodeInfo;
|
||||
@@ -77,5 +75,4 @@ private:
|
||||
};
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SOC_PERF_INCLUDE_CORE_SOCPERF_H
|
||||
#endif // SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_H
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -13,66 +13,35 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOC_PERF_INCLUDE_SOCPERF_COMMON_H
|
||||
#define SOC_PERF_INCLUDE_SOCPERF_COMMON_H
|
||||
#ifndef SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_COMMON_H
|
||||
#define SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_COMMON_H
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include "hilog/log.h"
|
||||
#include "socperf_log.h"
|
||||
#include "socperf_action_type.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace SOCPERF {
|
||||
#define LOG_TAG_SOC_PERF "socperf"
|
||||
#define LOG_TAG_DOMAIN_ID_SOC_PERF 0xD001703
|
||||
|
||||
static constexpr OHOS::HiviewDFX::HiLogLabel SOC_PERF_LOG_LABEL = {
|
||||
LOG_CORE,
|
||||
LOG_TAG_DOMAIN_ID_SOC_PERF,
|
||||
LOG_TAG_SOC_PERF
|
||||
};
|
||||
|
||||
#define SOC_PERF_LOGF(...) (void)OHOS::HiviewDFX::HiLog::Fatal(SOC_PERF_LOG_LABEL, __VA_ARGS__)
|
||||
#define SOC_PERF_LOGE(...) (void)OHOS::HiviewDFX::HiLog::Error(SOC_PERF_LOG_LABEL, __VA_ARGS__)
|
||||
#define SOC_PERF_LOGW(...) (void)OHOS::HiviewDFX::HiLog::Warn(SOC_PERF_LOG_LABEL, __VA_ARGS__)
|
||||
#define SOC_PERF_LOGI(...) (void)OHOS::HiviewDFX::HiLog::Info(SOC_PERF_LOG_LABEL, __VA_ARGS__)
|
||||
#define SOC_PERF_LOGD(...) (void)OHOS::HiviewDFX::HiLog::Debug(SOC_PERF_LOG_LABEL, __VA_ARGS__)
|
||||
|
||||
enum EventType {
|
||||
EVENT_INVALID = -1,
|
||||
EVENT_OFF,
|
||||
EVENT_ON
|
||||
};
|
||||
|
||||
enum ActionType {
|
||||
ACTION_TYPE_PERF,
|
||||
ACTION_TYPE_POWER,
|
||||
ACTION_TYPE_THERMAL,
|
||||
ACTION_TYPE_MAX
|
||||
};
|
||||
|
||||
namespace {
|
||||
const int32_t INNER_EVENT_ID_INIT_RES_NODE_INFO = 0;
|
||||
const int32_t INNER_EVENT_ID_INIT_GOV_RES_NODE_INFO = 1;
|
||||
const int32_t INNER_EVENT_ID_DO_FREQ_ACTION = 2;
|
||||
const int32_t INNER_EVENT_ID_DO_FREQ_ACTION_DELAYED = 3;
|
||||
const int32_t INNER_EVENT_ID_POWER_LIMIT_BOOST_FREQ = 4;
|
||||
const int32_t INNER_EVENT_ID_THERMAL_LIMIT_BOOST_FREQ = 5;
|
||||
}
|
||||
|
||||
namespace {
|
||||
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 = -1;
|
||||
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_AND_VALUE_PAIR = 2;
|
||||
const int32_t RES_ID_NUMS_PER_TYPE = 1000;
|
||||
}
|
||||
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 = -1;
|
||||
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_AND_VALUE_PAIR = 2;
|
||||
const int32_t RES_ID_NUMS_PER_TYPE = 1000;
|
||||
|
||||
class ResNode {
|
||||
public:
|
||||
@@ -372,4 +341,4 @@ static inline std::vector<std::string> Split(std::string str, std::string patter
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SOC_PERF_INCLUDE_SOCPERF_COMMON_H
|
||||
#endif // SOC_PERF_SERVICES_CORE_INCLUDE_COMMON_H
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -13,14 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOC_PERF_INCLUDE_CORE_SOCPERF_HANDLER_H
|
||||
#define SOC_PERF_INCLUDE_CORE_SOCPERF_HANDLER_H
|
||||
#ifndef SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_HANDLER_H
|
||||
#define SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_HANDLER_H
|
||||
|
||||
|
||||
#include <cstdint> // for int32_t
|
||||
#include <memory> // for allocator
|
||||
#include <unordered_map> // for unordered_map
|
||||
#include <iosfwd> // for string
|
||||
#include <memory> // for shared_ptr
|
||||
#include <string> // for string
|
||||
#include <unordered_map> // for unordered_map
|
||||
#include <stdint.h> // for uint32_t
|
||||
#include "event_handler.h" // for EventHandler
|
||||
#include "event_runner.h"
|
||||
#include "inner_event.h" // for InnerEvent, InnerEvent::Pointer
|
||||
@@ -31,6 +31,15 @@ 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_DELAYED,
|
||||
INNER_EVENT_ID_POWER_LIMIT_BOOST_FREQ,
|
||||
INNER_EVENT_ID_THERMAL_LIMIT_BOOST_FREQ,
|
||||
};
|
||||
|
||||
class SocPerfHandler : public AppExecFwk::EventHandler {
|
||||
public:
|
||||
explicit SocPerfHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner);
|
||||
@@ -63,4 +72,4 @@ private:
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
#endif
|
||||
#endif // SOC_PERF_SERVICES_CORE_INCLUDE_SOCPERF_HANDLER_H
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -29,8 +29,6 @@ SocPerf::~SocPerf()
|
||||
|
||||
bool SocPerf::Init()
|
||||
{
|
||||
debugLogEnabled = HiLogIsLoggable(LOG_TAG_DOMAIN_ID_SOC_PERF, LOG_TAG_SOC_PERF, LOG_DEBUG);
|
||||
|
||||
if (!LoadConfigXmlFile(SOCPERF_RESOURCE_CONFIG_XML)) {
|
||||
SOC_PERF_LOGE("%{public}s, Failed to load %{public}s", __func__, SOCPERF_RESOURCE_CONFIG_XML.c_str());
|
||||
return false;
|
||||
@@ -57,9 +55,7 @@ bool SocPerf::Init()
|
||||
|
||||
enabled = true;
|
||||
|
||||
if (debugLogEnabled) {
|
||||
SOC_PERF_LOGD("%{public}s, SocPerf Init SUCCESS!", __func__);
|
||||
}
|
||||
SOC_PERF_LOGD("%{public}s, SocPerf Init SUCCESS!", __func__);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -74,9 +70,8 @@ void SocPerf::PerfRequest(int32_t cmdId, const std::string& msg)
|
||||
SOC_PERF_LOGE("%{public}s, Invalid PerfRequest cmdId[%{public}d]", __func__, cmdId);
|
||||
return;
|
||||
}
|
||||
if (debugLogEnabled) {
|
||||
SOC_PERF_LOGD("%{public}s, cmdId[%{public}d]msg[%{public}s]", __func__, cmdId, msg.c_str());
|
||||
}
|
||||
SOC_PERF_LOGD("%{public}s, cmdId[%{public}d]msg[%{public}s]", __func__, 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("]");
|
||||
@@ -95,10 +90,9 @@ void SocPerf::PerfRequestEx(int32_t cmdId, bool onOffTag, const std::string& msg
|
||||
SOC_PERF_LOGE("%{public}s, Invalid PerfRequestEx cmdId[%{public}d]", __func__, cmdId);
|
||||
return;
|
||||
}
|
||||
if (debugLogEnabled) {
|
||||
SOC_PERF_LOGD("%{public}s, cmdId[%{public}d]onOffTag[%{public}d]msg[%{public}s]",
|
||||
__func__, cmdId, onOffTag, msg.c_str());
|
||||
}
|
||||
SOC_PERF_LOGD("%{public}s, cmdId[%{public}d]onOffTag[%{public}d]msg[%{public}s]",
|
||||
__func__, 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("]");
|
||||
@@ -114,9 +108,8 @@ void SocPerf::PowerLimitBoost(bool onOffTag, const std::string& msg)
|
||||
SOC_PERF_LOGE("%{public}s, SocPerf disabled!", __func__);
|
||||
return;
|
||||
}
|
||||
if (debugLogEnabled) {
|
||||
SOC_PERF_LOGD("%{public}s, onOffTag[%{public}d]msg[%{public}s]", __func__, onOffTag, msg.c_str());
|
||||
}
|
||||
SOC_PERF_LOGD("%{public}s, onOffTag[%{public}d]msg[%{public}s]", __func__, 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("]");
|
||||
@@ -134,9 +127,7 @@ void SocPerf::ThermalLimitBoost(bool onOffTag, const std::string& msg)
|
||||
SOC_PERF_LOGE("%{public}s, SocPerf disabled!", __func__);
|
||||
return;
|
||||
}
|
||||
if (debugLogEnabled) {
|
||||
SOC_PERF_LOGD("%{public}s, onOffTag[%{public}d]msg[%{public}s]", __func__, onOffTag, msg.c_str());
|
||||
}
|
||||
SOC_PERF_LOGD("%{public}s, onOffTag[%{public}d]msg[%{public}s]", __func__, 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("]");
|
||||
@@ -163,11 +154,9 @@ void SocPerf::LimitRequest(int32_t clientId,
|
||||
SOC_PERF_LOGE("%{public}s, clientId must be between ACTION_TYPE_PERF and ACTION_TYPE_MAX!", __func__);
|
||||
return;
|
||||
}
|
||||
if (debugLogEnabled) {
|
||||
for (int32_t i = 0; i < (int32_t)tags.size(); i++) {
|
||||
SOC_PERF_LOGD("%{public}s, clientId[%{public}d],tags[%{public}d],configs[%{public}lld],msg[%{public}s]",
|
||||
__func__, clientId, tags[i], (long long)configs[i], msg.c_str());
|
||||
}
|
||||
for (int32_t i = 0; i < (int32_t)tags.size(); i++) {
|
||||
SOC_PERF_LOGD("%{public}s, clientId[%{public}d],tags[%{public}d],configs[%{public}lld],msg[%{public}s]",
|
||||
__func__, clientId, tags[i], (long long)configs[i], msg.c_str());
|
||||
}
|
||||
for (int32_t i = 0; i < (int32_t)tags.size(); i++) {
|
||||
int32_t resId = tags[i];
|
||||
@@ -277,9 +266,7 @@ bool SocPerf::LoadConfigXmlFile(std::string configFile)
|
||||
return false;
|
||||
}
|
||||
xmlFreeDoc(file);
|
||||
if (debugLogEnabled) {
|
||||
SOC_PERF_LOGD("%{public}s, Success to Load %{public}s", __func__, configFile.c_str());
|
||||
}
|
||||
SOC_PERF_LOGD("%{public}s, Success to Load %{public}s", __func__, configFile.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -295,9 +282,7 @@ bool SocPerf::CreateHandlers()
|
||||
}
|
||||
handlers[i] = std::make_shared<SocPerfHandler>(runner);
|
||||
}
|
||||
if (debugLogEnabled) {
|
||||
SOC_PERF_LOGD("%{public}s, Success to Create All Handler threads", __func__);
|
||||
}
|
||||
SOC_PERF_LOGD("%{public}s, Success to Create All Handler threads", __func__);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -651,27 +636,25 @@ bool SocPerf::CheckActionResIdAndValueValid(std::string configFile)
|
||||
|
||||
void SocPerf::PrintCachedInfo()
|
||||
{
|
||||
if (debugLogEnabled) {
|
||||
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> 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> 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> actions = iter->second;
|
||||
actions->PrintString();
|
||||
}
|
||||
SOC_PERF_LOGD("------------------------------------");
|
||||
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> 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> 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> actions = iter->second;
|
||||
actions->PrintString();
|
||||
}
|
||||
SOC_PERF_LOGD("------------------------------------");
|
||||
}
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOC_PERF_INCLUDE_SERVER_SOCPERF_SERVER_H
|
||||
#define SOC_PERF_INCLUDE_SERVER_SOCPERF_SERVER_H
|
||||
#ifndef SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_SERVER_H
|
||||
#define SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_SERVER_H
|
||||
|
||||
#include <file_ex.h>
|
||||
#include <string_ex.h>
|
||||
@@ -53,4 +53,4 @@ private:
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SOC_PERF_INCLUDE_SERVER_SOCPERF_SERVER_H
|
||||
#endif // SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_SERVER_H
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef SOC_PERF_INCLUDE_SERVER_SOCPERF_STUB_H
|
||||
#define SOC_PERF_INCLUDE_SERVER_SOCPERF_STUB_H
|
||||
#ifndef SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_STUB_H
|
||||
#define SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_STUB_H
|
||||
|
||||
#include <cstdint> // for int32_t, uint32_t
|
||||
#include "i_socperf_service.h"
|
||||
@@ -33,4 +33,4 @@ public:
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // SOC_PERF_INCLUDE_SERVER_SOCPERF_STUB_H
|
||||
#endif // SOC_PERF_SERVICES_SERVER_INCLUDE_SOCPERF_STUB_H
|
||||
@@ -0,0 +1,23 @@
|
||||
# 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"
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# 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
|
||||
@@ -14,52 +14,46 @@
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import(
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/soc_perf.gni")
|
||||
module_output_path = "resource_schedule_service/soc_perf"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
config("module_private_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
include_dirs = [
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/include/server",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/include/core",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/include",
|
||||
"${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 = "//foundation/resourceschedule/resource_schedule_service/soc_perf/test/fuzztest/loadconfigxmlfile_fuzzer"
|
||||
|
||||
fuzz_config_file = "${socperf_test}/fuzztest/loadconfigxmlfile_fuzzer"
|
||||
configs = [ ":module_private_config" ]
|
||||
include_dirs = []
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "loadconfigxmlfile_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_server",
|
||||
"//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//third_party/libxml2:xml2",
|
||||
]
|
||||
deps = [ "${socperf_services}:socperf_server_static" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [
|
||||
deps = [
|
||||
# deps file
|
||||
":LoadConfigXmlFileFuzzTest",
|
||||
]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -22,28 +22,41 @@ namespace OHOS {
|
||||
namespace SOCPERF {
|
||||
const std::string fuzzedFile = "myFuzzed.xml";
|
||||
const int32_t FILE_RETURN_SUCCESS = 1;
|
||||
std::mutex mutexLock;
|
||||
std::unique_ptr<SocPerf> socPerf = nullptr;
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
bool DoInit()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutexLock);
|
||||
if (socPerf) {
|
||||
return true;
|
||||
}
|
||||
socPerf = std::make_unique<SocPerf>();
|
||||
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 false;
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t retCode = fwrite(reinterpret_cast<const void*>(data), size, 1, pFile); // 1 means count=1
|
||||
if (retCode < FILE_RETURN_SUCCESS) {
|
||||
(void)fclose(pFile);
|
||||
pFile = nullptr;
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
(void)fclose(pFile);
|
||||
pFile = nullptr;
|
||||
|
||||
std::shared_ptr<SocPerf> socPerf = std::make_shared<SocPerf>();
|
||||
bool ret = socPerf->LoadConfigXmlFile(fuzzedFile);
|
||||
return ret;
|
||||
socPerf->LoadConfigXmlFile(fuzzedFile);
|
||||
}
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# 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
|
||||
@@ -14,44 +14,33 @@
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/test.gni")
|
||||
import(
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/soc_perf.gni")
|
||||
module_output_path = "resource_schedule_service/soc_perf"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
config("module_private_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
include_dirs = [
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/include/server",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/include/core",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/include",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_fuzztest("SocPerfFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
fuzz_config_file = "//foundation/resourceschedule/resource_schedule_service/soc_perf/test/fuzztest/socperf_fuzzer"
|
||||
|
||||
configs = [ ":module_private_config" ]
|
||||
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 = [
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_server",
|
||||
"//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//third_party/libxml2:xml2",
|
||||
]
|
||||
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",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@@ -15,39 +15,54 @@
|
||||
|
||||
#include "socperf_fuzzer.h"
|
||||
|
||||
#define private public
|
||||
#include "socperf_server.h"
|
||||
#include "socperf_stub.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;
|
||||
static bool isInited = false;
|
||||
std::mutex mutexLock;
|
||||
sptr<IRemoteObject> remoteObj = nullptr;
|
||||
|
||||
bool DoInit()
|
||||
{
|
||||
std::lock_guard<std::mutex> 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)
|
||||
{
|
||||
int32_t ret = -1;
|
||||
if (!DoInit()) {
|
||||
return -1;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!isInited) {
|
||||
if (!DelayedSingleton<SocPerfServer>::GetInstance()->socPerf.Init()) {
|
||||
return ret;
|
||||
}
|
||||
isInited = true;
|
||||
}
|
||||
ret = DelayedSingleton<SocPerfServer>::GetInstance()->OnRemoteRequest(code, data, reply, option);
|
||||
return ret;
|
||||
return remoteObj->SendRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
void DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
|
||||
{
|
||||
if (size <= MIN_LEN) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataMessageParcel;
|
||||
if (!dataMessageParcel.WriteInterfaceToken(SocPerfStub::GetDescriptor())) {
|
||||
return;
|
||||
if (!dataMessageParcel.WriteInterfaceToken(IRemoteStub<ISocPerfService>::GetDescriptor())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t code = *(reinterpret_cast<const uint32_t*>(data));
|
||||
@@ -56,7 +71,9 @@ namespace SOCPERF {
|
||||
dataMessageParcel.WriteBuffer(data + sizeof(uint32_t), size);
|
||||
dataMessageParcel.RewindRead(0);
|
||||
|
||||
SOC_PERF_LOGD("_______________");
|
||||
onRemoteRequest(code, dataMessageParcel);
|
||||
return true;
|
||||
}
|
||||
} // namespace SOCPERF
|
||||
} // namespace OHOS
|
||||
|
||||
+31
-9
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# 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
|
||||
@@ -12,6 +12,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import(
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/soc_perf.gni")
|
||||
|
||||
module_output_path = "soc_perf/socperftest"
|
||||
|
||||
@@ -19,9 +21,9 @@ config("module_private_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
include_dirs = [
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/include/client",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/include/core",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf/include",
|
||||
"${socperf_common}/include",
|
||||
"${socperf_interfaces}/inner_api/socperf_client/include",
|
||||
"${socperf_services}/core/include",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -33,20 +35,40 @@ ohos_unittest("SocPerfSubTest") {
|
||||
configs = [ ":module_private_config" ]
|
||||
|
||||
deps = [
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/resourceschedule/resource_schedule_service/soc_perf:socperf_client",
|
||||
"//foundation/systemabilitymgr/safwk/interfaces/innerkits/safwk:system_ability_fwk",
|
||||
"//foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"${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_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",
|
||||
]
|
||||
|
||||
install_enable = true
|
||||
part_name = "soc_perf"
|
||||
subsystem_name = "resourceschedule"
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
deps = [ ":SocPerfSubTest" ]
|
||||
|
||||
Reference in New Issue
Block a user