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

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

Merge changes Ic0e454d8,I0f324389,Id98b6ad9,Ib17a35a8

* changes:
  rusty-gd: integrate logging
  rusty-gd: make RegistryBuilder follow the builder pattern
  rusty-gd: some tidying up of imports & formatting
  rusty-gd: swap rootcanal config to a more canonical ordering
parents a5674d10 492ddce7
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -6,7 +6,20 @@ rust_library {
    rustlibs: [
        "libtokio",
        "libnix",
        "liblog_rust",
    ],
    target: {
        android: {
            rustlibs: [
                "libandroid_logger",
            ],
        },
        host: {
            rustlibs: [
                "libenv_logger",
            ],
        },
    },
    host_supported: true,
}

@@ -18,5 +31,7 @@ rust_test_host {
    rustlibs: [
        "libtokio",
        "libnix",
        "liblog_rust",
        "libenv_logger",
    ],
}
+19 −1
Original line number Diff line number Diff line
@@ -6,7 +6,25 @@ pub mod time;
#[macro_use]
mod ready;


#[cfg(test)]
#[macro_use]
mod asserts;

/// Inits logging for Android
#[cfg(target_os = "android")]
pub fn init_logging() {
    android_logger::init_once(
        android_logger::Config::default()
            .with_tag("bt")
            .with_min_level(log::Level::Debug),
    );
}

/// Inits logging for host
#[cfg(not(target_os = "android"))]
pub fn init_logging() {
    env_logger::Builder::new()
        .filter(None, log::LevelFilter::Debug)
        .parse_default_env()
        .init();
}
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ rust_binary {
      "libgrpcio",
      "libtokio",
      "libnix",
      "libbt_common",
      "liblog_rust",
    ],
    host_supported: true,
}
+8 −18
Original line number Diff line number Diff line
@@ -10,26 +10,20 @@ pub mod empty {

use bt_facade_common_proto::common;
use bt_facade_rootservice_proto::rootservice;
use rootservice::*;
use rootservice_grpc::{create_root_facade, RootFacade};

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 tokio::runtime::Runtime;
use tokio::sync::mpsc::{channel, Sender};
use tokio::sync::oneshot;

use futures::executor::block_on;
use gddi::{module, Registry, RegistryBuilder};

use grpcio::*;

use rootservice::*;
use rootservice_grpc::{create_root_facade, RootFacade};
use std::sync::Arc;

use futures::executor::block_on;
use tokio::runtime::Runtime;
use tokio::sync::mpsc::{channel, Sender};
use tokio::sync::oneshot;

module! {
    stack_module,
@@ -110,16 +104,12 @@ impl FacadeServiceManager {
            while let Some(cmd) = rx.recv().await {
                match cmd {
                    LifecycleCommand::Start { req, done } => {
                        let registry = {
                            let mut builder = RegistryBuilder::new();
                            builder.register_module(stack_module);
                            Arc::new(builder.build())
                        };
                        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(rc_port, "127.0.0.1"))
                                .inject(RootcanalConfig::new("127.0.0.1", rc_port))
                                .await;
                        }

+8 −17
Original line number Diff line number Diff line
@@ -7,26 +7,21 @@ use clap::{App, Arg};
#[macro_use]
extern crate lazy_static;

use grpcio::*;

use bluetooth_with_facades::RootFacadeService;
use futures::channel::mpsc;
use futures::executor::block_on;
use futures::stream::StreamExt;

use bluetooth_with_facades::RootFacadeService;

use grpcio::*;
use nix::sys::signal;
use std::net::{IpAddr, Ipv4Addr, Shutdown, SocketAddr};
use std::sync::Arc;
use std::sync::Mutex;

use std::sync::{Arc, Mutex};
use tokio::net::TcpStream;

use tokio::runtime::Runtime;

use nix::sys::signal;
use log::debug;

fn main() {
    let sigint = install_sigint();
    bt_common::init_logging();
    let rt = Arc::new(Runtime::new().unwrap());
    rt.block_on(async_main(Arc::clone(&rt), sigint));
}
@@ -57,11 +52,7 @@ async fn async_main(rt: Arc<Runtime>, mut sigint: mpsc::UnboundedReceiver<()>) {
                .long("rootcanal-port")
                .takes_value(true),
        )
        .arg(
            Arg::with_name("btsnoop")
                .long("btsnoop")
                .takes_value(true),
        )
        .arg(Arg::with_name("btsnoop").long("btsnoop").takes_value(true))
        .arg(
            Arg::with_name("btconfig")
                .long("btconfig")
@@ -117,7 +108,7 @@ lazy_static! {
extern "C" fn handle_sigint(_: i32) {
    let mut sigint_tx = SIGINT_TX.lock().unwrap();
    if let Some(tx) = &*sigint_tx {
        println!("Stopping gRPC root server due to SIGINT");
        debug!("Stopping gRPC root server due to SIGINT");
        tx.unbounded_send(()).unwrap();
    }
    *sigint_tx = None;
Loading