Loading automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp +31 −9 Original line number Diff line number Diff line Loading @@ -81,10 +81,18 @@ using ::android::base::StartsWith; using ::android::base::StringPrintf; // In order to test large number of vehicle property configs, we might generate additional fake // property config start from this ID. Note these fake properties are for getAllPropertyConfigs // testing only. constexpr int32_t STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST = 0x5000; constexpr int32_t NUMBER_OF_TEST_VENDOR_CODES = 0x3000; // property config start from this ID. These fake properties are for getPropertyList, // getPropertiesAsync, and setPropertiesAsync. // 0x21403000 constexpr int32_t STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST = 0x3000 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | toInt(testpropertyutils_impl::VehiclePropertyType::INT32); // 0x21405000 constexpr int32_t ENDING_VENDOR_CODE_PROPERTIES_FOR_TEST = 0x5000 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | toInt(testpropertyutils_impl::VehiclePropertyType::INT32); // The directory for default property configuration file. // For config file format, see impl/default_config/config/README.md. constexpr char DEFAULT_CONFIG_DIR[] = "/vendor/etc/automotive/vhalconfig/"; Loading Loading @@ -590,6 +598,17 @@ FakeVehicleHardware::ValueResultType FakeVehicleHardware::maybeGetSpecialValue( int32_t propId = value.prop; ValueResultType result; if (propId >= STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST && propId < ENDING_VENDOR_CODE_PROPERTIES_FOR_TEST) { *isSpecialValue = true; result = mValuePool->obtainInt32(/* value= */ 5); result.value()->prop = propId; result.value()->areaId = 0; result.value()->timestamp = elapsedRealtimeNano(); return result; } if (mFakeUserHal->isSupported(propId)) { *isSpecialValue = true; return getUserHalProp(value); Loading Loading @@ -706,6 +725,12 @@ VhalResult<void> FakeVehicleHardware::maybeSetSpecialValue(const VehiclePropValu VehiclePropValuePool::RecyclableType updatedValue; int32_t propId = value.prop; if (propId >= STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST && propId < ENDING_VENDOR_CODE_PROPERTIES_FOR_TEST) { *isSpecialValue = true; return {}; } if (mFakeUserHal->isSupported(propId)) { *isSpecialValue = true; return setUserHalProp(value); Loading Loading @@ -829,7 +854,6 @@ VhalResult<void> FakeVehicleHardware::setValue(const VehiclePropValue& value) { // Here we are just updating mValuePool. bool isSpecialValue = false; auto setSpecialValueResult = maybeSetSpecialValue(value, &isSpecialValue); if (isSpecialValue) { if (!setSpecialValueResult.ok()) { return StatusError(getErrorCode(setSpecialValueResult)) Loading Loading @@ -1038,11 +1062,9 @@ std::string FakeVehicleHardware::parseErrMsg(std::string fieldName, std::string void FakeVehicleHardware::generateVendorConfigs( std::vector<VehiclePropConfig>& outAllConfigs) const { for (int i = STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST; i < STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST + NUMBER_OF_TEST_VENDOR_CODES; i++) { i < ENDING_VENDOR_CODE_PROPERTIES_FOR_TEST; i++) { VehiclePropConfig config; config.prop = i | toInt(propertyutils_impl::VehiclePropertyGroup::VENDOR) | toInt(propertyutils_impl::VehicleArea::GLOBAL) | toInt(propertyutils_impl::VehiclePropertyType::INT32); config.prop = i; config.access = VehiclePropertyAccess::READ_WRITE; outAllConfigs.push_back(config); } Loading Loading
automotive/vehicle/aidl/impl/fake_impl/hardware/src/FakeVehicleHardware.cpp +31 −9 Original line number Diff line number Diff line Loading @@ -81,10 +81,18 @@ using ::android::base::StartsWith; using ::android::base::StringPrintf; // In order to test large number of vehicle property configs, we might generate additional fake // property config start from this ID. Note these fake properties are for getAllPropertyConfigs // testing only. constexpr int32_t STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST = 0x5000; constexpr int32_t NUMBER_OF_TEST_VENDOR_CODES = 0x3000; // property config start from this ID. These fake properties are for getPropertyList, // getPropertiesAsync, and setPropertiesAsync. // 0x21403000 constexpr int32_t STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST = 0x3000 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | toInt(testpropertyutils_impl::VehiclePropertyType::INT32); // 0x21405000 constexpr int32_t ENDING_VENDOR_CODE_PROPERTIES_FOR_TEST = 0x5000 | toInt(testpropertyutils_impl::VehiclePropertyGroup::VENDOR) | toInt(testpropertyutils_impl::VehicleArea::GLOBAL) | toInt(testpropertyutils_impl::VehiclePropertyType::INT32); // The directory for default property configuration file. // For config file format, see impl/default_config/config/README.md. constexpr char DEFAULT_CONFIG_DIR[] = "/vendor/etc/automotive/vhalconfig/"; Loading Loading @@ -590,6 +598,17 @@ FakeVehicleHardware::ValueResultType FakeVehicleHardware::maybeGetSpecialValue( int32_t propId = value.prop; ValueResultType result; if (propId >= STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST && propId < ENDING_VENDOR_CODE_PROPERTIES_FOR_TEST) { *isSpecialValue = true; result = mValuePool->obtainInt32(/* value= */ 5); result.value()->prop = propId; result.value()->areaId = 0; result.value()->timestamp = elapsedRealtimeNano(); return result; } if (mFakeUserHal->isSupported(propId)) { *isSpecialValue = true; return getUserHalProp(value); Loading Loading @@ -706,6 +725,12 @@ VhalResult<void> FakeVehicleHardware::maybeSetSpecialValue(const VehiclePropValu VehiclePropValuePool::RecyclableType updatedValue; int32_t propId = value.prop; if (propId >= STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST && propId < ENDING_VENDOR_CODE_PROPERTIES_FOR_TEST) { *isSpecialValue = true; return {}; } if (mFakeUserHal->isSupported(propId)) { *isSpecialValue = true; return setUserHalProp(value); Loading Loading @@ -829,7 +854,6 @@ VhalResult<void> FakeVehicleHardware::setValue(const VehiclePropValue& value) { // Here we are just updating mValuePool. bool isSpecialValue = false; auto setSpecialValueResult = maybeSetSpecialValue(value, &isSpecialValue); if (isSpecialValue) { if (!setSpecialValueResult.ok()) { return StatusError(getErrorCode(setSpecialValueResult)) Loading Loading @@ -1038,11 +1062,9 @@ std::string FakeVehicleHardware::parseErrMsg(std::string fieldName, std::string void FakeVehicleHardware::generateVendorConfigs( std::vector<VehiclePropConfig>& outAllConfigs) const { for (int i = STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST; i < STARTING_VENDOR_CODE_PROPERTIES_FOR_TEST + NUMBER_OF_TEST_VENDOR_CODES; i++) { i < ENDING_VENDOR_CODE_PROPERTIES_FOR_TEST; i++) { VehiclePropConfig config; config.prop = i | toInt(propertyutils_impl::VehiclePropertyGroup::VENDOR) | toInt(propertyutils_impl::VehicleArea::GLOBAL) | toInt(propertyutils_impl::VehiclePropertyType::INT32); config.prop = i; config.access = VehiclePropertyAccess::READ_WRITE; outAllConfigs.push_back(config); } Loading