From a40bc188894fc39baa3ce92a003ddab1c95c2b4e Mon Sep 17 00:00:00 2001 From: h00514358 Date: Tue, 14 Sep 2021 07:30:53 +0000 Subject: [PATCH 1/2] Signed-off-by:hellohyh001 Signed-off-by: h00514358 --- frameworks/src/sensor_agent_proxy.c | 67 ++++++++++++++--------------- services/src/sensor_service.c | 33 +++++++------- 2 files changed, 49 insertions(+), 51 deletions(-) diff --git a/frameworks/src/sensor_agent_proxy.c b/frameworks/src/sensor_agent_proxy.c index dd88474..a04b8de 100755 --- a/frameworks/src/sensor_agent_proxy.c +++ b/frameworks/src/sensor_agent_proxy.c @@ -234,42 +234,41 @@ int32_t SensorChannelCallback(const IpcContext *context, void *ipcMsg, IpcIo *io int32_t RegisterSensorChannel(const void *proxy, int32_t sensorId) { HILOG_DEBUG(HILOG_MODULE_APP, "%s begin", __func__); - if (!IsRegisterCallback()) { - int32_t ret = RegisterIpcCallback(SensorChannelCallback, 0, IPC_WAIT_FOREVER, &g_svcIdentity, NULL); - if (ret != LITEIPC_OK) { - HILOG_ERROR(HILOG_MODULE_APP, "%s failed, ret: %d", __func__, ret); - return SENSOR_ERROR_INVALID_PARAM; - } - IpcIo request; - char data[IPC_IO_DATA_MAX]; - IpcIoInit(&request, data, IPC_IO_DATA_MAX, IPC_MAX_OBJECTS); - IpcIoPushInt32(&request, sensorId); - IpcIoPushSvc(&request, &g_svcIdentity); - if (!IpcIoAvailable(&request)) { - HILOG_ERROR(HILOG_MODULE_APP, "%s ipc communication failed", __func__); - return SENSOR_ERROR_INVALID_PARAM; - } - IClientProxy *client = (IClientProxy *)proxy; - if (client == NULL) { - HILOG_ERROR(HILOG_MODULE_APP, "%s client is null", __func__); + if (IsRegisterCallback()) { + HILOG_DEBUG(HILOG_MODULE_APP, "%s sensorChannel has been registered ", __func__); + return SENSOR_OK; + } + int32_t ret = RegisterIpcCallback(SensorChannelCallback, 0, IPC_WAIT_FOREVER, &g_svcIdentity, NULL); + if (ret != LITEIPC_OK) { + HILOG_ERROR(HILOG_MODULE_APP, "%s failed, ret: %d", __func__, ret); + return SENSOR_ERROR_INVALID_PARAM; + } + IpcIo request; + char data[IPC_IO_DATA_MAX]; + IpcIoInit(&request, data, IPC_IO_DATA_MAX, IPC_MAX_OBJECTS); + IpcIoPushInt32(&request, sensorId); + IpcIoPushSvc(&request, &g_svcIdentity); + if (!IpcIoAvailable(&request)) { + HILOG_ERROR(HILOG_MODULE_APP, "%s ipc communication failed", __func__); + return SENSOR_ERROR_INVALID_PARAM; + } + IClientProxy *client = (IClientProxy *)proxy; + if (client == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "%s client is null", __func__); + return SENSOR_ERROR_INVALID_PARAM; + } + int32_t retCode = -1; + ret = client->Invoke(client, SENSOR_SERVICE_ID_SubscribeSensor, &request, &retCode, Notify); + if ((ret != LITEIPC_OK) || (retCode != SENSOR_OK)) { + HILOG_ERROR(HILOG_MODULE_APP, "%s failed, ret: %d, retCode: %d", __func__, ret, retCode); + return SENSOR_ERROR_INVALID_PARAM; + } + if (g_sensorEvent == NULL) { + g_sensorEvent = (SensorEvent *)malloc(sizeof(SensorEvent)); + if (g_sensorEvent == NULL) { + HILOG_ERROR(HILOG_MODULE_APP, "%s malloc failed", __func__); return SENSOR_ERROR_INVALID_PARAM; - } else { - int32_t retCode = -1; - ret = client->Invoke(client, SENSOR_SERVICE_ID_SubscribeSensor, &request, &retCode, Notify); - if ((ret != LITEIPC_OK) || (retCode != SENSOR_OK)) { - HILOG_ERROR(HILOG_MODULE_APP, "%s failed, ret: %d, retCode: %d", __func__, ret, retCode); - return SENSOR_ERROR_INVALID_PARAM; - } - if (g_sensorEvent == NULL) { - g_sensorEvent = (SensorEvent *)malloc(sizeof(SensorEvent)); - if (g_sensorEvent == NULL) { - HILOG_ERROR(HILOG_MODULE_APP, "%s malloc failed", __func__); - return SENSOR_ERROR_INVALID_PARAM; - } - } } - } else { - HILOG_DEBUG(HILOG_MODULE_APP, "%s sensorChannel has been registered ", __func__); } return SENSOR_OK; } diff --git a/services/src/sensor_service.c b/services/src/sensor_service.c index f7bbb9d..10dff13 100755 --- a/services/src/sensor_service.c +++ b/services/src/sensor_service.c @@ -29,24 +29,23 @@ int32_t GetAllSensorsInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *rep HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, defaultApi is null", SENSOR_SERVICE, __func__); IpcIoPushInt32(reply, SENSOR_ERROR_UNKNOWN); return SENSOR_ERROR_UNKNOWN; - } else{ - SensorInfo *sensorInfo = NULL; - int32_t count = 0; - int32_t ret = defaultApi->GetAllSensors(&sensorInfo, &count); - if (ret != SENSOR_OK) { - HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, ret: %d", SENSOR_SERVICE, __func__, ret); - IpcIoPushInt32(reply, ret); - return ret; - } - BuffPtr dataBuff = { - .buffSz = (uint32_t)(count * sizeof(SensorInfo)), - .buff = sensorInfo - }; - IpcIoPushInt32(reply, SENSOR_OK); - IpcIoPushInt32(reply, count); - IpcIoPushDataBuff(reply, &dataBuff); - return SENSOR_OK; } + SensorInfo *sensorInfo = NULL; + int32_t count = 0; + int32_t ret = defaultApi->GetAllSensors(&sensorInfo, &count); + if (ret != SENSOR_OK) { + HILOG_ERROR(HILOG_MODULE_APP, "[SERVICE:%s]: %s failed, ret: %d", SENSOR_SERVICE, __func__, ret); + IpcIoPushInt32(reply, ret); + return ret; + } + BuffPtr dataBuff = { + .buffSz = (uint32_t)(count * sizeof(SensorInfo)), + .buff = sensorInfo + }; + IpcIoPushInt32(reply, SENSOR_OK); + IpcIoPushInt32(reply, count); + IpcIoPushDataBuff(reply, &dataBuff); + return SENSOR_OK; } int32_t ActivateSensorInvoke(SensorFeatureApi *defaultApi, IpcIo *req, IpcIo *reply) -- Gitee From eac9d43f4bc8adaa65f538764c30212ecd84186f Mon Sep 17 00:00:00 2001 From: SUE Date: Mon, 27 Sep 2021 07:19:23 +0000 Subject: [PATCH 2/2] git commit -sm "Signed-off-by:hellohyh001" --- OAT.xml | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 OAT.xml diff --git a/OAT.xml b/OAT.xml new file mode 100644 index 0000000..03b9e20 --- /dev/null +++ b/OAT.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file -- Gitee