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

Commit 4099b854 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Floss: Replace BT_STATUS_FAIL with more descriptive metrics" into main

parents e53c711d 3ac64c39
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -1735,7 +1735,7 @@ impl BluetoothGatt {
    /// It assumes that scanner.filter has already had the filter data.
    fn resume_scan(&mut self, scanner_id: u8) -> BtStatus {
        if !self.enabled {
            return BtStatus::Fail;
            return BtStatus::UnexpectedState;
        }

        if self.get_scan_suspend_mode() != SuspendMode::Resuming {
@@ -1756,7 +1756,7 @@ impl BluetoothGatt {
                        "This Scanner {} is supposed to resume from suspended state",
                        scanner_id
                    );
                    return BtStatus::Fail;
                    return BtStatus::UnexpectedState;
                }
            } else {
                log::warn!("Scanner {} not found", scanner_id);
@@ -1775,7 +1775,7 @@ impl BluetoothGatt {
        // Add and enable the monitor filter only when the MSFT extension is supported.
        if !is_msft_supported {
            log::error!("add_child_monitor: MSFT extension is not supported");
            return BtStatus::Fail;
            return BtStatus::Unsupported;
        }
        log::debug!(
            "add_child_monitor: monitoring address, scanner_id={}, filter={:?}",
@@ -2181,7 +2181,7 @@ impl IBluetoothGatt for BluetoothGatt {
        filter: Option<ScanFilter>,
    ) -> BtStatus {
        if !self.enabled {
            return BtStatus::Fail;
            return BtStatus::UnexpectedState;
        }

        if self.get_scan_suspend_mode() != SuspendMode::Normal {
@@ -2231,7 +2231,7 @@ impl IBluetoothGatt for BluetoothGatt {

    fn stop_scan(&mut self, scanner_id: u8) -> BtStatus {
        if !self.enabled {
            return BtStatus::Fail;
            return BtStatus::UnexpectedState;
        }

        let scan_suspend_mode = self.get_scan_suspend_mode();
+10 −10
Original line number Diff line number Diff line
@@ -600,7 +600,7 @@ impl BluetoothSocketManager {
                .any(|(_, v)| v.iter().any(|s| s.uuid.map_or(false, |u| u == uuid)))
            {
                log::warn!("Service {} already exists", DisplayUuid(&uuid));
                return SocketResult::new(BtStatus::Fail, INVALID_SOCKET_ID);
                return SocketResult::new(BtStatus::SocketError, INVALID_SOCKET_ID);
            }
        }

@@ -639,7 +639,7 @@ impl BluetoothSocketManager {
                    Some(v) => v,
                    None => {
                        log::debug!("Converting from file to unixstream failed");
                        return SocketResult::new(BtStatus::Fail, INVALID_SOCKET_ID);
                        return SocketResult::new(BtStatus::SocketError, INVALID_SOCKET_ID);
                    }
                };

@@ -773,7 +773,7 @@ impl BluetoothSocketManager {
            Self::wait_and_read_stream(connection_timeout, &stream, &mut channel_bytes).await;
        let channel = i32::from_ne_bytes(channel_bytes);
        if channel <= 0 {
            status = BtStatus::Fail;
            status = BtStatus::SocketError;
        }

        // If we don't get a valid channel, consider the socket as closed.
@@ -971,7 +971,7 @@ impl BluetoothSocketManager {
                                            SocketActions::OnIncomingSocketReady(
                                                cbid,
                                                cloned_socket_info,
                                                BtStatus::Fail,
                                                BtStatus::SocketError,
                                            ),
                                        ))
                                        .await;
@@ -1022,7 +1022,7 @@ impl BluetoothSocketManager {
                Ok(()) => {}
                Err(_e) => {
                    // Stream was not readable. This is usually due to some polling error.
                    return BtStatus::Fail;
                    return BtStatus::SocketError;
                }
            },
            Err(_) => {
@@ -1034,12 +1034,12 @@ impl BluetoothSocketManager {
        match stream.try_read(buf) {
            Ok(n) => {
                if n != buf.len() {
                    return BtStatus::Fail;
                    return BtStatus::SocketError;
                }
                return BtStatus::Success;
            }
            _ => {
                return BtStatus::Fail;
                return BtStatus::SocketError;
            }
        }
    }
@@ -1065,7 +1065,7 @@ impl BluetoothSocketManager {
                    .send(Message::SocketManagerActions(SocketActions::OnOutgoingConnectionResult(
                        cbid,
                        socket_id,
                        BtStatus::Fail,
                        BtStatus::SocketError,
                        None,
                    )))
                    .await;
@@ -1078,7 +1078,7 @@ impl BluetoothSocketManager {
        let mut status =
            Self::wait_and_read_stream(connection_timeout, &stream, &mut channel_bytes).await;
        if i32::from_ne_bytes(channel_bytes) <= 0 {
            status = BtStatus::Fail;
            status = BtStatus::SocketError;
        }
        if status != BtStatus::Success {
            log::info!(
@@ -1147,7 +1147,7 @@ impl BluetoothSocketManager {
                    .send(Message::SocketManagerActions(SocketActions::OnOutgoingConnectionResult(
                        cbid,
                        socket_id,
                        BtStatus::Fail,
                        BtStatus::SocketError,
                        None,
                    )))
                    .await;
+3 −0
Original line number Diff line number Diff line
@@ -218,6 +218,9 @@ pub enum BtStatus {
    JniThreadAttachError,
    WakeLockError,
    Timeout,
    DeviceNotFound,
    UnexpectedState,
    SocketError,

    // Any statuses that couldn't be cleanly converted
    Unknown = 0xff,