From 2d805f5c06cac55aeab03ae87db0a542a48b9f76 Mon Sep 17 00:00:00 2001 From: bailu1992 Date: Fri, 12 Apr 2024 20:15:49 +0800 Subject: [PATCH] sensor Alarm Modification Signed-off-by: bailu1992 --- frameworks/native/src/native_sensor.cpp | 12 ++++++------ frameworks/native/src/sensor_agent.cpp | 7 ++++++- interfaces/inner_api/sensor_agent.h | 5 ++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/frameworks/native/src/native_sensor.cpp b/frameworks/native/src/native_sensor.cpp index bd27c5f4..4720c54c 100644 --- a/frameworks/native/src/native_sensor.cpp +++ b/frameworks/native/src/native_sensor.cpp @@ -36,7 +36,7 @@ Sensor_Result OH_Sensor_GetInfos(Sensor_Info **sensors, uint32_t *count) } SensorInfo *sensorInfo = nullptr; int32_t sensorCount = -1; - int32_t ret = GetAllSensors(&sensorInfo, &sensorCount); + int32_t ret = OHOS::Sensors::GetAllSensors(&sensorInfo, &sensorCount); if (ret != SENSOR_SUCCESS || sensorCount < 0) { SEN_HILOGE("GetAllSensors fail"); return SENSOR_SERVICE_EXCEPTION; @@ -185,18 +185,18 @@ Sensor_Result OH_Sensor_Subscribe(const Sensor_SubscriptionId *id, } const SensorUser *sensorUser = reinterpret_cast(user); int32_t sensorType = id->sensorType; - int32_t ret = SubscribeSensor(sensorType, sensorUser); + int32_t ret = OHOS::Sensors::SubscribeSensor(sensorType, sensorUser); if (ret != SENSOR_SUCCESS) { SEN_HILOGE("SubscribeSensor failed, %{public}d", ret); return SENSOR_SERVICE_EXCEPTION; } int64_t samplingInterval = attribute->samplingInterval; - ret = SetBatch(sensorType, sensorUser, samplingInterval, samplingInterval); + ret = OHOS::Sensors::SetBatch(sensorType, sensorUser, samplingInterval, samplingInterval); if (ret != SENSOR_SUCCESS) { SEN_HILOGE("SetBatch failed, %{public}d", ret); return SENSOR_SERVICE_EXCEPTION; } - return static_cast(ActivateSensor(sensorType, sensorUser)); + return static_cast(OHOS::Sensors::ActivateSensor(sensorType, sensorUser)); } Sensor_Result OH_Sensor_Unsubscribe(const Sensor_SubscriptionId *id, @@ -208,12 +208,12 @@ Sensor_Result OH_Sensor_Unsubscribe(const Sensor_SubscriptionId *id, } const SensorUser *sensorUser = reinterpret_cast(user); int32_t sensorType = id->sensorType; - int32_t ret = DeactivateSensor(sensorType, sensorUser); + int32_t ret = OHOS::Sensors::DeactivateSensor(sensorType, sensorUser); if (ret != SENSOR_SUCCESS) { SEN_HILOGE("SetBatch failed, %{public}d", ret); return SENSOR_SERVICE_EXCEPTION; } - return static_cast(UnsubscribeSensor(sensorType, sensorUser)); + return static_cast(OHOS::Sensors::UnsubscribeSensor(sensorType, sensorUser)); } int32_t OH_SensorEvent_GetType(Sensor_Event* sensorEvent, Sensor_Type *sensorType) diff --git a/frameworks/native/src/sensor_agent.cpp b/frameworks/native/src/sensor_agent.cpp index 3a8d0e4f..1031f25d 100644 --- a/frameworks/native/src/sensor_agent.cpp +++ b/frameworks/native/src/sensor_agent.cpp @@ -20,6 +20,9 @@ #undef LOG_TAG #define LOG_TAG "SensorNativeAPI" + +namespace OHOS { +namespace Sensors { using OHOS::Sensors::SensorAgentProxy; using OHOS::Sensors::SERVICE_EXCEPTION; using OHOS::Sensors::PARAMETER_ERROR; @@ -169,4 +172,6 @@ int32_t ResetSensors() return NormalizeErrCode(ret); } return ret; -} \ No newline at end of file +} +} // namespace Sensors +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/sensor_agent.h b/interfaces/inner_api/sensor_agent.h index 246e42a5..5b0f165f 100755 --- a/interfaces/inner_api/sensor_agent.h +++ b/interfaces/inner_api/sensor_agent.h @@ -46,6 +46,8 @@ extern "C" { #endif #endif +namespace OHOS { +namespace Sensors { /** * @brief Obtains information about all sensors in the system. * @@ -188,7 +190,8 @@ int32_t Unregister(SensorActiveInfoCB callback); * @since 10 */ int32_t ResetSensors(); - +} // namespace Sensors +} // namespace OHOS #ifdef __cplusplus #if __cplusplus } -- Gitee