diff --git a/miscdevice.gni b/miscdevice.gni index a7f6ed343e18cc0791effd9239525ac73912dd4f..12489d6fc34bcf43a0c25d09da9765fe3522d040 100644 --- a/miscdevice.gni +++ b/miscdevice.gni @@ -37,3 +37,11 @@ if (!defined(global_parts_info) || } else { hdf_drivers_interface_light = false } + +if(build_variant == "eng") { + miscdevice_default_defines += [ "BUILD_VARIANT_ENG" ] + miscdevice_build_eng = true; +} +else { + miscdevice_build_eng = false; +} diff --git a/services/miscdevice_service/BUILD.gn b/services/miscdevice_service/BUILD.gn index 789b4f2e8720f22370374a34a191d37719b3a9d4..4c2b4a6186b22ecf95102c8145d348d7d5cc4b77 100644 --- a/services/miscdevice_service/BUILD.gn +++ b/services/miscdevice_service/BUILD.gn @@ -16,8 +16,6 @@ import("./../../miscdevice.gni") ohos_shared_library("libmiscdevice_service") { sources = [ - "hdi_connection/adapter/src/compatible_connection.cpp", - "hdi_connection/adapter/src/compatible_light_connection.cpp", "hdi_connection/adapter/src/hdi_connection.cpp", "hdi_connection/interface/src/light_hdi_connection.cpp", "hdi_connection/interface/src/vibrator_hdi_connection.cpp", @@ -38,6 +36,13 @@ ohos_shared_library("libmiscdevice_service") { "//third_party/cJSON", ] + if(miscdevice_build_eng) { + sources += [ + "hdi_connection/adapter/src/compatible_connection.cpp", + "hdi_connection/adapter/src/compatible_light_connection.cpp", + ] + } + cflags = [ "-Wno-error=inconsistent-missing-override" ] deps = [ "$SUBSYSTEM_DIR/utils:libmiscdevice_utils" ] @@ -100,6 +105,13 @@ ohos_shared_library("libmiscdevice_service_static") { "//third_party/cJSON", ] + if(miscdevice_build_eng) { + sources += [ + "hdi_connection/adapter/src/compatible_connection.cpp", + "hdi_connection/adapter/src/compatible_light_connection.cpp", + ] + } + cflags = [ "-Wno-error=inconsistent-missing-override" ] deps = [ "$SUBSYSTEM_DIR/utils:libmiscdevice_utils" ] diff --git a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp index 2dc885485474ddbedb3956348bed33f9ba243bcf..3233b34a6f571ff4489d0f8fde6aabd25f5c2865 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/compatible_connection.cpp +++ b/services/miscdevice_service/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 #include diff --git a/services/miscdevice_service/hdi_connection/adapter/src/compatible_light_connection.cpp b/services/miscdevice_service/hdi_connection/adapter/src/compatible_light_connection.cpp index 226884c281968ee88bc622527d0f0676699aef6a..ddab426eaf47d2be276194b332bcb4ee69d1ff12 100644 --- a/services/miscdevice_service/hdi_connection/adapter/src/compatible_light_connection.cpp +++ b/services/miscdevice_service/hdi_connection/adapter/src/compatible_light_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_light_connection.h" +#endif #include #include diff --git a/services/miscdevice_service/hdi_connection/interface/src/light_hdi_connection.cpp b/services/miscdevice_service/hdi_connection/interface/src/light_hdi_connection.cpp index 50767c0d99d41b0b98f098a10d0d36145154cda9..4b7307418cc3e909f622041471d9582210fc8a6d 100644 --- a/services/miscdevice_service/hdi_connection/interface/src/light_hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/interface/src/light_hdi_connection.cpp @@ -16,7 +16,9 @@ #include +#ifdef BUILD_VARIANT_ENG #include "compatible_light_connection.h" +#endif #ifdef HDF_DRIVERS_INTERFACE_LIGHT #include "hdi_light_connection.h" #endif // HDF_DRIVERS_INTERFACE_LIGHT @@ -41,8 +43,10 @@ int32_t LightHdiConnection::ConnectHdi() return ERR_OK; } #endif // HDF_DRIVERS_INTERFACE_LIGHT +#ifdef BUILD_VARIANT_ENG iLightHdiConnection_ = std::make_unique(); return ConnectHdiService(); +#endif } int32_t LightHdiConnection::ConnectHdiService() diff --git a/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp b/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp index 8090b6589b605cae2dc972565b9ef4c988f785d9..aebfd703a3dbdf6cc6029509c912a48c7554a632 100644 --- a/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp +++ b/services/miscdevice_service/hdi_connection/interface/src/vibrator_hdi_connection.cpp @@ -16,7 +16,9 @@ #include "hitrace_meter.h" +#ifdef BUILD_VARIANT_ENG #include "compatible_connection.h" +#endif #include "hdi_connection.h" #include "sensors_errors.h" @@ -34,8 +36,10 @@ int32_t VibratorHdiConnection::ConnectHdi() int32_t ret = iVibratorHdiConnection_->ConnectHdi(); if (ret != ERR_OK) { MISC_HILOGE("Hdi direct failed"); +#ifdef BUILD_VARIANT_ENG iVibratorHdiConnection_ = std::make_unique(); ret = iVibratorHdiConnection_->ConnectHdi(); +#endif } if (ret != ERR_OK) { MISC_HILOGE("Hdi connection failed");