Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6345017f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add complex data type to Vehicle HAL"

parents 6a56e38e f21639f6
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -67,6 +67,14 @@ public:
                    pValue = getValuePool()->obtainFloat(42.42);
                }
                break;
            case VehicleProperty::VEHICLE_MAPS_DATA_SERVICE:
                pValue = getValuePool()->obtainComplex();
                pValue->value.int32Values = hidl_vec<int32_t> { 10, 20 };
                pValue->value.int64Values = hidl_vec<int64_t> { 30, 40 };
                pValue->value.floatValues = hidl_vec<float_t> { 1.1, 2.2 };
                pValue->value.bytes = hidl_vec<uint8_t> { 1, 2, 3 };
                pValue->value.stringValue = kCarMake;
                break;
            default:
                auto key = makeKey(property, areaId);
                if (mValues.count(key) == 0) {
@@ -308,6 +316,32 @@ TEST_F(VehicleHalManagerTest, subscribe_WriteOnly) {
    ASSERT_EQ(StatusCode::OK, res);
}

TEST_F(VehicleHalManagerTest, get_Complex) {
    invokeGet(VehicleProperty::VEHICLE_MAPS_DATA_SERVICE, 0);

    ASSERT_EQ(StatusCode::OK, actualStatusCode);
    ASSERT_EQ(VehicleProperty::VEHICLE_MAPS_DATA_SERVICE, actualValue.prop);

    ASSERT_EQ(3, actualValue.value.bytes.size());
    ASSERT_EQ(1, actualValue.value.bytes[0]);
    ASSERT_EQ(2, actualValue.value.bytes[1]);
    ASSERT_EQ(3, actualValue.value.bytes[2]);

    ASSERT_EQ(2, actualValue.value.int32Values.size());
    ASSERT_EQ(10, actualValue.value.int32Values[0]);
    ASSERT_EQ(20, actualValue.value.int32Values[1]);

    ASSERT_EQ(2, actualValue.value.floatValues.size());
    ASSERT_FLOAT_EQ(1.1, actualValue.value.floatValues[0]);
    ASSERT_FLOAT_EQ(2.2, actualValue.value.floatValues[1]);

    ASSERT_EQ(2, actualValue.value.int64Values.size());
    ASSERT_FLOAT_EQ(30, actualValue.value.int64Values[0]);
    ASSERT_FLOAT_EQ(40, actualValue.value.int64Values[1]);

    ASSERT_STREQ(kCarMake, actualValue.value.stringValue.c_str());
}

TEST_F(VehicleHalManagerTest, get_StaticString) {
    invokeGet(VehicleProperty::INFO_MAKE, 0);

+7 −0
Original line number Diff line number Diff line
@@ -103,6 +103,13 @@ const VehiclePropConfig kVehicleProperties[] = {
        .access = VehiclePropertyAccess::READ_WRITE,
        .changeMode = VehiclePropertyChangeMode::ON_CHANGE,

    },

    // Complex data type.
    {
        .prop = VehicleProperty::VEHICLE_MAPS_DATA_SERVICE,
        .access = VehiclePropertyAccess::READ_WRITE,
        .changeMode = VehiclePropertyChangeMode::ON_CHANGE
    }
};

+4 −0
Original line number Diff line number Diff line
@@ -80,6 +80,10 @@ VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainString(
    return val;
}

VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainComplex() {
    return obtain(VehiclePropertyType::COMPLEX);
}

VehiclePropValuePool::RecyclableType VehiclePropValuePool::obtainRecylable(
        VehiclePropertyType type, size_t vecSize) {
    // VehiclePropertyType is not overlapping with vectorSize.
+3 −1
Original line number Diff line number Diff line
@@ -184,13 +184,15 @@ public:
    RecyclableType obtainInt64(int64_t value);
    RecyclableType obtainFloat(float value);
    RecyclableType obtainString(const char* cstr);
    RecyclableType obtainComplex();

    VehiclePropValuePool(VehiclePropValuePool& ) = delete;
    VehiclePropValuePool& operator=(VehiclePropValuePool&) = delete;
private:
    bool isDisposable(VehiclePropertyType type, size_t vecSize) const {
        return vecSize > mMaxRecyclableVectorSize ||
               VehiclePropertyType::STRING == type;
               VehiclePropertyType::STRING == type ||
               VehiclePropertyType::COMPLEX == type;
    }

    RecyclableType obtainDisposable(VehiclePropertyType valueType,
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ std::unique_ptr<VehiclePropValue> createVehiclePropValue(
            val->value.bytes.resize(vecSize);
            break;
        case VehiclePropertyType::STRING:
        case VehiclePropertyType::COMPLEX:
            break; // Valid, but nothing to do.
        default:
            ALOGE("createVehiclePropValue: unknown type: %d", type);
Loading