mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Fix empty array object obtain.
Test: atest VehicleHalVehicleUtilsTest Bug: 316432606 Change-Id: I6b2009cf3e96be33cc4abdfaa4c781b46a0f49f8
This commit is contained in:
@@ -235,7 +235,7 @@ class VehiclePropValuePool {
|
||||
|
||||
bool isDisposable(aidl::android::hardware::automotive::vehicle::VehiclePropertyType type,
|
||||
size_t vectorSize) const {
|
||||
return vectorSize > mMaxRecyclableVectorSize || isComplexType(type);
|
||||
return vectorSize == 0 || vectorSize > mMaxRecyclableVectorSize || isComplexType(type);
|
||||
}
|
||||
|
||||
RecyclableType obtainDisposable(
|
||||
|
||||
@@ -124,7 +124,6 @@ createVehiclePropValueVec(aidl::android::hardware::automotive::vehicle::VehicleP
|
||||
break; // Valid, but nothing to do.
|
||||
default:
|
||||
ALOGE("createVehiclePropValue: unknown type: %d", toInt(type));
|
||||
val.reset(nullptr);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
@@ -55,13 +55,6 @@ VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtain(const VehicleP
|
||||
int propId = src.prop;
|
||||
VehiclePropertyType type = getPropType(propId);
|
||||
size_t vectorSize = getVehicleRawValueVectorSize(src.value, type);
|
||||
if (vectorSize == 0 && !isComplexType(type)) {
|
||||
ALOGW("empty vehicle prop value, contains no content");
|
||||
ALOGW("empty vehicle prop value, contains no content, prop: %d", propId);
|
||||
// Return any empty VehiclePropValue.
|
||||
return RecyclableType{new VehiclePropValue{}, mDisposableDeleter};
|
||||
}
|
||||
|
||||
auto dest = obtain(type, vectorSize);
|
||||
|
||||
dest->prop = propId;
|
||||
|
||||
@@ -267,6 +267,20 @@ TEST_F(VehicleObjectPoolTest, testObtainCopyInt32Values) {
|
||||
ASSERT_EQ(*gotValue, prop);
|
||||
}
|
||||
|
||||
TEST_F(VehicleObjectPoolTest, testObtainCopyInt32ValuesEmptyArray) {
|
||||
VehiclePropValue prop{
|
||||
// INT32_VEC property.
|
||||
.prop = toInt(VehicleProperty::INFO_FUEL_TYPE),
|
||||
.areaId = 2,
|
||||
.timestamp = 3,
|
||||
.value = {.int32Values = {}},
|
||||
};
|
||||
auto gotValue = mValuePool->obtain(prop);
|
||||
|
||||
ASSERT_NE(gotValue, nullptr);
|
||||
ASSERT_EQ(*gotValue, prop);
|
||||
}
|
||||
|
||||
TEST_F(VehicleObjectPoolTest, testObtainCopyInt64Values) {
|
||||
VehiclePropValue prop{
|
||||
// INT64_VEC property.
|
||||
|
||||
Reference in New Issue
Block a user