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

Commit 5152fff0 authored by Yu Shan's avatar Yu Shan
Browse files

Implement getSupportedValuesLists in DefaultVehicleHal.

Implement getSupportedValuesLists in DefaultVehicleHal. This CL
also updates the doc to allow per [propId, areaId] to still kept
HasSupportedValueInfo as null for new VHAL implementation. This allows
VHAL implementation to opt-in the new supported values API on a
per [propId, areaId] basis.

Flag: EXEMPT HAL impl
Test: atest DefaultVehicleHalTest
Bug: 382563296
Change-Id: I931fe18c2e326c46446033204e8fdf63d5c10c8a
parent 2effe56f
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -267,6 +267,9 @@ interface IVehicle {
    /**
     * Gets the supported values lists for [propId, areaId]s.
     *
     * This is only supported for [propId, areaId]s that have non-null
     * {@code hasSupportedValueInfo} for their {@code VehicleAreaConfig}.
     *
     * For a specific [propId, areaId], if the hardware currently specifies
     * a list of supported values for it, then it is returned through the
     * {@code supportedValuesList} field inside
@@ -304,6 +307,9 @@ interface IVehicle {
    /**
     * Gets the min/max supported values for [propId, areaId]s.
     *
     * This is only supported for [propId, areaId]s that have non-null
     * {@code hasSupportedValueInfo} for their {@code VehicleAreaConfig}.
     *
     * For a specific [propId, areaId], if the hardware currently specifies
     * min/max supported value for it, then it is returned through the
     * {@code minSupportedValue} or {@code maxSupportedValue} field inside
@@ -342,6 +348,9 @@ interface IVehicle {
    /**
     * Registers the supported value change callback.
     *
     * This is only supported for [propId, areaId]s that have non-null
     * {@code hasSupportedValueInfo} for their {@code VehicleAreaConfig}.
     *
     * For the specified [propId, areaId]s,
     * {@code callback.onSupportedValueChange} must be invoked if change
     * happens.
@@ -360,6 +369,9 @@ interface IVehicle {
    /**
     * Unregisters the supported value change callback.
     *
     * This is only supported for [propId, areaId]s that have non-null
     * {@code hasSupportedValueInfo} for their {@code VehicleAreaConfig}.
     *
     * @param callback The callback to unregister.
     * @param propIdAreaIds A list of [propId, areaId]s to unregister.
     */
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ parcelable MinMaxSupportedValueResult {
     *
     * If the [propId, areaId] does not specify a max supported value, this
     * is {@code null}.
     *
     * This must be ignored if status is not {@code StatusCode.OK}.
     */
    @nullable RawPropValues maxSupportedValue;
}
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ parcelable SupportedValuesListResult {
     *
     * If the [propId, areaId] does not specify a supported values list, this
     * is {@code null}.
     *
     * This must be ignored if status is not {@code StatusCode.OK}.
     */
    @nullable List<RawPropValues> supportedValuesList;
}
+10 −3
Original line number Diff line number Diff line
@@ -230,10 +230,17 @@ parcelable VehicleAreaConfig {
    boolean supportVariableUpdateRate;

    /**
     * For VHAL implementation >= V4, this must not be {@code null}. This specifies whether
     * this property may have min/max supported value or supported values list.
     * This specifies whether this property may have min/max supported value or supported values
     * list for [propId, areaId] that supports new supported values APIs.
     *
     * For VHAL implementation < V4, this is always {@code null} and is not accessed.
     * If this is not {@code null}. The client may use {@code getMinMaxSupportedValue},
     * {@code getSupportedValuesLists}, {@code subscribeSupportedValueChange},
     * {@code unsubscribeSupportedValueChange}.
     *
     * If this is {@code null} for legacy properties, the APIs mentioned before are not supported.
     * Client must fallback to use static supported value information in {@code VehicleAreaConfig}.
     *
     * For VHAL implementation < V4, this is always {@code null}.
     */
    @nullable HasSupportedValueInfo hasSupportedValueInfo;
}
+85 −0
Original line number Diff line number Diff line
@@ -18,9 +18,11 @@
#define android_hardware_automotive_vehicle_aidl_impl_hardware_include_IVehicleHardware_H_

#include <VehicleHalTypes.h>
#include <VehicleUtils.h>

#include <memory>
#include <optional>
#include <unordered_set>
#include <vector>

namespace android {
@@ -59,10 +61,23 @@ class IVehicleHardware {
    using GetValuesCallback = std::function<void(std::vector<aidlvhal::GetValueResult>)>;
    using PropertyChangeCallback = std::function<void(std::vector<aidlvhal::VehiclePropValue>)>;
    using PropertySetErrorCallback = std::function<void(std::vector<SetValueErrorEvent>)>;
    using SupportedValueChangeCallback = std::function<void(std::vector<PropIdAreaId>)>;

    virtual ~IVehicleHardware() = default;

    // Get all the property configs.
    //
    // Note that {@code VehicleAreaConfig.HasSupportedValueInfo} field is newly introduced in VHAL
    // V4 to specify whether the [propertyId, areaId] has specified min/max supported value or
    // supported values list.
    //
    // Since IVehicleHardware is designed to be backward compatible, this field can be set to null.
    // If this field is set to null, VHAL client should fallback to use min/max supported value
    // information in {@code VehicleAreaConfig} and {@code supportedEnumVaules} for enum properties.
    //
    // It is highly recommended to specify {@code VehicleAreaConfig.HasSupportedValueInfo} for new
    // property implementations, even if the property does not specify supported values or the
    // supported values are static.
    virtual std::vector<aidlvhal::VehiclePropConfig> getAllPropertyConfigs() const = 0;

    // Get the property configs for the specified propId. This is used for early-boot
@@ -240,6 +255,76 @@ class IVehicleHardware {
                                                  [[maybe_unused]] float sampleRate) {
        return aidlvhal::StatusCode::OK;
    }

    // Gets the min/max supported values for each of the specified [propId, areaId]s.
    //
    // The returned result may change dynamically.
    //
    // This is only called for [propId, areaId] that has
    // {@code HasSupportedValueInfo.hasMinSupportedValue} or
    // {@code HasSupportedValueInfo.hasMinSupportedValue} set to true.
    //
    // Client must implement (override) this function if at least one [propId, areaId]'s
    // {@code HasSupportedValueInfo} is not null.
    virtual std::vector<aidlvhal::MinMaxSupportedValueResult> getMinMaxSupportedValues(
            [[maybe_unused]] const std::vector<PropIdAreaId>& propIdAreaIds) {
        return {};
    }

    // Gets the supported values list for each of the specified [propId, areaId]s.
    //
    // The returned result may change dynamically.
    //
    // This is only called for [propId, areaId] that has
    // {@code HasSupportedValueInfo.hasSupportedValuesList} set to true.
    //
    // Client must implement (override) this function if at least one [propId, areaId]'s
    // {@code HasSupportedValueInfo} is not null.
    virtual std::vector<aidlvhal::SupportedValuesListResult> getSupportedValuesLists(
            [[maybe_unused]] const std::vector<PropIdAreaId>& propIdAreaIds) {
        return {};
    }

    // Register a callback that would be called when the min/max supported value or supported
    // values list change dynamically for propertyID returned from
    // getPropertyIdsThatImplementGetSupportedValue
    //
    // This function must only be called once during initialization.
    //
    // Client must implement (override) this function if at least one [propId, areaId]'s
    // {@code HasSupportedValueInfo} is not null.
    virtual void registerSupportedValueChangeCallback(
            [[maybe_unused]] std::unique_ptr<const SupportedValueChangeCallback> callback) {
        // Do nothing.
    }

    // Subscribes to the min/max supported value or supported values list change for the specified
    // [propId, areaId]s.
    //
    // If the propertyId's supported values are static, then must do nothing.
    //
    // This is only called for [propId, areaId] that has non-null {@code HasSupportedValueInfo}.
    //
    // Client must implement (override) this function if at least one [propId, areaId]'s
    // {@code HasSupportedValueInfo} is not null.
    virtual aidlvhal::StatusCode subscribeSupportedValueChange(
            [[maybe_unused]] const std::vector<PropIdAreaId>& propIdAreaIds) {
        return aidlvhal::StatusCode::OK;
    }

    // Unsubscrbies to the min/max supported value or supported values list change.
    //
    // Must do nothing if the [propId, areaId] was not previously subscribed to for supported
    // values change.
    //
    // This is only called for [propId, areaId] that has non-null {@code HasSupportedValueInfo}.
    //
    // Client must implement (override) this function if at least one [propId, areaId]'s
    // {@code HasSupportedValueInfo} is not null.
    virtual aidlvhal::StatusCode unsubscribeSupportedValueChange(
            [[maybe_unused]] const std::vector<PropIdAreaId>& propIdAreaIds) {
        return aidlvhal::StatusCode::OK;
    }
};

}  // namespace vehicle
Loading