summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Duarte <licorne@google.com> 2024-04-19 17:23:59 +0000
committer David Duarte <licorne@google.com> 2024-04-19 18:04:37 +0000
commita20c2803abb9f4b44dabc87e8abe4817ecc879f0 (patch)
tree3dc34c3871aaa95ec7c266efc1d7ca0e8c49eff6
parent30bd4820e4875b389c37f995f7e9a38769640ea1 (diff)
Remove rust_event_loop flag
Bug: 290846388 Fix: 290846388 Test: m com.android.btservices Flag: EXEMPT, removing legacy flag Change-Id: I434d863d73cf5e78cb7f919598d5c6412a48eb5a
-rw-r--r--system/gd/rust/common/src/init_flags.rs4
-rw-r--r--system/gd/rust/shim/src/init_flags.rs1
-rw-r--r--system/rust/src/core/mod.rs23
-rw-r--r--system/rust/src/gatt/ffi.rs44
-rw-r--r--system/rust/src/lib.rs5
5 files changed, 15 insertions, 62 deletions
diff --git a/system/gd/rust/common/src/init_flags.rs b/system/gd/rust/common/src/init_flags.rs
index b81eb1c74f..bd3dfc46c6 100644
--- a/system/gd/rust/common/src/init_flags.rs
+++ b/system/gd/rust/common/src/init_flags.rs
@@ -241,7 +241,6 @@ init_flags!(
pbap_pse_dynamic_version_upgrade = false,
private_gatt = true,
redact_log = true,
- rust_event_loop = true,
sco_codec_select_lc3 = true,
sco_codec_timeout_clear,
sdp_serialization = true,
@@ -259,8 +258,7 @@ init_flags!(
"--hci" => parse_hci_adapter(_, _),
}
dependencies: {
- always_use_private_gatt_for_debugging => private_gatt,
- private_gatt => rust_event_loop
+ always_use_private_gatt_for_debugging => private_gatt
}
);
diff --git a/system/gd/rust/shim/src/init_flags.rs b/system/gd/rust/shim/src/init_flags.rs
index acf6495732..42a62c9cc0 100644
--- a/system/gd/rust/shim/src/init_flags.rs
+++ b/system/gd/rust/shim/src/init_flags.rs
@@ -30,7 +30,6 @@ mod ffi {
fn pbap_pse_dynamic_version_upgrade_is_enabled() -> bool;
fn private_gatt_is_enabled() -> bool;
fn redact_log_is_enabled() -> bool;
- fn rust_event_loop_is_enabled() -> bool;
fn sco_codec_select_lc3_is_enabled() -> bool;
fn sco_codec_timeout_clear_is_enabled() -> bool;
fn sdp_serialization_is_enabled() -> bool;
diff --git a/system/rust/src/core/mod.rs b/system/rust/src/core/mod.rs
index 51e24535be..2f48f19619 100644
--- a/system/rust/src/core/mod.rs
+++ b/system/rust/src/core/mod.rs
@@ -8,7 +8,6 @@ pub mod uuid;
use std::{pin::Pin, rc::Rc, thread};
-use bt_common::init_flags::rust_event_loop_is_enabled;
use cxx::UniquePtr;
use crate::{
@@ -24,18 +23,16 @@ fn start(
le_acl_manager: UniquePtr<LeAclManagerShim>,
on_started: Pin<&'static mut Future>,
) {
- if rust_event_loop_is_enabled() {
- thread::spawn(move || {
- GlobalModuleRegistry::start(
- Rc::new(GattCallbacksImpl(gatt_server_callbacks)),
- Rc::new(AttTransportImpl()),
- LeAclManagerImpl(le_acl_manager),
- || {
- future_ready(on_started);
- },
- );
- });
- }
+ thread::spawn(move || {
+ GlobalModuleRegistry::start(
+ Rc::new(GattCallbacksImpl(gatt_server_callbacks)),
+ Rc::new(AttTransportImpl()),
+ LeAclManagerImpl(le_acl_manager),
+ || {
+ future_ready(on_started);
+ },
+ );
+ });
}
fn stop() {
diff --git a/system/rust/src/gatt/ffi.rs b/system/rust/src/gatt/ffi.rs
index 5a0f3b548e..d21c23dd1c 100644
--- a/system/rust/src/gatt/ffi.rs
+++ b/system/rust/src/gatt/ffi.rs
@@ -4,9 +4,7 @@
use std::iter::Peekable;
use anyhow::{bail, Result};
-use bt_common::init_flags::{
- always_use_private_gatt_for_debugging_is_enabled, rust_event_loop_is_enabled,
-};
+use bt_common::init_flags::always_use_private_gatt_for_debugging_is_enabled;
use cxx::UniquePtr;
pub use inner::*;
use log::{error, info, trace, warn};
@@ -283,10 +281,6 @@ impl AttTransport for AttTransportImpl {
}
fn open_server(server_id: u8) {
- if !rust_event_loop_is_enabled() {
- return;
- }
-
let server_id = ServerId(server_id);
do_in_rust_thread(move |modules| {
@@ -303,10 +297,6 @@ fn open_server(server_id: u8) {
}
fn close_server(server_id: u8) {
- if !rust_event_loop_is_enabled() {
- return;
- }
-
let server_id = ServerId(server_id);
do_in_rust_thread(move |modules| {
@@ -368,17 +358,15 @@ fn records_to_service(service_records: &[GattRecord]) -> Result<GattServiceWithH
}
let Some((handle, uuid)) = service_handle_uuid else {
- bail!("got service registration but with no primary service! {characteristics:?}".to_string())
+ bail!(
+ "got service registration but with no primary service! {characteristics:?}".to_string()
+ )
};
Ok(GattServiceWithHandle { handle: AttHandle(handle), type_: uuid, characteristics })
}
fn add_service(server_id: u8, service_records: Vec<GattRecord>) {
- if !rust_event_loop_is_enabled() {
- return;
- }
-
// marshal into the form expected by GattModule
let server_id = ServerId(server_id);
@@ -408,10 +396,6 @@ fn add_service(server_id: u8, service_records: Vec<GattRecord>) {
}
fn remove_service(server_id: u8, service_handle: u16) {
- if !rust_event_loop_is_enabled() {
- return;
- }
-
let server_id = ServerId(server_id);
let service_handle = AttHandle(service_handle);
do_in_rust_thread(move |modules| {
@@ -428,18 +412,10 @@ fn remove_service(server_id: u8, service_handle: u16) {
}
fn is_connection_isolated(conn_id: u16) -> bool {
- if !rust_event_loop_is_enabled() {
- return false;
- }
-
with_arbiter(|arbiter| arbiter.is_connection_isolated(ConnectionId(conn_id).get_tcb_idx()))
}
fn send_response(_server_id: u8, conn_id: u16, trans_id: u32, status: u8, value: &[u8]) {
- if !rust_event_loop_is_enabled() {
- return;
- }
-
// TODO(aryarahul): fixup error codes to allow app-specific values (i.e. don't
// make it an enum in PDL)
let value = if status == 0 {
@@ -463,10 +439,6 @@ fn send_response(_server_id: u8, conn_id: u16, trans_id: u32, status: u8, value:
}
fn send_indication(_server_id: u8, handle: u16, conn_id: u16, value: &[u8]) {
- if !rust_event_loop_is_enabled() {
- return;
- }
-
let handle = AttHandle(handle);
let conn_id = ConnectionId(conn_id);
let value = AttAttributeDataChild::RawData(value.into());
@@ -488,10 +460,6 @@ fn send_indication(_server_id: u8, handle: u16, conn_id: u16, value: &[u8]) {
}
fn associate_server_with_advertiser(server_id: u8, advertiser_id: u8) {
- if !rust_event_loop_is_enabled() {
- return;
- }
-
let server_id = ServerId(server_id);
let advertiser_id = AdvertiserId(advertiser_id);
do_in_rust_thread(move |modules| {
@@ -503,10 +471,6 @@ fn associate_server_with_advertiser(server_id: u8, advertiser_id: u8) {
}
fn clear_advertiser(advertiser_id: u8) {
- if !rust_event_loop_is_enabled() {
- return;
- }
-
let advertiser_id = AdvertiserId(advertiser_id);
do_in_rust_thread(move |modules| {
diff --git a/system/rust/src/lib.rs b/system/rust/src/lib.rs
index 4693320516..b3361bad1e 100644
--- a/system/rust/src/lib.rs
+++ b/system/rust/src/lib.rs
@@ -15,7 +15,6 @@
//! The core event loop for Rust modules. Here Rust modules are started in
//! dependency order.
-use bt_common::init_flags::rust_event_loop_is_enabled;
use connection::le_manager::InactiveLeAclManager;
use gatt::{channel::AttTransport, GattCallbacks};
use log::{info, warn};
@@ -160,10 +159,6 @@ pub fn do_in_rust_thread<F>(f: F)
where
F: for<'a> FnOnce(&'a mut ModuleViews) + Send + 'static,
{
- if !rust_event_loop_is_enabled() {
- warn!("ignoring do_in_rust_thread() invocation since Rust loop is inactive");
- return;
- }
let ret = MAIN_THREAD_TX.with(|tx| tx.send(MainThreadTxMessage::Callback(Box::new(f))));
if ret.is_err() {
panic!("Rust call failed");