Merge "Use ro.boot.qemu to check if the device is an emulator" am: 03fb28b9fc am: f3593338c0 am: 02118721a7 am: 5b30be06fa

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1627762

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6b31a932d919a855b904bc594f2f24feff0d71b4
This commit is contained in:
Roman Kiryanov
2021-03-13 04:03:36 +00:00
committed by Automerger Merge Worker
3 changed files with 8 additions and 12 deletions

View File

@@ -276,17 +276,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;

View File

@@ -44,7 +44,7 @@ VehicleEmulator::VehicleEmulator(EmulatedVehicleHalIface* hal) : mHal{hal} {
mSocketComm = std::make_unique<SocketComm>(this);
mSocketComm->start();
if (android::base::GetBoolProperty("ro.kernel.qemu", false)) {
if (isInEmulator()) {
ALOGI("Starting PipeComm");
mPipeComm = std::make_unique<PipeComm>(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

View File

@@ -95,6 +95,9 @@ private:
std::unique_ptr<PipeComm> mPipeComm;
};
// determine if it's running inside Android Emulator
bool isInEmulator();
} // impl
} // namespace V2_0