diff --git a/frameworks/native/BUILD.gn b/frameworks/native/BUILD.gn index f7222ca6310c7d7a4d3ff58417dc673fc012a52b..1a496e58cead77d073d13d1f42f4bfc8479a965e 100644 --- a/frameworks/native/BUILD.gn +++ b/frameworks/native/BUILD.gn @@ -56,12 +56,15 @@ ohos_shared_library("libsensor_client") { "c_utils:utils", "eventhandler:libeventhandler", "hilog:libhilog", - "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_single", "samgr:samgr_proxy", ] + if (hiviewdfx_hisysevent_enable) { + external_deps += [ "hisysevent:libhisysevent" ] + } + innerapi_tags = [ "platformsdk_indirect" ] part_name = "sensor" subsystem_name = "sensors" diff --git a/frameworks/native/src/sensor_service_client.cpp b/frameworks/native/src/sensor_service_client.cpp index 7d6ceeecaf068f56a755338116f88d5c5b636a71..4afdbe6c3c090c3b95026b389cb1f0a24b9aa86a 100644 --- a/frameworks/native/src/sensor_service_client.cpp +++ b/frameworks/native/src/sensor_service_client.cpp @@ -21,7 +21,9 @@ #include #include "death_recipient_template.h" +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE #include "hisysevent.h" +#endif // HIVIEWDFX_HISYSEVENT_ENABLE #include "hitrace_meter.h" #include "ipc_skeleton.h" #include "sensor_errors.h" @@ -96,8 +98,10 @@ int32_t SensorServiceClient::InitServiceClient() std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_MS)); retry++; } +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "InitServiceClient", "ERROR_CODE", SENSOR_NATIVE_GET_SERVICE_ERR); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Get service failed"); return SENSOR_NATIVE_GET_SERVICE_ERR; } diff --git a/frameworks/native/src/sensor_service_proxy.cpp b/frameworks/native/src/sensor_service_proxy.cpp index 18790f4a973434c300289f4831e89e8bd96b7ddd..ea93b680261cf6784ea05cab8a02d94b0b194ab4 100644 --- a/frameworks/native/src/sensor_service_proxy.cpp +++ b/frameworks/native/src/sensor_service_proxy.cpp @@ -17,7 +17,9 @@ #include +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE #include "hisysevent.h" +#endif // HIVIEWDFX_HISYSEVENT_ENABLE #include "message_parcel.h" #include "sensor_client_proxy.h" #include "sensor_errors.h" @@ -50,8 +52,10 @@ ErrCode SensorServiceProxy::EnableSensor(int32_t sensorId, int64_t samplingPerio int32_t ret = remote->SendRequest(static_cast(SensorInterfaceCode::ENABLE_SENSOR), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "EnableSensor", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); } return static_cast(ret); @@ -72,8 +76,10 @@ ErrCode SensorServiceProxy::DisableSensor(int32_t sensorId) int32_t ret = remote->SendRequest(static_cast(SensorInterfaceCode::DISABLE_SENSOR), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "DisableSensor", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); } return static_cast(ret); @@ -97,8 +103,10 @@ std::vector SensorServiceProxy::GetSensorList() int32_t ret = remote->SendRequest(static_cast(SensorInterfaceCode::GET_SENSOR_LIST), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "GetSensorList", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); return sensors; } @@ -139,8 +147,10 @@ ErrCode SensorServiceProxy::TransferDataChannel(const sptrSendRequest(static_cast(SensorInterfaceCode::TRANSFER_DATA_CHANNEL), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "TransferDataChannel", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); } sensorBasicDataChannel->CloseSendFd(); @@ -163,8 +173,10 @@ ErrCode SensorServiceProxy::DestroySensorChannel(sptr sensorClien int32_t ret = remote->SendRequest(static_cast(SensorInterfaceCode::DESTROY_SENSOR_CHANNEL), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "DestroySensorChannel", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); } return static_cast(ret); @@ -259,8 +271,10 @@ ErrCode SensorServiceProxy::CreateSocketChannel(sptr sensorClient int32_t ret = remote->SendRequest(static_cast(SensorInterfaceCode::CREATE_SOCKET_CHANNEL), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "CreateSocketChannel", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); return ERROR; } @@ -288,8 +302,10 @@ ErrCode SensorServiceProxy::DestroySocketChannel(sptr sensorClien int32_t ret = remote->SendRequest(static_cast(SensorInterfaceCode::DESTROY_SOCKET_CHANNEL), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "DestroySocketChannel", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); } return static_cast(ret); @@ -309,8 +325,10 @@ ErrCode SensorServiceProxy::EnableActiveInfoCB() int32_t ret = remote->SendRequest(static_cast(SensorInterfaceCode::ENABLE_ACTIVE_INFO_CB), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "EnableActiveInfoCB", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); } return static_cast(ret); @@ -330,8 +348,10 @@ ErrCode SensorServiceProxy::DisableActiveInfoCB() int32_t ret = remote->SendRequest(static_cast(SensorInterfaceCode::DISABLE_ACTIVE_INFO_CB), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "DisableActiveInfoCB", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); } return static_cast(ret); @@ -351,8 +371,10 @@ ErrCode SensorServiceProxy::ResetSensors() int32_t ret = remote->SendRequest(static_cast(SensorInterfaceCode::RESET_SENSORS), data, reply, option); if (ret != NO_ERROR) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "SERVICE_IPC_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "ResetSensors", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Failed, ret:%{public}d", ret); } return static_cast(ret); diff --git a/sensor.gni b/sensor.gni index 4306a82493993915a47e402827d6bb0d3a5e6be7..674b98ea01aadaa92276d1d264bc0eaf4400b478 100644 --- a/sensor.gni +++ b/sensor.gni @@ -15,6 +15,7 @@ import("//build/ohos.gni") declare_args() { rust_socket_ipc = false + hiviewdfx_hisysevent_enable = true } SUBSYSTEM_DIR = "//base/sensors/sensor" @@ -48,3 +49,11 @@ if (build_variant == "root") { } else { sensor_build_eng = false } + +if (!defined(global_parts_info) || + defined(global_parts_info.hiviewdfx_hisysevent)) { + hiviewdfx_hisysevent_enable = true + sensor_default_defines += [ "HIVIEWDFX_HISYSEVENT_ENABLE" ] +} else { + hiviewdfx_hisysevent_enable = false +} diff --git a/services/BUILD.gn b/services/BUILD.gn index f8b346c3af3103a89be453c46e2d749a19cb9b88..235b2bfe26fc054d3d9a047b42f38c35d56492bc 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -59,7 +59,6 @@ ohos_shared_library("libsensor_service") { "access_token:libtokenid_sdk", "c_utils:utils", "hilog:libhilog", - "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_single", "safwk:system_ability_fwk", @@ -70,6 +69,10 @@ ohos_shared_library("libsensor_service") { external_deps += [ "memmgr:memmgrclient" ] } + if (hiviewdfx_hisysevent_enable) { + external_deps += [ "hisysevent:libhisysevent" ] + } + if (hdf_drivers_interface_sensor) { sources += [ "hdi_connection/adapter/src/hdi_connection.cpp", @@ -147,7 +150,6 @@ ohos_static_library("libsensor_service_static") { "access_token:libtokenid_sdk", "c_utils:utils", "hilog:libhilog", - "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_single", "safwk:system_ability_fwk", @@ -158,6 +160,10 @@ ohos_static_library("libsensor_service_static") { external_deps += [ "memmgr:memmgrclient" ] } + if (hiviewdfx_hisysevent_enable) { + external_deps += [ "hisysevent:libhisysevent" ] + } + if (hdf_drivers_interface_sensor) { sources += [ "hdi_connection/adapter/src/hdi_connection.cpp", diff --git a/services/hdi_connection/adapter/src/hdi_connection.cpp b/services/hdi_connection/adapter/src/hdi_connection.cpp index 977697dd6ac59848c8cad19142eacfcf46d418d9..5cd089aba48c7bb2175b0fbb7c9169b94846fb44 100644 --- a/services/hdi_connection/adapter/src/hdi_connection.cpp +++ b/services/hdi_connection/adapter/src/hdi_connection.cpp @@ -18,7 +18,9 @@ #include #include +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE #include "hisysevent.h" +#endif // HIVIEWDFX_HISYSEVENT_ENABLE #include "iproxy_broker.h" #include "v2_0/isensor_interface.h" @@ -65,8 +67,10 @@ int32_t HdiConnection::ConnectHdi() SEN_HILOGW("Connect hdi service failed, retry:%{public}d", retry); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_MS)); } +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "ConnectHdi", "ERROR_CODE", CONNECT_SENSOR_HDF_ERR); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Connect V2_0 hdi failed"); return ERR_NO_INIT; } @@ -78,8 +82,10 @@ int32_t HdiConnection::GetSensorList(std::vector &sensorList) std::vector sensorInfos; int32_t ret = g_sensorInterface->GetAllSensorInfo(sensorInfos); if (ret != 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "GetSensorList", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Get sensor list failed"); return ret; } @@ -114,8 +120,10 @@ int32_t HdiConnection::EnableSensor(int32_t sensorId) CHKPR(g_sensorInterface, ERR_NO_INIT); int32_t ret = g_sensorInterface->Enable(sensorId); if (ret != 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "EnableSensor", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Connect V2_0 hdi failed"); return ret; } @@ -128,8 +136,10 @@ int32_t HdiConnection::DisableSensor(int32_t sensorId) CHKPR(g_sensorInterface, ERR_NO_INIT); int32_t ret = g_sensorInterface->Disable(sensorId); if (ret != 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "DisableSensor", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Disable is failed"); return ret; } @@ -142,8 +152,10 @@ int32_t HdiConnection::SetBatch(int32_t sensorId, int64_t samplingInterval, int6 CHKPR(g_sensorInterface, ERR_NO_INIT); int32_t ret = g_sensorInterface->SetBatch(sensorId, samplingInterval, reportInterval); if (ret != 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "SetBatch", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("SetBatch is failed"); return ret; } @@ -157,8 +169,10 @@ int32_t HdiConnection::SetMode(int32_t sensorId, int32_t mode) CHKPR(g_sensorInterface, ERR_NO_INIT); int32_t ret = g_sensorInterface->SetMode(sensorId, mode); if (ret != 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "SetMode", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("SetMode is failed"); return ret; } @@ -172,8 +186,10 @@ int32_t HdiConnection::RegisterDataReport(ReportDataCb cb, sptrRegister(0, g_eventCallback); if (ret != 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "RegisterDataReport", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Register is failed"); return ret; } @@ -188,8 +204,10 @@ int32_t HdiConnection::DestroyHdiConnection() CHKPR(g_sensorInterface, ERR_NO_INIT); int32_t ret = g_sensorInterface->Unregister(0, g_eventCallback); if (ret != 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "HDF_SERVICE_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "DestroyHdiConnection", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Unregister is failed"); return ret; } diff --git a/services/src/sensor_data_processer.cpp b/services/src/sensor_data_processer.cpp index 86b6f58f08b6d8a752ae9e639d34c0dbd6c5227e..8daa190728cd2f10f9710c14dbc645d7fb89b856 100644 --- a/services/src/sensor_data_processer.cpp +++ b/services/src/sensor_data_processer.cpp @@ -20,7 +20,9 @@ #include #include +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE #include "hisysevent.h" +#endif // HIVIEWDFX_HISYSEVENT_ENABLE #include "permission_util.h" #include "securec.h" #include "sensor_basic_data_channel.h" diff --git a/services/src/sensor_service.cpp b/services/src/sensor_service.cpp index eef9a2f37e133c116e5b7e2fdeb20aa22a8193f0..03c04e88b8c711eb85fef5fe272fc4b48a35876a 100644 --- a/services/src/sensor_service.cpp +++ b/services/src/sensor_service.cpp @@ -20,7 +20,9 @@ #include #include +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE #include "hisysevent.h" +#endif // HIVIEWDFX_HISYSEVENT_ENABLE #include "iservice_registry.h" #ifdef MEMMGR_ENABLE #include "mem_mgr_client.h" @@ -184,15 +186,21 @@ void SensorService::ReportSensorSysEvent(int32_t sensorId, bool enable, int32_t std::string packageName(""); AccessTokenID tokenId = clientInfo_.GetTokenIdByPid(pid); sensorManager_.GetPackageName(tokenId, packageName); +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE const int logLevel = 4; int32_t uid = clientInfo_.GetUidByPid(pid); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE if (enable) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "ENABLE_SENSOR", HiSysEvent::EventType::STATISTIC, "LEVEL", logLevel, "UID", uid, "PKG_NAME", packageName, "TYPE", sensorId); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGI("PackageName:%{public}s open the sensor, sensorId:%{public}d", packageName.c_str(), sensorId); } else { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "DISABLE_SENSOR", HiSysEvent::EventType::STATISTIC, "LEVEL", logLevel, "UID", uid, "PKG_NAME", packageName, "TYPE", sensorId); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGI("PackageName:%{public}s close the sensor, sensorId:%{public}d", packageName.c_str(), sensorId); } } diff --git a/services/src/sensor_service_stub.cpp b/services/src/sensor_service_stub.cpp index 8d07287ad15624d98f99f4c20fbf0a7568bbeaa2..3d08b091b91743a795fe1c39e9880b5af1325fa2 100644 --- a/services/src/sensor_service_stub.cpp +++ b/services/src/sensor_service_stub.cpp @@ -22,7 +22,9 @@ #include #include "accesstoken_kit.h" +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE #include "hisysevent.h" +#endif // HIVIEWDFX_HISYSEVENT_ENABLE #include "ipc_skeleton.h" #include "message_parcel.h" #include "permission_util.h" @@ -136,8 +138,10 @@ ErrCode SensorServiceStub::SensorEnableInner(MessageParcel &data, MessageParcel PermissionUtil &permissionUtil = PermissionUtil::GetInstance(); int32_t ret = permissionUtil.CheckSensorPermission(GetCallingTokenID(), sensorId); if (ret != PERMISSION_GRANTED) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "VERIFY_ACCESS_TOKEN_FAIL", HiSysEvent::EventType::SECURITY, "PKG_NAME", "SensorEnableInner", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("sensorId:%{public}d grant failed, result:%{public}d", sensorId, ret); return PERMISSION_DENIED; } @@ -160,8 +164,10 @@ ErrCode SensorServiceStub::SensorDisableInner(MessageParcel &data, MessageParcel PermissionUtil &permissionUtil = PermissionUtil::GetInstance(); int32_t ret = permissionUtil.CheckSensorPermission(GetCallingTokenID(), sensorId); if (ret != PERMISSION_GRANTED) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiSysEvent::Domain::SENSOR, "VERIFY_ACCESS_TOKEN_FAIL", HiSysEvent::EventType::SECURITY, "PKG_NAME", "SensorDisableInner", "ERROR_CODE", ret); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("sensorId:%{public}d grant failed, result:%{public}d", sensorId, ret); return PERMISSION_DENIED; } diff --git a/utils/common/BUILD.gn b/utils/common/BUILD.gn index 48bce26e0b22d0f7f21321a598905ed917336150..82a1e942c5df5015b643c1e67faa7ebe2aa8ad01 100644 --- a/utils/common/BUILD.gn +++ b/utils/common/BUILD.gn @@ -43,9 +43,13 @@ ohos_shared_library("libsensor_utils") { "access_token:libprivacy_sdk", "c_utils:utils", "hilog:libhilog", - "hisysevent:libhisysevent", "ipc:ipc_single", ] + + defines = sensor_default_defines + if (hiviewdfx_hisysevent_enable) { + external_deps += [ "hisysevent:libhisysevent" ] + } innerapi_tags = [ "platformsdk_indirect" ] part_name = "sensor" diff --git a/utils/common/src/sensor_basic_data_channel.cpp b/utils/common/src/sensor_basic_data_channel.cpp index 39c435ad720c43ae517e2b5ddc67deed210e1a37..1851b6c63cb274c4759b8ee03da48a1eedd772b2 100644 --- a/utils/common/src/sensor_basic_data_channel.cpp +++ b/utils/common/src/sensor_basic_data_channel.cpp @@ -19,7 +19,9 @@ #include #include +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE #include "hisysevent.h" +#endif // HIVIEWDFX_HISYSEVENT_ENABLE #include "sensor_errors.h" #undef LOG_TAG @@ -49,8 +51,10 @@ int32_t SensorBasicDataChannel::CreateSensorBasicChannel() int32_t socketPair[SOCKET_PAIR_SIZE] = { 0 }; if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, socketPair) != 0) { +#ifdef HIVIEWDFX_HISYSEVENT_ENABLE HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::SENSOR, "DATA_CHANNEL_EXCEPTION", HiSysEvent::EventType::FAULT, "PKG_NAME", "CreateSensorBasicChannel", "ERROR_CODE", errno); +#endif // HIVIEWDFX_HISYSEVENT_ENABLE SEN_HILOGE("Create socketpair failed"); sendFd_ = -1; receiveFd_ = -1;