diff --git a/utils/src/dmd_report.cpp b/utils/src/dmd_report.cpp index dd25da825c4be36c0b64a756319108232dceca89..c83cbd7203026c856f8d99bf76cf4cffbff8f84c 100755 --- a/utils/src/dmd_report.cpp +++ b/utils/src/dmd_report.cpp @@ -79,7 +79,7 @@ void DmdReport::ReportException(int32_t eventId, const std::string &interfaceNam std::lock_guard eventLock(eventMutex_); auto eventIt = eventMap_.find(eventId); if (eventIt == eventMap_.end()) { - HiLog::Error(LABEL, "%{public}s eventId : %{public}d is not supported", __func__, eventId); + SEN_HILOGE("eventId : %{public}d is not supported", eventId); return; } int64_t curTime = GetSecondsSince1970ToNow(); @@ -89,7 +89,7 @@ void DmdReport::ReportException(int32_t eventId, const std::string &interfaceNam eventMap_[eventId] = curTime; return; } - HiLog::Warn(LABEL, "%{public}s eventId is reported every half an hour", __func__); + SEN_HILOGW("eventId is reported every half an hour"); } } // namespace Sensors } // namespace OHOS diff --git a/utils/src/miscdevice_common.cpp b/utils/src/miscdevice_common.cpp index 5520dee94930a8b71b4e36ff1d3b59d6f623971c..e7cbcf58bfd219564d5d9d03a98a7e21621bc1f6 100755 --- a/utils/src/miscdevice_common.cpp +++ b/utils/src/miscdevice_common.cpp @@ -14,6 +14,7 @@ */ #include "miscdevice_common.h" +#include "sensors_errors.h" #include "sensors_log_domain.h" namespace OHOS { @@ -33,11 +34,11 @@ bool MiscdeviceCommon::CheckCustomVibratorEffect(const std::vector &tim const std::vector &intensity, int32_t periodCount) { if ((periodCount < MIN_VIBRATOR_COUNT) || (periodCount > MAX_VIBRATOR_COUNT)) { - HiLog::Error(LABEL, "%{public}s failed, input param invalid", __func__); + SEN_HILOGE("failed, input param invalid"); return false; } if (timing.size() != intensity.size()) { - HiLog::Error(LABEL, "%{public}s failed, timing size invalid", __func__); + SEN_HILOGE("failed, timing size invalid"); return false; } int32_t totalTime = 0; @@ -45,7 +46,7 @@ bool MiscdeviceCommon::CheckCustomVibratorEffect(const std::vector &tim totalTime += timing[i]; } if (totalTime > HALF_AN_HOUR) { - HiLog::Error(LABEL, "%{public}s failed, totalTime invalid", __func__); + SEN_HILOGE("failed, totalTime invalid"); return false; } for (uint32_t i = 0; i < intensity.size(); i++) { diff --git a/utils/src/permission_util.cpp b/utils/src/permission_util.cpp index 3bdf81c63884cc29692d7b33d383131c32574eee..8cecf6c58f447b8b9dd9d863088f36bd77112529 100644 --- a/utils/src/permission_util.cpp +++ b/utils/src/permission_util.cpp @@ -51,11 +51,10 @@ bool PermissionUtil::CheckSensorPermission(AccessTokenID callerToken, int32_t se std::string permissionName = sensorPermissions_[sensorTypeId]; int32_t result = AccessTokenKit::VerifyAccessToken(callerToken, permissionName); if (result != PERMISSION_GRANTED) { - HiLog::Error(LABEL, "%{public}s sensorId: %{public}d grant failed, result: %{public}d", - __func__, sensorTypeId, result); + SEN_HILOGE("sensorId: %{public}d grant failed, result: %{public}d", sensorTypeId, result); return false; } - HiLog::Debug(LABEL, "%{public}s sensorId: %{public}d grant success", __func__, sensorTypeId); + SEN_HILOGD("sensorId: %{public}d grant success", sensorTypeId); return true; } } // namespace Sensors diff --git a/utils/src/report_data_callback.cpp b/utils/src/report_data_callback.cpp index 702fd0e7edbeb7f38ae99c18090b2edabb72e3da..3f00ae3552ae46dc2714dcded49d94cb3273c574 100644 --- a/utils/src/report_data_callback.cpp +++ b/utils/src/report_data_callback.cpp @@ -54,11 +54,11 @@ ReportDataCallback::~ReportDataCallback() int32_t ReportDataCallback::ReportEventCallback(const struct SensorEvent* event, sptr cb) { if (event == nullptr) { - HiLog::Error(LABEL, "%{public}s sensor data is null", __func__); + SEN_HILOGE("sensor data is null"); return ERROR; } if (cb == nullptr || cb->eventsBuf_.circularBuf == nullptr) { - HiLog::Error(LABEL, "%{public}s callback or circularBuf or event cannot be null", __func__); + SEN_HILOGE("callback or circularBuf or event cannot be null"); if (event->data != nullptr) { delete[] event->data; } diff --git a/utils/src/sensor.cpp b/utils/src/sensor.cpp index e5f598061fa8311531b0c04c1f48992f918f786e..76f72481ff30103d45b1faa7b28a35bd60c29777 100644 --- a/utils/src/sensor.cpp +++ b/utils/src/sensor.cpp @@ -174,55 +174,55 @@ void Sensor::SetMaxSamplePeriodNs(int64_t maxSamplePeriodNs) bool Sensor::Marshalling(Parcel &parcel) const { if (!parcel.WriteUint32(sensorId_)) { - HiLog::Error(LABEL, "%{public}s failed, write sensorId failed", __func__); + SEN_HILOGE("failed, write sensorId failed"); return false; } if (!parcel.WriteUint32(sensorTypeId_)) { - HiLog::Error(LABEL, "%{public}s failed, write sensorTypeId failed", __func__); + SEN_HILOGE("failed, write sensorTypeId failed"); return false; } if (!parcel.WriteString(sensorName_)) { - HiLog::Error(LABEL, "%{public}s failed, write sensorName failed", __func__); + SEN_HILOGE("failed, write sensorName failed"); return false; } if (!parcel.WriteString(vendorName_)) { - HiLog::Error(LABEL, "%{public}s failed, write vendorName failed", __func__); + SEN_HILOGE("failed, write vendorName failed"); return false; } if (!parcel.WriteString(firmwareVersion_)) { - HiLog::Error(LABEL, "%{public}s failed, write firmwareVersion failed", __func__); + SEN_HILOGE("failed, write firmwareVersion failed"); return false; } if (!parcel.WriteString(hardwareVersion_)) { - HiLog::Error(LABEL, "%{public}s failed, write hardwareVersion failed", __func__); + SEN_HILOGE("failed, write hardwareVersion failed"); return false; } if (!parcel.WriteFloat(maxRange_)) { - HiLog::Error(LABEL, "%{public}s failed, write maxRange failed", __func__); + SEN_HILOGE("failed, write maxRange failed"); return false; } if (!parcel.WriteFloat(resolution_)) { - HiLog::Error(LABEL, "%{public}s failed, write resolution failed", __func__); + SEN_HILOGE("failed, write resolution failed"); return false; } if (!parcel.WriteFloat(power_)) { - HiLog::Error(LABEL, "%{public}s failed, write power failed", __func__); + SEN_HILOGE("failed, write power failed"); return false; } if (!parcel.WriteUint32(flags_)) { - HiLog::Error(LABEL, "%{public}s failed, write flags failed", __func__); + SEN_HILOGE("failed, write flags failed"); return false; } if (!parcel.WriteInt32(fifoMaxEventCount_)) { - HiLog::Error(LABEL, "%{public}s failed, write fifoMaxEventCount failed", __func__); + SEN_HILOGE("failed, write fifoMaxEventCount failed"); return false; } if (!parcel.WriteInt64(minSamplePeriodNs_)) { - HiLog::Error(LABEL, "%{public}s failed, write minSamplePeriodNs failed", __func__); + SEN_HILOGE("failed, write minSamplePeriodNs failed"); return false; } if (!parcel.WriteInt64(maxSamplePeriodNs_)) { - HiLog::Error(LABEL, "%{public}s failed, write maxSamplePeriodNs failed", __func__); + SEN_HILOGE("failed, write maxSamplePeriodNs failed"); return false; } return true; @@ -232,12 +232,12 @@ std::unique_ptr Sensor::Unmarshalling(Parcel &parcel) { auto sensor = std::make_unique(); if (sensor == nullptr) { - HiLog::Error(LABEL, "%{public}s sensor cannot be null", __func__); + SEN_HILOGE("sensor cannot be null"); return nullptr; } if (!sensor->ReadFromParcel(parcel)) { - HiLog::Error(LABEL, "%{public}s ReadFromParcel failed", __func__); + SEN_HILOGE("ReadFromParcel is failed"); return nullptr; } return sensor; diff --git a/utils/src/sensor_basic_data_channel.cpp b/utils/src/sensor_basic_data_channel.cpp index de0d248765a92ab6bf0e60a3670942e4bdff23d8..2b513af97fa3cf9c8cb86faca28c4d8585c79551 100755 --- a/utils/src/sensor_basic_data_channel.cpp +++ b/utils/src/sensor_basic_data_channel.cpp @@ -36,13 +36,13 @@ constexpr int32_t SOCKET_PAIR_SIZE = 2; SensorBasicDataChannel::SensorBasicDataChannel() : sendFd_(-1), receiveFd_(-1), isActive_(false) { - HiLog::Debug(LABEL, "%{public}s isActive_ : %{public}d, sendFd: %{public}d", __func__, isActive_, sendFd_); + SEN_HILOGD("isActive_ : %{public}d, sendFd: %{public}d", isActive_, sendFd_); } int32_t SensorBasicDataChannel::CreateSensorBasicChannel() { if ((sendFd_ != -1) || (receiveFd_ != -1)) { - HiLog::Debug(LABEL, "%{public}s already create socketpair", __func__); + SEN_HILOGD("already create socketpair"); return ERR_OK; } @@ -50,7 +50,7 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel() if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, socketPair) != 0) { DmdReport::ReportException(SENSOR_DATA_CHANNEL_EXCEPTION, "CreateSensorBasicChannel", SENSOR_CHANNEL_SOCKET_CREATE_ERR); - HiLog::Error(LABEL, "%{public}s create socketpair failed", __func__); + SEN_HILOGE("create socketpair failed"); sendFd_ = -1; receiveFd_ = -1; return SENSOR_CHANNEL_SOCKET_CREATE_ERR; @@ -59,39 +59,38 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel() 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__); + SEN_HILOGE("setsockopt socketpair 0 failed"); 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__); + SEN_HILOGE("setsockopt socketpair 1 failed"); return SENSOR_CHANNEL_SOCKET_CREATE_ERR; } int32_t bufferSize = DEFAULT_CHANNEL_SIZE; ret = setsockopt(socketPair[0], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize)); if (ret != 0) { - HiLog::Error(LABEL, "%{public}s setsockopt socketpair 0 failed", __func__); + SEN_HILOGE("setsockopt socketpair 0 failed"); return SENSOR_CHANNEL_SOCKET_CREATE_ERR; } ret = setsockopt(socketPair[1], SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize)); if (ret != 0) { - HiLog::Error(LABEL, "%{public}s setsockopt socketpair 1 failed", __func__); + SEN_HILOGE("setsockopt socketpair 1 failed"); return SENSOR_CHANNEL_SOCKET_CREATE_ERR; } ret = fcntl(socketPair[0], F_SETFL, O_NONBLOCK); if (ret != 0) { - HiLog::Error(LABEL, "%{public}s fcntl socketpair 0 failed", __func__); + SEN_HILOGE("fcntl socketpair 0 failed"); return SENSOR_CHANNEL_SOCKET_CREATE_ERR; } ret = fcntl(socketPair[1], F_SETFL, O_NONBLOCK); if (ret != 0) { - HiLog::Error(LABEL, "%{public}s fcntl socketpair 1 failed", __func__); + SEN_HILOGE("fcntl socketpair 1 failed"); return SENSOR_CHANNEL_SOCKET_CREATE_ERR; } sendFd_ = socketPair[0]; receiveFd_ = socketPair[1]; - HiLog::Debug(LABEL, "%{public}s create socketpair success, receiveFd_ : %{public}d, sendFd_ : %{public}d", __func__, - receiveFd_, sendFd_); + SEN_HILOGD("create socketpair success, receiveFd_ : %{public}d, sendFd_ : %{public}d", receiveFd_, sendFd_); return ERR_OK; } @@ -99,18 +98,18 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel(MessageParcel &data) { CALL_LOG_ENTER; if ((sendFd_ != -1) || (receiveFd_ != -1)) { - HiLog::Debug(LABEL, "%{public}s already create socketpair", __func__); + SEN_HILOGD("already create socketpair"); return ERR_OK; } int32_t tmpFd = data.ReadFileDescriptor(); if (tmpFd < 0) { - HiLog::Error(LABEL, "%{public}s ReadFileDescriptor failed", __func__); + SEN_HILOGE("ReadFileDescriptor is failed"); sendFd_ = -1; return SENSOR_CHANNEL_DUP_ERR; } sendFd_ = dup(tmpFd); if (sendFd_ < 0) { - HiLog::Error(LABEL, "%{public}s dup FileDescriptor failed", __func__); + SEN_HILOGE("dup FileDescriptor is failed"); sendFd_ = -1; return SENSOR_CHANNEL_DUP_ERR; } @@ -124,14 +123,14 @@ SensorBasicDataChannel::~SensorBasicDataChannel() int32_t SensorBasicDataChannel::SendToBinder(MessageParcel &data) { - HiLog::Debug(LABEL, "%{public}s sendFd: %{public}d", __func__, sendFd_); + SEN_HILOGD("sendFd: %{public}d", sendFd_); if (sendFd_ < 0) { - HiLog::Error(LABEL, "%{public}s sendFd FileDescriptor error", __func__); + SEN_HILOGE("sendFd FileDescriptor error"); return SENSOR_CHANNEL_SENDFD_ERR; } bool result = data.WriteFileDescriptor(sendFd_); if (!result) { - HiLog::Error(LABEL, "%{public}s send sendFd_ failed", __func__); + SEN_HILOGE("send sendFd_ failed"); CloseSendFd(); return SENSOR_CHANNEL_WRITE_DESCRIPTOR_ERR; } @@ -143,14 +142,14 @@ void SensorBasicDataChannel::CloseSendFd() if (sendFd_ != -1) { close(sendFd_); sendFd_ = -1; - HiLog::Debug(LABEL, "%{public}s close sendFd_", __func__); + SEN_HILOGD("close sendFd_"); } } int32_t SensorBasicDataChannel::SendData(const void *vaddr, size_t size) { if (vaddr == nullptr || sendFd_ < 0) { - HiLog::Error(LABEL, "%{public}s failed, param is invalid", __func__); + SEN_HILOGE("failed, param is invalid"); return SENSOR_CHANNEL_SEND_ADDR_ERR; } ssize_t length; @@ -158,7 +157,7 @@ int32_t SensorBasicDataChannel::SendData(const void *vaddr, size_t size) length = send(sendFd_, vaddr, size, MSG_DONTWAIT | MSG_NOSIGNAL); } while (errno == EINTR); if (length < 0) { - HiLog::Error(LABEL, "%{public}s send fail : %{public}d, length = %{public}d", __func__, errno, (int32_t)length); + SEN_HILOGE("send fail : %{public}d, length = %{public}d", errno, (int32_t)length); return SENSOR_CHANNEL_SEND_DATA_ERR; } return ERR_OK; @@ -167,7 +166,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)) { - HiLog::Error(LABEL, "%{public}s failed, vaddr is null or receiveFd_ invalid", __func__); + SEN_HILOGE("failed, vaddr is null or receiveFd_ invalid"); return SENSOR_CHANNEL_RECEIVE_ADDR_ERR; } ssize_t length; @@ -195,12 +194,12 @@ int32_t SensorBasicDataChannel::DestroySensorBasicChannel() if (sendFd_ >= 0) { close(sendFd_); sendFd_ = -1; - HiLog::Debug(LABEL, "%{public}s close sendFd_ success", __func__); + SEN_HILOGD("close sendFd_ success"); } if (receiveFd_ >= 0) { close(receiveFd_); receiveFd_ = -1; - HiLog::Debug(LABEL, "%{public}s close receiveFd_ success", __func__); + SEN_HILOGD("close receiveFd_ success"); } return ERR_OK; } @@ -217,7 +216,7 @@ bool SensorBasicDataChannel::GetSensorStatus() const void SensorBasicDataChannel::SetSensorStatus(bool isActive) { - HiLog::Debug(LABEL, "%{public}s isActive_ : %{public}d", __func__, isActive); + SEN_HILOGD("isActive_ : %{public}d", isActive); std::unique_lock lock(statusLock_); isActive_ = isActive; return;