diff options
author | Pavel Maltsev <pavelm@google.com> | 2018-03-30 05:26:43 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-03-30 05:26:43 +0000 |
commit | 866f07671ca0351cd99faa6c744b8a0a7ebd2d5b (patch) | |
tree | 989f41463aa17a98a1b5edbcfd57d349248a5b5c /automotive | |
parent | fe2019bfa103eecf2170909ece50366188f343e4 (diff) | |
parent | 04db1bfe603f7db83bf7dca8742909a957118ccf (diff) | |
download | platform_hardware_interfaces-866f07671ca0351cd99faa6c744b8a0a7ebd2d5b.tar.gz platform_hardware_interfaces-866f07671ca0351cd99faa6c744b8a0a7ebd2d5b.tar.bz2 platform_hardware_interfaces-866f07671ca0351cd99faa6c744b8a0a7ebd2d5b.zip |
Merge "Extend VHAL test property to allow inject events" into pi-dev
am: 04db1bfe60
Change-Id: Ic3c060d747ecd3eabda8151b6eb3ff7029887c72
Diffstat (limited to 'automotive')
3 files changed, 50 insertions, 13 deletions
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h index e54de00753..e05b333935 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h @@ -46,18 +46,35 @@ constexpr int ALL_WHEELS = * * It has the following format: * - * int32Values[0] - command (1 - start fake data generation, 0 - stop) + * int32Values[0] - command (see FakeDataCommand below for possible values) * int32Values[1] - VehicleProperty to which command applies - * - * For start command, additional data should be provided: - * int64Values[0] - periodic interval in nanoseconds - * floatValues[0] - initial value - * floatValues[1] - dispersion defines min and max range relative to initial value - * floatValues[2] - increment, with every timer tick the value will be incremented by this amount */ const int32_t kGenerateFakeDataControllingProperty = 0x0666 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::MIXED; +enum class FakeDataCommand : int32_t { + /** Stops generating of fake data that was triggered by Start command */ + Stop = 0, + + /** + * Starts fake data generation. Caller must provide additional data: + * int64Values[0] - periodic interval in nanoseconds + * floatValues[0] - initial value + * floatValues[1] - dispersion defines min and max range relative to initial value + * floatValues[2] - increment, with every timer tick the value will be incremented by this + * amount + */ + Start = 1, + + /** + * Injects key press event (HAL incorporates UP/DOWN acction and triggers 2 HAL events for every + * key-press). Caller must provide the following data: int32Values[2] - Android key code + * int32Values[3] - target display (0 - for main display, 1 - for instrument cluster, see + * VehicleDisplay) + */ + KeyPress = 2, +}; + const int32_t kHvacPowerProperties[] = { toInt(VehicleProperty::HVAC_FAN_SPEED), toInt(VehicleProperty::HVAC_FAN_DIRECTION), 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 dc34a50af1..d51576eb44 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 @@ -85,11 +85,6 @@ static std::unique_ptr<Obd2SensorStore> fillDefaultObd2Frame(size_t numVendorInt return sensorStore; } -enum class FakeDataCommand : int32_t { - Stop = 0, - Start = 1, -}; - EmulatedVehicleHal::EmulatedVehicleHal(VehiclePropertyStore* propStore) : mPropStore(propStore), mHvacPowerProps(std::begin(kHvacPowerProperties), std::end(kHvacPowerProperties)), @@ -360,10 +355,20 @@ StatusCode EmulatedVehicleHal::handleGenerateFakeDataRequest(const VehiclePropVa break; } case FakeDataCommand::Stop: { - ALOGI("%s, FakeDataCommandStop", __func__); + ALOGI("%s, FakeDataCommand::Stop", __func__); mFakeValueGenerator.stopGeneratingHalEvents(propId); break; } + case FakeDataCommand::KeyPress: { + ALOGI("%s, FakeDataCommand::KeyPress", __func__); + int32_t keyCode = request.value.int32Values[2]; + int32_t display = request.value.int32Values[3]; + doHalEvent( + createHwInputKeyProp(VehicleHwKeyInputAction::ACTION_DOWN, keyCode, display)); + doHalEvent(createHwInputKeyProp(VehicleHwKeyInputAction::ACTION_UP, keyCode, display)); + break; + } + default: { ALOGE("%s: unexpected command: %d", __func__, command); return StatusCode::INVALID_ARG; @@ -372,6 +377,19 @@ StatusCode EmulatedVehicleHal::handleGenerateFakeDataRequest(const VehiclePropVa return StatusCode::OK; } +VehicleHal::VehiclePropValuePtr EmulatedVehicleHal::createHwInputKeyProp( + VehicleHwKeyInputAction action, int32_t keyCode, int32_t targetDisplay) { + auto keyEvent = getValuePool()->obtain(VehiclePropertyType::INT32_VEC, 3); + keyEvent->prop = toInt(VehicleProperty::HW_KEY_INPUT); + keyEvent->areaId = 0; + keyEvent->timestamp = elapsedRealtimeNano(); + keyEvent->status = VehiclePropertyStatus::AVAILABLE; + keyEvent->value.int32Values[0] = toInt(action); + keyEvent->value.int32Values[1] = keyCode; + keyEvent->value.int32Values[2] = targetDisplay; + return keyEvent; +} + void EmulatedVehicleHal::onFakeValueGenerated(int32_t propId, float value) { VehiclePropValuePtr updatedPropValue {}; switch (getPropType(propId)) { 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 62fc126203..d291dbad82 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 @@ -67,6 +67,8 @@ private: StatusCode handleGenerateFakeDataRequest(const VehiclePropValue& request); void onFakeValueGenerated(int32_t propId, float value); + VehiclePropValuePtr createHwInputKeyProp(VehicleHwKeyInputAction action, int32_t keyCode, + int32_t targetDisplay); void onContinuousPropertyTimer(const std::vector<int32_t>& properties); bool isContinuousProperty(int32_t propId) const; |