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

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

Merge "Vehicle HAL reference impl Part II"

parents d81c8e6d db179c5e
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -27,9 +27,13 @@ interface IVehicle {

  /*
   * Returns a list of property configurations for given properties.
   *
   * If requested VehicleProperty wasn't found it must return
   * StatusCode::INVALID_ARG, otherwise a list of vehicle property
   * configurations with StatusCode::OK
   */
  getPropConfigs(vec<VehicleProperty> props)
          generates (vec<VehiclePropConfig> propConfigs);
          generates (StatusCode status, vec<VehiclePropConfig> propConfigs);

  /**
   * Get a vehicle property value.
@@ -39,11 +43,14 @@ interface IVehicle {
   * For VehiclePropertyChangeMode::ON_CHANGE properties, it must return the
   * latest available value.
   *
   * Some properties like AUDIO_VOLUME requires to pass additional data in
   * GET request in VehiclePropValue object.
   *
   * If there is no data available yet, which can happen during initial stage,
   * this call must return immediately with an error code of
   * StatusCode::TRY_AGAIN.
   */
  get(VehicleProperty propId, int32_t areaId)
  get(VehiclePropValue requestedPropValue)
          generates (StatusCode status, VehiclePropValue propValue);

  /**
@@ -75,7 +82,7 @@ interface IVehicle {
   * Unsubscribes from property events.
   *
   * If this client wasn't subscribed to the given property, this method
   * must return StatusCode::INVALID_ARGUMENT.
   * must return StatusCode::INVALID_ARG.
   */
  unsubscribe(IVehicleCallback callback, VehicleProperty propId)
          generates (StatusCode status);
+10 −7
Original line number Diff line number Diff line
@@ -43,14 +43,17 @@ interface IVehicleCallback {
    oneway onPropertySet(VehiclePropValue propValue);

    /*
     * Called by HAL server when error condition has occurred.
     * Set property value is usually asynchronous operation. Thus even if
     * client received StatusCode::OK from the IVehicle::set(...) this
     * doesn't guarantee that the value was successfully propagated to the
     * vehicle network. If such rare event occurs this method must be called.
     *
     * @param errorCode - any value from StatusCode enum.
     * @parm property - a property where error has happened. If this is
     * a generic error, this value should be VehicleProperty::INVALID.
     * @param operation Represent the operation where the error has happened.
     * @param property - a property where error has happened.
     * @param areaId - bitmask that specifies in which areas the problem has
     *                 occurred, must be 0 for global properties
     */
    oneway onError(StatusCode errorCode,
    oneway onPropertySetError(StatusCode errorCode,
                              VehicleProperty propId,
                   VehiclePropertyOperation operation);
                              int32_t areaId);
};
+0 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ LOCAL_MODULE := $(module_prefix)-manager-lib
LOCAL_SRC_FILES := \
    vehicle_hal_manager/SubscriptionManager.cpp \
    vehicle_hal_manager/VehicleHalManager.cpp \
    vehicle_hal_manager/VehicleCallback.cpp \

LOCAL_SHARED_LIBRARIES := \
    liblog \
+13 −15
Original line number Diff line number Diff line
@@ -36,18 +36,15 @@ public:

    using HalEventFunction = std::function<void(VehiclePropValuePtr)>;
    using HalErrorFunction = std::function<void(
            VehicleProperty property,
            status_t errorCode,
            VehiclePropertyOperation operation)>;
            StatusCode errorCode, VehicleProperty property, int32_t areaId)>;

    virtual ~VehicleHal() {}

    virtual std::vector<VehiclePropConfig> listProperties() = 0;
    virtual VehiclePropValuePtr get(VehicleProperty property,
                                    int32_t areaId,
                                    status_t* outStatus) = 0;
    virtual VehiclePropValuePtr get(const VehiclePropValue& requestedPropValue,
                                    StatusCode* outStatus) = 0;

    virtual status_t set(const VehiclePropValue& propValue) = 0;
    virtual StatusCode set(const VehiclePropValue& propValue) = 0;

    /**
     * Subscribe to HAL property events. This method might be called multiple
@@ -60,7 +57,7 @@ public:
     *                   rate, e.g. for properties with
     *                   VehiclePropertyChangeMode::CONTINUOUS
     */
    virtual status_t subscribe(VehicleProperty property,
    virtual StatusCode subscribe(VehicleProperty property,
                               int32_t areas,
                               float sampleRate) = 0;

@@ -69,7 +66,7 @@ public:
     *
     * @param property vehicle property to unsubscribe
     */
    virtual status_t unsubscribe(VehicleProperty property) = 0;
    virtual StatusCode unsubscribe(VehicleProperty property) = 0;

    /**
     * Override this method if you need to do one-time initialization.
@@ -82,7 +79,7 @@ public:
        const HalErrorFunction& onHalError) {
        mValuePool = valueObjectPool;
        mOnHalEvent = onHalEvent;
        mOnHalError = onHalError;
        mOnHalPropertySetError = onHalError;

        onCreate();
    }
@@ -91,19 +88,20 @@ public:
        return mValuePool;
    }
protected:
    /* Propagates property change events to vehicle HAL clients. */
    void doHalEvent(VehiclePropValuePtr v) {
        mOnHalEvent(std::move(v));
    }

    void doHalError(VehicleProperty property,
                    status_t errorCode,
                    VehiclePropertyOperation operation) {
        mOnHalError(property, errorCode, operation);
    /* Propagates error during set operation to the vehicle HAL clients. */
    void doHalPropertySetError(StatusCode errorCode,
                               VehicleProperty propId, int32_t areaId) {
        mOnHalPropertySetError(errorCode, propId, areaId);
    }

private:
    HalEventFunction mOnHalEvent;
    HalErrorFunction mOnHalError;
    HalErrorFunction mOnHalPropertySetError;
    VehiclePropValuePool* mValuePool;
};

+2 −2
Original line number Diff line number Diff line
@@ -43,11 +43,11 @@ const VehiclePropConfig kVehicleProperties[] = {
            VehicleAreaZone::ROW_1_LEFT | VehicleAreaZone::ROW_1_RIGHT),
        .areaConfigs = init_hidl_vec({
                 VehicleAreaConfig {
                     .areaId = val(VehicleAreaZone::ROW_2_LEFT),
                     .areaId = toInt(VehicleAreaZone::ROW_2_LEFT),
                     .minInt32Value = 1,
                     .maxInt32Value = 7},
                 VehicleAreaConfig {
                     .areaId = val(VehicleAreaZone::ROW_1_RIGHT),
                     .areaId = toInt(VehicleAreaZone::ROW_1_RIGHT),
                     .minInt32Value = 1,
                     .maxInt32Value = 5,
                 }
Loading