diff --git a/sensor.gni b/sensor.gni index 4bf58c1eb560a503fb67c076a1dae089c4763877..bd380a54aea80e723117b962cdbf216983251c76 100644 --- a/sensor.gni +++ b/sensor.gni @@ -34,3 +34,11 @@ if (!defined(global_parts_info) || } else { hdf_drivers_interface_sensor = false } + +if(build_variant == "eng") { + sensor_default_defines += [ "BUILD_VARIANT_ENG" ] + sensor_build_eng = true; +} +else { + sensor_build_eng = false; +} \ No newline at end of file diff --git a/services/BUILD.gn b/services/BUILD.gn index 6513d2d9964e938c2a95df4027b1901184136624..2d4a88219f11cbe840c1f784475a653c05939494 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -59,7 +59,6 @@ ohos_shared_library("libsensor_service") { if (hdf_drivers_interface_sensor) { sources += [ - "hdi_connection/adapter/src/compatible_connection.cpp", "hdi_connection/adapter/src/hdi_connection.cpp", "hdi_connection/adapter/src/sensor_event_callback.cpp", "hdi_connection/hardware/src/hdi_service_impl.cpp", @@ -73,6 +72,12 @@ ohos_shared_library("libsensor_service") { "$SUBSYSTEM_DIR/services/hdi_connection/hardware/include", ] + if(sensor_build_eng) { + sources += [ + "hdi_connection/adapter/src/compatible_connection.cpp", + ] + } + external_deps += [ "drivers_interface_sensor:libsensor_proxy_1.1" ] } @@ -127,7 +132,6 @@ ohos_shared_library("libsensor_service_static") { if (hdf_drivers_interface_sensor) { sources += [ - "hdi_connection/adapter/src/compatible_connection.cpp", "hdi_connection/adapter/src/hdi_connection.cpp", "hdi_connection/adapter/src/sensor_event_callback.cpp", "hdi_connection/hardware/src/hdi_service_impl.cpp", @@ -140,6 +144,12 @@ ohos_shared_library("libsensor_service_static") { "$SUBSYSTEM_DIR/services/hdi_connection/adapter/include", "$SUBSYSTEM_DIR/services/hdi_connection/hardware/include", ] + + if(sensor_build_eng) { + sources += [ + "hdi_connection/adapter/src/compatible_connection.cpp", + ] + } external_deps += [ "drivers_interface_sensor:libsensor_proxy_1.1" ] } diff --git a/services/hdi_connection/adapter/src/compatible_connection.cpp b/services/hdi_connection/adapter/src/compatible_connection.cpp index 8a2ef420c83792bcc1801d1b85acb70b1406be02..f878ecb8db1fd14e38079ca63828c870e1e68eec 100644 --- a/services/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/hdi_connection/adapter/src/compatible_connection.cpp @@ -12,7 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifdef BUILD_VARIANT_ENG #include "compatible_connection.h" +#endif #include diff --git a/services/hdi_connection/interface/src/sensor_hdi_connection.cpp b/services/hdi_connection/interface/src/sensor_hdi_connection.cpp index d4337a9cafef430a848047867e4a298d8769a2bc..86647cd8282457fa458abcb6949ce8dc34ffd450 100644 --- a/services/hdi_connection/interface/src/sensor_hdi_connection.cpp +++ b/services/hdi_connection/interface/src/sensor_hdi_connection.cpp @@ -14,7 +14,9 @@ */ #include "sensor_hdi_connection.h" +#ifdef BUILD_VARIANT_ENG #include "compatible_connection.h" +#endif #include "hdi_connection.h" #include "hitrace_meter.h" #include "sensor_errors.h" @@ -43,13 +45,16 @@ int32_t SensorHdiConnection::ConnectHdi() int32_t ret = ConnectHdiService(); if (ret != ERR_OK) { SEN_HILOGE("Connect hdi service failed, try to connect compatible connection, ret:%{public}d", ret); - iSensorHdiConnection_ = std::make_unique(); - ret = ConnectHdiService(); - if (ret != ERR_OK) { - SEN_HILOGE("Connect compatible connection failed, ret:%{public}d", ret); - return ret; + #ifdef BUILD_VARIANT_ENG + iSensorHdiConnection_ = std::make_unique(); + ret = ConnectHdiService(); + if (ret != ERR_OK) { + SEN_HILOGE("Connect compatible connection failed, ret:%{public}d", ret); + return ret; + } + hdiConnectionStatus_ = false; + #endif } - hdiConnectionStatus_ = false; } else { hdiConnectionStatus_ = true; } @@ -83,6 +88,7 @@ int32_t SensorHdiConnection::ConnectHdiService() return ERR_OK; } +#ifdef BUILD_VARIANT_ENG int32_t SensorHdiConnection::ConnectCompatibleHdi() { if (iSensorCompatibleHdiConnection_ == nullptr) { @@ -95,6 +101,7 @@ int32_t SensorHdiConnection::ConnectCompatibleHdi() } return ERR_OK; } +#endif bool SensorHdiConnection::FindAllInSensorSet(const std::unordered_set &sensors) {