Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +24 −7 Original line number Diff line number Diff line Loading @@ -46,17 +46,34 @@ 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: */ 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 * 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; 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), Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp +24 −6 Original line number Diff line number Diff line Loading @@ -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)), Loading Loading @@ -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; Loading @@ -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)) { Loading automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h +2 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h +24 −7 Original line number Diff line number Diff line Loading @@ -46,17 +46,34 @@ 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: */ 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 * 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; 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), Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.cpp +24 −6 Original line number Diff line number Diff line Loading @@ -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)), Loading Loading @@ -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; Loading @@ -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)) { Loading
automotive/vehicle/2.0/default/impl/vhal_v2_0/EmulatedVehicleHal.h +2 −0 Original line number Diff line number Diff line Loading @@ -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; Loading