From de942b54a9304eaaa4be3865d741416502b8e66f Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Wed, 10 Mar 2021 16:49:36 -0800 Subject: [PATCH] Use `ro.boot.qemu` to check if the device is an emulator `ro.kernel.qemu` is deprecated. Bug: 182291166 Test: presubmit Signed-off-by: Roman Kiryanov Change-Id: I0d078fad7152c4fda9fbb1fce6bb399436e8c60a --- .../2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp | 11 ----------- .../2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp | 6 +++++- .../2.0/default/impl/vhal_v2_0/VehicleEmulator.h | 3 +++ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp index a0b566d1ee..3ef42f1683 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp @@ -272,17 +272,6 @@ static bool isDiagnosticProperty(VehiclePropConfig propConfig) { return false; } -// determine if it's running inside Android Emulator -static bool isInEmulator() { - char propValue[PROP_VALUE_MAX]; - bool isEmulator = (__system_property_get("ro.kernel.qemu", propValue) != 0); - if (!isEmulator) { - isEmulator = (__system_property_get("ro.hardware", propValue) != 0) && - (!strcmp(propValue, "ranchu") || !strcmp(propValue, "goldfish")); - } - return isEmulator; -} - // Parse supported properties list and generate vector of property values to hold current values. void EmulatedVehicleHal::onCreate() { static constexpr bool shouldUpdateStatus = true; diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp index 263ca62f42..f7d0854d1c 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp @@ -44,7 +44,7 @@ VehicleEmulator::VehicleEmulator(EmulatedVehicleHalIface* hal) : mHal{hal} { mSocketComm = std::make_unique(this); mSocketComm->start(); - if (android::base::GetBoolProperty("ro.kernel.qemu", false)) { + if (isInEmulator()) { ALOGI("Starting PipeComm"); mPipeComm = std::make_unique(this); mPipeComm->start(); @@ -226,6 +226,10 @@ void VehicleEmulator::populateProtoVehiclePropValue(vhal_proto::VehiclePropValue return proto_msg_converter::toProto(protoVal, *val); } +bool isInEmulator() { + return android::base::GetBoolProperty("ro.boot.qemu", false); +} + } // impl } // namespace V2_0 diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.h index 82947beef1..434d79b542 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.h +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.h @@ -95,6 +95,9 @@ private: std::unique_ptr mPipeComm; }; +// determine if it's running inside Android Emulator +bool isInEmulator(); + } // impl } // namespace V2_0