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

Commit 9f69e1ac authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8107456 from 66a8c978 to tm-release

Change-Id: Ifb19bfe605a26d8a301491fe7911f766decd9dbf
parents 90fdc6d9 66a8c978
Loading
Loading
Loading
Loading
+0 −110
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 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.
 */

syntax = "proto2";

package vhal_proto;

// CMD messages are from workstation --> VHAL
// RESP messages are from VHAL --> workstation
enum MsgType {
    GET_CONFIG_CMD                      = 0;
    GET_CONFIG_RESP                     = 1;
    GET_CONFIG_ALL_CMD                  = 2;
    GET_CONFIG_ALL_RESP                 = 3;
    GET_PROPERTY_CMD                    = 4;
    GET_PROPERTY_RESP                   = 5;
    GET_PROPERTY_ALL_CMD                = 6;
    GET_PROPERTY_ALL_RESP               = 7;
    SET_PROPERTY_CMD                    = 8;
    SET_PROPERTY_RESP                   = 9;
    SET_PROPERTY_ASYNC                  = 10;
    DEBUG_CMD                           = 11;
    DEBUG_RESP                          = 12;
}
enum Status {
    RESULT_OK                           = 0;
    ERROR_UNKNOWN                       = 1;
    ERROR_UNIMPLEMENTED_CMD             = 2;
    ERROR_INVALID_PROPERTY              = 3;
    ERROR_INVALID_AREA_ID               = 4;
    ERROR_PROPERTY_UNINITIALIZED        = 5;
    ERROR_WRITE_ONLY_PROPERTY           = 6;
    ERROR_MEMORY_ALLOC_FAILED           = 7;
    ERROR_INVALID_OPERATION             = 8;
}

enum VehiclePropStatus {
    AVAILABLE                           = 0;
    UNAVAILABLE                         = 1;
    ERROR                               = 2;
}

message VehicleAreaConfig {
    required int32  area_id             = 1;
    optional sint32 min_int32_value     = 2;
    optional sint32 max_int32_value     = 3;
    optional sint64 min_int64_value     = 4;
    optional sint64 max_int64_value     = 5;
    optional float  min_float_value     = 6;
    optional float  max_float_value     = 7;
}

message VehiclePropConfig {
    required int32             prop                = 1;
    optional int32             access              = 2;
    optional int32             change_mode         = 3;
    optional int32             value_type          = 4;
    optional int32             supported_areas     = 5;     // Deprecated - DO NOT USE
    repeated VehicleAreaConfig area_configs        = 6;
    optional int32             config_flags        = 7;
    repeated int32             config_array        = 8;
    optional string            config_string       = 9;
    optional float             min_sample_rate     = 10;
    optional float             max_sample_rate     = 11;
};

message VehiclePropValue {
    // common data
    required int32  prop                = 1;
    optional int32  value_type          = 2;
    optional int64  timestamp           = 3;    // required for valid data from HAL, skipped for set
    optional VehiclePropStatus  status  = 10;   // required for valid data from HAL, skipped for set

    // values
    optional int32  area_id             = 4;
    repeated sint32 int32_values        = 5;    // this also covers boolean value.
    repeated sint64 int64_values        = 6;
    repeated float  float_values        = 7;
    optional string string_value        = 8;
    optional bytes  bytes_value         = 9;
};

// This structure is used to notify what values to get from the Vehicle HAL
message VehiclePropGet {
    required int32 prop                 = 1;
    optional int32 area_id              = 2;
};

message EmulatorMessage {
    required MsgType           msg_type       = 1;
    optional Status            status         = 2; // Only for RESP messages
    repeated VehiclePropGet    prop           = 3; // Provided for getConfig, getProperty commands
    repeated VehiclePropConfig config         = 4;
    repeated VehiclePropValue  value          = 5;
    repeated string            debug_commands = 6; // Required for debug command
    optional string            debug_result   = 7; // Required for debug RESP messages
};
+43 −4
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@
#include <IVehicleHardware.h>
#include <VehicleHalTypes.h>
#include <VehiclePropertyStore.h>
#include <android-base/parseint.h>
#include <android-base/result.h>
#include <android-base/stringprintf.h>
#include <android-base/thread_annotations.h>

#include <map>
@@ -37,7 +39,7 @@ namespace automotive {
namespace vehicle {
namespace fake {

class FakeVehicleHardware final : public IVehicleHardware {
class FakeVehicleHardware : public IVehicleHardware {
  public:
    FakeVehicleHardware();

@@ -78,13 +80,21 @@ class FakeVehicleHardware final : public IVehicleHardware {
    void registerOnPropertySetErrorEvent(
            std::unique_ptr<const PropertySetErrorCallback> callback) override;

  protected:
    // mValuePool is also used in mServerSidePropStore.
    const std::shared_ptr<VehiclePropValuePool> mValuePool;
    const std::shared_ptr<VehiclePropertyStore> mServerSidePropStore;

    ::android::base::Result<VehiclePropValuePool::RecyclableType> getValue(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value) const;

    ::android::base::Result<void> setValue(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value);

  private:
    // Expose private methods to unit test.
    friend class FakeVehicleHardwareTestHelper;

    // mValuePool is also used in mServerSidePropStore.
    const std::shared_ptr<VehiclePropValuePool> mValuePool;
    const std::shared_ptr<VehiclePropertyStore> mServerSidePropStore;
    const std::unique_ptr<obd2frame::FakeObd2Frame> mFakeObd2Frame;
    const std::unique_ptr<FakeUserHal> mFakeUserHal;
    std::mutex mCallbackLock;
@@ -120,6 +130,35 @@ class FakeVehicleHardware final : public IVehicleHardware {
    ::android::base::Result<VehiclePropValuePool::RecyclableType> getUserHalProp(
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropValue& value) const;
    bool isHvacPropAndHvacNotAvailable(int32_t propId);

    std::string dumpAllProperties();
    std::string dumpOnePropertyByConfig(
            int rowNumber,
            const ::aidl::android::hardware::automotive::vehicle::VehiclePropConfig& config);
    std::string dumpOnePropertyById(int32_t propId, int32_t areaId);
    std::string dumpHelp();
    std::string dumpListProperties();
    std::string dumpSpecificProperty(const std::vector<std::string>& options);
    std::string dumpSetProperties(const std::vector<std::string>& options);

    template <typename T>
    ::android::base::Result<T> safelyParseInt(int index, const std::string& s) {
        T out;
        if (!::android::base::ParseInt(s, &out)) {
            return ::android::base::Error() << ::android::base::StringPrintf(
                           "non-integer argument at index %d: %s\n", index, s.c_str());
        }
        return out;
    }
    ::android::base::Result<float> safelyParseFloat(int index, const std::string& s);
    std::vector<std::string> getOptionValues(const std::vector<std::string>& options,
                                             size_t* index);
    ::android::base::Result<::aidl::android::hardware::automotive::vehicle::VehiclePropValue>
    parseSetPropOptions(const std::vector<std::string>& options);
    ::android::base::Result<std::vector<uint8_t>> parseHexString(const std::string& s);

    ::android::base::Result<void> checkArgumentsSize(const std::vector<std::string>& options,
                                                     size_t minSize);
};

}  // namespace fake
Loading