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

Commit 52d6e032 authored by Enrico Granata's avatar Enrico Granata
Browse files

Move the virtualized vehicle hal code into the trout tree

AAOS virtualization work is happening under the trout tree, and
we should be building reference HAL implementations for the
virtualized deployment under that tree

Bug: 148816426
Test: build
Change-Id: I90fd2bc4191f8076475e034c7feb07b2664e63c8
parent 127f33b7
Loading
Loading
Loading
Loading
+0 −70
Original line number Diff line number Diff line
@@ -85,20 +85,6 @@ cc_library_static {
    ],
}

// VHal virtualization utils
cc_library_static {
    name: "android.hardware.automotive.vehicle@2.0-virtualization-utils",
    vendor: true,
    defaults: ["vhal_v2_0_defaults"],
    srcs: [
        "impl/vhal_v2_0/virtualization/Utils.cpp",
    ],
    export_include_dirs: ["impl"],
    shared_libs: [
        "libbase",
    ],
}

cc_test {
    name: "android.hardware.automotive.vehicle@2.0-manager-unit-tests",
    vendor: true,
@@ -153,59 +139,3 @@ cc_binary {
        "libqemu_pipe",
    ],
}

cc_binary {
    name: "android.hardware.automotive.vehicle@2.0-virtualization-service",
    defaults: ["vhal_v2_0_defaults"],
    init_rc: ["android.hardware.automotive.vehicle@2.0-virtualization-service.rc"],
    vendor: true,
    relative_install_path: "hw",
    srcs: [
        "impl/vhal_v2_0/virtualization/GrpcVehicleClient.cpp",
        "VirtualizedVehicleService.cpp",
    ],
    shared_libs: [
        "libbase",
        "libcutils",
        "libjsoncpp",
        "libprotobuf-cpp-full",
        "libgrpc++",
    ],
    static_libs: [
        "android.hardware.automotive.vehicle@2.0-manager-lib",
        "android.hardware.automotive.vehicle@2.0-default-impl-lib",
        "android.hardware.automotive.vehicle@2.0-grpc",
        "android.hardware.automotive.vehicle@2.0-virtualization-utils",
        "libqemu_pipe",
    ],
    cflags: [
        "-Wno-unused-parameter",
    ],
}

cc_binary {
    name: "android.hardware.automotive.vehicle@2.0-virtualization-grpc-server",
    init_rc: ["android.hardware.automotive.vehicle@2.0-virtualization-grpc-server.rc"],
    defaults: ["vhal_v2_0_defaults"],
    vendor: true,
    relative_install_path: "hw",
    srcs: [
        "impl/vhal_v2_0/virtualization/GrpcVehicleServer.cpp",
        "VirtualizationGrpcServer.cpp",
    ],
    shared_libs: [
        "libbase",
        "libjsoncpp",
        "libprotobuf-cpp-full",
        "libgrpc++",
    ],
    static_libs: [
        "android.hardware.automotive.vehicle@2.0-manager-lib",
        "android.hardware.automotive.vehicle@2.0-default-impl-lib",
        "android.hardware.automotive.vehicle@2.0-grpc",
        "android.hardware.automotive.vehicle@2.0-virtualization-utils",
    ],
    cflags: [
        "-Wno-unused-parameter",
    ],
}
+0 −15
Original line number Diff line number Diff line
#include <android-base/logging.h>

#include "vhal_v2_0/virtualization/GrpcVehicleServer.h"
#include "vhal_v2_0/virtualization/Utils.h"

int main(int argc, char* argv[]) {
    namespace vhal_impl = android::hardware::automotive::vehicle::V2_0::impl;

    auto serverInfo = vhal_impl::VsockServerInfo::fromCommandLine(argc, argv);
    CHECK(serverInfo.has_value()) << "Invalid server CID/port combination";

    auto server = vhal_impl::makeGrpcVehicleServer(serverInfo->toUri());
    server->Start();
    return 0;
}
+0 −56
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.
 */

#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>

#include <vhal_v2_0/EmulatedVehicleConnector.h>
#include <vhal_v2_0/EmulatedVehicleHal.h>
#include <vhal_v2_0/VehicleHalManager.h>
#include <vhal_v2_0/virtualization/GrpcVehicleClient.h>
#include <vhal_v2_0/virtualization/Utils.h>

using namespace android;
using namespace android::hardware;
using namespace android::hardware::automotive::vehicle::V2_0;

int main(int argc, char* argv[]) {
    namespace vhal_impl = android::hardware::automotive::vehicle::V2_0::impl;

    auto serverInfo = vhal_impl::VsockServerInfo::fromRoPropertyStore();
    CHECK(serverInfo.has_value()) << "Invalid server CID/port combination";

    auto store = std::make_unique<VehiclePropertyStore>();
    auto connector = impl::makeGrpcVehicleClient(serverInfo->toUri());
    auto hal = std::make_unique<impl::EmulatedVehicleHal>(store.get(), connector.get());
    auto emulator = std::make_unique<impl::VehicleEmulator>(hal.get());
    auto service = std::make_unique<VehicleHalManager>(hal.get());

    configureRpcThreadpool(4, true /* callerWillJoin */);

    LOG(INFO) << "Registering as service...";
    status_t status = service->registerAsService();

    if (status != OK) {
        LOG(ERROR) << "Unable to register vehicle service (" << status << ")";
        return 1;
    }

    LOG(INFO) << "Ready";
    joinRpcThreadpool();

    return 1;
}
+0 −10
Original line number Diff line number Diff line
# It is an interim state to run GRPC server as an Android service.
# Eventually it will run outside of Android (e.g., AGL),
# so the command line arguments are expected, though not conventionally used in Android
service vendor.vehicle-hal-2.0-server \
        /vendor/bin/hw/android.hardware.automotive.vehicle@2.0-virtualization-grpc-server \
        -server_cid ${ro.vendor.vehiclehal.server.cid:-pleaseconfigurethis} \
        -server_port ${ro.vendor.vehiclehal.server.port:-pleaseconfigurethis}
    class hal
    user vehicle_network
    group system inet
+0 −4
Original line number Diff line number Diff line
service vendor.vehicle-hal-2.0 /vendor/bin/hw/android.hardware.automotive.vehicle@2.0-virtualization-service
    class hal
    user vehicle_network
    group system inet
Loading