From 3b458b46d33339b557784fe47f9df504a9c7e7fb Mon Sep 17 00:00:00 2001 From: wuzhihuitmac Date: Tue, 25 Jun 2024 19:08:01 +0800 Subject: [PATCH] Add NotifyProcessStatus for vibrator Signed-off-by: wuzhihuitmac Change-Id: Ie5628aa660760641e7fbff3f009b195fbcfda9ba --- miscdevice.gni | 7 +++++++ services/miscdevice_service/BUILD.gn | 12 ++++++++++-- .../src/miscdevice_service.cpp | 19 +++++++++++-------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/miscdevice.gni b/miscdevice.gni index 8e7a46e..ca5e956 100644 --- a/miscdevice.gni +++ b/miscdevice.gni @@ -38,6 +38,13 @@ if (!defined(global_parts_info) || hdf_drivers_interface_light = false } +if (!defined(global_parts_info) || + defined(global_parts_info.resourceschedule_memmgr_override)) { + miscdevice_memmgr_enable = true +} else { + miscdevice_memmgr_enable = false +} + if (build_variant == "root") { miscdevice_default_defines += [ "BUILD_VARIANT_ENG" ] miscdevice_build_eng = true diff --git a/services/miscdevice_service/BUILD.gn b/services/miscdevice_service/BUILD.gn index 8768581..73c781f 100644 --- a/services/miscdevice_service/BUILD.gn +++ b/services/miscdevice_service/BUILD.gn @@ -74,13 +74,17 @@ ohos_shared_library("libmiscdevice_service") { "hitrace:hitrace_meter", "ipc:ipc_single", "json:nlohmann_json_static", - "memmgr:memmgrclient", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] defines = miscdevice_default_defines + if (miscdevice_memmgr_enable) { + defines += [ "MEMMGR_ENABLE" ] + external_deps += [ "memmgr:memmgrclient" ] + } + if (miscdevice_feature_vibrator_custom) { external_deps += [ "init:libbegetutil" ] } @@ -157,13 +161,17 @@ ohos_static_library("libmiscdevice_service_static") { "hitrace:hitrace_meter", "ipc:ipc_single", "json:nlohmann_json_static", - "memmgr:memmgrclient", "safwk:system_ability_fwk", "samgr:samgr_proxy", ] defines = miscdevice_default_defines + if (miscdevice_memmgr_enable) { + defines += [ "MEMMGR_ENABLE" ] + external_deps += [ "memmgr:memmgrclient" ] + } + if (miscdevice_feature_vibrator_custom) { external_deps += [ "init:libbegetutil" ] } diff --git a/services/miscdevice_service/src/miscdevice_service.cpp b/services/miscdevice_service/src/miscdevice_service.cpp index 51d5c16..7e2f712 100644 --- a/services/miscdevice_service/src/miscdevice_service.cpp +++ b/services/miscdevice_service/src/miscdevice_service.cpp @@ -20,9 +20,10 @@ #include #include "death_recipient_template.h" +#ifdef MEMMGR_ENABLE #include "iservice_registry.h" #include "mem_mgr_client.h" -#include "mem_mgr_proxy.h" +#endif // MEMMGR_ENABLE #include "system_ability_definition.h" #include "sensors_errors.h" @@ -64,10 +65,6 @@ constexpr int32_t VIBRATOR_ID = 0; constexpr int32_t BASE_YEAR = 1900; constexpr int32_t BASE_MON = 1; constexpr int32_t CONVERSION_RATE = 1000; -constexpr int32_t SA_ID = 3602; -constexpr int32_t SYSTEM_STATUS_START = 1; -constexpr int32_t SYSTEM_STATUS_STOP = 0; -constexpr int32_t SYSTEM_PROCESS_TYPE = 1; VibratorCapacity g_capacity; #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM const std::string PHONE_TYPE = "phone"; @@ -119,8 +116,10 @@ void MiscdeviceService::OnAddSystemAbility(int32_t systemAbilityId, const std::s switch (systemAbilityId) { case MEMORY_MANAGER_SA_ID: { MISC_HILOGI("Memory manager service start"); +#ifdef MEMMGR_ENABLE Memory::MemMgrClient::GetInstance().NotifyProcessStatus(getpid(), - SYSTEM_PROCESS_TYPE, SYSTEM_STATUS_START, SA_ID); + PROCESS_TYPE_SA, PROCESS_STATUS_STARTED, MISCDEVICE_SERVICE_ABILITY_ID); +#endif // MEMMGR_ENABLE break; } case COMMON_EVENT_SERVICE_ID: { @@ -199,7 +198,9 @@ void MiscdeviceService::OnStart() ret.first->second = vibratorExist_; } state_ = MiscdeviceServiceState::STATE_RUNNING; +#ifdef MEMMGR_ENABLE AddSystemAbilityListener(MEMORY_MANAGER_SA_ID); +#endif // MEMMGR_ENABLE AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); } @@ -293,8 +294,10 @@ void MiscdeviceService::OnStop() if (ret != ERR_OK) { MISC_HILOGE("Destroy hdi connection fail"); } - Memory::MemMgrClient::GetInstance().NotifyProcessStatus(getpid(), - SYSTEM_PROCESS_TYPE, SYSTEM_STATUS_STOP, SA_ID); +#ifdef MEMMGR_ENABLE + Memory::MemMgrClient::GetInstance().NotifyProcessStatus(getpid(), PROCESS_TYPE_SA, PROCESS_STATUS_DIED, + MISCDEVICE_SERVICE_ABILITY_ID); +#endif // MEMMGR_ENABLE } bool MiscdeviceService::ShouldIgnoreVibrate(const VibrateInfo &info) -- Gitee