From 529145c07ce8fbcfe7b1856efe0f3c8a63f39d69 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Thu, 24 Mar 2022 17:29:55 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- frameworks/native/sensor/include/sensor_data_channel.h | 3 +-- frameworks/native/sensor/src/sensor_data_channel.cpp | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/frameworks/native/sensor/include/sensor_data_channel.h b/frameworks/native/sensor/include/sensor_data_channel.h index 782c68b4..6a4bcebd 100755 --- a/frameworks/native/sensor/include/sensor_data_channel.h +++ b/frameworks/native/sensor/include/sensor_data_channel.h @@ -28,7 +28,6 @@ namespace Sensors { typedef void (*DataChannelCB)(struct SensorEvent *events, int32_t num, void *data); class SensorDataChannel : public SensorBasicDataChannel { public: - SensorDataChannel(); ~SensorDataChannel(); static int32_t HandleEvent(int32_t fd, int32_t events, void *data); int32_t CreateSensorDataChannel(DataChannelCB callBack, void *data); @@ -37,7 +36,7 @@ public: bool IsThreadStart(); int32_t RestoreSensorDataChannel(); int32_t test = 10; - DataChannelCB dataCB_; + DataChannelCB dataCB_ = nullptr; void *privateData_ = nullptr; private: diff --git a/frameworks/native/sensor/src/sensor_data_channel.cpp b/frameworks/native/sensor/src/sensor_data_channel.cpp index 641e75f9..e87adc90 100755 --- a/frameworks/native/sensor/src/sensor_data_channel.cpp +++ b/frameworks/native/sensor/src/sensor_data_channel.cpp @@ -43,11 +43,6 @@ constexpr HiLogLabel LABEL = { LOG_CORE, SensorsLogDomain::SENSOR_NATIVE, "Senso constexpr uint32_t STOP_EVENT_ID = 0; } // namespace -SensorDataChannel::SensorDataChannel() - : dataCB_(nullptr), - privateData_(nullptr) -{} - int32_t SensorDataChannel::CreateSensorDataChannel(DataChannelCB callBack, void *data) { if (callBack == nullptr) { -- Gitee From 29a12c14a3a8693ba5050aae4bd63874f54dd15a Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sat, 26 Mar 2022 14:49:22 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- .../native/sensor/src/sensor_agent_proxy.cpp | 6 +-- .../native/sensor/src/sensor_data_channel.cpp | 18 ++++----- utils/include/report_data_callback.h | 4 +- utils/include/sensor_basic_data_channel.h | 1 - utils/include/sensor_log.h | 8 ++-- utils/include/sensors_errors.h | 32 ++++++++-------- utils/src/report_data_callback.cpp | 8 ++-- utils/src/sensor_basic_data_channel.cpp | 38 +++++++++++-------- 8 files changed, 61 insertions(+), 54 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_agent_proxy.cpp b/frameworks/native/sensor/src/sensor_agent_proxy.cpp index e7273665..37691a6f 100644 --- a/frameworks/native/sensor/src/sensor_agent_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_agent_proxy.cpp @@ -93,7 +93,7 @@ const SensorAgentProxy *SensorAgentProxy::GetSensorsObj() void SensorAgentProxy::HandleSensorData(struct SensorEvent *events, int32_t num, void *data) { if (events == nullptr || num <= 0) { - SENSOR_LOGE("events is null or num is invalid"); + SEN_HILOGE("events is null or num is invalid"); return; } struct SensorEvent eventStream; @@ -101,7 +101,7 @@ void SensorAgentProxy::HandleSensorData(struct SensorEvent *events, int32_t num, eventStream = events[i]; CHKPV(eventStream.data); if (g_subscribeMap.find(eventStream.sensorTypeId) == g_subscribeMap.end()) { - SENSOR_LOGE("sensorTypeId not in g_subscribeMap"); + SEN_HILOGE("sensorTypeId not in g_subscribeMap"); return; } g_subscribeMap[eventStream.sensorTypeId]->callback(&eventStream); @@ -119,7 +119,7 @@ int32_t SensorAgentProxy::CreateSensorDataChannel() const CHKPR(dataChannel_, INVALID_POINTER); auto ret = dataChannel_->CreateSensorDataChannel(HandleSensorData, nullptr); if (ret != ERR_OK) { - SENSOR_LOGE("create data channel failed, ret: %{public}d", ret); + SEN_HILOGE("create data channel failed, ret: %{public}d", ret); return ret; } auto &client = SensorServiceClient::GetInstance(); diff --git a/frameworks/native/sensor/src/sensor_data_channel.cpp b/frameworks/native/sensor/src/sensor_data_channel.cpp index e87adc90..799458c1 100755 --- a/frameworks/native/sensor/src/sensor_data_channel.cpp +++ b/frameworks/native/sensor/src/sensor_data_channel.cpp @@ -60,7 +60,7 @@ int32_t SensorDataChannel::RestoreSensorDataChannel() HiLog::Error(LABEL, "%{public}s dataCB_ cannot be null", __func__); return SENSOR_CHANNEL_RESTORE_CB_ERR; } - if (GetReceiveDataFd() != INVALID_FD) { + if (GetReceiveDataFd() != -1) { HiLog::Error(LABEL, "%{public}s fd not close", __func__); return SENSOR_CHANNEL_RESTORE_FD_ERR; } @@ -81,19 +81,19 @@ int32_t SensorDataChannel::InnerSensorDataChannel() auto myRunner = AppExecFwk::EventRunner::Create(true); if (myRunner == nullptr) { HiLog::Error(LABEL, "%{public}s myRunner is null", __func__); - return -1; + return ERROR; } auto handler = std::make_shared(myRunner); if (handler == nullptr) { HiLog::Error(LABEL, "%{public}s handler is null", __func__); - return -1; + return ERROR; } int32_t receiveFd = GetReceiveDataFd(); - auto inResult = handler->AddFileDescriptorListener(receiveFd, AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, listener); - if (inResult != 0) { + auto ret = handler->AddFileDescriptorListener(receiveFd, AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, listener); + if (ret != 0) { HiLog::Error(LABEL, "%{public}s AddFileDescriptorListener fail", __func__); - return -1; + return ERROR; } eventHandler_ = handler; eventRunner_ = myRunner; @@ -102,12 +102,12 @@ int32_t SensorDataChannel::InnerSensorDataChannel() bool sendEventResult = eventHandler_->SendEvent(STOP_EVENT_ID, param, delayTime); if (!sendEventResult) { HiLog::Error(LABEL, "%{public}s EventHandler SendEvent fail", __func__); - return -1; + return ERROR; } int32_t runResult = eventRunner_->Run(); if (!runResult) { HiLog::Error(LABEL, "%{public}s EventRunner run fail", __func__); - return -1; + return ERROR; } return ERR_OK; } @@ -117,7 +117,7 @@ int32_t SensorDataChannel::DestroySensorDataChannel() std::lock_guard eventRunnerLock(eventRunnerMutex_); if (eventHandler_ == nullptr || eventRunner_ == nullptr) { HiLog::Error(LABEL, "%{public}s handler or eventRunner is null", __func__); - return -1; + return ERROR; } int32_t receiveFd = GetReceiveDataFd(); eventHandler_->RemoveFileDescriptorListener(receiveFd); diff --git a/utils/include/report_data_callback.h b/utils/include/report_data_callback.h index a1b7a297..1bd9bb70 100644 --- a/utils/include/report_data_callback.h +++ b/utils/include/report_data_callback.h @@ -29,7 +29,7 @@ constexpr int32_t SENSOR_DATA_LENGHT = 64; struct CircularEventBuf { struct SensorEvent *circularBuf; - int32_t readPosition; + int32_t readPos; int32_t writePosition; int32_t eventNum; }; @@ -38,7 +38,7 @@ class ReportDataCallback : public RefBase { public: ReportDataCallback(); ~ReportDataCallback(); - int32_t ZReportDataCallback(const struct SensorEvent *event, sptr cb); + int32_t ReportEventCallback(const struct SensorEvent *event, sptr cb); struct CircularEventBuf &GetEventData(); struct CircularEventBuf eventsBuf_; }; diff --git a/utils/include/sensor_basic_data_channel.h b/utils/include/sensor_basic_data_channel.h index 9b421705..bd4d3f04 100644 --- a/utils/include/sensor_basic_data_channel.h +++ b/utils/include/sensor_basic_data_channel.h @@ -26,7 +26,6 @@ namespace OHOS { namespace Sensors { -constexpr int32_t INVALID_FD = -1; constexpr int32_t SENSOR_MAX_LENGTH = 64; struct TransferSensorEvents { uint32_t sensorTypeId; diff --git a/utils/include/sensor_log.h b/utils/include/sensor_log.h index 716fb658..aaf115f9 100755 --- a/utils/include/sensor_log.h +++ b/utils/include/sensor_log.h @@ -30,16 +30,16 @@ constexpr uint32_t SENSOR_LOG_DOMAIN = 0xD002800; #define SENSOR_FUNC_INFO __FUNCTION__, __LINE__ #endif -#define SENSOR_LOGD(fmt, ...) do { \ +#define SEN_HILOGD(fmt, ...) do { \ OHOS::HiviewDFX::HiLog::Debug(LABEL, SENSOR_FUNC_FMT fmt, SENSOR_FUNC_INFO, ##__VA_ARGS__); \ } while (0) -#define SENSOR_LOGI(fmt, ...) do { \ +#define SEN_HILOGI(fmt, ...) do { \ OHOS::HiviewDFX::HiLog::Info(LABEL, SENSOR_FUNC_FMT fmt, SENSOR_FUNC_INFO, ##__VA_ARGS__); \ } while (0) -#define SENSOR_LOGW(fmt, ...) do { \ +#define SEN_HILOGW(fmt, ...) do { \ OHOS::HiviewDFX::HiLog::Warn(LABEL, SENSOR_FUNC_FMT fmt, SENSOR_FUNC_INFO, ##__VA_ARGS__); \ } while (0) -#define SENSOR_LOGE(fmt, ...) do { \ +#define SEN_HILOGE(fmt, ...) do { \ OHOS::HiviewDFX::HiLog::Error(LABEL, SENSOR_FUNC_FMT fmt, SENSOR_FUNC_INFO, ##__VA_ARGS__); \ } while (0) #define SENSOR_LOGF(fmt, ...) do { \ diff --git a/utils/include/sensors_errors.h b/utils/include/sensors_errors.h index 48c713a7..f2de7258 100644 --- a/utils/include/sensors_errors.h +++ b/utils/include/sensors_errors.h @@ -131,7 +131,7 @@ private: #define CHKPL(cond, ...) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("%{public}s, (%{public}d), CHKPL(%{public}s) is null, do nothing", \ + SEN_HILOGE("%{public}s, (%{public}d), CHKPL(%{public}s) is null, do nothing", \ __FILE__, __LINE__, #cond); \ } \ } while (0) @@ -139,7 +139,7 @@ private: #define CHKPV(cond) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("%{public}s, (%{public}d), CHKPV(%{public}s) is null", \ + SEN_HILOGE("%{public}s, (%{public}d), CHKPV(%{public}s) is null", \ __FILE__, __LINE__, #cond); \ return; \ } \ @@ -148,7 +148,7 @@ private: #define CHKPF(cond) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("%{public}s, (%{public}d), CHKPF(%{public}s) is null", \ + SEN_HILOGE("%{public}s, (%{public}d), CHKPF(%{public}s) is null", \ __FILE__, __LINE__, #cond); \ return false; \ } \ @@ -157,7 +157,7 @@ private: #define CHKPC(cond) \ { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then continue", \ + SEN_HILOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then continue", \ __FILE__, __LINE__, #cond); \ continue; \ } \ @@ -166,7 +166,7 @@ private: #define CHKPB(cond) \ { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then break", \ + SEN_HILOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then break", \ __FILE__, __LINE__, #cond); \ break; \ } \ @@ -175,7 +175,7 @@ private: #define CHKPR(cond, r) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("%{public}s, (%{public}d), CHKPR(%{public}s) is null, return value is %{public}d", \ + SEN_HILOGE("%{public}s, (%{public}d), CHKPR(%{public}s) is null, return value is %{public}d", \ __FILE__, __LINE__, #cond, r); \ return r; \ } \ @@ -184,7 +184,7 @@ private: #define CHKPP(cond) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("%{public}s, (%{public}d), CHKPP(%{public}s) is null, return value is null", \ + SEN_HILOGE("%{public}s, (%{public}d), CHKPP(%{public}s) is null, return value is null", \ __FILE__, __LINE__, #cond); \ return nullptr; \ } \ @@ -193,7 +193,7 @@ private: #define CK(cond, ec) \ do { \ if (!(cond)) { \ - SENSOR_LOGE("%{public}s, (%{public}d), CK(%{public}s), errCode:%{public}d", \ + SEN_HILOGE("%{public}s, (%{public}d), CK(%{public}s), errCode:%{public}d", \ __FILE__, __LINE__, #cond, ec); \ } \ } while (0) @@ -202,14 +202,14 @@ private: #define CHKPL(cond) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("CHKPL(%{public}s) is null, do nothing", #cond); \ + SEN_HILOGE("CHKPL(%{public}s) is null, do nothing", #cond); \ } \ } while (0) #define CHKPV(cond) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("CHKPV(%{public}s) is null", #cond); \ + SEN_HILOGE("CHKPV(%{public}s) is null", #cond); \ return; \ } \ } while (0) @@ -217,7 +217,7 @@ private: #define CHKPF(cond) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("CHKPF(%{public}s) is null", #cond); \ + SEN_HILOGE("CHKPF(%{public}s) is null", #cond); \ return false; \ } \ } while (0) @@ -225,7 +225,7 @@ private: #define CHKPC(cond) \ { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("CHKPC(%{public}s) is null, skip then continue", #cond); \ + SEN_HILOGE("CHKPC(%{public}s) is null, skip then continue", #cond); \ continue; \ } \ } @@ -233,7 +233,7 @@ private: #define CHKPB(cond) \ { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("CHKPC(%{public}s) is null, skip then break", #cond); \ + SEN_HILOGE("CHKPC(%{public}s) is null, skip then break", #cond); \ break; \ } \ } @@ -241,7 +241,7 @@ private: #define CHKPR(cond, r) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("CHKPR(%{public}s) is null, return value is %{public}d", #cond, r); \ + SEN_HILOGE("CHKPR(%{public}s) is null, return value is %{public}d", #cond, r); \ return r; \ } \ } while (0) @@ -249,7 +249,7 @@ private: #define CHKPP(cond) \ do { \ if ((cond) == nullptr) { \ - SENSOR_LOGE("CHKPP(%{public}s) is null, return value is null", #cond); \ + SEN_HILOGE("CHKPP(%{public}s) is null, return value is null", #cond); \ return nullptr; \ } \ } while (0) @@ -257,7 +257,7 @@ private: #define CK(cond, ec) \ do { \ if (!(cond)) { \ - SENSOR_LOGE("CK(%{public}s), errCode:%{public}d", #cond, ec); \ + SEN_HILOGE("CK(%{public}s), errCode:%{public}d", #cond, ec); \ } \ } while (0) diff --git a/utils/src/report_data_callback.cpp b/utils/src/report_data_callback.cpp index 4317c7cd..702fd0e7 100644 --- a/utils/src/report_data_callback.cpp +++ b/utils/src/report_data_callback.cpp @@ -35,7 +35,7 @@ constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { ReportDataCallback::ReportDataCallback() { eventsBuf_.circularBuf = new struct SensorEvent[CIRCULAR_BUF_LEN]; - eventsBuf_.readPosition = 0; + eventsBuf_.readPos = 0; eventsBuf_.writePosition = 0; eventsBuf_.eventNum = 0; } @@ -46,12 +46,12 @@ ReportDataCallback::~ReportDataCallback() delete[] eventsBuf_.circularBuf; } eventsBuf_.circularBuf = nullptr; - eventsBuf_.readPosition = 0; + eventsBuf_.readPos = 0; eventsBuf_.writePosition = 0; eventsBuf_.eventNum = 0; } -int32_t ReportDataCallback::ZReportDataCallback(const struct SensorEvent* event, sptr cb) +int32_t ReportDataCallback::ReportEventCallback(const struct SensorEvent* event, sptr cb) { if (event == nullptr) { HiLog::Error(LABEL, "%{public}s sensor data is null", __func__); @@ -74,7 +74,7 @@ int32_t ReportDataCallback::ZReportDataCallback(const struct SensorEvent* event, cb->eventsBuf_.writePosition += 1; } if (leftSize < 1) { - cb->eventsBuf_.readPosition = cb->eventsBuf_.writePosition; + cb->eventsBuf_.readPos = cb->eventsBuf_.writePosition; } cb->eventsBuf_.eventNum += 1; if (cb->eventsBuf_.eventNum >= CIRCULAR_BUF_LEN) { diff --git a/utils/src/sensor_basic_data_channel.cpp b/utils/src/sensor_basic_data_channel.cpp index 85f10db9..8bb5bc72 100755 --- a/utils/src/sensor_basic_data_channel.cpp +++ b/utils/src/sensor_basic_data_channel.cpp @@ -34,14 +34,14 @@ constexpr int32_t DEFAULT_CHANNEL_SIZE = 2 * 1024; constexpr int32_t SOCKET_PAIR_SIZE = 2; } // namespace -SensorBasicDataChannel::SensorBasicDataChannel() : sendFd_(INVALID_FD), receiveFd_(INVALID_FD), isActive_(false) +SensorBasicDataChannel::SensorBasicDataChannel() : sendFd_(-1), receiveFd_(-1), isActive_(false) { HiLog::Debug(LABEL, "%{public}s isActive_ : %{public}d, sendFd: %{public}d", __func__, isActive_, sendFd_); } int32_t SensorBasicDataChannel::CreateSensorBasicChannel() { - if ((sendFd_ != INVALID_FD) || (receiveFd_ != INVALID_FD)) { + if ((sendFd_ != -1) || (receiveFd_ != -1)) { HiLog::Debug(LABEL, "%{public}s already create socketpair", __func__); return ERR_OK; } @@ -51,15 +51,23 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel() DmdReport::ReportException(SENSOR_DATA_CHANNEL_EXCEPTION, "CreateSensorBasicChannel", SENSOR_CHANNEL_SOCKET_CREATE_ERR); HiLog::Error(LABEL, "%{public}s create socketpair failed", __func__); - sendFd_ = INVALID_FD; - receiveFd_ = INVALID_FD; + sendFd_ = -1; + receiveFd_ = -1; return SENSOR_CHANNEL_SOCKET_CREATE_ERR; } // set socket attr - setsockopt(socketPair[0], SOL_SOCKET, SO_SNDBUF, &SENSOR_READ_DATA_SIZE, sizeof(SENSOR_READ_DATA_SIZE)); - setsockopt(socketPair[1], SOL_SOCKET, SO_RCVBUF, &SENSOR_READ_DATA_SIZE, sizeof(SENSOR_READ_DATA_SIZE)); + int32_t ret = setsockopt(socketPair[0], SOL_SOCKET, SO_SNDBUF, &SENSOR_READ_DATA_SIZE, sizeof(SENSOR_READ_DATA_SIZE)); + if (ret != 0) { + HiLog::Error(LABEL, "%{public}s setsockopt socketpair 0 failed", __func__); + return SENSOR_CHANNEL_SOCKET_CREATE_ERR; + } + ret = setsockopt(socketPair[1], SOL_SOCKET, SO_RCVBUF, &SENSOR_READ_DATA_SIZE, sizeof(SENSOR_READ_DATA_SIZE)); + if (ret != 0) { + HiLog::Error(LABEL, "%{public}s setsockopt socketpair 1 failed", __func__); + return SENSOR_CHANNEL_SOCKET_CREATE_ERR; + } int32_t bufferSize = DEFAULT_CHANNEL_SIZE; - int32_t ret = setsockopt(socketPair[0], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize)); + ret = setsockopt(socketPair[0], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize)); if (ret != 0) { HiLog::Error(LABEL, "%{public}s setsockopt socketpair 0 failed", __func__); return SENSOR_CHANNEL_SOCKET_CREATE_ERR; @@ -89,20 +97,20 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel() int32_t SensorBasicDataChannel::CreateSensorBasicChannel(MessageParcel &data) { CALL_LOG_ENTER; - if ((sendFd_ != INVALID_FD) || (receiveFd_ != INVALID_FD)) { + if ((sendFd_ != -1) || (receiveFd_ != -1)) { HiLog::Debug(LABEL, "%{public}s already create socketpair", __func__); return ERR_OK; } int32_t tmpFd = data.ReadFileDescriptor(); if (tmpFd < 0) { HiLog::Error(LABEL, "%{public}s ReadFileDescriptor failed", __func__); - sendFd_ = INVALID_FD; + sendFd_ = -1; return SENSOR_CHANNEL_DUP_ERR; } sendFd_ = dup(tmpFd); if (sendFd_ < 0) { HiLog::Error(LABEL, "%{public}s dup FileDescriptor failed", __func__); - sendFd_ = INVALID_FD; + sendFd_ = -1; return SENSOR_CHANNEL_DUP_ERR; } return ERR_OK; @@ -131,9 +139,9 @@ int32_t SensorBasicDataChannel::SendToBinder(MessageParcel &data) void SensorBasicDataChannel::CloseSendFd() { - if (sendFd_ != INVALID_FD) { + if (sendFd_ != -1) { close(sendFd_); - sendFd_ = INVALID_FD; + sendFd_ = -1; HiLog::Debug(LABEL, "%{public}s close sendFd_", __func__); } } @@ -157,7 +165,7 @@ int32_t SensorBasicDataChannel::SendData(const void *vaddr, size_t size) int32_t SensorBasicDataChannel::ReceiveData(void *vaddr, size_t size) { - if (vaddr == nullptr || (receiveFd_ == INVALID_FD)) { + if (vaddr == nullptr || (receiveFd_ == -1)) { HiLog::Error(LABEL, "%{public}s failed, vaddr is null or receiveFd_ invalid", __func__); return SENSOR_CHANNEL_RECEIVE_ADDR_ERR; } @@ -185,12 +193,12 @@ int32_t SensorBasicDataChannel::DestroySensorBasicChannel() { if (sendFd_ >= 0) { close(sendFd_); - sendFd_ = INVALID_FD; + sendFd_ = -1; HiLog::Debug(LABEL, "%{public}s close sendFd_ success", __func__); } if (receiveFd_ >= 0) { close(receiveFd_); - receiveFd_ = INVALID_FD; + receiveFd_ = -1; HiLog::Debug(LABEL, "%{public}s close receiveFd_ success", __func__); } return ERR_OK; -- Gitee From aebc52f0190963e8421dfacb943f08e62e53e70f Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sat, 26 Mar 2022 15:23:30 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- .../native/sensor/src/sensor_agent_proxy.cpp | 6 ++-- .../native/sensor/src/sensor_data_channel.cpp | 7 ++-- utils/include/report_data_callback.h | 4 +-- utils/include/sensor_basic_data_channel.h | 1 + utils/include/sensor_log.h | 8 ++--- utils/include/sensors_errors.h | 32 +++++++++---------- utils/src/report_data_callback.cpp | 8 ++--- utils/src/sensor_basic_data_channel.cpp | 24 +++++++------- 8 files changed, 45 insertions(+), 45 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_agent_proxy.cpp b/frameworks/native/sensor/src/sensor_agent_proxy.cpp index 37691a6f..e7273665 100644 --- a/frameworks/native/sensor/src/sensor_agent_proxy.cpp +++ b/frameworks/native/sensor/src/sensor_agent_proxy.cpp @@ -93,7 +93,7 @@ const SensorAgentProxy *SensorAgentProxy::GetSensorsObj() void SensorAgentProxy::HandleSensorData(struct SensorEvent *events, int32_t num, void *data) { if (events == nullptr || num <= 0) { - SEN_HILOGE("events is null or num is invalid"); + SENSOR_LOGE("events is null or num is invalid"); return; } struct SensorEvent eventStream; @@ -101,7 +101,7 @@ void SensorAgentProxy::HandleSensorData(struct SensorEvent *events, int32_t num, eventStream = events[i]; CHKPV(eventStream.data); if (g_subscribeMap.find(eventStream.sensorTypeId) == g_subscribeMap.end()) { - SEN_HILOGE("sensorTypeId not in g_subscribeMap"); + SENSOR_LOGE("sensorTypeId not in g_subscribeMap"); return; } g_subscribeMap[eventStream.sensorTypeId]->callback(&eventStream); @@ -119,7 +119,7 @@ int32_t SensorAgentProxy::CreateSensorDataChannel() const CHKPR(dataChannel_, INVALID_POINTER); auto ret = dataChannel_->CreateSensorDataChannel(HandleSensorData, nullptr); if (ret != ERR_OK) { - SEN_HILOGE("create data channel failed, ret: %{public}d", ret); + SENSOR_LOGE("create data channel failed, ret: %{public}d", ret); return ret; } auto &client = SensorServiceClient::GetInstance(); diff --git a/frameworks/native/sensor/src/sensor_data_channel.cpp b/frameworks/native/sensor/src/sensor_data_channel.cpp index 799458c1..339698d4 100755 --- a/frameworks/native/sensor/src/sensor_data_channel.cpp +++ b/frameworks/native/sensor/src/sensor_data_channel.cpp @@ -60,7 +60,7 @@ int32_t SensorDataChannel::RestoreSensorDataChannel() HiLog::Error(LABEL, "%{public}s dataCB_ cannot be null", __func__); return SENSOR_CHANNEL_RESTORE_CB_ERR; } - if (GetReceiveDataFd() != -1) { + if (GetReceiveDataFd() != INVALID_FD) { HiLog::Error(LABEL, "%{public}s fd not close", __func__); return SENSOR_CHANNEL_RESTORE_FD_ERR; } @@ -71,7 +71,7 @@ int32_t SensorDataChannel::InnerSensorDataChannel() { std::lock_guard eventRunnerLock(eventRunnerMutex_); // create basic data channel - int32_t ret = CreateSensorBasicChannel(); + auto ret = CreateSensorBasicChannel(); if (ret != ERR_OK) { HiLog::Error(LABEL, "%{public}s create basic channel failed, ret : %{public}d", __func__, ret); return ret; @@ -88,9 +88,8 @@ int32_t SensorDataChannel::InnerSensorDataChannel() HiLog::Error(LABEL, "%{public}s handler is null", __func__); return ERROR; } - int32_t receiveFd = GetReceiveDataFd(); - auto ret = handler->AddFileDescriptorListener(receiveFd, AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, listener); + ret = handler->AddFileDescriptorListener(receiveFd, AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, listener); if (ret != 0) { HiLog::Error(LABEL, "%{public}s AddFileDescriptorListener fail", __func__); return ERROR; diff --git a/utils/include/report_data_callback.h b/utils/include/report_data_callback.h index 1bd9bb70..a1b7a297 100644 --- a/utils/include/report_data_callback.h +++ b/utils/include/report_data_callback.h @@ -29,7 +29,7 @@ constexpr int32_t SENSOR_DATA_LENGHT = 64; struct CircularEventBuf { struct SensorEvent *circularBuf; - int32_t readPos; + int32_t readPosition; int32_t writePosition; int32_t eventNum; }; @@ -38,7 +38,7 @@ class ReportDataCallback : public RefBase { public: ReportDataCallback(); ~ReportDataCallback(); - int32_t ReportEventCallback(const struct SensorEvent *event, sptr cb); + int32_t ZReportDataCallback(const struct SensorEvent *event, sptr cb); struct CircularEventBuf &GetEventData(); struct CircularEventBuf eventsBuf_; }; diff --git a/utils/include/sensor_basic_data_channel.h b/utils/include/sensor_basic_data_channel.h index bd4d3f04..9b421705 100644 --- a/utils/include/sensor_basic_data_channel.h +++ b/utils/include/sensor_basic_data_channel.h @@ -26,6 +26,7 @@ namespace OHOS { namespace Sensors { +constexpr int32_t INVALID_FD = -1; constexpr int32_t SENSOR_MAX_LENGTH = 64; struct TransferSensorEvents { uint32_t sensorTypeId; diff --git a/utils/include/sensor_log.h b/utils/include/sensor_log.h index aaf115f9..716fb658 100755 --- a/utils/include/sensor_log.h +++ b/utils/include/sensor_log.h @@ -30,16 +30,16 @@ constexpr uint32_t SENSOR_LOG_DOMAIN = 0xD002800; #define SENSOR_FUNC_INFO __FUNCTION__, __LINE__ #endif -#define SEN_HILOGD(fmt, ...) do { \ +#define SENSOR_LOGD(fmt, ...) do { \ OHOS::HiviewDFX::HiLog::Debug(LABEL, SENSOR_FUNC_FMT fmt, SENSOR_FUNC_INFO, ##__VA_ARGS__); \ } while (0) -#define SEN_HILOGI(fmt, ...) do { \ +#define SENSOR_LOGI(fmt, ...) do { \ OHOS::HiviewDFX::HiLog::Info(LABEL, SENSOR_FUNC_FMT fmt, SENSOR_FUNC_INFO, ##__VA_ARGS__); \ } while (0) -#define SEN_HILOGW(fmt, ...) do { \ +#define SENSOR_LOGW(fmt, ...) do { \ OHOS::HiviewDFX::HiLog::Warn(LABEL, SENSOR_FUNC_FMT fmt, SENSOR_FUNC_INFO, ##__VA_ARGS__); \ } while (0) -#define SEN_HILOGE(fmt, ...) do { \ +#define SENSOR_LOGE(fmt, ...) do { \ OHOS::HiviewDFX::HiLog::Error(LABEL, SENSOR_FUNC_FMT fmt, SENSOR_FUNC_INFO, ##__VA_ARGS__); \ } while (0) #define SENSOR_LOGF(fmt, ...) do { \ diff --git a/utils/include/sensors_errors.h b/utils/include/sensors_errors.h index f2de7258..48c713a7 100644 --- a/utils/include/sensors_errors.h +++ b/utils/include/sensors_errors.h @@ -131,7 +131,7 @@ private: #define CHKPL(cond, ...) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("%{public}s, (%{public}d), CHKPL(%{public}s) is null, do nothing", \ + SENSOR_LOGE("%{public}s, (%{public}d), CHKPL(%{public}s) is null, do nothing", \ __FILE__, __LINE__, #cond); \ } \ } while (0) @@ -139,7 +139,7 @@ private: #define CHKPV(cond) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("%{public}s, (%{public}d), CHKPV(%{public}s) is null", \ + SENSOR_LOGE("%{public}s, (%{public}d), CHKPV(%{public}s) is null", \ __FILE__, __LINE__, #cond); \ return; \ } \ @@ -148,7 +148,7 @@ private: #define CHKPF(cond) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("%{public}s, (%{public}d), CHKPF(%{public}s) is null", \ + SENSOR_LOGE("%{public}s, (%{public}d), CHKPF(%{public}s) is null", \ __FILE__, __LINE__, #cond); \ return false; \ } \ @@ -157,7 +157,7 @@ private: #define CHKPC(cond) \ { \ if ((cond) == nullptr) { \ - SEN_HILOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then continue", \ + SENSOR_LOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then continue", \ __FILE__, __LINE__, #cond); \ continue; \ } \ @@ -166,7 +166,7 @@ private: #define CHKPB(cond) \ { \ if ((cond) == nullptr) { \ - SEN_HILOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then break", \ + SENSOR_LOGE("%{public}s, (%{public}d), CHKPC(%{public}s) is null, skip then break", \ __FILE__, __LINE__, #cond); \ break; \ } \ @@ -175,7 +175,7 @@ private: #define CHKPR(cond, r) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("%{public}s, (%{public}d), CHKPR(%{public}s) is null, return value is %{public}d", \ + SENSOR_LOGE("%{public}s, (%{public}d), CHKPR(%{public}s) is null, return value is %{public}d", \ __FILE__, __LINE__, #cond, r); \ return r; \ } \ @@ -184,7 +184,7 @@ private: #define CHKPP(cond) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("%{public}s, (%{public}d), CHKPP(%{public}s) is null, return value is null", \ + SENSOR_LOGE("%{public}s, (%{public}d), CHKPP(%{public}s) is null, return value is null", \ __FILE__, __LINE__, #cond); \ return nullptr; \ } \ @@ -193,7 +193,7 @@ private: #define CK(cond, ec) \ do { \ if (!(cond)) { \ - SEN_HILOGE("%{public}s, (%{public}d), CK(%{public}s), errCode:%{public}d", \ + SENSOR_LOGE("%{public}s, (%{public}d), CK(%{public}s), errCode:%{public}d", \ __FILE__, __LINE__, #cond, ec); \ } \ } while (0) @@ -202,14 +202,14 @@ private: #define CHKPL(cond) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("CHKPL(%{public}s) is null, do nothing", #cond); \ + SENSOR_LOGE("CHKPL(%{public}s) is null, do nothing", #cond); \ } \ } while (0) #define CHKPV(cond) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("CHKPV(%{public}s) is null", #cond); \ + SENSOR_LOGE("CHKPV(%{public}s) is null", #cond); \ return; \ } \ } while (0) @@ -217,7 +217,7 @@ private: #define CHKPF(cond) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("CHKPF(%{public}s) is null", #cond); \ + SENSOR_LOGE("CHKPF(%{public}s) is null", #cond); \ return false; \ } \ } while (0) @@ -225,7 +225,7 @@ private: #define CHKPC(cond) \ { \ if ((cond) == nullptr) { \ - SEN_HILOGE("CHKPC(%{public}s) is null, skip then continue", #cond); \ + SENSOR_LOGE("CHKPC(%{public}s) is null, skip then continue", #cond); \ continue; \ } \ } @@ -233,7 +233,7 @@ private: #define CHKPB(cond) \ { \ if ((cond) == nullptr) { \ - SEN_HILOGE("CHKPC(%{public}s) is null, skip then break", #cond); \ + SENSOR_LOGE("CHKPC(%{public}s) is null, skip then break", #cond); \ break; \ } \ } @@ -241,7 +241,7 @@ private: #define CHKPR(cond, r) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("CHKPR(%{public}s) is null, return value is %{public}d", #cond, r); \ + SENSOR_LOGE("CHKPR(%{public}s) is null, return value is %{public}d", #cond, r); \ return r; \ } \ } while (0) @@ -249,7 +249,7 @@ private: #define CHKPP(cond) \ do { \ if ((cond) == nullptr) { \ - SEN_HILOGE("CHKPP(%{public}s) is null, return value is null", #cond); \ + SENSOR_LOGE("CHKPP(%{public}s) is null, return value is null", #cond); \ return nullptr; \ } \ } while (0) @@ -257,7 +257,7 @@ private: #define CK(cond, ec) \ do { \ if (!(cond)) { \ - SEN_HILOGE("CK(%{public}s), errCode:%{public}d", #cond, ec); \ + SENSOR_LOGE("CK(%{public}s), errCode:%{public}d", #cond, ec); \ } \ } while (0) diff --git a/utils/src/report_data_callback.cpp b/utils/src/report_data_callback.cpp index 702fd0e7..08df9527 100644 --- a/utils/src/report_data_callback.cpp +++ b/utils/src/report_data_callback.cpp @@ -35,7 +35,7 @@ constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { ReportDataCallback::ReportDataCallback() { eventsBuf_.circularBuf = new struct SensorEvent[CIRCULAR_BUF_LEN]; - eventsBuf_.readPos = 0; + eventsBuf_.readPosition = 0; eventsBuf_.writePosition = 0; eventsBuf_.eventNum = 0; } @@ -46,12 +46,12 @@ ReportDataCallback::~ReportDataCallback() delete[] eventsBuf_.circularBuf; } eventsBuf_.circularBuf = nullptr; - eventsBuf_.readPos = 0; + eventsBuf_.readPosition = 0; eventsBuf_.writePosition = 0; eventsBuf_.eventNum = 0; } -int32_t ReportDataCallback::ReportEventCallback(const struct SensorEvent* event, sptr cb) +int32_t ReportDataCallback::ZReportDataCallback(const struct SensorEvent* event, sptr cb) { if (event == nullptr) { HiLog::Error(LABEL, "%{public}s sensor data is null", __func__); @@ -74,7 +74,7 @@ int32_t ReportDataCallback::ReportEventCallback(const struct SensorEvent* event, cb->eventsBuf_.writePosition += 1; } if (leftSize < 1) { - cb->eventsBuf_.readPos = cb->eventsBuf_.writePosition; + cb->eventsBuf_.readPosition = cb->eventsBuf_.writePosition; } cb->eventsBuf_.eventNum += 1; if (cb->eventsBuf_.eventNum >= CIRCULAR_BUF_LEN) { diff --git a/utils/src/sensor_basic_data_channel.cpp b/utils/src/sensor_basic_data_channel.cpp index 8bb5bc72..7ed91f12 100755 --- a/utils/src/sensor_basic_data_channel.cpp +++ b/utils/src/sensor_basic_data_channel.cpp @@ -34,14 +34,14 @@ constexpr int32_t DEFAULT_CHANNEL_SIZE = 2 * 1024; constexpr int32_t SOCKET_PAIR_SIZE = 2; } // namespace -SensorBasicDataChannel::SensorBasicDataChannel() : sendFd_(-1), receiveFd_(-1), isActive_(false) +SensorBasicDataChannel::SensorBasicDataChannel() : sendFd_(INVALID_FD), receiveFd_(INVALID_FD), isActive_(false) { HiLog::Debug(LABEL, "%{public}s isActive_ : %{public}d, sendFd: %{public}d", __func__, isActive_, sendFd_); } int32_t SensorBasicDataChannel::CreateSensorBasicChannel() { - if ((sendFd_ != -1) || (receiveFd_ != -1)) { + if ((sendFd_ != INVALID_FD) || (receiveFd_ != INVALID_FD)) { HiLog::Debug(LABEL, "%{public}s already create socketpair", __func__); return ERR_OK; } @@ -51,8 +51,8 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel() DmdReport::ReportException(SENSOR_DATA_CHANNEL_EXCEPTION, "CreateSensorBasicChannel", SENSOR_CHANNEL_SOCKET_CREATE_ERR); HiLog::Error(LABEL, "%{public}s create socketpair failed", __func__); - sendFd_ = -1; - receiveFd_ = -1; + sendFd_ = INVALID_FD; + receiveFd_ = INVALID_FD; return SENSOR_CHANNEL_SOCKET_CREATE_ERR; } // set socket attr @@ -97,20 +97,20 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel() int32_t SensorBasicDataChannel::CreateSensorBasicChannel(MessageParcel &data) { CALL_LOG_ENTER; - if ((sendFd_ != -1) || (receiveFd_ != -1)) { + if ((sendFd_ != INVALID_FD) || (receiveFd_ != INVALID_FD)) { HiLog::Debug(LABEL, "%{public}s already create socketpair", __func__); return ERR_OK; } int32_t tmpFd = data.ReadFileDescriptor(); if (tmpFd < 0) { HiLog::Error(LABEL, "%{public}s ReadFileDescriptor failed", __func__); - sendFd_ = -1; + sendFd_ = INVALID_FD; return SENSOR_CHANNEL_DUP_ERR; } sendFd_ = dup(tmpFd); if (sendFd_ < 0) { HiLog::Error(LABEL, "%{public}s dup FileDescriptor failed", __func__); - sendFd_ = -1; + sendFd_ = INVALID_FD; return SENSOR_CHANNEL_DUP_ERR; } return ERR_OK; @@ -139,9 +139,9 @@ int32_t SensorBasicDataChannel::SendToBinder(MessageParcel &data) void SensorBasicDataChannel::CloseSendFd() { - if (sendFd_ != -1) { + if (sendFd_ != INVALID_FD) { close(sendFd_); - sendFd_ = -1; + sendFd_ = INVALID_FD; HiLog::Debug(LABEL, "%{public}s close sendFd_", __func__); } } @@ -165,7 +165,7 @@ int32_t SensorBasicDataChannel::SendData(const void *vaddr, size_t size) int32_t SensorBasicDataChannel::ReceiveData(void *vaddr, size_t size) { - if (vaddr == nullptr || (receiveFd_ == -1)) { + if (vaddr == nullptr || (receiveFd_ == INVALID_FD)) { HiLog::Error(LABEL, "%{public}s failed, vaddr is null or receiveFd_ invalid", __func__); return SENSOR_CHANNEL_RECEIVE_ADDR_ERR; } @@ -193,12 +193,12 @@ int32_t SensorBasicDataChannel::DestroySensorBasicChannel() { if (sendFd_ >= 0) { close(sendFd_); - sendFd_ = -1; + sendFd_ = INVALID_FD; HiLog::Debug(LABEL, "%{public}s close sendFd_ success", __func__); } if (receiveFd_ >= 0) { close(receiveFd_); - receiveFd_ = -1; + receiveFd_ = INVALID_FD; HiLog::Debug(LABEL, "%{public}s close receiveFd_ success", __func__); } return ERR_OK; -- Gitee From 5bb44195e6ece4afe4648a935d4b4b2b863ed618 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sat, 26 Mar 2022 15:27:28 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- utils/src/report_data_callback.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/src/report_data_callback.cpp b/utils/src/report_data_callback.cpp index 08df9527..4317c7cd 100644 --- a/utils/src/report_data_callback.cpp +++ b/utils/src/report_data_callback.cpp @@ -35,7 +35,7 @@ constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { ReportDataCallback::ReportDataCallback() { eventsBuf_.circularBuf = new struct SensorEvent[CIRCULAR_BUF_LEN]; - eventsBuf_.readPosition = 0; + eventsBuf_.readPosition = 0; eventsBuf_.writePosition = 0; eventsBuf_.eventNum = 0; } @@ -46,7 +46,7 @@ ReportDataCallback::~ReportDataCallback() delete[] eventsBuf_.circularBuf; } eventsBuf_.circularBuf = nullptr; - eventsBuf_.readPosition = 0; + eventsBuf_.readPosition = 0; eventsBuf_.writePosition = 0; eventsBuf_.eventNum = 0; } @@ -74,7 +74,7 @@ int32_t ReportDataCallback::ZReportDataCallback(const struct SensorEvent* event, cb->eventsBuf_.writePosition += 1; } if (leftSize < 1) { - cb->eventsBuf_.readPosition = cb->eventsBuf_.writePosition; + cb->eventsBuf_.readPosition = cb->eventsBuf_.writePosition; } cb->eventsBuf_.eventNum += 1; if (cb->eventsBuf_.eventNum >= CIRCULAR_BUF_LEN) { -- Gitee From 8d27c9f9006123f6b374a6db33654d3125ebd886 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sat, 26 Mar 2022 15:45:23 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- utils/src/sensor_basic_data_channel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/src/sensor_basic_data_channel.cpp b/utils/src/sensor_basic_data_channel.cpp index 7ed91f12..9969c127 100755 --- a/utils/src/sensor_basic_data_channel.cpp +++ b/utils/src/sensor_basic_data_channel.cpp @@ -56,7 +56,8 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel() return SENSOR_CHANNEL_SOCKET_CREATE_ERR; } // set socket attr - int32_t ret = setsockopt(socketPair[0], SOL_SOCKET, SO_SNDBUF, &SENSOR_READ_DATA_SIZE, sizeof(SENSOR_READ_DATA_SIZE)); + int32_t ret = setsockopt(socketPair[0], SOL_SOCKET, SO_SNDBUF, &SENSOR_READ_DATA_SIZE, + sizeof(SENSOR_READ_DATA_SIZE)); if (ret != 0) { HiLog::Error(LABEL, "%{public}s setsockopt socketpair 0 failed", __func__); return SENSOR_CHANNEL_SOCKET_CREATE_ERR; -- Gitee From fc7ad413a736b6917300857818cdb1ad4644aa70 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sat, 26 Mar 2022 16:34:55 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- frameworks/native/sensor/src/sensor_data_channel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frameworks/native/sensor/src/sensor_data_channel.cpp b/frameworks/native/sensor/src/sensor_data_channel.cpp index 339698d4..d0b2cdf7 100755 --- a/frameworks/native/sensor/src/sensor_data_channel.cpp +++ b/frameworks/native/sensor/src/sensor_data_channel.cpp @@ -71,7 +71,7 @@ int32_t SensorDataChannel::InnerSensorDataChannel() { std::lock_guard eventRunnerLock(eventRunnerMutex_); // create basic data channel - auto ret = CreateSensorBasicChannel(); + int32_t ret = CreateSensorBasicChannel(); if (ret != ERR_OK) { HiLog::Error(LABEL, "%{public}s create basic channel failed, ret : %{public}d", __func__, ret); return ret; -- Gitee From 28d6031f0eb2d7c7125bba160b72eac19d1ba1e2 Mon Sep 17 00:00:00 2001 From: cff-gite Date: Sat, 26 Mar 2022 16:54:17 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- frameworks/native/sensor/src/sensor_data_channel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frameworks/native/sensor/src/sensor_data_channel.cpp b/frameworks/native/sensor/src/sensor_data_channel.cpp index d0b2cdf7..a9dff957 100755 --- a/frameworks/native/sensor/src/sensor_data_channel.cpp +++ b/frameworks/native/sensor/src/sensor_data_channel.cpp @@ -89,8 +89,8 @@ int32_t SensorDataChannel::InnerSensorDataChannel() return ERROR; } int32_t receiveFd = GetReceiveDataFd(); - ret = handler->AddFileDescriptorListener(receiveFd, AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, listener); - if (ret != 0) { + auto inResult = handler->AddFileDescriptorListener(receiveFd, AppExecFwk::FILE_DESCRIPTOR_INPUT_EVENT, listener); + if (inResult != 0) { HiLog::Error(LABEL, "%{public}s AddFileDescriptorListener fail", __func__); return ERROR; } -- Gitee From 6e3ba55be510e25d31aaf59387a946f394e6228b Mon Sep 17 00:00:00 2001 From: cff-gite Date: Mon, 28 Mar 2022 10:44:39 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9sensor=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: cff-gite --- frameworks/native/sensor/include/sensor_data_channel.h | 1 + 1 file changed, 1 insertion(+) diff --git a/frameworks/native/sensor/include/sensor_data_channel.h b/frameworks/native/sensor/include/sensor_data_channel.h index 6a4bcebd..0e767b1a 100755 --- a/frameworks/native/sensor/include/sensor_data_channel.h +++ b/frameworks/native/sensor/include/sensor_data_channel.h @@ -28,6 +28,7 @@ namespace Sensors { typedef void (*DataChannelCB)(struct SensorEvent *events, int32_t num, void *data); class SensorDataChannel : public SensorBasicDataChannel { public: + SensorDataChannel() = default; ~SensorDataChannel(); static int32_t HandleEvent(int32_t fd, int32_t events, void *data); int32_t CreateSensorDataChannel(DataChannelCB callBack, void *data); -- Gitee