/*
 * 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
