diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-03-12 23:17:32 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-03-12 23:17:32 +0000 |
commit | aba045f5617fb9cdacc8c52483db82d765b117d9 (patch) | |
tree | aa2846b0a17ea774a524233e0c3917816544233f | |
parent | 7a669c97e60baff3e3bf0e9207b13540f89567ed (diff) | |
parent | 092efbd9f47b038bab33072dd8f5c2bd0f8ab50d (diff) | |
download | android_hardware_interfaces-aba045f5617fb9cdacc8c52483db82d765b117d9.tar.gz android_hardware_interfaces-aba045f5617fb9cdacc8c52483db82d765b117d9.tar.bz2 android_hardware_interfaces-aba045f5617fb9cdacc8c52483db82d765b117d9.zip |
Snap for 6290189 from 092efbd9f47b038bab33072dd8f5c2bd0f8ab50d to qt-qpr3-release
Change-Id: I1edd50c1aa0b7f3c8637919fb0ce4569606220fd
-rw-r--r-- | automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp | 26 | ||||
-rw-r--r-- | automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h | 1 |
2 files changed, 25 insertions, 2 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 ba81a521a..79ce81c4d 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 @@ -15,8 +15,9 @@ */ #define LOG_TAG "DefaultVehicleHal_v2_0" -#include <android/log.h> #include <android-base/macros.h> +#include <android/log.h> +#include <sys/system_properties.h> #include "EmulatedVehicleHal.h" #include "JsonFakeValueGenerator.h" @@ -203,8 +204,16 @@ StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) { } getEmulatorOrDie()->doSetValueFromClient(propValue); - doHalEvent(getValuePool()->obtain(propValue)); + if (mInEmulator && propValue.prop == toInt(VehicleProperty::DISPLAY_BRIGHTNESS)) { + // Emulator does not support remote brightness control, b/139959479 + // do not send it down so that it does not bring unnecessary property change event + // return other error code, such NOT_AVAILABLE, causes Emulator to be freezing + // TODO: return StatusCode::NOT_AVAILABLE once the above issue is fixed + return StatusCode::OK; + } + + doHalEvent(getValuePool()->obtain(propValue)); return StatusCode::OK; } @@ -219,6 +228,17 @@ 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; @@ -269,6 +289,8 @@ void EmulatedVehicleHal::onCreate() { } initObd2LiveFrame(*mPropStore->getConfigOrDie(OBD2_LIVE_FRAME)); initObd2FreezeFrame(*mPropStore->getConfigOrDie(OBD2_FREEZE_FRAME)); + mInEmulator = isInEmulator(); + ALOGD("mInEmulator=%s", mInEmulator ? "true" : "false"); } std::vector<VehiclePropConfig> EmulatedVehicleHal::listProperties() { diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h index 78895e3db..367a6ec96 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h @@ -86,6 +86,7 @@ private: std::unordered_set<int32_t> mHvacPowerProps; RecurrentTimer mRecurrentTimer; GeneratorHub mGeneratorHub; + bool mInEmulator; }; } // impl |