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

Commit b7ff5bc0 authored by Henri Chataing's avatar Henri Chataing Committed by Automerger Merge Worker
Browse files

Merge "rust/gatt: Suppress rust panics on LE disconnection events received...

Merge "rust/gatt: Suppress rust panics on LE disconnection events received after rust module unloading" into main am: ba3eea1e

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2692963



Change-Id: Ia549393cb56dc8611bdecd89f936f6d3b8da8eca
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents e3fdcb7e ba3eea1e
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -52,6 +52,11 @@ pub fn with_arbiter<T>(f: impl FnOnce(&mut IsolationManager) -> T) -> T {
    f(ARBITER.read().unwrap().as_ref().expect("Rust stack is not started").lock().as_mut().unwrap())
}

/// Check if the Arbiter is initialized.
pub fn has_arbiter() -> bool {
    ARBITER.read().unwrap().is_some()
}

/// Test to see if a buffer contains a valid ATT packet with an opcode we
/// are interested in intercepting (those intended for servers that are isolated)
fn try_parse_att_server_packet(
@@ -89,6 +94,13 @@ fn on_le_connect(tcb_idx: u8, advertiser: u8) {
}

fn on_le_disconnect(tcb_idx: u8) {
    // Disconnection events may be received after a FactoryReset
    // is initiated for Bluetooth and the rust arbiter is taken
    // down.
    if !has_arbiter() {
        return;
    }

    let tcb_idx = TransportIndex(tcb_idx);
    let was_isolated = with_arbiter(|arbiter| arbiter.is_connection_isolated(tcb_idx));
    if was_isolated {