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

Commit 43a16056 authored by JohnLai's avatar JohnLai
Browse files

Floss: Refactor send_response to pass the value correctly

The method try_into cannot convert a variable length vector into a
fixed size array, so instead of using try_into, you can use a loop
to copy the elements of the value vector into a fixed size array.

Bug: 267596712
Test: Manually
Tag: #floss
Change-Id: I745ad3f9ef65ebd410173ea3a4463a093f64105e
parent 5c7ddd47
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2484,7 +2484,15 @@ impl IBluetoothGatt for BluetoothGatt {
            let conn_id = self.server_context_map.get_conn_id_from_address(server_id, &addr)?;
            let handle = self.server_context_map.get_request_handle_from_id(request_id)?;
            let len = value.len() as u16;
            let data: [u8; 600] = value.try_into().ok()?;

            let data: [u8; 600] = value
                .iter()
                .chain(std::iter::repeat(&0))
                .take(600)
                .cloned()
                .collect::<Vec<u8>>()
                .try_into()
                .ok()?;

            self.gatt.as_ref().unwrap().lock().unwrap().server.send_response(
                conn_id,