diff --git a/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp b/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp index b4e0b79859981d49ff1d3ee12a4ae7a4ae18352f..d451dde1654428c206b4eecb4058d944d6eebd1d 100644 --- a/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/sensor/hdi_connection/adapter/src/compatible_connection.cpp @@ -70,7 +70,7 @@ int32_t CompatibleConnection::GetSensorList(std::vector& sensorList) int32_t CompatibleConnection::EnableSensor(int32_t sensorId) { int32_t ret = hdiServiceImpl_.EnableSensor(sensorId); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("enable sensor failed, sensorId: %{public}d", sensorId); return ret; } @@ -80,7 +80,7 @@ int32_t CompatibleConnection::EnableSensor(int32_t sensorId) int32_t CompatibleConnection::DisableSensor(int32_t sensorId) { int32_t ret = hdiServiceImpl_.DisableSensor(sensorId); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("disable sensor failed, sensorId: %{public}d", sensorId); return ret; } @@ -90,7 +90,7 @@ int32_t CompatibleConnection::DisableSensor(int32_t sensorId) int32_t CompatibleConnection::SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) { int32_t ret = hdiServiceImpl_.SetBatch(sensorId, samplingInterval, reportInterval); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("set batch failed, sensorId: %{public}d", sensorId); return ret; } @@ -156,7 +156,7 @@ int32_t CompatibleConnection::RegisteDataReport(ZReportDataCb cb, sptrEnable(sensorId); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("connect v1_0 hdi failed"); return ret; } @@ -105,7 +105,7 @@ int32_t HdiConnection::DisableSensor(int32_t sensorId) { CHKPR(sensorInterface_, ERR_NO_INIT); int32_t ret = sensorInterface_->Disable(sensorId); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("Disable is failed"); return ret; } @@ -117,7 +117,7 @@ int32_t HdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval, int6 { CHKPR(sensorInterface_, ERR_NO_INIT); int32_t ret = sensorInterface_->SetBatch(sensorId, samplingInterval, reportInterval); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("SetBatch is failed"); return ret; } @@ -130,7 +130,7 @@ int32_t HdiConnection::SetMode(int32_t sensorId, int32_t mode) CALL_LOG_ENTER; CHKPR(sensorInterface_, ERR_NO_INIT); int32_t ret = sensorInterface_->SetMode(sensorId, mode); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("SetMode is failed"); return ret; } @@ -142,7 +142,7 @@ int32_t HdiConnection::SetOption(int32_t sensorId, int32_t option) CALL_LOG_ENTER; CHKPR(sensorInterface_, ERR_NO_INIT); int32_t ret = sensorInterface_->SetOption(sensorId, option); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("SetOption is failed"); return ret; } @@ -155,7 +155,7 @@ int32_t HdiConnection::RegisteDataReport(ZReportDataCb cb, sptrRegister(0, eventCallback_); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("Register is failed"); return ret; } @@ -169,7 +169,7 @@ int32_t HdiConnection::DestroyHdiConnection() CALL_LOG_ENTER; CHKPR(sensorInterface_, ERR_NO_INIT); int32_t ret = sensorInterface_->Unregister(0, eventCallback_); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("Unregister is failed"); return ret; } @@ -261,18 +261,18 @@ void HdiConnection::reconnect() { CALL_LOG_ENTER; int32_t ret = ConnectHdi(); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("failed to get an instance of hdi service"); return; } ret = sensorInterface_->Register(0, eventCallback_); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("register callback fail"); return; } std::vector sensorList; ret = GetSensorList(sensorList); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("get sensor list fail"); return; } @@ -281,12 +281,12 @@ void HdiConnection::reconnect() int32_t sensorTypeId = sensorInfo.first; ret = SetBatch(sensorTypeId, sensorInfo.second.GetSamplingPeriodNs(), sensorInfo.second.GetMaxReportDelayNs()); - if (ret < 0 || sensorInfo.second.GetSensorState() != true) { + if (ret != 0 || sensorInfo.second.GetSensorState() != true) { SEN_HILOGE("sensorTypeId: %{public}d set batch fail or not need enable sensor", sensorTypeId); continue; } ret = EnableSensor(sensorTypeId); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("enable sensor fail, sensorTypeId: %{public}d", sensorTypeId); } } diff --git a/services/sensor/src/client_info.cpp b/services/sensor/src/client_info.cpp index 3b99d8738667c63394ddb8e8f777f6a29cb2ef84..fdc5643d536a6b4120ee8f66354d8609671fb9fc 100644 --- a/services/sensor/src/client_info.cpp +++ b/services/sensor/src/client_info.cpp @@ -463,7 +463,7 @@ void ClientInfo::StoreEvent(const struct SensorEvent &event) } std::vector sensors; int32_t ret = sensorHdiConnection->GetSensorList(sensors); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("GetSensorList is failed"); return; } diff --git a/services/sensor/src/sensor_service.cpp b/services/sensor/src/sensor_service.cpp index 5b4501bfd64a5166388f48f4899a31311ae1db83..a630e25c583811b95ff0768b50047fd37298a629 100644 --- a/services/sensor/src/sensor_service.cpp +++ b/services/sensor/src/sensor_service.cpp @@ -118,7 +118,7 @@ bool SensorService::InitSensorList() { std::lock_guard sensorLock(sensorsMutex_); int32_t ret = sensorHdiConnection_.GetSensorList(sensors_); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("GetSensorList is failed"); return false; } @@ -344,7 +344,7 @@ std::vector SensorService::GetSensorList() { std::lock_guard sensorLock(sensorsMutex_); int32_t ret = sensorHdiConnection_.GetSensorList(sensors_); - if (ret < 0) { + if (ret != 0) { SEN_HILOGE("GetSensorList is failed"); return sensors_; }