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

Commit e2a11c5a authored by Yu Shan's avatar Yu Shan Committed by Android (Google) Code Review
Browse files

Merge changes from topic "cf-host-vhal" into main

* changes:
  Implement Unsubscribe in vhal proxy.
  Add host prebuilt for fake VHAL config.
  Add require_root to FakeVehicleHardwareTest.
parents c4ebb1ea cb00b1f8
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -45,3 +45,24 @@ prebuilt_etc {
    sub_dir: "automotive/vhalconfig/",
    vendor: true,
}

prebuilt_etc_host {
    name: "Host_Prebuilt_VehicleHalDefaultProperties_JSON",
    filename_from_src: true,
    src: "DefaultProperties.json",
    relative_install_path: "automotive/vhalconfig/",
}

prebuilt_etc_host {
    name: "Host_Prebuilt_VehicleHalTestProperties_JSON",
    filename_from_src: true,
    src: "TestProperties.json",
    relative_install_path: "automotive/vhalconfig/",
}

prebuilt_etc_host {
    name: "Host_Prebuilt_VehicleHalVendorClusterTestProperties_JSON",
    filename_from_src: true,
    src: "VendorClusterTestProperties.json",
    relative_install_path: "automotive/vhalconfig/",
}
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@ cc_test {
    defaults: [
        "VehicleHalDefaults",
    ],
    // Need root to use vendor lib: libgrpc++.
    require_root: true,
    test_suites: ["device-tests"],
}

+19 −0
Original line number Diff line number Diff line
@@ -206,6 +206,25 @@ aidlvhal::StatusCode GRPCVehicleHardware::subscribe(aidlvhal::SubscribeOptions o
    return static_cast<aidlvhal::StatusCode>(protoStatus.status_code());
}

aidlvhal::StatusCode GRPCVehicleHardware::unsubscribe(int32_t propId, int32_t areaId) {
    proto::UnsubscribeRequest request;
    ::grpc::ClientContext context;
    proto::VehicleHalCallStatus protoStatus;
    request.set_prop_id(propId);
    request.set_area_id(areaId);
    auto grpc_status = mGrpcStub->Unsubscribe(&context, request, &protoStatus);
    if (!grpc_status.ok()) {
        if (grpc_status.error_code() == ::grpc::StatusCode::UNIMPLEMENTED) {
            // This is a legacy sever. Ignore unsubscribe request.
            LOG(INFO) << __func__ << ": GRPC Unsubscribe is not supported by the server";
            return aidlvhal::StatusCode::OK;
        }
        LOG(ERROR) << __func__ << ": GRPC Unsubscribe Failed: " << grpc_status.error_message();
        return aidlvhal::StatusCode::INTERNAL_ERROR;
    }
    return static_cast<aidlvhal::StatusCode>(protoStatus.status_code());
}

aidlvhal::StatusCode GRPCVehicleHardware::updateSampleRate(int32_t propId, int32_t areaId,
                                                           float sampleRate) {
    ::grpc::ClientContext context;
+2 −0
Original line number Diff line number Diff line
@@ -85,6 +85,8 @@ class GRPCVehicleHardware : public IVehicleHardware {

    aidlvhal::StatusCode subscribe(aidlvhal::SubscribeOptions options) override;

    aidlvhal::StatusCode unsubscribe(int32_t propId, int32_t areaId) override;

    bool waitForConnected(std::chrono::milliseconds waitTime);

  protected:
+10 −0
Original line number Diff line number Diff line
@@ -175,6 +175,16 @@ GrpcVehicleProxyServer::GrpcVehicleProxyServer(std::string serverAddr,
    return ::grpc::Status::OK;
}

::grpc::Status GrpcVehicleProxyServer::Unsubscribe(::grpc::ServerContext* context,
                                                   const proto::UnsubscribeRequest* request,
                                                   proto::VehicleHalCallStatus* status) {
    int32_t propId = request->prop_id();
    int32_t areaId = request->area_id();
    const auto status_code = mHardware->unsubscribe(propId, areaId);
    status->set_status_code(static_cast<proto::StatusCode>(status_code));
    return ::grpc::Status::OK;
}

::grpc::Status GrpcVehicleProxyServer::CheckHealth(::grpc::ServerContext* context,
                                                   const ::google::protobuf::Empty*,
                                                   proto::VehicleHalCallStatus* status) {
Loading