summaryrefslogtreecommitdiff
path: root/system/rust/src
AgeCommit message (Collapse)Author
2025-02-19system/rust: Add some debug code to try and track down crash Chris Suter
This has no functional change; it just contains logs that might help us diagnose the issue. Bug: 356462170 Test: m com.android.btservices Flag: EXEMPT refactor only Change-Id: Iad9cdb0d61bc815a7a2bc97c24fae7cbe18d48e7
2025-02-12system/rust: Set imports_granularity rustfmt option to Module Chris Suter
This matches the Fuchsia style. See https://fxbug.dev/340943530 for rationale. I've also reformatted all Rust files under system/rust with this style as there seemed to be some inconsistencies. Fix: 396241824 Test: m com.android.btservices Flag: EXEMPT refactor only Change-Id: I74425bfbe98a402fa5f9fd5f1746a00b9767a321
2025-02-11Delete libbt_common Henri Chataing
This rust library only exports the method `init_logging`, which is used solely by the bluetooth_core crate. `init_logging` is inlined to system/rust/src/utils.rs Bug: 331817295 Test: m libbluetooth_core_rs Flag: EXEMPT, dead code removal Change-Id: Ib8fce44be854f095a3a95324df102ef060717084
2025-02-10system/rust: Wait forever for Rust module to initialize Chris Suter
Not waiting leads to a high chance of a later crash; it's better to wait forever. Fix: 385666726 Test: m com.android.btservices Flag: EXEMPT bugfix Change-Id: I07dd7fde11b1949606a69478cc5eca70f88ff8c9
2025-02-10system/rust: Restructure and add logs for FFI Marie Janssen
Restructure the GlobalModuleRegistry: - Rename to RustModuleRunner - Clarify states - Internalize the static global - Add a number of logs when error states occur This is reland of https://r.android.com/3318393 except that starting and stopping the module multiple times is now supported. Tested with `atest net_test_bluetooth` to verify the cause of revert has been fixed. Fix: 356462170 Test: m com.android.btservices Flag: EXEMPT refactor only Change-Id: I2aece397937e075a494b0b6e200492bb5664f46c
2025-01-30Merge "Revert "system/rust: Restructure and add logs for FFI"" into main Treehugger Robot
2025-01-30Revert "system/rust: Restructure and add logs for FFI" Omair Kamil
This reverts commit b182e3dd6daaa2c2f5076e18128e07c6b8c3c6a9. Reason for revert: b/393481018 Change-Id: I26d3fe5ffc9cd7854e2e3b8e7b9226b976978bbb
2025-01-30Merge "system/rust: Restructure and add logs for FFI" into main Omair Kamil
2025-01-15Code changes for Rust 1.83.0 Chris Wailes
Test: m rust Bug: 384401387 Change-Id: I647a63976830e5071cb4dac8c0480a00ecf4d973
2024-11-20system: Migrate from {fmt} to std::format Henri Chataing
Bug: 305066880 Test: m com.android.btservices Flag: EXEMPT, log change Change-Id: If1dbab99250a4f62626206fc9f73d27e71ebab56
2024-11-12Remove 'system/types' from include_dirs Henri Chataing
Bug: 331817295 Test: m com.android.btservices Flag: EXEMPT, build change Change-Id: I259a974e5d0bf389d69876889118de0d5eed9b5e
2024-10-31system/rust: Restructure and add logs for FFI Marie Janssen
Restructure the GlobalModuleRegistry: - Rename to RustModuleRunner - Clarify states - Internalize the static global - Add a number of logs when error states occur Logs should be output before panic to make crashes identifiable. Bug: 356462170 Test: m com.android.btservices Flag: EXEMPT refactor only Change-Id: Iecd62aa2b6e743b2726f2cf87808e6718d98fedf
2024-10-17Remove os/log.h Henri Chataing
The logging macros within have long been removed, this is just cleanup work to inline the included headers where necessary Bug: 331817295 Test: m com.android.btservices Flag: EXEMPT, no logical change Change-Id: I2147ce4bdcea977b92318b2cb96e7020a8958161
2024-10-09use_unified_connection_manager removal Jakub Pawlowski
Unused, out of date Test: mma -j32 Bug: 290846969 Bug: 349469413 Bug: 372202918 Flag: EXEMPT, just delting unused code under flag Change-Id: Ie01c56f81d81affeed5c7285bcf8d712b6af59b0
2024-10-02Remove the init_flags module Henri Chataing
All existing init flags have been migrated to feature flags or removed and the rust module can now be deleted. Bug: 331817295 Test: m com.android.btservices Flag: EXEMPT, dead code removal Change-Id: I38be97fad7f9bd42f432d74e5b8090a08dc4502a
2024-09-20Remove unused <base/*.h> includes from hardware headers Henri Chataing
Bug: 331817295 Test: m com.android.btservices Flag: EXEMPT, no logical change Change-Id: Ia465d52ae9c4889db5529cb2fec9085befd8104f
2024-09-12Define tCONN_ID for GATT Connection ID Kyunglyul Hyun
Introduce tCONN_ID as a type for GATT connection IDs used internally by the native stack. Althogh this change itself doesn't do anything, this is a preparatory step for expanding tGATT_IF to uint16_t and tCONN_ID to uint32_t. Rust stack cleanup will follow in a subsequent CL. Flag: EXEMPT, mechanical refactor Bug: 273561907 Test: atest BluetoothInstrumentationTests Change-Id: I307fbb0815f3f3c31c80e75c12c4223237099adc
2024-09-05Update Android for Rust 1.81.0 Chris Wailes
Test: m rust Bug: 364333811 Change-Id: I0431582199a8039ce226d6376bdc0ee65a53fa1d
2024-09-03Convert the unified_connection_manager flag Myles Watson
Initflags are deprecated, use a trunkstable flag. Bug: 349469413 Test: mma -j32 Change-Id: I4e5917098167261289f9f64f6827b7b28f97df81
2024-08-05Merge "system/rust/gatt: Switch to the default PDL rust generator" into main Treehugger Robot
2024-08-02Merge "Prevent NPE in bt_gatt_callback" into main Kyunglyul Hyun
2024-07-30Adjust Safety annotation but also just silence lint warning Stephen Hines
This external function declaration isn't able to be handled nicely by clippy in this case, so we suppress the lint. I also added a formatting fix to make it look more like other Safety sections. ``` error: unsafe function's docs miss `# Safety` section --> packages/modules/Bluetooth/system/rust/src/connection/ffi.rs:62:9 | 62 | / unsafe fn unchecked_register_rust_callbacks( 63 | | self: Pin<&mut Self>, 64 | | callbacks: Box<LeAclManagerCallbackShim>, 65 | | ); | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc = note: `-D clippy::missing-safety-doc` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::missing_safety_doc)]` error: aborting due to 1 previous error ``` Bug: http://b/346588808 Test: ./toolchain/android_rust/tools/test_compiler.py --prebuilt-path dist/rust-linux.tar.xz --target aosp_cf_x86_64_phone --image --reuse-prebuilt Bug: 346588808 Test: m aosp_cf_x86_64_phone Change-Id: I015915f20cd97172bbc66913412da5f139a909de
2024-07-30Prevent NPE in bt_gatt_callback Kyunglyul Hyun
A thread setting bt_gatt_callbacks and a thread using it may be different, potentially causing an NPE if bt_gatt_callbacks is accessed after being cleaned up. Use a local variable to ensure safe access in threaded environments. Bug: 353974484 Flag: EXEMPT, strict null check. Test: atest BluetoothInstrumentaionTests Change-Id: I2bd8dd62d0fab0e58db1c1b690406341fc251bf8
2024-07-16system/rust/gatt: Switch to the default PDL rust generator Henri Chataing
The generator rust_no_alloc is no longer maintained and the default rust generator is now the preferred rust generator. Bug: 331817295 Test: m com.android.btservices Test: atest --host libbluetooth_core_rs_test Flag: EXEMPT, mechanical refactor Change-Id: I18da339ffb2537229fb870594edd344b6a924241
2024-07-07Format: apply clang rules William Escande
Restore SpacesBeforeTrailingComments to 2 to match current style Then run clang-format -i **/**.{c,h,cc,cpp,hpp} Then fix a bunch of typo (reported by gerrit) Then fix unnecessary multiline string Then fix whitespace for disabled clang format (reported by cpplint) This is no-op Bug: 311772251 Test: mmm packages/modules/Bluetooth Flag: Exempt Format only Change-Id: If135447803a40a2a07d4630ba2195e08ef8d250c
2024-06-27InitFlags: Remove always_use_private_gatt Myles Watson
Bug: 255880936 Fixes: 290842873 Test: mma -j32 Flag: EXEMPT, no logical change Change-Id: Ia1d6f2ea775087680f5d34472e32d44f574854d4
2024-06-14system/rust: Update GATT packet definition to use 8[] for ATT values Henri Chataing
Bug: 331817295 Test: m com.android.btservices Test: atest --host libbluetooth_core_rs_test Flag: EXEMPT, mechanical refactor Change-Id: Ia8b5fbf470df7ed3d20fced5339beb136e3aa9ba
2024-06-12system/rust: Update GATT datastore interfaces to use raw values Henri Chataing
The code almost never makes use of the structured type and mostly relies on AttAttributeDataChild::RawData. Removing this type will help convert the pdl rust backend later as the generated type AttAttributeDataChild will no longer exist under this form. Bug: 331817295 Test: m com.android.btservices Test: atest --host libbluetooth_core_rs_test Flag: EXEMPT, mechanical refactor Change-Id: I429341ed0ccc4a8cdaba7cc86d1249f16f11a28e
2024-06-12Merge "system/rust: Apply cargo fmt" into main Treehugger Robot
2024-06-11system/rust: Apply cargo fmt Henri Chataing
Bug: 331817295 Test: m com.android.btservices Flag: EXEMPT, formatting Change-Id: Ibda132cef7bc849eea175bb9b978c6b58e311afc
2024-06-11Remove usage of base::Owned in GattServerCallbacks::OnServerWrite David Duarte
Test: mmm packages/modules/Bluetooth Bug: 345074109 Flag: EXEMPT, mechanical refactor Change-Id: Ief3f4c1ddd614f697ec8d5bb0b6eabc2adfde5e1
2024-06-05Remove FROM_HERE from do_in_jni_thread invocations David Duarte
In production FROM_HERE only convey the filename and the pc and only log the pc in case of internal libchrome failures. It's mainly useful in debugging by enabling ENABLE_LOCATION_SOURCE and logging the base::Location object ourselves. The same information can be retrieved using c++'s [source_location](https://en.cppreference.com/w/cpp/utility/source_location) without needing to modify every caller. The benefit outweight the cost of needing to provide that (correctly) in every call site. Bug: 345074109 Test: mmm packages/modules/Bluetooth Flag: EXEMPT mechanical refactor Change-Id: I5ba252baa6c885f3c34bffec058517bf39539bbe
2024-04-19Remove rust_event_loop flag David Duarte
Bug: 290846388 Fix: 290846388 Test: m com.android.btservices Flag: EXEMPT, removing legacy flag Change-Id: I434d863d73cf5e78cb7f919598d5c6412a48eb5a
2024-04-04Gatt Rust: Convince rustc that OwnedHandle is used Myles Watson
OwnedHandle is dropped when a connection is dropped with a Pending transaction. Removing this will change the behavior. warning: field `0` is never read --> src/gatt/server/att_server_bearer.rs:37:13 | 37 | Pending(OwnedHandle<()>), | ------- ^^^^^^^^^^^^^^^ | | | field in this variant | = note: `#[warn(dead_code)]` on by default help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | 37 | Pending(()), | Bug: 330185853 Test: atest libbluetooth_core_rs_test Flag: EXEMPT, build-only change Change-Id: I00d61e2a1f91667931edf0beaea7961c5e00296b
2024-03-21system: Migrate to libbluetooth_log Henri Chataing
Test: m com.android.btservices Bug: 305066880 Flag: EXEMPT, mechanical refactor Change-Id: Ia6632bc2c6ab18d93fd9d5d21bb863eb8a3150ff
2024-02-09Inline osi/include/log.h David Duarte
Bug: 279512287 Test: mmm packages/modules/Bluetooth Flag: Exempt, mechanical refactor Change-Id: I962860d1e39a0b1b32bfa2816c12a79b557b8a62
2023-11-04[Invisalign2] Move (wrap) the following 2 APIs Hui Peng
BTM_BackgroundConnectAddressKnown -> BTM_Sec_AddressKnown convert_to_address_with_type -> BTM_Sec_GetAddressWithType Bug: 301661850 Test: m com.android.btservices Change-Id: Iaa71a5d07704a83e298035dd2f9b5670dcbcc866
2023-09-05Migrate base::Bind to base::BindOnce for do_in_jni_thread Wei-Luan Wang
The second argument of do_in_jni_thread is a base::OnceCallback so it's safe to use base::BindOnce to construct the callback. Bug: 272116782 Test: m . Change-Id: Ibaffe5fd569100063a778e40b61b0cb2ab8c5686
2023-08-16Changes for Rust 1.72 James Farrell
Remove unneeded import and call to into_iter(). Bug: 295883071 Test: m libbluetooth_core_rs Change-Id: I7f8ab535a7993fa249df710505dd19e8a43c2f48
2023-08-08has_artbiter checks for intercept_packet received after rust module unloading Hyun Jae Moon
Bug: 289280004 Test: atest avatar Change-Id: Iec110ae7314111d0b9b9466bbaa0bcdd1e4e0b26
2023-08-03rust/gatt: Suppress rust panics on LE disconnection events received Henri Chataing
after rust module unloading Disconnection events received after the rust module is unloaded (from shutting down the stack) cause the rust module to raise a panic because the arbiter is no longer initialized. This change silences LE disconnection events received in this context. Bug: 289280004 Test: atest avatar Change-Id: Iec122a42feed059f6fa1826b625df10e92ad64bb
2023-07-21Add safety comments, or temporarily allow them to be omitted. Andrew Walbran
These will soon be required by a lint. Bug: 290018030 Test: m rust Change-Id: I13fc1bc46b855603b4ee8410e89fc7ec75c27e65
2023-07-12Fix errors from rustc 1.71.0 Chris Wailes
Bug: 288268986 Test: m rust Change-Id: Ia6555a46e87f2072cf015889cf3f6c37579558d2
2023-06-27Gatt arbiter: use RwLock to allow global cleanup William Escande
The test for this code is flaky and never works on the first iteration but works on the second attempt. This is because the crash is cleaning the bluetooth stack and let the arbiter be set a second time. The proper fix is to clean the arbiter when the stack is shut down, but being a OnceCell prevent it. Option 1 to solve it is to no longer use a OnceCell but a optional value that will require a lock to be shared across multiples caller. Option 2 is to have a mutable OnceCell but this looks like an anti-pattern The cost of this CL is an added rwlock when doing a call on the arbiter Bug: 287403942 Test: atest net_test_bluetooth.GattTest.GattServerBuild Change-Id: Ibe70e51dcdade64570ff95894aad21f5bd35a109
2023-05-31Merge changes I956e035b,Idc3cdd78,I1e5591b0,I470d40e7 Rahul Arya
* changes: [GATT Server] Simplify API of IsolationManager [GATT Server] Expose IsolationManager from GATT server module [GATT Server] Simplify IsolationManager interface [GATT Server] Split up Arbiter logic and FFI
2023-05-18rust: Make AttPermissions compatible with libbitflags 2.2.1 Jakob Vukalovic
For compatibility with the new version of libbitflags (2.2.1), implement Copy, Clone, Debug, PartialEq, Eq for AttPermissions. Bug: 261439617 Test: Build Change-Id: I67a64634a5f1bd320f983154c25ba2b7e2a813dc Merged-In: Ib00d6cf4c55ce69481aab277ae86365aac3eaa8f
2023-05-13Merge changes I168473c9,Id248cc02 Rahul Arya
* changes: Revert^2 [Connection Manager] Forward disconnection callbacks [Connection Manager] Unregister for callbacks on shutdown
2023-05-12Merge "libchrome: Update headers from libchrome" Nathan Muggli
2023-05-10[GATT Server] Simplify API of IsolationManager Rahul Arya
Test: unit Bug: 274945531 Change-Id: I956e035b9646dac149357f74e3d4a3d0236a9b0e
2023-05-10[GATT Server] Expose IsolationManager from GATT server module Rahul Arya
The IsolationManager is made a submodule of the GATT server, so we can query it to figure out what services are exposed to each connection. It is temporarily also available directly from FFI, solely for the purpose of arbitration. This will be removed once the Rust server is used for 100% of GATT server operations. Test: unit + CTS multi-device Bug: 274945531 Change-Id: Idc3cdd78ec2435a7a286413d7b1ebaae83a8f07a