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

Commit b33ac200 authored by Yu Shan's avatar Yu Shan
Browse files

Implement getPropConfigs in Default VHAL.

Test: atest DefaultVehicleHalTest
Bug: 200737967
Change-Id: Id0152cb2dbf489f5d709845108b87961f6d9a019
parent d652835d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@
    },
    {
      "name": "FakeUserHalTest"
    },
    {
      "name": "DefaultVehicleHalTest"
    }
  ]
}
+9 −2
Original line number Diff line number Diff line
@@ -22,10 +22,17 @@ cc_library {
    name: "FakeVehicleHardware",
    vendor: true,
    srcs: ["src/*.cpp"],
    cflags: ["-DENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING"],
    local_include_dirs: ["include"],
    export_include_dirs: ["include"],
    defaults: ["VehicleHalDefaults"],
    defaults: [
        "VehicleHalDefaults",
        "FakeVehicleHardwareDefaults",
    ],
}

cc_defaults {
    name: "FakeVehicleHardwareDefaults",
    cflags: ["-DENABLE_VENDOR_CLUSTER_PROPERTY_FOR_TESTING"],
    header_libs: [
        "IVehicleHardware",
        "VehicleHalDefaultConfig",
+0 −21
Original line number Diff line number Diff line
@@ -62,27 +62,6 @@ using ::android::base::Result;
const char* VENDOR_OVERRIDE_DIR = "/vendor/etc/automotive/vhaloverride/";
const char* OVERRIDE_PROPERTY = "persist.vendor.vhal_init_value_override";

template <class T>
StatusCode getErrorCode(const Result<T>& result) {
    if (result.ok()) {
        return StatusCode::OK;
    }
    return static_cast<StatusCode>(result.error().code());
}

template <class T>
int getIntErrorCode(const Result<T>& result) {
    return toInt(getErrorCode(result));
}

template <class T>
std::string getErrorMsg(const Result<T>& result) {
    if (result.ok()) {
        return "";
    }
    return result.error().message();
}

}  // namespace

void FakeVehicleHardware::storePropInitialValue(const defaultconfig::ConfigDeclaration& config) {
+25 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#define android_hardware_automotive_vehicle_aidl_impl_utils_common_include_VehicleUtils_H_

#include <VehicleHalTypes.h>

#include <android-base/result.h>
#include <utils/Log.h>

namespace android {
@@ -183,6 +185,29 @@ inline size_t getVehiclePropValueSize(
    return size;
}

template <class T>
::aidl::android::hardware::automotive::vehicle::StatusCode getErrorCode(
        const ::android::base::Result<T>& result) {
    if (result.ok()) {
        return ::aidl::android::hardware::automotive::vehicle::StatusCode::OK;
    }
    return static_cast<::aidl::android::hardware::automotive::vehicle::StatusCode>(
            result.error().code());
}

template <class T>
int getIntErrorCode(const ::android::base::Result<T>& result) {
    return toInt(getErrorCode(result));
}

template <class T>
std::string getErrorMsg(const ::android::base::Result<T>& result) {
    if (result.ok()) {
        return "";
    }
    return result.error().message();
}

}  // namespace vehicle
}  // namespace automotive
}  // namespace hardware
+51 −23
Original line number Diff line number Diff line
// Copyright (C) 2021 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.
/*
 * Copyright (C) 2021 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.
 */

package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "hardware_interfaces_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["hardware_interfaces_license"],
    default_applicable_licenses: ["Android-Apache-2.0"],
}

cc_binary {
    name: "android.hardware.automotive.vehicle-aidl-default-service",
    defaults: ["VehicleHalDefaults"],
    local_include_dirs: ["include"],
    vendor: true,
    defaults: [
        "FakeVehicleHardwareDefaults",
        "VehicleHalDefaults",
        "android-automotive-large-parcelable-defaults",
    ],
    vintf_fragments: ["vhal-default-service.xml"],
    init_rc: ["vhal-default-service.rc"],
    vendor: true,
    relative_install_path: "hw",
    srcs: ["src/*.cpp"],
    srcs: ["src/VehicleService.cpp"],
    static_libs: [
        "DefaultVehicleHal",
        "FakeVehicleHardware",
        "VehicleHalUtils",
        "android-automotive-large-parcelable-vendor-lib",
    ],
    header_libs: [
        "IVehicleHardware",
    ],
    shared_libs: [
        "libbinder_ndk",
    ],
}

cc_library {
    name: "DefaultVehicleHal",
    vendor: true,
    defaults: [
        "VehicleHalDefaults",
        "android-automotive-large-parcelable-defaults",
    ],
    local_include_dirs: ["include"],
    export_include_dirs: ["include"],
    srcs: ["src/DefaultVehicleHal.cpp"],
    static_libs: [
        "VehicleHalUtils",
        "android-automotive-large-parcelable-vendor-lib",
    ],
    header_libs: [
        "IVehicleHardware",
    ],
    shared_libs: [
        "libbinder_ndk",
Loading