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

Commit 6cd2fd7e authored by Yu Shan's avatar Yu Shan
Browse files

Move VehicleHalProto out from vhal_v2_0.

VehicleHalProto would be used by AIDL Vhal as well so move it to
a common place.

Test: Presubmit
Bug: 215419573
Change-Id: I1e886a64a6c5ef76f7dc918feccc9cf63b8bca0c
parent 73446f49
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
};
+6 −4
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ namespace automotive {
namespace vehicle {
namespace fake {

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

@@ -80,13 +80,15 @@ 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;

  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;
+2 −2
Original line number Diff line number Diff line
@@ -25,8 +25,8 @@ package {
cc_library_static {
    name: "android.hardware.automotive.vehicle@2.0-libproto-native",
    visibility: [
        "//hardware/interfaces/automotive/vehicle/2.0/default:__subpackages__",
        "//device/generic/car/emulator/vhal_v2_0:__subpackages__",
        "//hardware/interfaces/automotive/vehicle:__subpackages__",
        "//device/generic/car/emulator:__subpackages__",
    ],
    vendor: true,
    host_supported: true,
+110 −0
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
};