Add NotifyProcessStatus for sensor

Signed-off-by: wuzhihuitmac <wuzhihui4@huawei.com>
Change-Id: I75e2e681170e6133148fa1b1a6c94c85c70afe8d
This commit is contained in:
wuzhihuitmac 2024-06-25 18:22:40 +08:00
parent 974cd90c42
commit 5f3568da80
3 changed files with 28 additions and 12 deletions

View File

@ -35,6 +35,13 @@ if (!defined(global_parts_info) ||
hdf_drivers_interface_sensor = false
}
if (!defined(global_parts_info) ||
defined(global_parts_info.resourceschedule_memmgr_override)) {
sensor_memmgr_enable = true
} else {
sensor_memmgr_enable = false
}
if (build_variant == "root") {
sensor_default_defines += [ "BUILD_VARIANT_ENG" ]
sensor_build_eng = true

View File

@ -62,11 +62,14 @@ ohos_shared_library("libsensor_service") {
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
"ipc:ipc_single",
"memmgr:memmgrclient",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (sensor_memmgr_enable) {
defines += [ "MEMMGR_ENABLE" ]
external_deps += [ "memmgr:memmgrclient" ]
}
if (hdf_drivers_interface_sensor) {
sources += [
"hdi_connection/adapter/src/hdi_connection.cpp",
@ -147,11 +150,14 @@ ohos_static_library("libsensor_service_static") {
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
"ipc:ipc_single",
"memmgr:memmgrclient",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (sensor_memmgr_enable) {
defines += [ "MEMMGR_ENABLE" ]
external_deps += [ "memmgr:memmgrclient" ]
}
if (hdf_drivers_interface_sensor) {
sources += [
"hdi_connection/adapter/src/hdi_connection.cpp",

View File

@ -22,8 +22,9 @@
#include "hisysevent.h"
#include "iservice_registry.h"
#ifdef MEMMGR_ENABLE
#include "mem_mgr_client.h"
#include "mem_mgr_proxy.h"
#endif // MEMMGR_ENABLE
#include "permission_util.h"
#include "securec.h"
@ -43,10 +44,6 @@ auto g_sensorService = SensorDelayedSpSingleton<SensorService>::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
@ -66,10 +63,12 @@ void SensorService::OnDump()
void SensorService::OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId)
{
SEN_HILOGI("OnAddSystemAbility systemAbilityId:%{public}d", systemAbilityId);
#ifdef MEMMGR_ENABLE
if (systemAbilityId == MEMORY_MANAGER_SA_ID) {
Memory::MemMgrClient::GetInstance().NotifyProcessStatus(getpid(),
SYSTEM_PROCESS_TYPE, SYSTEM_STATUS_START, SA_ID);
PROCESS_TYPE_SA, PROCESS_STATUS_STARTED, SENSOR_SERVICE_ABILITY_ID);
}
#endif // MEMMGR_ENABLE
}
void SensorService::OnStart()
@ -105,7 +104,9 @@ void SensorService::OnStart()
return;
}
state_ = SensorServiceState::STATE_RUNNING;
#ifdef MEMMGR_ENABLE
AddSystemAbilityListener(MEMORY_MANAGER_SA_ID);
#endif // MEMMGR_ENABLE
}
#ifdef HDF_DRIVERS_INTERFACE_SENSOR
@ -172,8 +173,10 @@ void SensorService::OnStop()
}
#endif // HDF_DRIVERS_INTERFACE_SENSOR
UnregisterPermCallback();
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,
SENSOR_SERVICE_ABILITY_ID);
#endif // MEMMGR_ENABLE
}
void SensorService::ReportSensorSysEvent(int32_t sensorId, bool enable, int32_t pid)