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

Commit c4e37137 authored by Zach Johnson's avatar Zach Johnson Committed by Gerrit Code Review
Browse files

Merge changes I428211dc,I20f897a8

* changes:
  rusty-gd: reorganize HCI shim to make cpp and rust distinct
  rusty-gd: move common stack logic to bt_main
parents b3ea5bc4 2d930b81
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ rust_library {
        "libnix",
        "liblog_rust",
        "libcxx",
        "libgrpcio",
    ],
    target: {
        android: {
@@ -38,6 +39,7 @@ rust_test_host {
        "liblog_rust",
        "libenv_logger",
        "libcxx",
        "libgrpcio",
    ],
    proc_macros: [
        "libpaste",
+6 −0
Original line number Diff line number Diff line
@@ -34,3 +34,9 @@ pub fn init_logging() {
        .try_init()
        .ok();
}

/// Indicates the object can be converted to a GRPC service
pub trait GrpcFacade {
    /// Convert the object into the service
    fn into_grpc(self) -> grpcio::Service;
}
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ rust_library {
      "libprotobuf",
      "libtokio",
      "libgddi",
      "libbt_main",
    ],
    host_supported: true,
}
+7 −25
Original line number Diff line number Diff line
@@ -11,12 +11,8 @@ pub mod empty {
use bt_facade_common_proto::common;
use bt_facade_rootservice_proto::rootservice;
use bt_hal::facade::HciHalFacadeService;
use bt_hal::hal_module;
use bt_hal::rootcanal_hal::RootcanalConfig;
use bt_hci::facade::HciLayerFacadeService;
use bt_hci::hci_module;
use futures::executor::block_on;
use gddi::{module, Registry, RegistryBuilder};
use grpcio::*;
use rootservice::*;
use rootservice_grpc::{create_root_facade, RootFacade};
@@ -24,14 +20,7 @@ use std::sync::Arc;
use tokio::runtime::Runtime;
use tokio::sync::mpsc::{channel, Sender};
use tokio::sync::oneshot;

module! {
    stack_module,
    submodules {
        hal_module,
        hci_module,
    }
}
use bt_main::Stack;

/// Bluetooth testing root facade service
#[derive(Clone)]
@@ -104,16 +93,9 @@ impl FacadeServiceManager {
            while let Some(cmd) = rx.recv().await {
                match cmd {
                    LifecycleCommand::Start { req, done } => {
                        let registry = Arc::new(RegistryBuilder::new().register_module(stack_module).build());

                        registry.inject(local_rt.clone()).await;
                        if let Some(rc_port) = rootcanal_port {
                            registry
                                .inject(RootcanalConfig::new("127.0.0.1", rc_port))
                                .await;
                        }

                        server = Some(Self::start_internal(&registry, req, grpc_port).await);
                        let stack = Stack::new(local_rt.clone()).await;
                        stack.set_rootcanal_port(rootcanal_port).await;
                        server = Some(Self::start_internal(&stack, req, grpc_port).await);
                        done.send(()).unwrap();
                    }
                    LifecycleCommand::Stop { done } => {
@@ -149,17 +131,17 @@ impl FacadeServiceManager {
    }

    async fn start_internal(
        registry: &Arc<Registry>,
        stack: &Stack,
        req: StartStackRequest,
        grpc_port: u16,
    ) -> Server {
        let mut services = Vec::new();
        match req.get_module_under_test() {
            BluetoothModule::HAL => {
                services.push(registry.get::<HciHalFacadeService>().await.create_grpc());
                services.push(stack.get_grpc::<HciHalFacadeService>().await);
            }
            BluetoothModule::HCI => {
                services.push(registry.get::<HciLayerFacadeService>().await.create_grpc());
                services.push(stack.get_grpc::<HciLayerFacadeService>().await);
            }
            _ => unimplemented!(),
        }
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ rust_library {
        "libcxx",
        "liblazy_static",
        "liblog_rust",
        "libbt_common",
    ],
    host_supported: true,
    target: {
Loading