mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 13:49:45 +00:00
Merge "Refactor VHAL"
This commit is contained in:
committed by
Android (Google) Code Review
commit
f30add84f8
@@ -56,6 +56,7 @@ hidl_interface {
|
||||
"VehiclePropertyChangeMode",
|
||||
"VehiclePropertyGroup",
|
||||
"VehiclePropertyOperation",
|
||||
"VehiclePropertyStatus",
|
||||
"VehiclePropertyType",
|
||||
"VehicleRadioConstants",
|
||||
"VehicleTurnSignal",
|
||||
|
||||
@@ -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<int32_t> 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<recyclable_ptr<VehiclePropValue>>& propValues,
|
||||
SubscribeFlags flags) const;
|
||||
|
||||
std::list<sp<HalClient>> getSubscribedClients(int32_t propId,
|
||||
int32_t area,
|
||||
SubscribeFlags flags) const;
|
||||
std::list<sp<HalClient>> 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<sp<HalClient>> 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<HalClient>& client);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<HalClientValues> 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<HalClientValues> SubscriptionManager::distributeValuesToClients(
|
||||
return clientValues;
|
||||
}
|
||||
|
||||
std::list<sp<HalClient>> SubscriptionManager::getSubscribedClients(
|
||||
int32_t propId, int32_t area, SubscribeFlags flags) const {
|
||||
std::list<sp<HalClient>> SubscriptionManager::getSubscribedClients(int32_t propId,
|
||||
SubscribeFlags flags) const {
|
||||
MuxGuard g(mLock);
|
||||
return getSubscribedClientsLocked(propId, area, flags);
|
||||
return getSubscribedClientsLocked(propId, flags);
|
||||
}
|
||||
|
||||
std::list<sp<HalClient>> SubscriptionManager::getSubscribedClientsLocked(
|
||||
int32_t propId, int32_t area, SubscribeFlags flags) const {
|
||||
int32_t propId, SubscribeFlags flags) const {
|
||||
std::list<sp<HalClient>> subscribedClients;
|
||||
|
||||
sp<HalClientVector> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,15 +142,6 @@ Return<StatusCode> VehicleHalManager::subscribe(const sp<IVehicleCallback> &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<StatusCode> VehicleHalManager::subscribe(const sp<IVehicleCallback> &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);
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -42,13 +42,14 @@ std::unique_ptr<VehiclePropValue> 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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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<int32_t>& 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<size_t>(propConfig.configArray[0]),
|
||||
static_cast<size_t>(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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -51,11 +51,7 @@ public:
|
||||
}
|
||||
|
||||
hidl_vec<SubscribeOptions> subscrToProp1 = {
|
||||
SubscribeOptions {
|
||||
.propId = PROP1,
|
||||
.vehicleAreas = toInt(VehicleAreaZone::ROW_1_LEFT),
|
||||
.flags = SubscribeFlags::HAL_EVENT
|
||||
},
|
||||
SubscribeOptions{.propId = PROP1, .flags = SubscribeFlags::HAL_EVENT},
|
||||
};
|
||||
|
||||
hidl_vec<SubscribeOptions> subscrToProp2 = {
|
||||
@@ -66,15 +62,8 @@ public:
|
||||
};
|
||||
|
||||
hidl_vec<SubscribeOptions> 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<sp<IVehicleCallback>> extractCallbacks(
|
||||
@@ -87,14 +76,11 @@ public:
|
||||
}
|
||||
|
||||
std::list<sp<HalClient>> clientsToProp1() {
|
||||
return manager.getSubscribedClients(PROP1,
|
||||
toInt(VehicleAreaZone::ROW_1_LEFT),
|
||||
SubscribeFlags::DEFAULT);
|
||||
return manager.getSubscribedClients(PROP1, SubscribeFlags::DEFAULT);
|
||||
}
|
||||
|
||||
std::list<sp<HalClient>> 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));
|
||||
}
|
||||
|
||||
@@ -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: "
|
||||
|
||||
@@ -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<int32_t>(
|
||||
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<int32_t>(
|
||||
VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT),
|
||||
.areaConfigs = {
|
||||
VehicleAreaConfig {
|
||||
.areaId = toInt(VehicleAreaZone::ROW_1_LEFT),
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user