diff --git a/bundle.json b/bundle.json index 63dca8dbbfc742861ab866204e6cc2b749213a04..cccf86e7a6fa300224cfe284478a33534725c293 100755 --- a/bundle.json +++ b/bundle.json @@ -28,6 +28,7 @@ "access_token", "hitrace", "ipc", + "memmgr", "safwk", "samgr", "eventhandler" diff --git a/services/BUILD.gn b/services/BUILD.gn index 56722a036d126547143723f44e97ed8bf4a6db87..1e249f469ab603ac9e44eedefa3fdf85592cd077 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -62,7 +62,9 @@ ohos_shared_library("libsensor_service") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_single", + "memmgr:memmgrclient", "safwk:system_ability_fwk", + "samgr:samgr_proxy", ] if (hdf_drivers_interface_sensor) { @@ -145,7 +147,9 @@ ohos_shared_library("libsensor_service_static") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_single", + "memmgr:memmgrclient", "safwk:system_ability_fwk", + "samgr:samgr_proxy", ] if (hdf_drivers_interface_sensor) { diff --git a/services/include/sensor_service.h b/services/include/sensor_service.h index 9e83d3540ebdf21c9691f0a87a69e7198d99fab7..67d9b4b0bcc613c17d5e60368254c82a3ed4e738 100644 --- a/services/include/sensor_service.h +++ b/services/include/sensor_service.h @@ -69,6 +69,7 @@ public: private: DISALLOW_COPY_AND_MOVE(SensorService); + void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; class PermStateChangeCb : public Security::AccessToken::PermStateChangeCallbackCustomize { public: diff --git a/services/src/sensor_service.cpp b/services/src/sensor_service.cpp index 9f90ffd88dd3eabb6d147a068c9c46538342121f..22c4851f733b2f36dca3d1d234c3b39fcd382910 100644 --- a/services/src/sensor_service.cpp +++ b/services/src/sensor_service.cpp @@ -22,7 +22,10 @@ #include "hisysevent.h" #include "iservice_registry.h" +#include "mem_mgr_client.h" +#include "mem_mgr_proxy.h" #include "permission_util.h" + #include "securec.h" #include "sensor.h" #include "sensor_dump.h" @@ -40,6 +43,10 @@ auto g_sensorService = SensorDelayedSpSingleton::GetInstance(); const bool G_REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(g_sensorService.GetRefPtr()); constexpr int32_t INVALID_PID = -1; constexpr int64_t MAX_EVENT_COUNT = 1000; +constexpr int32_t SA_ID = 3601; +constexpr int32_t SYSTEM_STATUS_START = 1; +constexpr int32_t SYSTEM_STATUS_STOP = 0; +constexpr int32_t SYSTEM_PROCESS_TYPE = 1; std::atomic_bool g_isRegister = false; } // namespace @@ -56,6 +63,15 @@ void SensorService::OnDump() SEN_HILOGI("OnDump"); } +void SensorService::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) +{ + SEN_HILOGI("OnAddSystemAbility systemAbilityId:%{public}d", systemAbilityId); + if (systemAbilityId == MEMORY_MANAGER_SA_ID) { + Memory::MemMgrClient::GetInstance().NotifyProcessStatus(getpid(), + SYSTEM_PROCESS_TYPE, SYSTEM_STATUS_START, SA_ID); + } +} + void SensorService::OnStart() { CALL_LOG_ENTER; @@ -89,6 +105,7 @@ void SensorService::OnStart() sensorManager_.InitSensorMap(sensorMap_); #endif // HDF_DRIVERS_INTERFACE_SENSOR state_ = SensorServiceState::STATE_RUNNING; + AddSystemAbilityListener(MEMORY_MANAGER_SA_ID); } #ifdef HDF_DRIVERS_INTERFACE_SENSOR @@ -155,6 +172,8 @@ void SensorService::OnStop() } #endif // HDF_DRIVERS_INTERFACE_SENSOR UnregisterPermCallback(); + Memory::MemMgrClient::GetInstance().NotifyProcessStatus(getpid(), + SYSTEM_PROCESS_TYPE, SYSTEM_STATUS_STOP, SA_ID); } void SensorService::ReportSensorSysEvent(int32_t sensorId, bool enable, int32_t pid)