From 57032fd8f936d04dd5be44ff85ef88d732a87d75 Mon Sep 17 00:00:00 2001 From: h00514358 Date: Thu, 16 Sep 2021 06:49:49 +0000 Subject: [PATCH] Signed-off-by:hellohyh001 Signed-off-by: h00514358 --- .../native/sensor/src/sensor_data_channel.cpp | 26 ------------------- interfaces/plugin/src/sensor_js.cpp | 6 ++--- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_data_channel.cpp b/frameworks/native/sensor/src/sensor_data_channel.cpp index b6693aa9..38287de6 100755 --- a/frameworks/native/sensor/src/sensor_data_channel.cpp +++ b/frameworks/native/sensor/src/sensor_data_channel.cpp @@ -57,32 +57,6 @@ SensorDataChannel::SensorDataChannel() } } -int32_t SensorDataChannel::HandleEvent(int32_t fd, int32_t events, void *data) -{ - HiLog::Debug(LABEL, "%{public}s fd : %{public}d", __func__, fd); - constexpr int32_t allowSkip = 1; - if (data == nullptr) { - HiLog::Error(LABEL, "%{public}s data cannot be null", __func__); - return allowSkip; - } - SensorDataChannel *channel = reinterpret_cast(data); - if (channel->receiveDataBuff_ == nullptr) { - HiLog::Error(LABEL, "%{public}s channel receiveDataBuff_ cannot be null", __func__); - return allowSkip; - } - int32_t len = channel->ReceiveData(channel->receiveDataBuff_, SENSOR_READ_DATA_SIZE); - while (len > 0) { - int32_t eventSize = sizeof(SensorEvent); - if (eventSize > 0) { - int32_t num = len / eventSize; - HiLog::Debug(LABEL, "%{public}s num : %{public}d", __func__, num); - channel->dataCB_(channel->receiveDataBuff_, num, channel->privateData_); - len = channel->ReceiveData(channel->receiveDataBuff_, SENSOR_READ_DATA_SIZE); - } - } - return allowSkip; -} - int32_t SensorDataChannel::CreateSensorDataChannel(DataChannelCB callBack, void *data) { if (callBack == nullptr) { diff --git a/interfaces/plugin/src/sensor_js.cpp b/interfaces/plugin/src/sensor_js.cpp index 96e611a6..f56fcf68 100755 --- a/interfaces/plugin/src/sensor_js.cpp +++ b/interfaces/plugin/src/sensor_js.cpp @@ -125,7 +125,7 @@ static int32_t SubscribeSensor(int32_t sensorTypeId, int64_t interval, RecordSen static napi_value Once(napi_env env, napi_callback_info info) { HiLog::Info(LABEL, "%{public}s in", __func__); - size_t argc; + size_t argc = 2; napi_value args[2]; napi_value thisVar; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &thisVar, NULL)); @@ -168,7 +168,7 @@ static napi_value Once(napi_env env, napi_callback_info info) static napi_value On(napi_env env, napi_callback_info info) { HiLog::Info(LABEL, "%{public}s in", __func__); - size_t argc; + size_t argc = 3; napi_value args[3]; napi_value thisVar; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &thisVar, NULL)); @@ -219,7 +219,7 @@ static napi_value On(napi_env env, napi_callback_info info) static napi_value Off(napi_env env, napi_callback_info info) { HiLog::Info(LABEL, "%{public}s in", __func__); - size_t argc; + size_t argc = 2; napi_value args[2]; napi_value thisVar; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &thisVar, NULL)); -- Gitee