Convert Vehicle Property to integer
This make sense for easier extending Vehicle Hal interface
by OEMs and creating new versions.
Test: adb shell "su system /data/nativetest/android.hardware.vehicle@2.0-manager-unit-tests/android.hardware.vehicle@2.0-manager-unit-tests" ; ENABLE_TREBLE=true make vts BUILD_GOOGLE_VTS=true -j32 && vts-tradefed run commandAndExit vts --skip-all-system-status-check --primary-abi-only --skip-preconditions --module VehicleHidlTest -l INFO
Change-Id: I02415a1c180a6d24fded48a1583f7cb150419820
Fix: b/34894217
diff --git a/vehicle/2.0/IVehicle.hal b/vehicle/2.0/IVehicle.hal
index cab6ce0..dc13089 100644
--- a/vehicle/2.0/IVehicle.hal
+++ b/vehicle/2.0/IVehicle.hal
@@ -32,7 +32,7 @@
* StatusCode::INVALID_ARG, otherwise a list of vehicle property
* configurations with StatusCode::OK
*/
- getPropConfigs(vec<VehicleProperty> props)
+ getPropConfigs(vec<int32_t> props)
generates (StatusCode status, vec<VehiclePropConfig> propConfigs);
/**
@@ -84,7 +84,7 @@
* If this client wasn't subscribed to the given property, this method
* must return StatusCode::INVALID_ARG.
*/
- unsubscribe(IVehicleCallback callback, VehicleProperty propId)
+ unsubscribe(IVehicleCallback callback, int32_t propId)
generates (StatusCode status);
/**
diff --git a/vehicle/2.0/IVehicleCallback.hal b/vehicle/2.0/IVehicleCallback.hal
index e7e05bf..eb626ff 100644
--- a/vehicle/2.0/IVehicleCallback.hal
+++ b/vehicle/2.0/IVehicleCallback.hal
@@ -54,6 +54,6 @@
* occurred, must be 0 for global properties
*/
oneway onPropertySetError(StatusCode errorCode,
- VehicleProperty propId,
+ int32_t propId,
int32_t areaId);
};
diff --git a/vehicle/2.0/default/VehicleHal.h b/vehicle/2.0/default/VehicleHal.h
index 2807f28..c882def 100644
--- a/vehicle/2.0/default/VehicleHal.h
+++ b/vehicle/2.0/default/VehicleHal.h
@@ -36,7 +36,7 @@
using HalEventFunction = std::function<void(VehiclePropValuePtr)>;
using HalErrorFunction = std::function<void(
- StatusCode errorCode, VehicleProperty property, int32_t areaId)>;
+ StatusCode errorCode, int32_t property, int32_t areaId)>;
virtual ~VehicleHal() {}
@@ -57,16 +57,16 @@
* rate, e.g. for properties with
* VehiclePropertyChangeMode::CONTINUOUS
*/
- virtual StatusCode subscribe(VehicleProperty property,
- int32_t areas,
- float sampleRate) = 0;
+ virtual StatusCode subscribe(int32_t property,
+ int32_t areas,
+ float sampleRate) = 0;
/**
* Unsubscribe from HAL events for given property
*
* @param property vehicle property to unsubscribe
*/
- virtual StatusCode unsubscribe(VehicleProperty property) = 0;
+ virtual StatusCode unsubscribe(int32_t property) = 0;
/**
* Override this method if you need to do one-time initialization.
@@ -95,7 +95,8 @@
/* Propagates error during set operation to the vehicle HAL clients. */
void doHalPropertySetError(StatusCode errorCode,
- VehicleProperty propId, int32_t areaId) {
+ int32_t propId,
+ int32_t areaId) {
mOnHalPropertySetError(errorCode, propId, areaId);
}
diff --git a/vehicle/2.0/default/impl/DefaultConfig.h b/vehicle/2.0/default/impl/DefaultConfig.h
index 12c1c1b..85bba2c 100644
--- a/vehicle/2.0/default/impl/DefaultConfig.h
+++ b/vehicle/2.0/default/impl/DefaultConfig.h
@@ -29,20 +29,20 @@
const VehiclePropConfig kVehicleProperties[] = {
{
- .prop = VehicleProperty::INFO_MAKE,
+ .prop = toInt(VehicleProperty::INFO_MAKE),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::STATIC,
},
{
- .prop = VehicleProperty::HVAC_POWER_ON,
+ .prop = toInt(VehicleProperty::HVAC_POWER_ON),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.supportedAreas = toInt(VehicleAreaZone::ROW_1)
},
{
- .prop = VehicleProperty::HVAC_DEFROSTER,
+ .prop = toInt(VehicleProperty::HVAC_DEFROSTER),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.supportedAreas =
@@ -51,28 +51,28 @@
},
{
- .prop = VehicleProperty::HVAC_RECIRC_ON,
+ .prop = toInt(VehicleProperty::HVAC_RECIRC_ON),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.supportedAreas = toInt(VehicleAreaZone::ROW_1)
},
{
- .prop = VehicleProperty::HVAC_AC_ON,
+ .prop = toInt(VehicleProperty::HVAC_AC_ON),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.supportedAreas = toInt(VehicleAreaZone::ROW_1)
},
{
- .prop = VehicleProperty::HVAC_AUTO_ON,
+ .prop = toInt(VehicleProperty::HVAC_AUTO_ON),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.supportedAreas = toInt(VehicleAreaZone::ROW_1)
},
{
- .prop = VehicleProperty::HVAC_FAN_SPEED,
+ .prop = toInt(VehicleProperty::HVAC_FAN_SPEED),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.supportedAreas = toInt(VehicleAreaZone::ROW_1),
@@ -86,14 +86,14 @@
},
{
- .prop = VehicleProperty::HVAC_FAN_DIRECTION,
+ .prop = toInt(VehicleProperty::HVAC_FAN_DIRECTION),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.supportedAreas = toInt(VehicleAreaZone::ROW_1),
},
{
- .prop = VehicleProperty::HVAC_TEMPERATURE_SET,
+ .prop = toInt(VehicleProperty::HVAC_TEMPERATURE_SET),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.supportedAreas =
@@ -114,25 +114,25 @@
},
{
- .prop = VehicleProperty::NIGHT_MODE,
+ .prop = toInt(VehicleProperty::NIGHT_MODE),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
},
{
- .prop = VehicleProperty::DRIVING_STATUS,
+ .prop = toInt(VehicleProperty::DRIVING_STATUS),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
},
{
- .prop = VehicleProperty::GEAR_SELECTION,
+ .prop = toInt(VehicleProperty::GEAR_SELECTION),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
},
{
- .prop = VehicleProperty::INFO_FUEL_CAPACITY,
+ .prop = toInt(VehicleProperty::INFO_FUEL_CAPACITY),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.areaConfigs = {
@@ -144,7 +144,7 @@
},
{
- .prop = VehicleProperty::DISPLAY_BRIGHTNESS,
+ .prop = toInt(VehicleProperty::DISPLAY_BRIGHTNESS),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.areaConfigs = {
@@ -156,19 +156,19 @@
},
{
- .prop = VehicleProperty::IGNITION_STATE,
+ .prop = toInt(VehicleProperty::IGNITION_STATE),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
},
{
- .prop = VehicleProperty::OBD2_LIVE_FRAME,
+ .prop = toInt(VehicleProperty::OBD2_LIVE_FRAME),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
},
{
- .prop = VehicleProperty::OBD2_FREEZE_FRAME,
+ .prop = toInt(VehicleProperty::OBD2_FREEZE_FRAME),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
}
diff --git a/vehicle/2.0/default/impl/DefaultVehicleHal.cpp b/vehicle/2.0/default/impl/DefaultVehicleHal.cpp
index 4541168..65bd49d 100644
--- a/vehicle/2.0/default/impl/DefaultVehicleHal.cpp
+++ b/vehicle/2.0/default/impl/DefaultVehicleHal.cpp
@@ -31,7 +31,7 @@
*outStatus = StatusCode::OK;
VehiclePropValuePtr v;
- VehicleProperty property = requestedPropValue.prop;
+ auto property = static_cast<VehicleProperty>(requestedPropValue.prop);
int32_t areaId = requestedPropValue.areaId;
auto& pool = *getValuePool();
@@ -103,7 +103,7 @@
}
if (StatusCode::OK == *outStatus && v.get() != nullptr) {
- v->prop = property;
+ v->prop = toInt(property);
v->areaId = areaId;
v->timestamp = elapsedRealtimeNano();
}
@@ -112,7 +112,7 @@
}
StatusCode DefaultVehicleHal::set(const VehiclePropValue& propValue) {
- auto property = propValue.prop;
+ auto property = static_cast<VehicleProperty>(propValue.prop);
const auto& v = propValue.value;
StatusCode status = StatusCode::OK;
diff --git a/vehicle/2.0/default/impl/DefaultVehicleHal.h b/vehicle/2.0/default/impl/DefaultVehicleHal.h
index 15a4789..b01c963 100644
--- a/vehicle/2.0/default/impl/DefaultVehicleHal.h
+++ b/vehicle/2.0/default/impl/DefaultVehicleHal.h
@@ -40,14 +40,14 @@
StatusCode set(const VehiclePropValue& propValue) override;
- StatusCode subscribe(VehicleProperty property,
- int32_t areas,
- float sampleRate) {
+ StatusCode subscribe(int32_t /*property*/,
+ int32_t /*areas*/,
+ float /*sampleRate*/) override {
// TODO(pavelm): implement
return StatusCode::OK;
}
- StatusCode unsubscribe(VehicleProperty property) {
+ StatusCode unsubscribe(int32_t /*property*/) override {
// TODO(pavelm): implement
return StatusCode::OK;
}
diff --git a/vehicle/2.0/default/tests/AccessControlConfigParser_test.cpp b/vehicle/2.0/default/tests/AccessControlConfigParser_test.cpp
index 92d7e39..5b09135 100644
--- a/vehicle/2.0/default/tests/AccessControlConfigParser_test.cpp
+++ b/vehicle/2.0/default/tests/AccessControlConfigParser_test.cpp
@@ -20,6 +20,7 @@
#include <unordered_set>
#include "vehicle_hal_manager/AccessControlConfigParser.h"
+#include <vehicle_hal_manager/VehicleUtils.h>
namespace android {
namespace hardware {
@@ -31,9 +32,9 @@
class AccessControlConfigParserTest : public ::testing::Test {
protected:
void SetUp() override {
- std::vector<VehicleProperty> supportedProperties {
- VehicleProperty::HVAC_FAN_SPEED,
- VehicleProperty::HVAC_FAN_DIRECTION,
+ std::vector<int32_t> supportedProperties {
+ toInt(VehicleProperty::HVAC_FAN_SPEED),
+ toInt(VehicleProperty::HVAC_FAN_DIRECTION),
};
parser.reset(new AccessControlConfigParser(supportedProperties));
}
@@ -49,10 +50,10 @@
ASSERT_TRUE(parser->parseFromStream(&file, &aclMap));
ASSERT_EQ(1, aclMap.size());
- auto it = aclMap.find(VehicleProperty::HVAC_FAN_SPEED);
+ auto it = aclMap.find(toInt(VehicleProperty::HVAC_FAN_SPEED));
ASSERT_NE(aclMap.end(), it);
ASSERT_EQ(VehiclePropertyAccess::READ_WRITE, it->second.access);
- ASSERT_EQ(VehicleProperty::HVAC_FAN_SPEED, it->second.propId);
+ ASSERT_EQ(toInt(VehicleProperty::HVAC_FAN_SPEED), it->second.propId);
ASSERT_EQ(1000u, it->second.uid);
}
@@ -68,7 +69,7 @@
ASSERT_TRUE(parser->parseFromStream(&file, &aclMap));
- auto range = aclMap.equal_range(VehicleProperty::HVAC_FAN_SPEED);
+ auto range = aclMap.equal_range(toInt(VehicleProperty::HVAC_FAN_SPEED));
for (auto it = range.first; it != range.second; ++it) {
auto& acl = it->second;
@@ -92,10 +93,10 @@
ASSERT_FALSE(parser->parseFromStream(&file, &aclMap));
ASSERT_EQ(1, aclMap.size());
- auto it = aclMap.find(VehicleProperty::HVAC_FAN_SPEED);
+ auto it = aclMap.find(toInt(VehicleProperty::HVAC_FAN_SPEED));
ASSERT_NE(aclMap.end(), it);
ASSERT_EQ(VehiclePropertyAccess::READ, it->second.access);
- ASSERT_EQ(VehicleProperty::HVAC_FAN_SPEED, it->second.propId);
+ ASSERT_EQ(toInt(VehicleProperty::HVAC_FAN_SPEED), it->second.propId);
ASSERT_EQ(0xbeef, it->second.uid);
}
@@ -127,16 +128,16 @@
ASSERT_TRUE(parser->parseFromStream(&configFile2, &aclMap));
ASSERT_EQ(2, aclMap.size());
- auto it = aclMap.find(VehicleProperty::HVAC_FAN_SPEED);
+ auto it = aclMap.find(toInt(VehicleProperty::HVAC_FAN_SPEED));
ASSERT_NE(aclMap.end(), it);
ASSERT_EQ(VehiclePropertyAccess::READ_WRITE, it->second.access);
- ASSERT_EQ(VehicleProperty::HVAC_FAN_SPEED, it->second.propId);
+ ASSERT_EQ(toInt(VehicleProperty::HVAC_FAN_SPEED), it->second.propId);
ASSERT_EQ(1000u, it->second.uid);
- it = aclMap.find(VehicleProperty::HVAC_FAN_DIRECTION);
+ it = aclMap.find(toInt(VehicleProperty::HVAC_FAN_DIRECTION));
ASSERT_NE(aclMap.end(), it);
ASSERT_EQ(VehiclePropertyAccess::READ_WRITE, it->second.access);
- ASSERT_EQ(VehicleProperty::HVAC_FAN_DIRECTION, it->second.propId);
+ ASSERT_EQ(toInt(VehicleProperty::HVAC_FAN_DIRECTION), it->second.propId);
ASSERT_EQ(1004u, it->second.uid);
}
diff --git a/vehicle/2.0/default/tests/SubscriptionManager_test.cpp b/vehicle/2.0/default/tests/SubscriptionManager_test.cpp
index 863142e..1b12bfd 100644
--- a/vehicle/2.0/default/tests/SubscriptionManager_test.cpp
+++ b/vehicle/2.0/default/tests/SubscriptionManager_test.cpp
@@ -36,8 +36,8 @@
public:
SubscriptionManager manager;
- const VehicleProperty PROP1 = VehicleProperty::HVAC_FAN_SPEED;
- const VehicleProperty PROP2 = VehicleProperty::DISPLAY_BRIGHTNESS;
+ static constexpr int32_t PROP1 = toInt(VehicleProperty::HVAC_FAN_SPEED);
+ static constexpr int32_t PROP2 = toInt(VehicleProperty::DISPLAY_BRIGHTNESS);
sp<IVehicleCallback> cb1 = new MockedVehicleCallback();
sp<IVehicleCallback> cb2 = new MockedVehicleCallback();
@@ -116,7 +116,7 @@
// Wrong prop
clients = manager.getSubscribedClients(
- VehicleProperty::AP_POWER_BOOTUP_REASON,
+ toInt(VehicleProperty::AP_POWER_BOOTUP_REASON),
toInt(VehicleAreaZone::ROW_1_LEFT),
SubscribeFlags::HAL_EVENT);
ASSERT_TRUE(clients.empty());
diff --git a/vehicle/2.0/default/tests/VehicleHalManager_test.cpp b/vehicle/2.0/default/tests/VehicleHalManager_test.cpp
index dc32252..c20ab7f 100644
--- a/vehicle/2.0/default/tests/VehicleHalManager_test.cpp
+++ b/vehicle/2.0/default/tests/VehicleHalManager_test.cpp
@@ -52,7 +52,7 @@
StatusCode* outStatus) override {
*outStatus = StatusCode::OK;
VehiclePropValuePtr pValue;
- VehicleProperty property = requestedPropValue.prop;
+ auto property = static_cast<VehicleProperty>(requestedPropValue.prop);
int32_t areaId = requestedPropValue.areaId;
switch (property) {
@@ -76,7 +76,7 @@
pValue->value.stringValue = kCarMake;
break;
default:
- auto key = makeKey(property, areaId);
+ auto key = makeKey(toInt(property), areaId);
if (mValues.count(key) == 0) {
ALOGW("");
}
@@ -84,7 +84,7 @@
}
if (*outStatus == StatusCode::OK && pValue.get() != nullptr) {
- pValue->prop = property;
+ pValue->prop = toInt(property);
pValue->areaId = areaId;
pValue->timestamp = elapsedRealtimeNano();
}
@@ -93,7 +93,7 @@
}
StatusCode set(const VehiclePropValue& propValue) override {
- if (VehicleProperty::MIRROR_FOLD == propValue.prop
+ if (toInt(VehicleProperty::MIRROR_FOLD) == propValue.prop
&& mirrorFoldAttemptsLeft-- > 0) {
return StatusCode::TRY_AGAIN;
}
@@ -102,13 +102,13 @@
return StatusCode::OK;
}
- StatusCode subscribe(VehicleProperty property,
- int32_t areas,
- float sampleRate) override {
+ StatusCode subscribe(int32_t property,
+ int32_t areas,
+ float sampleRate) override {
return StatusCode::OK;
}
- StatusCode unsubscribe(VehicleProperty property) override {
+ StatusCode unsubscribe(int32_t property) override {
return StatusCode::OK;
}
@@ -116,8 +116,7 @@
doHalEvent(std::move(value));
}
- void sendHalError(StatusCode error, VehicleProperty property,
- int32_t areaId) {
+ void sendHalError(StatusCode error, int32_t property, int32_t areaId) {
doHalPropertySetError(error, property, areaId);
}
@@ -130,7 +129,7 @@
return makeKey(v.prop, v.areaId);
}
- int64_t makeKey(VehicleProperty prop, int32_t area) const {
+ int64_t makeKey(int32_t prop, int32_t area) const {
return (static_cast<int64_t>(prop) << 32) | area;
}
@@ -153,7 +152,7 @@
hal.reset(nullptr);
}
public:
- void invokeGet(VehicleProperty property, int32_t areaId) {
+ void invokeGet(int32_t property, int32_t areaId) {
VehiclePropValue requestedValue {};
requestedValue.prop = property;
requestedValue.areaId = areaId;
@@ -174,7 +173,7 @@
called = true;
});
ASSERT_TRUE(called) << "callback wasn't called for prop: "
- << enumToHexString(requestedPropValue.prop);
+ << hexString(requestedPropValue.prop);
actualValue = refValue;
actualStatusCode = refStatus;
@@ -190,8 +189,9 @@
};
TEST_F(VehicleHalManagerTest, getPropConfigs) {
- hidl_vec<VehicleProperty> properties =
- { VehicleProperty::HVAC_FAN_SPEED, VehicleProperty::INFO_MAKE };
+ hidl_vec<int32_t> properties =
+ { toInt(VehicleProperty::HVAC_FAN_SPEED),
+ toInt(VehicleProperty::INFO_MAKE) };
bool called = false;
manager->getPropConfigs(properties,
@@ -205,7 +205,7 @@
ASSERT_TRUE(called); // Verify callback received.
called = false;
- manager->getPropConfigs({ VehicleProperty::HVAC_FAN_SPEED },
+ manager->getPropConfigs({ toInt(VehicleProperty::HVAC_FAN_SPEED) },
[&called] (StatusCode status,
const hidl_vec<VehiclePropConfig>& c) {
ASSERT_EQ(StatusCode::OK, status);
@@ -234,7 +234,7 @@
}
TEST_F(VehicleHalManagerTest, halErrorEvent) {
- const VehicleProperty PROP = VehicleProperty::DISPLAY_BRIGHTNESS;
+ const auto PROP = toInt(VehicleProperty::DISPLAY_BRIGHTNESS);
sp<MockedVehicleCallback> cb = new MockedVehicleCallback();
@@ -252,7 +252,7 @@
}
TEST_F(VehicleHalManagerTest, subscribe) {
- const VehicleProperty PROP = VehicleProperty::DISPLAY_BRIGHTNESS;
+ const auto PROP = toInt(VehicleProperty::DISPLAY_BRIGHTNESS);
sp<MockedVehicleCallback> cb = new MockedVehicleCallback();
@@ -267,7 +267,7 @@
ASSERT_EQ(StatusCode::OK, res);
auto unsubscribedValue = objectPool->obtain(VehiclePropertyType::INT32);
- unsubscribedValue->prop = VehicleProperty::HVAC_FAN_SPEED;
+ unsubscribedValue->prop = toInt(VehicleProperty::HVAC_FAN_SPEED);
hal->sendPropEvent(std::move(unsubscribedValue));
auto& receivedEnvents = cb->getReceivedEvents();
@@ -293,7 +293,7 @@
}
TEST_F(VehicleHalManagerTest, subscribe_WriteOnly) {
- const VehicleProperty PROP = VehicleProperty::HVAC_SEAT_TEMPERATURE;
+ const auto PROP = toInt(VehicleProperty::HVAC_SEAT_TEMPERATURE);
sp<MockedVehicleCallback> cb = new MockedVehicleCallback();
@@ -317,10 +317,10 @@
}
TEST_F(VehicleHalManagerTest, get_Complex) {
- invokeGet(VehicleProperty::VEHICLE_MAP_SERVICE, 0);
+ invokeGet(toInt(VehicleProperty::VEHICLE_MAP_SERVICE), 0);
ASSERT_EQ(StatusCode::OK, actualStatusCode);
- ASSERT_EQ(VehicleProperty::VEHICLE_MAP_SERVICE, actualValue.prop);
+ ASSERT_EQ(toInt(VehicleProperty::VEHICLE_MAP_SERVICE), actualValue.prop);
ASSERT_EQ(3, actualValue.value.bytes.size());
ASSERT_EQ(1, actualValue.value.bytes[0]);
@@ -343,20 +343,20 @@
}
TEST_F(VehicleHalManagerTest, get_StaticString) {
- invokeGet(VehicleProperty::INFO_MAKE, 0);
+ invokeGet(toInt(VehicleProperty::INFO_MAKE), 0);
ASSERT_EQ(StatusCode::OK, actualStatusCode);
- ASSERT_EQ(VehicleProperty::INFO_MAKE, actualValue.prop);
+ ASSERT_EQ(toInt(VehicleProperty::INFO_MAKE), actualValue.prop);
ASSERT_STREQ(kCarMake, actualValue.value.stringValue.c_str());
}
TEST_F(VehicleHalManagerTest, get_NegativeCases) {
// Write-only property must fail.
- invokeGet(VehicleProperty::HVAC_SEAT_TEMPERATURE, 0);
+ invokeGet(toInt(VehicleProperty::HVAC_SEAT_TEMPERATURE), 0);
ASSERT_EQ(StatusCode::ACCESS_DENIED, actualStatusCode);
// Unknown property must fail.
- invokeGet(VehicleProperty::MIRROR_Z_MOVE, 0);
+ invokeGet(toInt(VehicleProperty::MIRROR_Z_MOVE), 0);
ASSERT_EQ(StatusCode::INVALID_ARG, actualStatusCode);
}
@@ -364,7 +364,7 @@
actualStatusCode = StatusCode::TRY_AGAIN;
int attempts = 0;
while (StatusCode::TRY_AGAIN == actualStatusCode && ++attempts < 10) {
- invokeGet(VehicleProperty::INFO_FUEL_CAPACITY, 0);
+ invokeGet(toInt(VehicleProperty::INFO_FUEL_CAPACITY), 0);
}
ASSERT_EQ(StatusCode::OK, actualStatusCode);
@@ -373,7 +373,7 @@
}
TEST_F(VehicleHalManagerTest, set_Basic) {
- const auto PROP = VehicleProperty::DISPLAY_BRIGHTNESS;
+ const auto PROP = toInt(VehicleProperty::DISPLAY_BRIGHTNESS);
const auto VAL = 7;
auto expectedValue = hal->getValuePool()->obtainInt32(VAL);
@@ -390,7 +390,7 @@
}
TEST_F(VehicleHalManagerTest, set_DifferentAreas) {
- const auto PROP = VehicleProperty::HVAC_FAN_SPEED;
+ const auto PROP = toInt(VehicleProperty::HVAC_FAN_SPEED);
const auto VAL1 = 1;
const auto VAL2 = 2;
const auto AREA1 = toInt(VehicleAreaZone::ROW_1_LEFT);
@@ -426,7 +426,7 @@
}
TEST_F(VehicleHalManagerTest, set_Retriable) {
- const auto PROP = VehicleProperty::MIRROR_FOLD;
+ const auto PROP = toInt(VehicleProperty::MIRROR_FOLD);
auto v = hal->getValuePool()->obtainBoolean(true);
v->prop = PROP;
diff --git a/vehicle/2.0/default/tests/VehicleHalTestUtils.h b/vehicle/2.0/default/tests/VehicleHalTestUtils.h
index 538c022..fab420a 100644
--- a/vehicle/2.0/default/tests/VehicleHalTestUtils.h
+++ b/vehicle/2.0/default/tests/VehicleHalTestUtils.h
@@ -29,14 +29,14 @@
const VehiclePropConfig kVehicleProperties[] = {
{
- .prop = VehicleProperty::INFO_MAKE,
+ .prop = toInt(VehicleProperty::INFO_MAKE),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::STATIC,
.configString = "Some=config,options=if,you=have_any",
},
{
- .prop = VehicleProperty::HVAC_FAN_SPEED,
+ .prop = toInt(VehicleProperty::HVAC_FAN_SPEED),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.supportedAreas = static_cast<int32_t>(
@@ -56,7 +56,7 @@
// Write-only property
{
- .prop = VehicleProperty::HVAC_SEAT_TEMPERATURE,
+ .prop = toInt(VehicleProperty::HVAC_SEAT_TEMPERATURE),
.access = VehiclePropertyAccess::WRITE,
.changeMode = VehiclePropertyChangeMode::ON_SET,
.supportedAreas = static_cast<int32_t>(
@@ -75,7 +75,7 @@
},
{
- .prop = VehicleProperty::INFO_FUEL_CAPACITY,
+ .prop = toInt(VehicleProperty::INFO_FUEL_CAPACITY),
.access = VehiclePropertyAccess::READ,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.areaConfigs = {
@@ -87,7 +87,7 @@
},
{
- .prop = VehicleProperty::DISPLAY_BRIGHTNESS,
+ .prop = toInt(VehicleProperty::DISPLAY_BRIGHTNESS),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
.areaConfigs = {
@@ -99,7 +99,7 @@
},
{
- .prop = VehicleProperty::MIRROR_FOLD,
+ .prop = toInt(VehicleProperty::MIRROR_FOLD),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE,
@@ -107,7 +107,7 @@
// Complex data type.
{
- .prop = VehicleProperty::VEHICLE_MAP_SERVICE,
+ .prop = toInt(VehicleProperty::VEHICLE_MAP_SERVICE),
.access = VehiclePropertyAccess::READ_WRITE,
.changeMode = VehiclePropertyChangeMode::ON_CHANGE
}
@@ -134,7 +134,7 @@
return Return<void>();
}
Return<void> onPropertySetError(StatusCode errorCode,
- VehicleProperty propId,
+ int32_t propId,
int32_t areaId) override {
return Return<void>();
}
@@ -218,7 +218,7 @@
inline std::string toString(const VehiclePropValue &v) {
std::stringstream ss;
ss << "VehiclePropValue {n"
- << " prop: " << enumToHexString(v.prop) << ",\n"
+ << " prop: " << hexString(v.prop) << ",\n"
<< " areaId: " << hexString(v.areaId) << ",\n"
<< " timestamp: " << v.timestamp << ",\n"
<< " value {\n"
@@ -236,7 +236,7 @@
inline std::string toString(const VehiclePropConfig &config) {
std::stringstream ss;
ss << "VehiclePropConfig {\n"
- << " prop: " << enumToHexString(config.prop) << ",\n"
+ << " prop: " << hexString(config.prop) << ",\n"
<< " supportedAreas: " << hexString(config.supportedAreas) << ",\n"
<< " access: " << enumToHexString(config.access) << ",\n"
<< " changeMode: " << enumToHexString(config.changeMode) << ",\n"
diff --git a/vehicle/2.0/default/tests/VehiclePropConfigIndex_test.cpp b/vehicle/2.0/default/tests/VehiclePropConfigIndex_test.cpp
index 28cdcbb..4e1daf8 100644
--- a/vehicle/2.0/default/tests/VehiclePropConfigIndex_test.cpp
+++ b/vehicle/2.0/default/tests/VehiclePropConfigIndex_test.cpp
@@ -43,11 +43,11 @@
TEST_F(PropConfigTest, hasConfig) {
VehiclePropConfigIndex index(configs);
- ASSERT_TRUE(index.hasConfig(VehicleProperty::HVAC_FAN_SPEED));
- ASSERT_TRUE(index.hasConfig(VehicleProperty::INFO_MAKE));
- ASSERT_TRUE(index.hasConfig(VehicleProperty::INFO_FUEL_CAPACITY));
+ ASSERT_TRUE(index.hasConfig(toInt(VehicleProperty::HVAC_FAN_SPEED)));
+ ASSERT_TRUE(index.hasConfig(toInt(VehicleProperty::INFO_MAKE)));
+ ASSERT_TRUE(index.hasConfig(toInt(VehicleProperty::INFO_FUEL_CAPACITY)));
- ASSERT_FALSE(index.hasConfig(VehicleProperty::INVALID));
+ ASSERT_FALSE(index.hasConfig(toInt(VehicleProperty::INVALID)));
}
TEST_F(PropConfigTest, getAllConfig) {
@@ -63,7 +63,7 @@
TEST_F(PropConfigTest, getConfigs) {
VehiclePropConfigIndex index(configs);
- auto actualConfig = index.getConfig(VehicleProperty::HVAC_FAN_SPEED);
+ auto actualConfig = index.getConfig(toInt(VehicleProperty::HVAC_FAN_SPEED));
ASSERT_EQ(toString(configs[1]), toString(actualConfig));
}
diff --git a/vehicle/2.0/default/vehicle_hal_manager/AccessControlConfigParser.cpp b/vehicle/2.0/default/vehicle_hal_manager/AccessControlConfigParser.cpp
index 063a16d..9cc994d 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/AccessControlConfigParser.cpp
+++ b/vehicle/2.0/default/vehicle_hal_manager/AccessControlConfigParser.cpp
@@ -17,6 +17,7 @@
#define LOG_TAG "android.hardware.vehicle@2.0-impl"
#include "AccessControlConfigParser.h"
+#include "VehicleUtils.h"
#include <fstream>
#include <iostream>
@@ -30,17 +31,17 @@
namespace V2_0 {
AccessControlConfigParser::AccessControlConfigParser(
- const std::vector<VehicleProperty>& properties) {
+ const std::vector<int32_t>& properties) {
// Property Id in the config file doesn't include information about
// type and area. So we want to create a map from these kind of
// *stripped* properties to the whole VehicleProperty.
// We also want to filter out ACL to the properties that supported
// by concrete Vehicle HAL implementation.
- for (VehicleProperty vehicleProperty : properties) {
- auto numProp = static_cast<int>(vehicleProperty);
- numProp &= ~static_cast<int>(VehiclePropertyType::MASK)
- & ~static_cast<int>(VehicleArea::MASK);
- mStrippedToVehiclePropertyMap.emplace(numProp, vehicleProperty);
+ for (auto prop : properties) {
+ auto strippedProp = prop
+ & ~toInt(VehiclePropertyType::MASK)
+ & ~toInt(VehicleArea::MASK);
+ mStrippedToVehiclePropertyMap.emplace(strippedProp, prop);
}
}
@@ -130,8 +131,8 @@
bool AccessControlConfigParser::parsePropertyId(
const std::string& strPropId,
VehiclePropertyGroup propertyGroup,
- VehicleProperty* outVehicleProperty) const {
- int propId;
+ int32_t* outVehicleProperty) const {
+ int32_t propId;
if (!parseInt(strPropId.c_str(), &propId)) {
ALOGW("Failed to convert property id to integer: %s",
strPropId.c_str());
diff --git a/vehicle/2.0/default/vehicle_hal_manager/AccessControlConfigParser.h b/vehicle/2.0/default/vehicle_hal_manager/AccessControlConfigParser.h
index 5cd0c3e..0c3753f 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/AccessControlConfigParser.h
+++ b/vehicle/2.0/default/vehicle_hal_manager/AccessControlConfigParser.h
@@ -30,12 +30,12 @@
namespace V2_0 {
struct PropertyAcl {
- VehicleProperty propId;
+ int32_t propId;
unsigned uid;
VehiclePropertyAccess access;
};
-using PropertyAclMap = std::unordered_multimap<VehicleProperty, PropertyAcl>;
+using PropertyAclMap = std::unordered_multimap<int32_t, PropertyAcl>;
/**
* Parser for per-property access control in vehicle HAL.
@@ -64,7 +64,7 @@
*
* @param properties - properties supported by HAL implementation
*/
- AccessControlConfigParser(const std::vector<VehicleProperty>& properties);
+ AccessControlConfigParser(const std::vector<int32_t>& properties);
/**
* Parses config content from given stream and writes results to
@@ -81,7 +81,7 @@
bool parsePropertyId(const std::string& strPropId,
VehiclePropertyGroup propertyGroup,
- VehicleProperty* outVehicleProperty) const;
+ int32_t* outVehicleProperty) const;
bool parseUid(const std::string& strUid, unsigned* outUid) const;
@@ -100,7 +100,7 @@
// aliases.
// Map property ids w/o TYPE and AREA to VehicleProperty.
- std::unordered_map<int, VehicleProperty> mStrippedToVehiclePropertyMap;
+ std::unordered_map<int32_t, int32_t> mStrippedToVehiclePropertyMap;
};
} // namespace V2_0
diff --git a/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.cpp b/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.cpp
index c190c71..72b0a83 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.cpp
+++ b/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.cpp
@@ -70,7 +70,9 @@
}
}
-bool HalClient::isSubscribed(VehicleProperty propId, int32_t areaId, SubscribeFlags flags) {
+bool HalClient::isSubscribed(int32_t propId,
+ int32_t areaId,
+ SubscribeFlags flags) {
auto it = mSubscriptions.find(propId);
if (it == mSubscriptions.end()) {
return false;
@@ -136,13 +138,13 @@
}
std::list<sp<HalClient>> SubscriptionManager::getSubscribedClients(
- VehicleProperty propId, int32_t area, SubscribeFlags flags) const {
+ int32_t propId, int32_t area, SubscribeFlags flags) const {
MuxGuard g(mLock);
return getSubscribedClientsLocked(propId, area, flags);
}
std::list<sp<HalClient>> SubscriptionManager::getSubscribedClientsLocked(
- VehicleProperty propId, int32_t area, SubscribeFlags flags) const {
+ int32_t propId, int32_t area, SubscribeFlags flags) const {
std::list<sp<HalClient>> subscribedClients;
sp<HalClientVector> propClients = getClientsForPropertyLocked(propId);
@@ -180,7 +182,7 @@
}
void SubscriptionManager::addClientToPropMapLocked(
- VehicleProperty propId, const sp<HalClient> &client) {
+ int32_t propId, const sp<HalClient> &client) {
auto it = mPropToClients.find(propId);
sp<HalClientVector> propClients;
if (it == mPropToClients.end()) {
@@ -193,7 +195,7 @@
}
sp<HalClientVector> SubscriptionManager::getClientsForPropertyLocked(
- VehicleProperty propId) const {
+ int32_t propId) const {
auto it = mPropToClients.find(propId);
return it == mPropToClients.end() ? nullptr : it->second;
}
@@ -214,7 +216,7 @@
}
bool SubscriptionManager::unsubscribe(const sp<IVehicleCallback>& callback,
- VehicleProperty propId) {
+ int32_t propId) {
MuxGuard g(mLock);
auto propertyClients = getClientsForPropertyLocked(propId);
auto clientIter = mClients.find(callback);
diff --git a/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.h b/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.h
index 9f2ed8d..7a74295 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.h
+++ b/vehicle/2.0/default/vehicle_hal_manager/SubscriptionManager.h
@@ -50,7 +50,7 @@
void addOrUpdateSubscription(const SubscribeOptions &opts);
- bool isSubscribed(VehicleProperty propId,
+ bool isSubscribed(int32_t propId,
int32_t areaId,
SubscribeFlags flags);
@@ -59,7 +59,7 @@
const int32_t mPid;
const int32_t mUid;
- std::map<VehicleProperty, SubscribeOptions> mSubscriptions;
+ std::map<int32_t, SubscribeOptions> mSubscriptions;
};
class HalClientVector : private SortedVector<sp<HalClient>> , public RefBase {
@@ -103,26 +103,26 @@
SubscribeFlags flags) const;
std::list<sp<HalClient>> getSubscribedClients(
- VehicleProperty propId, int32_t area, SubscribeFlags flags) const;
+ int32_t propId, int32_t area, SubscribeFlags flags) const;
/**
* Returns true the client was unsubscribed successfully and there are
* no more clients subscribed to given propId.
*/
bool unsubscribe(const sp<IVehicleCallback>& callback,
- VehicleProperty propId);
+ int32_t propId);
private:
std::list<sp< HalClient>> getSubscribedClientsLocked(
- VehicleProperty propId, int32_t area, SubscribeFlags flags) const;
+ int32_t propId, int32_t area, SubscribeFlags flags) const;
bool updateHalEventSubscriptionLocked(const SubscribeOptions &opts,
SubscribeOptions *out);
- void addClientToPropMapLocked(VehicleProperty propId,
+ void addClientToPropMapLocked(int32_t propId,
const sp<HalClient> &client);
sp<HalClientVector> getClientsForPropertyLocked(
- VehicleProperty propId) const;
+ int32_t propId) const;
sp<HalClient> getOrCreateHalClientLocked(
const sp<IVehicleCallback> &callback);
@@ -133,8 +133,8 @@
mutable std::mutex mLock;
std::map<sp<IVehicleCallback>, sp<HalClient>> mClients;
- std::map<VehicleProperty, sp<HalClientVector>> mPropToClients;
- std::map<VehicleProperty, SubscribeOptions> mHalEventSubscribeOptions;
+ std::map<int32_t, sp<HalClientVector>> mPropToClients;
+ std::map<int32_t, SubscribeOptions> mHalEventSubscribeOptions;
};
diff --git a/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.cpp b/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.cpp
index 5d2e6fe..8b243a3 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.cpp
+++ b/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.cpp
@@ -58,11 +58,11 @@
}
Return<void> VehicleHalManager::getPropConfigs(
- const hidl_vec<VehicleProperty> &properties,
+ const hidl_vec<int32_t> &properties,
getPropConfigs_cb _hidl_cb) {
std::vector<VehiclePropConfig> configs;
for (size_t i = 0; i < properties.size(); i++) {
- VehicleProperty prop = properties[i];
+ auto prop = properties[i];
if (mConfigIndex->hasConfig(prop)) {
configs.push_back(mConfigIndex->getConfig(prop));
} else {
@@ -125,7 +125,7 @@
auto caller = getCaller();
for (size_t i = 0; i < verifiedOptions.size(); i++) {
SubscribeOptions& ops = verifiedOptions[i];
- VehicleProperty prop = ops.propId;
+ auto prop = ops.propId;
const auto* config = getPropConfigOrNull(prop);
if (config == nullptr) {
@@ -168,7 +168,7 @@
}
Return<StatusCode> VehicleHalManager::unsubscribe(
- const sp<IVehicleCallback>& callback, VehicleProperty propId) {
+ const sp<IVehicleCallback>& callback, int32_t propId) {
if (mSubscriptionManager.unsubscribe(callback, propId)) {
mHal->unsubscribe(propId);
}
@@ -200,7 +200,7 @@
auto supportedPropConfigs = mHal->listProperties();
mConfigIndex.reset(new VehiclePropConfigIndex(supportedPropConfigs));
- std::vector<VehicleProperty> supportedProperties(
+ std::vector<int32_t> supportedProperties(
supportedPropConfigs.size());
for (const auto& config : supportedPropConfigs) {
supportedProperties.push_back(config.prop);
@@ -228,7 +228,7 @@
}
void VehicleHalManager::onHalPropertySetError(StatusCode errorCode,
- VehicleProperty property,
+ int32_t property,
int32_t areaId) {
const auto& clients = mSubscriptionManager.getSubscribedClients(
property, 0, SubscribeFlags::HAL_EVENT);
@@ -309,7 +309,7 @@
return true;
}
-bool VehicleHalManager::checkAcl(uid_t callerUid, VehicleProperty propertyId,
+bool VehicleHalManager::checkAcl(uid_t callerUid, int32_t propertyId,
VehiclePropertyAccess requiredAccess) const {
if (callerUid == AID_SYSTEM && isSystemProperty(propertyId)) {
return true;
@@ -353,7 +353,7 @@
}
const VehiclePropConfig* VehicleHalManager::getPropConfigOrNull(
- VehicleProperty prop) const {
+ int32_t prop) const {
return mConfigIndex->hasConfig(prop)
? &mConfigIndex->getConfig(prop) : nullptr;
}
diff --git a/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.h b/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.h
index 6768741..49723da 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.h
+++ b/vehicle/2.0/default/vehicle_hal_manager/VehicleHalManager.h
@@ -66,7 +66,7 @@
// ---------------------------------------------------------------------------------------------
// Methods derived from IVehicle
Return<void> getAllPropConfigs(getAllPropConfigs_cb _hidl_cb) override;
- Return<void> getPropConfigs(const hidl_vec<VehicleProperty>& properties,
+ Return<void> getPropConfigs(const hidl_vec<int32_t>& properties,
getPropConfigs_cb _hidl_cb) override;
Return<void> get(const VehiclePropValue& requestedPropValue,
get_cb _hidl_cb) override;
@@ -74,7 +74,7 @@
Return<StatusCode> subscribe(const sp<IVehicleCallback>& callback,
const hidl_vec<SubscribeOptions>& options) override;
Return<StatusCode> unsubscribe(const sp<IVehicleCallback>& callback,
- VehicleProperty propId) override;
+ int32_t propId) override;
Return<void> debugDump(debugDump_cb _hidl_cb = nullptr) override;
private:
@@ -85,7 +85,7 @@
// ---------------------------------------------------------------------------------------------
// Events received from VehicleHal
void onHalEvent(VehiclePropValuePtr v);
- void onHalPropertySetError(StatusCode errorCode, VehicleProperty property,
+ void onHalPropertySetError(StatusCode errorCode, int32_t property,
int32_t areaId);
// ---------------------------------------------------------------------------------------------
@@ -94,14 +94,14 @@
void handlePropertySetEvent(const VehiclePropValue& value);
- const VehiclePropConfig* getPropConfigOrNull(VehicleProperty prop) const;
+ const VehiclePropConfig* getPropConfigOrNull(int32_t prop) const;
bool checkWritePermission(const VehiclePropConfig &config,
const Caller& callee) const;
bool checkReadPermission(const VehiclePropConfig &config,
const Caller& caller) const;
bool checkAcl(uid_t callerUid,
- VehicleProperty propertyId,
+ int32_t propertyId,
VehiclePropertyAccess requiredAccess) const;
static bool isSubscribable(const VehiclePropConfig& config,
diff --git a/vehicle/2.0/default/vehicle_hal_manager/VehicleObjectPool.cpp b/vehicle/2.0/default/vehicle_hal_manager/VehicleObjectPool.cpp
index e9dd68d..5fa77b1 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/VehicleObjectPool.cpp
+++ b/vehicle/2.0/default/vehicle_hal_manager/VehicleObjectPool.cpp
@@ -36,7 +36,7 @@
VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtain(
const VehiclePropValue& src) {
- if (src.prop == VehicleProperty::INVALID) {
+ if (src.prop == toInt(VehicleProperty::INVALID)) {
ALOGE("Unable to obtain an object from pool for unknown property");
return RecyclableType();
}
diff --git a/vehicle/2.0/default/vehicle_hal_manager/VehiclePropConfigIndex.h b/vehicle/2.0/default/vehicle_hal_manager/VehiclePropConfigIndex.h
index 540fc33..a08ac42 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/VehiclePropConfigIndex.h
+++ b/vehicle/2.0/default/vehicle_hal_manager/VehiclePropConfigIndex.h
@@ -37,11 +37,11 @@
: mConfigs(properties), mPropToConfig(mConfigs)
{}
- bool hasConfig(VehicleProperty property) const {
+ bool hasConfig(int32_t property) const {
return mPropToConfig.indexOfKey(property) >= 0;
}
- const VehiclePropConfig& getConfig(VehicleProperty property) const {
+ const VehiclePropConfig& getConfig(int32_t property) const {
return *mPropToConfig.valueFor(property);
}
@@ -50,7 +50,7 @@
}
private:
- typedef KeyedVector<VehicleProperty, const VehiclePropConfig*> PropConfigMap;
+ typedef KeyedVector<int32_t, const VehiclePropConfig*> PropConfigMap;
class ImmutablePropConfigMap : private PropConfigMap {
public:
ImmutablePropConfigMap(const std::vector<VehiclePropConfig>& configs) {
diff --git a/vehicle/2.0/default/vehicle_hal_manager/VehicleUtils.h b/vehicle/2.0/default/vehicle_hal_manager/VehicleUtils.h
index 1177ddd..c24d860 100644
--- a/vehicle/2.0/default/vehicle_hal_manager/VehicleUtils.h
+++ b/vehicle/2.0/default/vehicle_hal_manager/VehicleUtils.h
@@ -33,32 +33,30 @@
/** Returns underlying (integer) value for given enum. */
template<typename ENUM>
-inline typename std::underlying_type<ENUM>::type toInt(ENUM const value) {
+inline constexpr typename std::underlying_type<ENUM>::type toInt(
+ ENUM const value) {
return static_cast<typename std::underlying_type<ENUM>::type>(value);
}
-inline VehiclePropertyType getPropType(VehicleProperty prop) {
+inline constexpr VehiclePropertyType getPropType(int32_t prop) {
return static_cast<VehiclePropertyType>(
- static_cast<int32_t>(prop)
- & static_cast<int32_t>(VehiclePropertyType::MASK));
+ prop & toInt(VehiclePropertyType::MASK));
}
-inline VehiclePropertyGroup getPropGroup(VehicleProperty prop) {
+inline constexpr VehiclePropertyGroup getPropGroup(int32_t prop) {
return static_cast<VehiclePropertyGroup>(
- static_cast<int32_t>(prop)
- & static_cast<int32_t>(VehiclePropertyGroup::MASK));
+ prop & toInt(VehiclePropertyGroup::MASK));
}
-inline VehicleArea getPropArea(VehicleProperty prop) {
- return static_cast<VehicleArea>(
- static_cast<int32_t>(prop) & static_cast<int32_t>(VehicleArea::MASK));
+inline constexpr VehicleArea getPropArea(int32_t prop) {
+ return static_cast<VehicleArea>(prop & toInt(VehicleArea::MASK));
}
-inline bool isGlobalProp(VehicleProperty prop) {
+inline constexpr bool isGlobalProp(int32_t prop) {
return getPropArea(prop) == VehicleArea::GLOBAL;
}
-inline bool isSystemProperty(VehicleProperty prop) {
+inline constexpr bool isSystemProperty(int32_t prop) {
return VehiclePropertyGroup::SYSTEM == getPropGroup(prop);
}
diff --git a/vehicle/2.0/types.hal b/vehicle/2.0/types.hal
index 9fda4fd..e1e4453 100644
--- a/vehicle/2.0/types.hal
+++ b/vehicle/2.0/types.hal
@@ -2488,7 +2488,8 @@
};
struct VehiclePropConfig {
- VehicleProperty prop;
+ /* Property identifier */
+ int32_t prop;
/*
* Defines if the property is read or write or both.
@@ -2549,7 +2550,7 @@
*/
struct VehiclePropValue {
/* Property identifier */
- VehicleProperty prop;
+ int32_t prop;
/* Time is elapsed nanoseconds since boot */
int64_t timestamp;
@@ -2669,7 +2670,7 @@
*/
struct SubscribeOptions {
/* Property to subscribe */
- VehicleProperty propId;
+ int32_t propId;
/*
* Area ids - this must be a bit mask of areas to subscribe or 0 to subscribe