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

Commit f6791115 authored by Henri Chataing's avatar Henri Chataing
Browse files

system/rust: Apply cargo fmt

Bug: 331817295
Test: m com.android.btservices
Flag: EXEMPT, formatting
Change-Id: Ibda132cef7bc849eea175bb9b978c6b58e311afc
parent ea5ee524
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ impl WeakBoxRef<'_, ConnectionManager> {
        Ok(async move {
            let Some((attempt, guard)) = attempt_and_guard else {
                // if we did not make an attempt, the connection must be ready
                return Ok(LeConnection { remote_address: address })
                return Ok(LeConnection { remote_address: address });
            };
            // otherwise, wait until the attempt resolves
            let ret = attempt.await;
+2 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ impl ConnectionAttempts {

        let id = self.new_attempt_id();
        let Entry::Vacant(entry) = self.attempts.entry(attempt) else {
            return Err(CreateConnectionFailure::ConnectionAlreadyPending)
            return Err(CreateConnectionFailure::ConnectionAlreadyPending);
        };
        let (tx, rx) = oneshot::channel();
        entry.insert(ConnectionAttemptData { conn_tx: Some(tx), id });
@@ -120,7 +120,7 @@ impl ConnectionAttempts {

        let id = self.new_attempt_id();
        let Entry::Vacant(entry) = self.attempts.entry(attempt) else {
            return Err(CreateConnectionFailure::ConnectionAlreadyPending)
            return Err(CreateConnectionFailure::ConnectionAlreadyPending);
        };
        entry.insert(ConnectionAttemptData { conn_tx: None, id });

+32 −19
Original line number Diff line number Diff line
@@ -818,7 +818,8 @@ mod test {
                        CHARACTERISTIC_VALUE_HANDLE,
                        AttributeBackingType::Characteristic,
                        reply,
                ) = data_evts.recv().await.unwrap() else {
                    ) = data_evts.recv().await.unwrap()
                    else {
                        unreachable!()
                    };
                    reply.send(Ok(data.clone())).unwrap();
@@ -951,7 +952,8 @@ mod test {
                AttributeBackingType::Characteristic,
                recv_data,
                _,
            ) = data_evts.recv().await.unwrap() else {
            ) = data_evts.recv().await.unwrap()
            else {
                unreachable!();
            };
            recv_data
@@ -992,7 +994,9 @@ mod test {
        let res = tokio_test::block_on(async {
            join!(
                async {
                    let MockDatastoreEvents::Write(_,_,_,_,reply) = data_evts.recv().await.unwrap() else {
                    let MockDatastoreEvents::Write(_, _, _, _, reply) =
                        data_evts.recv().await.unwrap()
                    else {
                        unreachable!();
                    };
                    reply.send(Err(AttErrorCode::UNLIKELY_ERROR)).unwrap();
@@ -1073,7 +1077,8 @@ mod test {
                DESCRIPTOR_HANDLE,
                AttributeBackingType::Descriptor,
                reply,
            ) = data_evts.recv().await.unwrap() else {
            ) = data_evts.recv().await.unwrap()
            else {
                unreachable!();
            };

@@ -1126,7 +1131,8 @@ mod test {
                AttributeBackingType::Descriptor,
                _,
                _,
            ) = data_evts.recv().await.unwrap() else {
            ) = data_evts.recv().await.unwrap()
            else {
                unreachable!();
            };
        });
@@ -1256,7 +1262,8 @@ mod test {
                        AttHandle(6),
                        AttributeBackingType::Characteristic,
                        reply,
                ) = data_evts_2.recv().await.unwrap() else {
                    ) = data_evts_2.recv().await.unwrap()
                    else {
                        unreachable!()
                    };
                    reply.send(Ok(data.clone())).unwrap();
@@ -1511,7 +1518,13 @@ mod test {

        // assert: we got a callback
        let event = data_evts.blocking_recv().unwrap();
        let MockRawDatastoreEvents::WriteNoResponse(TCB_IDX, CHARACTERISTIC_VALUE_HANDLE, AttributeBackingType::Characteristic, recv_data) = event else {
        let MockRawDatastoreEvents::WriteNoResponse(
            TCB_IDX,
            CHARACTERISTIC_VALUE_HANDLE,
            AttributeBackingType::Characteristic,
            recv_data,
        ) = event
        else {
            unreachable!("{event:?}");
        };
        assert_eq!(
+6 −3
Original line number Diff line number Diff line
@@ -261,7 +261,8 @@ mod test {
            block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap();

        // assert: we are not registered for either indications/notifications
        let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else {
        let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp
        else {
            unreachable!()
        };
        assert_eq!(
@@ -300,7 +301,8 @@ mod test {
            block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap();

        // assert: we are registered for indications
        let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else {
        let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp
        else {
            unreachable!()
        };
        assert_eq!(
@@ -344,7 +346,8 @@ mod test {
            block_on_locally(att_db.read_attribute(SERVICE_CHANGE_CCC_DESCRIPTOR_HANDLE)).unwrap();

        // assert: we are not registered for indications
        let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp else {
        let AttAttributeDataChild::GattClientCharacteristicConfiguration(configuration) = resp
        else {
            unreachable!()
        };
        assert_eq!(
+2 −6
Original line number Diff line number Diff line
@@ -238,9 +238,7 @@ mod test {
            tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db));

        // assert
        let AttChild::AttErrorResponse(response) = response else {
            unreachable!("{response:?}")
        };
        let AttChild::AttErrorResponse(response) = response else { unreachable!("{response:?}") };
        assert_eq!(
            response,
            AttErrorResponseBuilder {
@@ -274,9 +272,7 @@ mod test {
            tokio_test::block_on(handle_find_by_type_value_request(att_view.view(), 128, &db));

        // assert: got ATTRIBUTE_NOT_FOUND erro
        let AttChild::AttErrorResponse(response) = response else {
            unreachable!("{response:?}")
        };
        let AttChild::AttErrorResponse(response) = response else { unreachable!("{response:?}") };
        assert_eq!(
            response,
            AttErrorResponseBuilder {
Loading