diff --git a/frameworks/native/sensor/src/sensor_service_client.cpp b/frameworks/native/sensor/src/sensor_service_client.cpp index 6f06de7e06148f2c79875bea21f99ba7ba52807a..1e94dd376d33ac325f0e5a18346f94b90a493340 100755 --- a/frameworks/native/sensor/src/sensor_service_client.cpp +++ b/frameworks/native/sensor/src/sensor_service_client.cpp @@ -22,9 +22,9 @@ #include "death_recipient_template.h" #include "dmd_report.h" +#include "hitrace_meter.h" #include "ipc_skeleton.h" #include "sensor_service_proxy.h" -#include "sensor_trace.h" #include "sensors_errors.h" #include "system_ability_definition.h" @@ -104,9 +104,9 @@ int32_t SensorServiceClient::EnableSensor(uint32_t sensorId, int64_t samplingPer return ret; } CHKPR(sensorServer_, ERROR); - HITRACE_BEGIN("EnableSensor"); + StartTrace(HITRACE_TAG_SENSORS, "EnableSensor"); ret = sensorServer_->EnableSensor(sensorId, samplingPeriod, maxReportDelay); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret == ERR_OK) { UpdateSensorInfoMap(sensorId, samplingPeriod, maxReportDelay); } @@ -126,9 +126,9 @@ int32_t SensorServiceClient::DisableSensor(uint32_t sensorId) return ret; } CHKPR(sensorServer_, ERROR); - HITRACE_BEGIN("DisableSensor"); + StartTrace(HITRACE_TAG_SENSORS, "DisableSensor"); ret = sensorServer_->DisableSensor(sensorId); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret == ERR_OK) { DeleteSensorInfoItem(sensorId); } @@ -148,9 +148,9 @@ int32_t SensorServiceClient::RunCommand(uint32_t sensorId, int32_t cmdType, int3 return ret; } CHKPR(sensorServer_, ERROR); - HITRACE_BEGIN("RunCommand"); + StartTrace(HITRACE_TAG_SENSORS, "RunCommand"); ret = sensorServer_->RunCommand(sensorId, cmdType, params); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret != ERR_OK) { SEN_HILOGE("RunCommand failed"); return ret; @@ -182,9 +182,9 @@ int32_t SensorServiceClient::TransferDataChannel(sptr sensorD return ret; } CHKPR(sensorServer_, ERROR); - HITRACE_BEGIN("TransferDataChannel"); + StartTrace(HITRACE_TAG_SENSORS, "TransferDataChannel"); ret = sensorServer_->TransferDataChannel(sensorDataChannel, sensorClientStub_); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); return ret; } @@ -197,9 +197,9 @@ int32_t SensorServiceClient::DestroyDataChannel() return ret; } CHKPR(sensorServer_, ERROR); - HITRACE_BEGIN("DestroyDataChannel"); + StartTrace(HITRACE_TAG_SENSORS, "DestroyDataChannel"); ret = sensorServer_->DestroySensorChannel(sensorClientStub_); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); return ret; } diff --git a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp index c8bb5c210088bad5d4f63da9d88d9515b4bc2977..1a8d935f153da026865c41c42b869316eb15ca80 100644 --- a/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp +++ b/services/sensor/hdi_connection/interface/src/sensor_hdi_connection.cpp @@ -16,7 +16,7 @@ #include "compatible_connection.h" #include "hdi_connection.h" -#include "sensor_trace.h" +#include "hitrace_meter.h" #include "sensors_errors.h" namespace OHOS { @@ -65,9 +65,9 @@ int32_t SensorHdiConnection::GetSensorList(std::vector& sensorList) int32_t SensorHdiConnection::EnableSensor(int32_t sensorId) { - HITRACE_BEGIN("EnableSensor"); + StartTrace(HITRACE_TAG_SENSORS, "EnableSensor"); int32_t ret = iSensorHdiConnection_->EnableSensor(sensorId); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret != 0) { SEN_HILOGI("enable sensor failed, sensorId: %{public}d", sensorId); return ENABLE_SENSOR_ERR; @@ -77,9 +77,9 @@ int32_t SensorHdiConnection::EnableSensor(int32_t sensorId) int32_t SensorHdiConnection::DisableSensor(int32_t sensorId) { - HITRACE_BEGIN("DisableSensor"); + StartTrace(HITRACE_TAG_SENSORS, "DisableSensor"); int32_t ret = iSensorHdiConnection_->DisableSensor(sensorId); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret != 0) { SEN_HILOGI("disable sensor failed, sensorId: %{public}d", sensorId); return DISABLE_SENSOR_ERR; @@ -89,9 +89,9 @@ int32_t SensorHdiConnection::DisableSensor(int32_t sensorId) int32_t SensorHdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval, int64_t reportInterval) { - HITRACE_BEGIN("SetBatch"); + StartTrace(HITRACE_TAG_SENSORS, "SetBatch"); int32_t ret = iSensorHdiConnection_->SetBatch(sensorId, samplingInterval, reportInterval); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret != 0) { SEN_HILOGI("set batch failed, sensorId: %{public}d", sensorId); return SET_SENSOR_CONFIG_ERR; @@ -101,9 +101,9 @@ int32_t SensorHdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval int32_t SensorHdiConnection::SetMode(int32_t sensorId, int32_t mode) { - HITRACE_BEGIN("SetMode"); + StartTrace(HITRACE_TAG_SENSORS, "SetMode"); int32_t ret = iSensorHdiConnection_->SetMode(sensorId, mode); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret != 0) { SEN_HILOGI("set mode failed, sensorId: %{public}d", sensorId); return SET_SENSOR_MODE_ERR; @@ -113,9 +113,9 @@ int32_t SensorHdiConnection::SetMode(int32_t sensorId, int32_t mode) int32_t SensorHdiConnection::SetOption(int32_t sensorId, int32_t option) { - HITRACE_BEGIN("SetOption"); + StartTrace(HITRACE_TAG_SENSORS, "SetOption"); int32_t ret = iSensorHdiConnection_->SetOption(sensorId, option); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret != 0) { SEN_HILOGI("set option failed, sensorId: %{public}d", sensorId); return SET_SENSOR_OPTION_ERR; @@ -125,9 +125,9 @@ int32_t SensorHdiConnection::SetOption(int32_t sensorId, int32_t option) int32_t SensorHdiConnection::RunCommand(int32_t sensorId, int32_t cmd, int32_t params) { - HITRACE_BEGIN("RunCommand"); + StartTrace(HITRACE_TAG_SENSORS, "RunCommand"); int32_t ret = iSensorHdiConnection_->RunCommand(sensorId, cmd, params); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret != 0) { SEN_HILOGI("run command failed, sensorId: %{public}d", sensorId); return RUN_COMMAND_ERR; @@ -137,9 +137,9 @@ int32_t SensorHdiConnection::RunCommand(int32_t sensorId, int32_t cmd, int32_t p int32_t SensorHdiConnection::RegisteDataReport(ZReportDataCb cb, sptr reportDataCallback) { - HITRACE_BEGIN("RegisteDataReport"); + StartTrace(HITRACE_TAG_SENSORS, "RegisteDataReport"); int32_t ret = iSensorHdiConnection_->RegisteDataReport(cb, reportDataCallback); - HITRACE_END(); + FinishTrace(HITRACE_TAG_SENSORS); if (ret != 0) { SEN_HILOGI("registe dataReport failed"); return REGIST_CALLBACK_ERR; diff --git a/utils/include/sensor_trace.h b/utils/include/sensor_trace.h deleted file mode 100644 index 70e0e1bc4ec0cc5eedd666e15aaef032ff0a6a12..0000000000000000000000000000000000000000 --- a/utils/include/sensor_trace.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef SENSOR_TRACE_H -#define SENSOR_TRACE_H - -#include "hitrace_meter.h" - -namespace OHOS { -namespace Sensors { -#define HITRACE_BEGIN(name) StartTrace(HITRACE_TAG_SENSORS, name) -#define HITRACE_END() FinishTrace(HITRACE_TAG_SENSORS) -} // namespace Sensors -} // namespace OHOS -#endif // SENSOR_TRACE_H \ No newline at end of file