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

Commit d969b57d authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge changes from topic "am-aa23dce5dfef4eabb0d598df92a6d955" into rvc-d1-dev-plus-aosp

* changes:
  Merge changes from topic "rvc-dev-trout" into rvc-dev am: 7bb7ec3d am: 72446749
  Split client and server impl am: a6d6fa3d am: 6fc5d411
  Split vehicle client and server interface header am: 2f2b3bbe am: af57a4d6
  Add headers and macros for building VHAL server for AGL am: d5990965 am: 47b61bce
parents 17b62d76 b3f67fd3
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ cc_library_static {
        "impl/vhal_v2_0/CommConn.cpp",
        "impl/vhal_v2_0/EmulatedVehicleConnector.cpp",
        "impl/vhal_v2_0/EmulatedVehicleHal.cpp",
        "impl/vhal_v2_0/VehicleHalClient.cpp",
        "impl/vhal_v2_0/VehicleHalServer.cpp",
        "impl/vhal_v2_0/VehicleEmulator.cpp",
        "impl/vhal_v2_0/PipeComm.cpp",
        "impl/vhal_v2_0/ProtoMessageConverter.cpp",
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <vector>

#include <android/hardware/automotive/vehicle/2.0/types.h>

namespace android::hardware::automotive::vehicle::V2_0 {

/**
 *  Vehicle HAL talks to the vehicle through a client, instead of accessing
 *  the car bus directly, to give us more flexibility on the implementation.
 *  Android OS do not need direct access to the vehicle, and the communication
 *  channel is also customizable.
 *
 *  Client lives on the Android (HAL) side to talk to the vehicle
 */
class IVehicleClient {
  public:
    IVehicleClient() = default;

    IVehicleClient(const IVehicleClient&) = delete;

    IVehicleClient& operator=(const IVehicleClient&) = delete;

    IVehicleClient(IVehicleClient&&) = default;

    virtual ~IVehicleClient() = default;

    // Get configuration of all properties from server
    virtual std::vector<VehiclePropConfig> getAllPropertyConfig() const = 0;

    // Send the set property request to server
    // updateStatus indicate if VHal should change the status of the value
    // it should be false except injecting values for e2e tests
    virtual StatusCode setProperty(const VehiclePropValue& value, bool updateStatus) = 0;

    // Receive a new property value from server
    // updateStatus is true if and only if the value is
    // generated by car (ECU/fake generator/injected)
    virtual void onPropertyValue(const VehiclePropValue& value, bool updateStatus) = 0;

    // Dump method forwarded from HIDL's debug()
    // If implemented, it must return whether the caller should dump its state.
    virtual bool dump(const hidl_handle& /* handle */, const hidl_vec<hidl_string>& /* options */) {
        return true;
    }
};

}  // namespace android::hardware::automotive::vehicle::V2_0
+3 −79
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@

#include <android/hardware/automotive/vehicle/2.0/types.h>

#include "VehicleClient.h"
#include "VehicleServer.h"

namespace android {
namespace hardware {
namespace automotive {
@@ -33,85 +36,6 @@ namespace V2_0 {
 *  regardless of the underlying communication channels.
 */

/**
 *  Vehicle HAL talks to the vehicle through a client, instead of accessing
 *  the car bus directly, to give us more flexibility on the implementation.
 *  Android OS do not need direct access to the vehicle, and the communication
 *  channel is also customizable.
 *
 *  Client lives on the Android (HAL) side to talk to the vehicle
 */
class IVehicleClient {
  public:
    IVehicleClient() = default;

    IVehicleClient(const IVehicleClient&) = delete;

    IVehicleClient& operator=(const IVehicleClient&) = delete;

    IVehicleClient(IVehicleClient&&) = default;

    virtual ~IVehicleClient() = default;

    // Get configuration of all properties from server
    virtual std::vector<VehiclePropConfig> getAllPropertyConfig() const = 0;

    // Send the set property request to server
    // updateStatus indicate if VHal should change the status of the value
    // it should be false except injecting values for e2e tests
    virtual StatusCode setProperty(const VehiclePropValue& value, bool updateStatus) = 0;

    // Receive a new property value from server
    // updateStatus is true if and only if the value is
    // generated by car (ECU/fake generator/injected)
    virtual void onPropertyValue(const VehiclePropValue& value, bool updateStatus) = 0;

    // Dump method forwarded from HIDL's debug()
    // If implemented, it must return whether the caller should dump its state.
    virtual bool dump(const hidl_handle& /* handle */, const hidl_vec<hidl_string>& /* options */) {
        return true;
    }
};

/**
 *  Server lives on the vehicle side to talk to Android HAL
 */
class IVehicleServer {
  public:
    IVehicleServer() = default;

    IVehicleServer(const IVehicleServer&) = delete;

    IVehicleServer& operator=(const IVehicleServer&) = delete;

    IVehicleServer(IVehicleServer&&) = default;

    virtual ~IVehicleServer() = default;

    // Receive the get property configuration request from HAL.
    // Return a list of all property config
    virtual std::vector<VehiclePropConfig> onGetAllPropertyConfig() const = 0;

    // Receive the set property request from HAL.
    // Process the setting and return the status code
    // updateStatus indicate if VHal should change the status of the value
    // it should be false except injecting values for e2e tests
    virtual StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) = 0;

    // Receive a new property value from car (via direct connection to the car bus or the emulator)
    // and forward the value to HAL
    // updateStatus is true if and only if the value is
    // generated by car (ECU/fake generator/injected)
    virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0;

    // Dump method forwarded from HIDL's debug()
    // If implemented, it must return whether the caller should dump its state.
    virtual bool onDump(const hidl_handle& /* handle */,
                        const hidl_vec<hidl_string>& /* options */) {
        return true;
    }
};

/**
 *  If Android has direct access to the vehicle, then the client and
 *  the server may act in passthrough mode to avoid extra IPC
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <deque>
#include <map>
#include <mutex>
#include <memory>

#include <android/hardware/automotive/vehicle/2.0/types.h>

+68 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <vector>

#include <android/hardware/automotive/vehicle/2.0/types.h>

namespace android::hardware::automotive::vehicle::V2_0 {

/**
 *  Server lives on the vehicle side to talk to Android HAL.
 *  Note that the server may not be run on Android
 */
class IVehicleServer {
  public:
    IVehicleServer() = default;

    IVehicleServer(const IVehicleServer&) = delete;

    IVehicleServer& operator=(const IVehicleServer&) = delete;

    IVehicleServer(IVehicleServer&&) = default;

    virtual ~IVehicleServer() = default;

    // Receive the get property configuration request from HAL.
    // Return a list of all property config
    virtual std::vector<VehiclePropConfig> onGetAllPropertyConfig() const = 0;

    // Receive the set property request from HAL.
    // Process the setting and return the status code
    // updateStatus indicate if VHal should change the status of the value
    // it should be false except injecting values for e2e tests
    virtual StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) = 0;

    // Receive a new property value from car (via direct connection to the car bus or the emulator)
    // and forward the value to HAL
    // updateStatus is true if and only if the value is
    // generated by car (ECU/fake generator/injected)
    virtual void onPropertyValueFromCar(const VehiclePropValue& value, bool updateStatus) = 0;

    // TODO (chenhaosjtuacm): fix this since there are no HIDL in non-Android OS
#ifdef __ANDROID__
    // Dump method forwarded from HIDL's debug()
    // If implemented, it must return whether the caller should dump its state.
    virtual bool onDump(const hidl_handle& /* handle */,
                        const hidl_vec<hidl_string>& /* options */) {
        return true;
    }
#endif  // __ANDROID__
};

}  // namespace android::hardware::automotive::vehicle::V2_0
Loading