Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp +23 −1 Original line number Original line Diff line number Diff line Loading @@ -15,8 +15,9 @@ */ */ #define LOG_TAG "DefaultVehicleHal_v2_0" #define LOG_TAG "DefaultVehicleHal_v2_0" #include <android/log.h> #include <android-base/macros.h> #include <android-base/macros.h> #include <android/log.h> #include <sys/system_properties.h> #include "EmulatedVehicleHal.h" #include "EmulatedVehicleHal.h" #include "JsonFakeValueGenerator.h" #include "JsonFakeValueGenerator.h" Loading Loading @@ -186,6 +187,14 @@ StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) { return StatusCode::NOT_AVAILABLE; return StatusCode::NOT_AVAILABLE; } } 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; } /** /** * After checking all conditions, such as the property is available, a real vhal will * After checking all conditions, such as the property is available, a real vhal will * sent the events to Car ECU to take actions. * sent the events to Car ECU to take actions. Loading @@ -211,6 +220,17 @@ static bool isDiagnosticProperty(VehiclePropConfig propConfig) { return false; 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. // Parse supported properties list and generate vector of property values to hold current values. void EmulatedVehicleHal::onCreate() { void EmulatedVehicleHal::onCreate() { static constexpr bool shouldUpdateStatus = true; static constexpr bool shouldUpdateStatus = true; Loading Loading @@ -261,6 +281,8 @@ void EmulatedVehicleHal::onCreate() { } } initObd2LiveFrame(*mPropStore->getConfigOrDie(OBD2_LIVE_FRAME)); initObd2LiveFrame(*mPropStore->getConfigOrDie(OBD2_LIVE_FRAME)); initObd2FreezeFrame(*mPropStore->getConfigOrDie(OBD2_FREEZE_FRAME)); initObd2FreezeFrame(*mPropStore->getConfigOrDie(OBD2_FREEZE_FRAME)); mInEmulator = isInEmulator(); ALOGD("mInEmulator=%s", mInEmulator ? "true" : "false"); } } std::vector<VehiclePropConfig> EmulatedVehicleHal::listProperties() { std::vector<VehiclePropConfig> EmulatedVehicleHal::listProperties() { Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,7 @@ private: std::unordered_set<int32_t> mHvacPowerProps; std::unordered_set<int32_t> mHvacPowerProps; RecurrentTimer mRecurrentTimer; RecurrentTimer mRecurrentTimer; VehicleHalClient* mVehicleClient; VehicleHalClient* mVehicleClient; bool mInEmulator; }; }; } // impl } // impl Loading Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp +23 −1 Original line number Original line Diff line number Diff line Loading @@ -15,8 +15,9 @@ */ */ #define LOG_TAG "DefaultVehicleHal_v2_0" #define LOG_TAG "DefaultVehicleHal_v2_0" #include <android/log.h> #include <android-base/macros.h> #include <android-base/macros.h> #include <android/log.h> #include <sys/system_properties.h> #include "EmulatedVehicleHal.h" #include "EmulatedVehicleHal.h" #include "JsonFakeValueGenerator.h" #include "JsonFakeValueGenerator.h" Loading Loading @@ -186,6 +187,14 @@ StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) { return StatusCode::NOT_AVAILABLE; return StatusCode::NOT_AVAILABLE; } } 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; } /** /** * After checking all conditions, such as the property is available, a real vhal will * After checking all conditions, such as the property is available, a real vhal will * sent the events to Car ECU to take actions. * sent the events to Car ECU to take actions. Loading @@ -211,6 +220,17 @@ static bool isDiagnosticProperty(VehiclePropConfig propConfig) { return false; 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. // Parse supported properties list and generate vector of property values to hold current values. void EmulatedVehicleHal::onCreate() { void EmulatedVehicleHal::onCreate() { static constexpr bool shouldUpdateStatus = true; static constexpr bool shouldUpdateStatus = true; Loading Loading @@ -261,6 +281,8 @@ void EmulatedVehicleHal::onCreate() { } } initObd2LiveFrame(*mPropStore->getConfigOrDie(OBD2_LIVE_FRAME)); initObd2LiveFrame(*mPropStore->getConfigOrDie(OBD2_LIVE_FRAME)); initObd2FreezeFrame(*mPropStore->getConfigOrDie(OBD2_FREEZE_FRAME)); initObd2FreezeFrame(*mPropStore->getConfigOrDie(OBD2_FREEZE_FRAME)); mInEmulator = isInEmulator(); ALOGD("mInEmulator=%s", mInEmulator ? "true" : "false"); } } std::vector<VehiclePropConfig> EmulatedVehicleHal::listProperties() { std::vector<VehiclePropConfig> EmulatedVehicleHal::listProperties() { Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,7 @@ private: std::unordered_set<int32_t> mHvacPowerProps; std::unordered_set<int32_t> mHvacPowerProps; RecurrentTimer mRecurrentTimer; RecurrentTimer mRecurrentTimer; VehicleHalClient* mVehicleClient; VehicleHalClient* mVehicleClient; bool mInEmulator; }; }; } // impl } // impl Loading