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

Commit ed48cd23 authored by Yuncheol Heo's avatar Yuncheol Heo Committed by Android (Google) Code Review
Browse files

Merge "Redirect the Cluster VHAL messages to vendor ones, or vice versa." into sc-dev

parents 016d01a9 e3eea4f9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -210,6 +210,7 @@ cc_binary {
    vendor: true,
    relative_install_path: "hw",
    srcs: ["VehicleService.cpp"],
    cflags: ["-DENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING"],
    shared_libs: [
        "libbase",
        "libjsoncpp",
+66 −0
Original line number Diff line number Diff line
@@ -115,6 +115,28 @@ const int32_t kSetBooleanPropertyFromVehicleForTest =
 */
const int32_t kMixedTypePropertyForTest =
        0x1111 | VehiclePropertyGroup::VENDOR | VehicleArea::GLOBAL | VehiclePropertyType::MIXED;

#ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING
/**
 * Converts the system property to the vendor property.
 * WARNING: This is only for the end-to-end testing, Should NOT include in the
 * user build */
inline constexpr int32_t toVendor(VehicleProperty prop) {
    return (toInt(prop) & ~toInt(VehiclePropertyGroup::MASK)) | VehiclePropertyGroup::VENDOR;
}

/**
 * These properties are used for the end-to-end testing of ClusterHomeService.
 */
constexpr int32_t VENDOR_CLUSTER_SWITCH_UI = toVendor(VehicleProperty::CLUSTER_SWITCH_UI);
constexpr int32_t VENDOR_CLUSTER_DISPLAY_STATE = toVendor(VehicleProperty::CLUSTER_DISPLAY_STATE);
constexpr int32_t VENDOR_CLUSTER_REPORT_STATE = toVendor(VehicleProperty::CLUSTER_REPORT_STATE);
constexpr int32_t VENDOR_CLUSTER_REQUEST_DISPLAY =
        toVendor(VehicleProperty::CLUSTER_REQUEST_DISPLAY);
constexpr int32_t VENDOR_CLUSTER_NAVIGATION_STATE =
        toVendor(VehicleProperty::CLUSTER_NAVIGATION_STATE);
#endif  // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING

/**
 * FakeDataCommand enum defines the supported command type for kGenerateFakeDataControllingProperty.
 * All those commands can be send independently with each other. And each will override the one sent
@@ -1237,6 +1259,50 @@ const ConfigDeclaration kVehicleProperties[]{
                                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                        },
        },
#ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING
        // Vendor propetry for E2E ClusterHomeService testing.
        {
                .config =
                        {
                                .prop = VENDOR_CLUSTER_SWITCH_UI,
                                .access = VehiclePropertyAccess::WRITE,
                                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                        },
        },
        {
                .config =
                        {
                                .prop = VENDOR_CLUSTER_DISPLAY_STATE,
                                .access = VehiclePropertyAccess::WRITE,
                                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                        },
        },
        {
                .config =
                        {
                                .prop = VENDOR_CLUSTER_REPORT_STATE,
                                .access = VehiclePropertyAccess::READ,
                                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                                .configArray = {0, 0, 0, 9, 0, 0, 0, 0, 16},
                        },
        },
        {
                .config =
                        {
                                .prop = VENDOR_CLUSTER_REQUEST_DISPLAY,
                                .access = VehiclePropertyAccess::READ,
                                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                        },
        },
        {
                .config =
                        {
                                .prop = VENDOR_CLUSTER_NAVIGATION_STATE,
                                .access = VehiclePropertyAccess::READ,
                                .changeMode = VehiclePropertyChangeMode::ON_CHANGE,
                        },
        },
#endif  // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING
};

}  // impl
+22 −0
Original line number Diff line number Diff line
@@ -247,6 +247,28 @@ StatusCode VehicleHalServer::onSetProperty(const VehiclePropValue& value, bool u
                    break;
            }
            break;

#ifdef ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING
        case toInt(VehicleProperty::CLUSTER_REPORT_STATE):
        case toInt(VehicleProperty::CLUSTER_REQUEST_DISPLAY):
        case toInt(VehicleProperty::CLUSTER_NAVIGATION_STATE):
        case VENDOR_CLUSTER_SWITCH_UI:
        case VENDOR_CLUSTER_DISPLAY_STATE: {
            auto updatedPropValue = createVehiclePropValue(getPropType(value.prop), 0);
            updatedPropValue->prop = value.prop & ~toInt(VehiclePropertyGroup::MASK);
            if (isSystemProperty(value.prop)) {
                updatedPropValue->prop |= toInt(VehiclePropertyGroup::VENDOR);
            } else {
                updatedPropValue->prop |= toInt(VehiclePropertyGroup::SYSTEM);
            }
            updatedPropValue->value = value.value;
            updatedPropValue->timestamp = elapsedRealtimeNano();
            updatedPropValue->areaId = value.areaId;
            onPropertyValueFromCar(*updatedPropValue, updateStatus);
            return StatusCode::OK;
        }
#endif  // ENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING

        default:
            break;
    }