diff --git a/automotive/vehicle/2.0/Android.bp b/automotive/vehicle/2.0/Android.bp index a13359e16d..a0d20f352e 100644 --- a/automotive/vehicle/2.0/Android.bp +++ b/automotive/vehicle/2.0/Android.bp @@ -56,6 +56,7 @@ hidl_interface { "VehiclePropertyChangeMode", "VehiclePropertyGroup", "VehiclePropertyOperation", + "VehiclePropertyStatus", "VehiclePropertyType", "VehicleRadioConstants", "VehicleTurnSignal", diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h index 8e9089d600..6086c01116 100644 --- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h +++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/SubscriptionManager.h @@ -49,7 +49,7 @@ public: } void addOrUpdateSubscription(const SubscribeOptions &opts); - bool isSubscribed(int32_t propId, int32_t areaId, SubscribeFlags flags); + bool isSubscribed(int32_t propId, SubscribeFlags flags); std::vector getSubscribedProperties() const; private: @@ -87,8 +87,7 @@ public: /** * Constructs SubscriptionManager * - * @param onPropertyUnsubscribed - this callback function will be called when there are no - * more client subscribed to particular property. + * @param onPropertyUnsubscribed - called when no more clients are subscribed to the property. */ SubscriptionManager(const OnPropertyUnsubscribed& onPropertyUnsubscribed) : mOnPropertyUnsubscribed(onPropertyUnsubscribed), @@ -115,9 +114,7 @@ public: const std::vector>& propValues, SubscribeFlags flags) const; - std::list> getSubscribedClients(int32_t propId, - int32_t area, - SubscribeFlags flags) const; + std::list> getSubscribedClients(int32_t propId, SubscribeFlags flags) const; /** * If there are no clients subscribed to given properties than callback function provided * in the constructor will be called. @@ -125,10 +122,9 @@ public: void unsubscribe(ClientId clientId, int32_t propId); private: std::list> getSubscribedClientsLocked(int32_t propId, - int32_t area, SubscribeFlags flags) const; - bool updateHalEventSubscriptionLocked(const SubscribeOptions &opts, SubscribeOptions* out); + bool updateHalEventSubscriptionLocked(const SubscribeOptions& opts, SubscribeOptions* out); void addClientToPropMapLocked(int32_t propId, const sp& client); diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h index 8203a1e61d..fd28483a4e 100644 --- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h +++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleHal.h @@ -48,17 +48,14 @@ public: /** * Subscribe to HAL property events. This method might be called multiple - * times for the same vehicle property to update subscribed areas or sample - * rate. + * times for the same vehicle property to update sample rate. * * @param property to subscribe - * @param areas a bitwise vehicle areas or 0 for all supported areas * @param sampleRate sample rate in Hz for properties that support sample * rate, e.g. for properties with * VehiclePropertyChangeMode::CONTINUOUS */ virtual StatusCode subscribe(int32_t property, - int32_t areas, float sampleRate) = 0; /** diff --git a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h index 05c649bee0..359bb6df31 100644 --- a/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h +++ b/automotive/vehicle/2.0/default/common/include/vhal_v2_0/VehicleObjectPool.h @@ -191,9 +191,8 @@ public: VehiclePropValuePool& operator=(VehiclePropValuePool&) = delete; private: bool isDisposable(VehiclePropertyType type, size_t vecSize) const { - return vecSize > mMaxRecyclableVectorSize || - VehiclePropertyType::STRING == type || - VehiclePropertyType::COMPLEX == type; + return vecSize > mMaxRecyclableVectorSize || VehiclePropertyType::STRING == type || + VehiclePropertyType::MIXED == type; } RecyclableType obtainDisposable(VehiclePropertyType valueType, diff --git a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp index 74f0a5f55e..a7d5f509e7 100644 --- a/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp +++ b/automotive/vehicle/2.0/default/common/src/SubscriptionManager.cpp @@ -34,23 +34,12 @@ namespace V2_0 { bool mergeSubscribeOptions(const SubscribeOptions &oldOpts, const SubscribeOptions &newOpts, SubscribeOptions *outResult) { - - int32_t updatedAreas = oldOpts.vehicleAreas; - if (updatedAreas != kAllSupportedAreas) { - updatedAreas = newOpts.vehicleAreas != kAllSupportedAreas - ? updatedAreas | newOpts.vehicleAreas - : kAllSupportedAreas; - } - float updatedRate = std::max(oldOpts.sampleRate, newOpts.sampleRate); SubscribeFlags updatedFlags = SubscribeFlags(oldOpts.flags | newOpts.flags); - bool updated = updatedRate > oldOpts.sampleRate - || updatedAreas != oldOpts.vehicleAreas - || updatedFlags != oldOpts.flags; + bool updated = (updatedRate > oldOpts.sampleRate) || (updatedFlags != oldOpts.flags); if (updated) { *outResult = oldOpts; - outResult->vehicleAreas = updatedAreas; outResult->sampleRate = updatedRate; outResult->flags = updatedFlags; } @@ -75,15 +64,13 @@ void HalClient::addOrUpdateSubscription(const SubscribeOptions &opts) { } bool HalClient::isSubscribed(int32_t propId, - int32_t areaId, SubscribeFlags flags) { auto it = mSubscriptions.find(propId); if (it == mSubscriptions.end()) { return false; } const SubscribeOptions& opts = it->second; - bool res = (opts.flags & flags) - && (opts.vehicleAreas == 0 || areaId == 0 || opts.vehicleAreas & areaId); + bool res = (opts.flags & flags); return res; } @@ -139,8 +126,7 @@ std::list SubscriptionManager::distributeValuesToClients( MuxGuard g(mLock); for (const auto& propValue: propValues) { VehiclePropValue* v = propValue.get(); - auto clients = getSubscribedClientsLocked( - v->prop, v->areaId, flags); + auto clients = getSubscribedClientsLocked(v->prop, flags); for (const auto& client : clients) { clientValuesMap[client].push_back(v); } @@ -158,21 +144,21 @@ std::list SubscriptionManager::distributeValuesToClients( return clientValues; } -std::list> SubscriptionManager::getSubscribedClients( - int32_t propId, int32_t area, SubscribeFlags flags) const { +std::list> SubscriptionManager::getSubscribedClients(int32_t propId, + SubscribeFlags flags) const { MuxGuard g(mLock); - return getSubscribedClientsLocked(propId, area, flags); + return getSubscribedClientsLocked(propId, flags); } std::list> SubscriptionManager::getSubscribedClientsLocked( - int32_t propId, int32_t area, SubscribeFlags flags) const { + int32_t propId, SubscribeFlags flags) const { std::list> subscribedClients; sp propClients = getClientsForPropertyLocked(propId); if (propClients.get() != nullptr) { for (size_t i = 0; i < propClients->size(); i++) { const auto& client = propClients->itemAt(i); - if (client->isSubscribed(propId, area, flags)) { + if (client->isSubscribed(propId, flags)) { subscribedClients.push_back(client); } } diff --git a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp index ae543bb3fc..1918421a54 100644 --- a/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp +++ b/automotive/vehicle/2.0/default/common/src/VehicleHalManager.cpp @@ -142,15 +142,6 @@ Return VehicleHalManager::subscribe(const sp &call return StatusCode::INVALID_ARG; } - int32_t areas = isGlobalProp(prop) ? 0 : ops.vehicleAreas; - if (areas != 0 && ((areas & config->supportedAreas) != areas)) { - ALOGE("Failed to subscribe property 0x%x. Requested areas 0x%x are " - "out of supported range of 0x%x", prop, ops.vehicleAreas, - config->supportedAreas); - return StatusCode::INVALID_ARG; - } - - ops.vehicleAreas = areas; ops.sampleRate = checkSampleRate(*config, ops.sampleRate); } @@ -164,7 +155,7 @@ Return VehicleHalManager::subscribe(const sp &call } for (auto opt : updatedOptions) { - mHal->subscribe(opt.propId, opt.vehicleAreas, opt.sampleRate); + mHal->subscribe(opt.propId, opt.sampleRate); } return StatusCode::OK; @@ -224,8 +215,8 @@ void VehicleHalManager::onHalEvent(VehiclePropValuePtr v) { void VehicleHalManager::onHalPropertySetError(StatusCode errorCode, int32_t property, int32_t areaId) { - const auto& clients = mSubscriptionManager.getSubscribedClients( - property, 0, SubscribeFlags::HAL_EVENT); + const auto& clients = + mSubscriptionManager.getSubscribedClients(property, SubscribeFlags::HAL_EVENT); for (auto client : clients) { client->getCallback()->onPropertySetError(errorCode, property, areaId); @@ -326,8 +317,7 @@ bool VehicleHalManager::checkReadPermission(const VehiclePropConfig &config) con } void VehicleHalManager::handlePropertySetEvent(const VehiclePropValue& value) { - auto clients = mSubscriptionManager.getSubscribedClients( - value.prop, value.areaId, SubscribeFlags::SET_CALL); + auto clients = mSubscriptionManager.getSubscribedClients(value.prop, SubscribeFlags::SET_CALL); for (auto client : clients) { client->getCallback()->onPropertySet(value); } diff --git a/automotive/vehicle/2.0/default/common/src/VehicleObjectPool.cpp b/automotive/vehicle/2.0/default/common/src/VehicleObjectPool.cpp index ac1245a087..3f98a94091 100644 --- a/automotive/vehicle/2.0/default/common/src/VehicleObjectPool.cpp +++ b/automotive/vehicle/2.0/default/common/src/VehicleObjectPool.cpp @@ -82,7 +82,7 @@ VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainString( } VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainComplex() { - return obtain(VehiclePropertyType::COMPLEX); + return obtain(VehiclePropertyType::MIXED); } VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainRecylable( @@ -138,18 +138,14 @@ void VehiclePropValuePool::InternalPool::recycle(VehiclePropValue* o) { } bool VehiclePropValuePool::InternalPool::check(VehiclePropValue::RawValue* v) { - return check(&v->int32Values, - (VehiclePropertyType::INT32 == mPropType - || VehiclePropertyType::INT32_VEC == mPropType - || VehiclePropertyType::BOOLEAN == mPropType)) - && check(&v->floatValues, - (VehiclePropertyType::FLOAT == mPropType - || VehiclePropertyType::FLOAT_VEC == mPropType)) - && check(&v->int64Values, - VehiclePropertyType::INT64 == mPropType) - && check(&v->bytes, - VehiclePropertyType::BYTES == mPropType) - && v->stringValue.size() == 0; + return check(&v->int32Values, (VehiclePropertyType::INT32 == mPropType || + VehiclePropertyType::INT32_VEC == mPropType || + VehiclePropertyType::BOOLEAN == mPropType)) && + check(&v->floatValues, (VehiclePropertyType::FLOAT == mPropType || + VehiclePropertyType::FLOAT_VEC == mPropType)) && + check(&v->int64Values, (VehiclePropertyType::INT64 == mPropType || + VehiclePropertyType::INT64_VEC == mPropType)) && + check(&v->bytes, VehiclePropertyType::BYTES == mPropType) && v->stringValue.size() == 0; } VehiclePropValue* VehiclePropValuePool::InternalPool::createObject() { diff --git a/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp b/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp index 9146fa1228..34a63806aa 100644 --- a/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp +++ b/automotive/vehicle/2.0/default/common/src/VehicleUtils.cpp @@ -42,13 +42,14 @@ std::unique_ptr createVehiclePropValue( val->value.floatValues.resize(vecSize); break; case VehiclePropertyType::INT64: + case VehiclePropertyType::INT64_VEC: val->value.int64Values.resize(vecSize); break; case VehiclePropertyType::BYTES: val->value.bytes.resize(vecSize); break; case VehiclePropertyType::STRING: - case VehiclePropertyType::COMPLEX: + case VehiclePropertyType::MIXED: break; // Valid, but nothing to do. default: ALOGE("createVehiclePropValue: unknown type: %d", type); @@ -68,6 +69,7 @@ size_t getVehicleRawValueVectorSize( case VehiclePropertyType::FLOAT_VEC: return value.floatValues.size(); case VehiclePropertyType::INT64: + case VehiclePropertyType::INT64_VEC: return value.int64Values.size(); case VehiclePropertyType::BYTES: return value.bytes.size(); 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 71601a0868..18e8c40069 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 @@ -54,10 +54,8 @@ constexpr int ALL_WHEELS = * 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::COMPLEX; +const int32_t kGenerateFakeDataControllingProperty = + 0x0666 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::MIXED; const int32_t kHvacPowerProperties[] = { toInt(VehicleProperty::HVAC_FAN_SPEED), @@ -238,7 +236,8 @@ const ConfigDeclaration kVehicleProperties[]{ .prop = toInt(VehicleProperty::HVAC_POWER_ON), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - .supportedAreas = toInt(VehicleAreaZone::ROW_1), + .areaConfigs = {VehicleAreaConfig{ + .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}, // TODO(bryaneyler): Ideally, this is generated dynamically from // kHvacPowerProperties. .configString = "0x12400500,0x12400501" // HVAC_FAN_SPEED,HVAC_FAN_DIRECTION @@ -249,51 +248,52 @@ const ConfigDeclaration kVehicleProperties[]{ .config = {.prop = toInt(VehicleProperty::HVAC_DEFROSTER), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - .supportedAreas = - VehicleAreaWindow::FRONT_WINDSHIELD | VehicleAreaWindow::REAR_WINDSHIELD}, + .areaConfigs = + {VehicleAreaConfig{.areaId = toInt(VehicleAreaWindow::FRONT_WINDSHIELD)}, + VehicleAreaConfig{.areaId = toInt(VehicleAreaWindow::REAR_WINDSHIELD)}}}, .initialValue = {.int32Values = {0}} // Will be used for all areas. }, {.config = {.prop = toInt(VehicleProperty::HVAC_RECIRC_ON), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - .supportedAreas = toInt(VehicleAreaZone::ROW_1)}, + .areaConfigs = {VehicleAreaConfig{ + .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}}, .initialValue = {.int32Values = {1}}}, {.config = {.prop = toInt(VehicleProperty::HVAC_AC_ON), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - .supportedAreas = toInt(VehicleAreaZone::ROW_1)}, + .areaConfigs = {VehicleAreaConfig{ + .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}}, .initialValue = {.int32Values = {1}}}, {.config = {.prop = toInt(VehicleProperty::HVAC_AUTO_ON), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - .supportedAreas = toInt(VehicleAreaZone::ROW_1)}, + .areaConfigs = {VehicleAreaConfig{ + .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}}, .initialValue = {.int32Values = {1}}}, {.config = {.prop = toInt(VehicleProperty::HVAC_FAN_SPEED), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - .supportedAreas = toInt(VehicleAreaZone::ROW_1), - .areaConfigs = {VehicleAreaConfig{.areaId = toInt(VehicleAreaZone::ROW_1), - .minInt32Value = 1, - .maxInt32Value = 7}}}, + .areaConfigs = {VehicleAreaConfig{ + .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT), + .minInt32Value = 1, + .maxInt32Value = 7}}}, .initialValue = {.int32Values = {3}}}, - {.config = - { - .prop = toInt(VehicleProperty::HVAC_FAN_DIRECTION), - .access = VehiclePropertyAccess::READ_WRITE, - .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - .supportedAreas = toInt(VehicleAreaZone::ROW_1), - }, + {.config = {.prop = toInt(VehicleProperty::HVAC_FAN_DIRECTION), + .access = VehiclePropertyAccess::READ_WRITE, + .changeMode = VehiclePropertyChangeMode::ON_CHANGE, + .areaConfigs = {VehicleAreaConfig{ + .areaId = (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)}}}, .initialValue = {.int32Values = {toInt(VehicleHvacFanDirection::FACE)}}}, {.config = {.prop = toInt(VehicleProperty::HVAC_TEMPERATURE_SET), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - .supportedAreas = VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT, .areaConfigs = {VehicleAreaConfig{ .areaId = toInt(VehicleAreaZone::ROW_1_LEFT), .minFloatValue = 16, 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 6bc0522403..16d2b0b52f 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 @@ -138,8 +138,9 @@ StatusCode EmulatedVehicleHal::set(const VehiclePropValue& propValue) { return status; } } else if (mHvacPowerProps.count(propValue.prop)) { - auto hvacPowerOn = mPropStore->readValueOrNull(toInt(VehicleProperty::HVAC_POWER_ON), - toInt(VehicleAreaZone::ROW_1)); + auto hvacPowerOn = mPropStore->readValueOrNull( + toInt(VehicleProperty::HVAC_POWER_ON), + (VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT)); if (hvacPowerOn && hvacPowerOn->value.int32Values.size() == 1 && hvacPowerOn->value.int32Values[0] == 0) { @@ -177,7 +178,7 @@ static bool isDiagnosticProperty(VehiclePropConfig propConfig) { void EmulatedVehicleHal::onCreate() { for (auto& it : kVehicleProperties) { VehiclePropConfig cfg = it.config; - int32_t supportedAreas = cfg.supportedAreas; + int32_t numAreas = cfg.areaConfigs.size(); if (isDiagnosticProperty(cfg)) { // do not write an initial empty value for the diagnostic properties @@ -185,22 +186,26 @@ void EmulatedVehicleHal::onCreate() { continue; } - // A global property will have supportedAreas = 0 + // A global property will have only a single area if (isGlobalProp(cfg.prop)) { - supportedAreas = 0; + numAreas = 1; } - // This loop is a do-while so it executes at least once to handle global properties - do { - int32_t curArea = supportedAreas; - supportedAreas &= supportedAreas - 1; // Clear the right-most bit of supportedAreas. - curArea ^= supportedAreas; // Set curArea to the previously cleared bit. + for (int i = 0; i < numAreas; i++) { + int32_t curArea; + + if (isGlobalProp(cfg.prop)) { + curArea = 0; + } else { + curArea = cfg.areaConfigs[i].areaId; + } // Create a separate instance for each individual zone VehiclePropValue prop = { .prop = cfg.prop, .areaId = curArea, }; + if (it.initialAreaValues.size() > 0) { auto valueForAreaIt = it.initialAreaValues.find(curArea); if (valueForAreaIt != it.initialAreaValues.end()) { @@ -213,8 +218,7 @@ void EmulatedVehicleHal::onCreate() { prop.value = it.initialValue; } mPropStore->writeValue(prop); - - } while (supportedAreas != 0); + } } initObd2LiveFrame(*mPropStore->getConfigOrDie(OBD2_LIVE_FRAME)); initObd2FreezeFrame(*mPropStore->getConfigOrDie(OBD2_FREEZE_FRAME)); @@ -246,8 +250,7 @@ void EmulatedVehicleHal::onContinuousPropertyTimer(const std::vector& p } } -StatusCode EmulatedVehicleHal::subscribe(int32_t property, int32_t, - float sampleRate) { +StatusCode EmulatedVehicleHal::subscribe(int32_t property, float sampleRate) { ALOGI("%s propId: 0x%x, sampleRate: %f", __func__, property, sampleRate); if (isContinuousProperty(property)) { @@ -389,7 +392,7 @@ void EmulatedVehicleHal::initStaticConfig() { } void EmulatedVehicleHal::initObd2LiveFrame(const VehiclePropConfig& propConfig) { - auto liveObd2Frame = createVehiclePropValue(VehiclePropertyType::COMPLEX, 0); + auto liveObd2Frame = createVehiclePropValue(VehiclePropertyType::MIXED, 0); auto sensorStore = fillDefaultObd2Frame(static_cast(propConfig.configArray[0]), static_cast(propConfig.configArray[1])); sensorStore->fillPropValue("", liveObd2Frame.get()); @@ -406,7 +409,7 @@ void EmulatedVehicleHal::initObd2FreezeFrame(const VehiclePropConfig& propConfig "P0102" "P0123"}; for (auto&& dtc : sampleDtcs) { - auto freezeFrame = createVehiclePropValue(VehiclePropertyType::COMPLEX, 0); + auto freezeFrame = createVehiclePropValue(VehiclePropertyType::MIXED, 0); sensorStore->fillPropValue(dtc, freezeFrame.get()); freezeFrame->prop = OBD2_FREEZE_FRAME; 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 99d7edbc78..62fc126203 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 @@ -53,7 +53,7 @@ public: VehiclePropValuePtr get(const VehiclePropValue& requestedPropValue, StatusCode* outStatus) override; StatusCode set(const VehiclePropValue& propValue) override; - StatusCode subscribe(int32_t property, int32_t areas, float sampleRate) override; + StatusCode subscribe(int32_t property, float sampleRate) override; StatusCode unsubscribe(int32_t property) override; // Methods from EmulatedVehicleHalIface diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp index 38cb74375e..fca8e9ed44 100644 --- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp +++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/VehicleEmulator.cpp @@ -234,10 +234,6 @@ void VehicleEmulator::populateProtoVehicleConfig(emulator::VehiclePropConfig* pr protoCfg->set_change_mode(toInt(cfg.changeMode)); protoCfg->set_value_type(toInt(getPropType(cfg.prop))); - if (!isGlobalProp(cfg.prop)) { - protoCfg->set_supported_areas(cfg.supportedAreas); - } - for (auto& configElement : cfg.configArray) { protoCfg->add_config_array(configElement); } @@ -251,9 +247,10 @@ void VehicleEmulator::populateProtoVehicleConfig(emulator::VehiclePropConfig* pr case VehiclePropertyType::STRING: case VehiclePropertyType::BOOLEAN: case VehiclePropertyType::INT32_VEC: + case VehiclePropertyType::INT64_VEC: case VehiclePropertyType::FLOAT_VEC: case VehiclePropertyType::BYTES: - case VehiclePropertyType::COMPLEX: + case VehiclePropertyType::MIXED: // Do nothing. These types don't have min/max values break; case VehiclePropertyType::INT64: diff --git a/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp b/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp index 5688dd6da1..4865e9e80d 100644 --- a/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp +++ b/automotive/vehicle/2.0/default/tests/SubscriptionManager_test.cpp @@ -51,11 +51,7 @@ public: } hidl_vec subscrToProp1 = { - SubscribeOptions { - .propId = PROP1, - .vehicleAreas = toInt(VehicleAreaZone::ROW_1_LEFT), - .flags = SubscribeFlags::HAL_EVENT - }, + SubscribeOptions{.propId = PROP1, .flags = SubscribeFlags::HAL_EVENT}, }; hidl_vec subscrToProp2 = { @@ -66,15 +62,8 @@ public: }; hidl_vec subscrToProp1and2 = { - SubscribeOptions { - .propId = PROP1, - .vehicleAreas = toInt(VehicleAreaZone::ROW_1_LEFT), - .flags = SubscribeFlags::HAL_EVENT - }, - SubscribeOptions { - .propId = PROP2, - .flags = SubscribeFlags::HAL_EVENT - }, + SubscribeOptions{.propId = PROP1, .flags = SubscribeFlags::HAL_EVENT}, + SubscribeOptions{.propId = PROP2, .flags = SubscribeFlags::HAL_EVENT}, }; static std::list> extractCallbacks( @@ -87,14 +76,11 @@ public: } std::list> clientsToProp1() { - return manager.getSubscribedClients(PROP1, - toInt(VehicleAreaZone::ROW_1_LEFT), - SubscribeFlags::DEFAULT); + return manager.getSubscribedClients(PROP1, SubscribeFlags::DEFAULT); } std::list> clientsToProp2() { - return manager.getSubscribedClients(PROP2, 0, - SubscribeFlags::DEFAULT); + return manager.getSubscribedClients(PROP2, SubscribeFlags::DEFAULT); } void onPropertyUnsubscribed(int propertyId) { @@ -126,7 +112,6 @@ TEST_F(SubscriptionManagerTest, multipleClients) { auto clients = manager.getSubscribedClients( PROP1, - toInt(VehicleAreaZone::ROW_1_LEFT), SubscribeFlags::HAL_EVENT); ASSERT_ALL_EXISTS({cb1, cb2}, extractCallbacks(clients)); @@ -137,24 +122,14 @@ TEST_F(SubscriptionManagerTest, negativeCases) { ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(1, cb1, subscrToProp1, &updatedOptions)); - // Wrong zone - auto clients = manager.getSubscribedClients( - PROP1, - toInt(VehicleAreaZone::ROW_2_LEFT), - SubscribeFlags::HAL_EVENT); - ASSERT_TRUE(clients.empty()); - // Wrong prop - clients = manager.getSubscribedClients( - toInt(VehicleProperty::AP_POWER_BOOTUP_REASON), - toInt(VehicleAreaZone::ROW_1_LEFT), - SubscribeFlags::HAL_EVENT); + auto clients = manager.getSubscribedClients(toInt(VehicleProperty::AP_POWER_BOOTUP_REASON), + SubscribeFlags::HAL_EVENT); ASSERT_TRUE(clients.empty()); // Wrong flag clients = manager.getSubscribedClients( PROP1, - toInt(VehicleAreaZone::ROW_1_LEFT), SubscribeFlags::SET_CALL); ASSERT_TRUE(clients.empty()); } @@ -166,7 +141,6 @@ TEST_F(SubscriptionManagerTest, mulipleSubscriptions) { auto clients = manager.getSubscribedClients( PROP1, - toInt(VehicleAreaZone::ROW_1_LEFT), SubscribeFlags::DEFAULT); ASSERT_EQ((size_t) 1, clients.size()); ASSERT_EQ(cb1, clients.front()->getCallback()); @@ -176,18 +150,15 @@ TEST_F(SubscriptionManagerTest, mulipleSubscriptions) { ASSERT_EQ(StatusCode::OK, manager.addOrUpdateSubscription(1, cb1, { SubscribeOptions { .propId = PROP1, - .vehicleAreas = toInt(VehicleAreaZone::ROW_2), .flags = SubscribeFlags::DEFAULT } }, &updatedOptions)); clients = manager.getSubscribedClients(PROP1, - toInt(VehicleAreaZone::ROW_1_LEFT), SubscribeFlags::DEFAULT); ASSERT_ALL_EXISTS({cb1}, extractCallbacks(clients)); clients = manager.getSubscribedClients(PROP1, - toInt(VehicleAreaZone::ROW_2), SubscribeFlags::DEFAULT); ASSERT_ALL_EXISTS({cb1}, extractCallbacks(clients)); } diff --git a/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp b/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp index 4864d5d464..5b195db804 100644 --- a/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp +++ b/automotive/vehicle/2.0/default/tests/VehicleHalManager_test.cpp @@ -106,7 +106,6 @@ public: } StatusCode subscribe(int32_t /* property */, - int32_t /* areas */, float /* sampleRate */) override { return StatusCode::OK; } @@ -286,6 +285,7 @@ TEST_F(VehicleHalManagerTest, subscribe) { cb->reset(); VehiclePropValue actualValue(*subscribedValue.get()); + actualValue.status = VehiclePropertyStatus::AVAILABLE; hal->sendPropEvent(std::move(subscribedValue)); ASSERT_TRUE(cb->waitForExpectedEvents(1)) << "Events received: " diff --git a/automotive/vehicle/2.0/default/tests/VehicleHalTestUtils.h b/automotive/vehicle/2.0/default/tests/VehicleHalTestUtils.h index 2a064175a7..3cabcf292b 100644 --- a/automotive/vehicle/2.0/default/tests/VehicleHalTestUtils.h +++ b/automotive/vehicle/2.0/default/tests/VehicleHalTestUtils.h @@ -29,10 +29,8 @@ namespace automotive { namespace vehicle { namespace V2_0 { -constexpr int32_t kCustomComplexProperty = 0xbeef - | VehiclePropertyGroup::VENDOR - | VehiclePropertyType::COMPLEX - | VehicleArea::GLOBAL; +constexpr int32_t kCustomComplexProperty = + 0xbeef | VehiclePropertyGroup::VENDOR | VehiclePropertyType::MIXED | VehicleArea::GLOBAL; const VehiclePropConfig kVehicleProperties[] = { { @@ -46,8 +44,6 @@ const VehiclePropConfig kVehicleProperties[] = { .prop = toInt(VehicleProperty::HVAC_FAN_SPEED), .access = VehiclePropertyAccess::READ_WRITE, .changeMode = VehiclePropertyChangeMode::ON_CHANGE, - .supportedAreas = static_cast( - VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT), .areaConfigs = { VehicleAreaConfig { .areaId = toInt(VehicleAreaZone::ROW_1_LEFT), @@ -66,8 +62,6 @@ const VehiclePropConfig kVehicleProperties[] = { .prop = toInt(VehicleProperty::HVAC_SEAT_TEMPERATURE), .access = VehiclePropertyAccess::WRITE, .changeMode = VehiclePropertyChangeMode::ON_SET, - .supportedAreas = static_cast( - VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT), .areaConfigs = { VehicleAreaConfig { .areaId = toInt(VehicleAreaZone::ROW_1_LEFT), diff --git a/automotive/vehicle/2.0/types.hal b/automotive/vehicle/2.0/types.hal index d88479abb0..f673d1ad61 100644 --- a/automotive/vehicle/2.0/types.hal +++ b/automotive/vehicle/2.0/types.hal @@ -27,6 +27,7 @@ enum VehiclePropertyType : int32_t { INT32 = 0x00400000, INT32_VEC = 0x00410000, INT64 = 0x00500000, + INT64_VEC = 0x00510000, FLOAT = 0x00600000, FLOAT_VEC = 0x00610000, BYTES = 0x00700000, @@ -35,7 +36,7 @@ enum VehiclePropertyType : int32_t { * Any combination of scalar or vector types. The exact format must be * provided in the description of the property. */ - COMPLEX = 0x00e00000, + MIXED = 0x00e00000, MASK = 0x00ff0000 }; @@ -315,7 +316,7 @@ enum VehicleProperty: int32_t { WHEEL_TICK = ( 0x0306 | VehiclePropertyGroup:SYSTEM - | VehiclePropertyType:COMPLEX + | VehiclePropertyType:MIXED | VehicleArea:GLOBAL), @@ -1673,7 +1674,7 @@ enum VehicleProperty: int32_t { /** * Vehicle Maps Service (VMS) message * - * This property uses COMPLEX data to communicate vms messages. + * This property uses MIXED data to communicate vms messages. * * Its contents are to be interpreted as follows: * the indices defined in VmsMessageIntegerValuesIndex are to be used to @@ -1689,7 +1690,7 @@ enum VehicleProperty: int32_t { VEHICLE_MAP_SERVICE = ( 0x0C00 | VehiclePropertyGroup:SYSTEM - | VehiclePropertyType:COMPLEX + | VehiclePropertyType:MIXED | VehicleArea:GLOBAL), /** @@ -1736,7 +1737,7 @@ enum VehicleProperty: int32_t { OBD2_LIVE_FRAME = ( 0x0D00 | VehiclePropertyGroup:SYSTEM - | VehiclePropertyType:COMPLEX + | VehiclePropertyType:MIXED | VehicleArea:GLOBAL), /** @@ -1766,7 +1767,7 @@ enum VehicleProperty: int32_t { OBD2_FREEZE_FRAME = ( 0x0D01 | VehiclePropertyGroup:SYSTEM - | VehiclePropertyType:COMPLEX + | VehiclePropertyType:MIXED | VehicleArea:GLOBAL), /** @@ -1787,7 +1788,7 @@ enum VehicleProperty: int32_t { OBD2_FREEZE_FRAME_INFO = ( 0x0D02 | VehiclePropertyGroup:SYSTEM - | VehiclePropertyType:COMPLEX + | VehiclePropertyType:MIXED | VehicleArea:GLOBAL), /** @@ -1813,7 +1814,7 @@ enum VehicleProperty: int32_t { OBD2_FREEZE_FRAME_CLEAR = ( 0x0D03 | VehiclePropertyGroup:SYSTEM - | VehiclePropertyType:COMPLEX + | VehiclePropertyType:MIXED | VehicleArea:GLOBAL), }; @@ -2168,6 +2169,21 @@ enum VehiclePropertyAccess : int32_t { READ_WRITE = 0x03, }; +/** + * Property status is a dynamic value that may change based on the vehicle state. + */ +enum VehiclePropertyStatus : int32_t { + /** Property is available and behaving normally */ + AVAILABLE = 0x00, + /** + * Property is not available, for read and/or write. This is a transient state, as the + * property is expected to be available at a later time. + */ + UNAVAILABLE = 0x01, + /** There is an error with this property. */ + ERROR = 0x02, +}; + /** * Car states. * @@ -2212,20 +2228,15 @@ enum VehicleAreaZone : int32_t { ROW_1_LEFT = 0x00000001, ROW_1_CENTER = 0x00000002, ROW_1_RIGHT = 0x00000004, - ROW_1 = 0x00000008, ROW_2_LEFT = 0x00000010, ROW_2_CENTER = 0x00000020, ROW_2_RIGHT = 0x00000040, - ROW_2 = 0x00000080, ROW_3_LEFT = 0x00000100, ROW_3_CENTER = 0x00000200, ROW_3_RIGHT = 0x00000400, - ROW_3 = 0x00000800, ROW_4_LEFT = 0x00001000, ROW_4_CENTER = 0x00002000, ROW_4_RIGHT = 0x00004000, - ROW_4 = 0x00008000, - WHOLE_CABIN = 0x80000000, }; /** @@ -2312,13 +2323,6 @@ struct VehiclePropConfig { */ VehiclePropertyChangeMode changeMode; - /** - * Some of the properties may have associated areas (for example, some hvac - * properties are associated with VehicleAreaZone), in these - * cases the config may contain an ORed value for the associated areas. - */ - int32_t supportedAreas; - /** * Contains per-area configuration. */ @@ -2372,6 +2376,9 @@ struct VehiclePropValue { */ int32_t areaId; + /** Status of the property */ + VehiclePropertyStatus status; + /** * Contains value for a single property. Depending on property data type of * this property (VehiclePropetyType) one field of this structure must be filled in. @@ -2483,12 +2490,6 @@ struct SubscribeOptions { /** Property to subscribe */ int32_t propId; - /** - * Area ids - this must be a bit mask of areas to subscribe or 0 to subscribe - * to all areas. - */ - int32_t vehicleAreas; - /** * Sample rate in Hz. *