summaryrefslogtreecommitdiff
path: root/src/rust/uci/mod.rs
AgeCommit message (Collapse)Author
2022-11-22uwb(uci): Remove unused rust stack + dependenciesRoshan Pius
Bug: 259462957 Test: Compiles Change-Id: Iade712396d653f924a500d3c1d1d20eb41699c3f
2022-11-18Update source for Rust 1.63.0Chris Wailes
Test: m rust Bug: 241303140 Merged-In: I8d250f541c99c619a750ec8b9ee5870335994268 Change-Id: I8d250f541c99c619a750ec8b9ee5870335994268
2022-10-13Add message control and subsession key to controlee.ziyiw
Message control and subsession key are fields required when Provisioned STS is used. But, we cannot directly add these fields because of backward compatability. So we come up with this workaround to fix the compatability problem: when using provisioned STS, we will switch the command from SessionUpdateControllerMulticastList to SessionUpdateControllerMulticastListV2. Test: atest ServiceUwbTests, libuwb_uci_rust_tests, libuwb_uci_packet_tests Bug: 232453347 Bug: 231581242 Change-Id: Id2bded30b073eea46c6cb803c693806dea3823a3
2022-10-07Fix flaky test test_hal_error_eventAnte
This test would fail on average every 2nd run when ran on a device. This was due to a race condition between UwbEvent::ERROR event and the test method dropping and thus invoking assert!(self.expected_calls.lock().unwrap().is_empty()) from mock_adaptation Drop too early. To fix it I sent another event UwbEvent::CLOSE_CPLT at the end which is processed only after the ERROR event, and since sending CLOSE_CPLT event exits the dispatcher this enables calling dispatcher.wait_for_exit() which then makes sure the test method doesn't drop before both events get processed. Bug: 251879446 Test: atest libuwb_uci_rust_tests --rerun-until-failure 20 Change-Id: If30794d6cff3c0130b4675af0eead27777803df8
2022-10-03Fix flaky test_deinitialize in uwb_uci_rust_testsAnte
This fixes a race condition where multiple UwbEvents CLOSE_CPLT were sent to hal at the same time. In cases where the wrong call got executed first, the list of expected events in mock_adaptation object weren't properly cleared. This caused assert!(self.expected_calls.lock().unwrap().is_empty()) implemented on Drop to fail. This fix removes the second unnecessary call to hal with CLOSE_CPLT since the same call will be made by calling dispatcher.send_jni_command(JNICommand::Disable(true).. after properly clearing the expected calls list. Bug: 250003544 Test: atest libuwb_uci_rust_tests --retry-until-failure 20 Change-Id: I675519deb74b930d65f68c77a6e079cfa3c3f06c
2022-08-17Send initialize result back to JNI layer.ziyiw
The result of Enable Uwb was not handled. For now, if it fails to enable uwb, the error will be sent back to JNI layer. Test: libuwb_uci_rust_tests Bug: 236139368 Change-Id: I4c81dab1cd1d6f2f0427ffa513eef915c3ec0a63
2022-08-09Merge "Parse the diagnostic notification when received in uci layer." into ↵Bob Wang
tm-mainline-prod
2022-08-09Parse the diagnostic notification when received in uci layer.ziyiw
Test: atest libuwb_uci_rust_tests Bug: 236969605 Change-Id: I41b32eff1b584df397c7d97499da657b1b0672ec
2022-08-05Add chip_id to UWB native callbacks.Leslie Watkins
Bug: 238366471 Test: atest Change-Id: Ia090d6933ce2d7520ae63a60bd6616120620d6c3
2022-07-27Update get_hal_service to take a chip_id and return the correctLeslie Watkins
IUwbChip implementation based on the chip name. Include chip_id in jni and uci callbacks. Bug: 205605642 Test: atest libuwb_core_tests Test: atest libuwb_uci_packet_tests Test: atest libuwb_uci_rust_tests Change-Id: I2a7053b2eed26e71a580b2b72f15c67b5dfd2458 Merged-In: I2a7053b2eed26e71a580b2b72f15c67b5dfd2458
2022-06-17uwb(rust): Handle HAL close failure when HAL has crashedRoshan Pius
As a part of the stack recovery, we toggle off UWB & then start it again. This fails currently because the native stack does not exit as expected on doDenitialize(). This was because the HAL close API fails (because the HAL is dead) and we would not receive the HAL close completed callback. So, instead exit the native stack immediately if the HAL close invocation fails for some reason. Bug: 236392438 Test: Manual steps: 1. Start a ranging session. 2. Kill vendor HAL. 3. Wait for recovery. 4. Start a new ranging session and ensure that it succeeds. Change-Id: I709ead843a9632147a131b9ba80c08b0f4658624
2022-04-14uwb(uci-rust): Reorganize unit test codebaseRoshan Pius
i. Move all Mocks to separate files. ii. Add #cfg(tests) or #cfg(tests, fuzzing) for all mocks. Bug: 229275354 Test: make uwb_uci_rust_fuzzer libuwb_uci_rust_tests Change-Id: Id6bc6631d034112a7f0aa603b120184a01da046d
2022-04-14uwb(uci-rust): Wait for CLOSE_CPLT HAL event for deinitializingRoshan Pius
Otherwise, this leads to race conditions in the lower layers since they might still be cleaning up (from the toggle off) when we reinitializae (for the toggle on). Also, i. Removed JNICommand::Exit since we don't need an explicit message to exit the looper. ii. Make Disable non-blocking since we are anyway waiting for the close_cplt callback from doDeinitialize(). iii. Changed unit tests to assert on failures instead of returning Result. iv. Remove redundant setup_dispatcher helper method in unit tests. Bug: 228347909 Test: atest libuwb_uci_rust_tests Test: Manual tests Change-Id: I3cb1b7b7cff7840a19c14c1fa07c03dd1f3e89ef
2022-04-12uwb(uci-rust): Add more unit tests in adaptationRoshan Pius
Also, i. Fixed some errors in the PDL unit tests (which were not caught before some reason!) ii. Initialized logging for each test to ensure that we can get erorr logs for debugging unit test failures. iii. Send notification before response in MockUwbAdapatation to prevent races. Bug: 216552887 Test: atest libuwb_uci_rust_tests Change-Id: Ib6d929f315a5623f2fa0280e65fe2e9cafabcf6c
2022-04-08uwb(uci-rust): Add more unit testsRoshan Pius
Bug: 216552887 Test: atest libuwb_uci_rust_tests Change-Id: Ic5dad51d246f43aba76e905b26c75f03f960a649
2022-04-08uwb(uci-rust): Cleanup MockUwbAdaptionRoshan Pius
Clients using mocks should ideally be only dealing with the interface exposed by the corresponding module. The current impl of MockUwbAdaptation needs clients to dig into the internals of UwbClientCallback. For ex: Uci module tests have to deal with packet fragmentation inside UwbClientCallback impl which should be hidden from unit tests of clients. Bug: 216552887 Test: atest libuwb_uci_rust_tests Change-Id: I071daedd7b1f92089ac4db28707c44baf7a1598e
2022-04-08uwb(uci-rust): Add more unit testsRoshan Pius
Bug: 216552887 Test: atest libuwb_uci_rust_tests Change-Id: Ib218bf868f9f6fa6636f8d7d8f9d5b15acbd8f50
2022-04-07Create basic fuzz tests.ziyiw
Create a mock adaptation to send mock JNICommand to lower level without triggering HAL. Only SessionInit command is implemented now. More commands are to be added. Test: adb shell /data/fuzz/$(get_build_var TARGET_ARCH)/uwb_uci_rust_fuzzer/uwb_uci_rust_fuzzer Bug: 202531943 Change-Id: I446aec2318869073444cb36ecae085a9153531f9
2022-04-06uwb(uci_rust): Handle vendor HAL crashes gracefullyRoshan Pius
Send DeviceStatusNotification with state = Error to the java stack when there is a fatal error in the HAL (indicated by HAL crash or explicit HAL event with event = Error). Bug: 227488208 Test: Manual tests Test: atest libuwb_uci_rust_tests Change-Id: I6e8c394c4c27e4173cb25528d0cbf04a2029a2c1
2022-04-05uci(rust): Handle fragmentation/defragmentation of packetsRoshan Pius
UCI spec mandates fragmentation of cmd/rsp/ntf if the payload size if > 255 (len field is 8 byte). Ideally this should be handled by the PDL more cleanly in the future But, we need a fix for UWB in Android T. Changes: 1. Add a new base |UciPacket| definition which can hold the whole cmd/rsp/notif and is used throughout the UWB stack. Use this as the base packet for all packet definitions in the PDL. This allows the stack to abstract the fragmentation to |UwbAdaption| module. 2. Add a separate |UciPacketHal| definition representing the spec defined UCI packet. This packet is sent/received from the HAL interface. 3. Add conversion mechanism from |UciPacket| to |UciPacketHal| & vice-versa for incoming/outgoing HAL packets. 4. added a MockHal for testing of UwbAdaptationImpl. Bug: 202760099 Test: Existing Manual tests. Test: atest CtsUwbTestCases Test: atest libuwb_uci_rust_tests Change-Id: Id275000cf27e10d6e35285c5bfb2beca095f6d75
2022-03-31Handle error for invalid input.ziyiw
Handle the invalid input for creating Uci packet. It should not be panicked. Test: manual Bug: 202531943 Change-Id: Icf0c28de2891b042476157d1bf01300831bc6114
2022-03-04Add Dispatcher traitChih-Yu Huang
Bug: 216552887 Test: libuwb_uci_rust_tests Change-Id: Ia6739f470fe6239b0ffdae65b78067a6ccfe608f
2022-03-01Change the wrapper of UwbAdaptation to Arc.ziyiw
Test: UwbManagerTest Bug: 216512326 Change-Id: Ieba46c57e33c2729a7cc8349fb4508b8d7240b29
2022-02-26Merge "uwb(uci-rust): Uci Logging" into tm-devTreeHugger Robot
2022-02-25uwb(uci-rust): Uci Loggingziyiw
Add Uci packet logging, the function that the log will be automatically deleted after 24 hrs is to be added. Bug: 216512326 Test: Manual Change-Id: I99b944cad1d9389517a4b2c4b4f359325b47b975
2022-02-25Increase retry timeout to 800 msTaha HADMI
Bug: 221164955 Test: Manual steps Signed-off-by: Taha HADMI <taha.hamdi@qorvo.com> Change-Id: I2ee391b0fcff28295215f732aebc1e842b77deaa
2022-02-18Change Disable command to be a blocking one.ziyiw
Test: UwbManagerTest Bug: 216512326 Change-Id: Idfb1e693e604c109188e18949054985841c935f9
2022-02-14Update power stats structure and add JNI commandKai Shi
Update power stats response data structure based on the vendor feedback. Add power stats JNI commands. Bug: 199768480 Test: atest libuwb_uci_packet_tests Change-Id: I1a99ffe895a56072bea074a6f7f5ebb2fdf357ae
2022-02-11uwb(uci-rust): Fix Vendor Rsp/Ntf UCI packet heirarchyRoshan Pius
This ensures that we always have a fully parsed packet as the payload for the rsp/notification enums. Bug: b/202760099 Test: Unit tests Change-Id: Ifd5148707ecefef7c3c683a586700f9938d21b40
2022-02-10uwb(uci-rust): Implement device resetRoshan Pius
Bug: 218898203 Test: Compiles Change-Id: Ie43fbb68c87fa6e2eace63ee04b7ad71a661a629
2022-02-09uci-rust: add test case for handling notificationChih-Yu Huang
This CL adds a test case to verify the logic of handling notification. The MockUwbAdaptation sends a notification after receiving a UCI command. Then MockEventManager should get the notification call. Bug: 216552887 Test: atest --host libuwb_uci_rust_tests Change-Id: Iebe7093b7929dc0748112a8b0f7e4942c13fc46b
2022-02-08uci-rust: add a test case for verifying failed to send UCI commandChih-Yu Huang
This CL verifies the logic that fails to send a uci command. The block_on_jni_command() method should be fail at this situation. Bug: 216552887 Test: atest --host libuwb_uci_rust_tests Change-Id: Iacbfb1b7a1f74da8255c32347b7bb482021c49bc
2022-02-08uci-rust: add a test case for verifying retry logicChih-Yu Huang
This CL verifies the retry logic for sending a uci command. The test lets the first 2 tries not responding, then make the 3rd one successfully return the repsonse. Bug: 216552887 Test: atest --host libuwb_uci_rust_tests Change-Id: I6eb9945ee44a66842487d9a662a9b905feb70ebf
2022-02-08uci-rust: verify sending a UCI messageChih-Yu Huang
This CL adds a test case that verifies the flow of sending a UCI message, and waiting for the response. Bug: 216552887 Test: atest --host libuwb_uci_rust_tests Change-Id: Ie8eb5a59f34a0701adbd7ccd9329b848014014a7
2022-02-08uci-rust: handle the panic in the working threadChih-Yu Huang
This CL handles the panic inside the working thread that makes the exit() method returns a Error. Bug: 216552887 Test: atest --host libuwb_uci_rust_tests pass Test: make the thread panic and confirm the test fails Change-Id: I1b3517bc5a40c28aa378a2410ef3811a65c3cfd3
2022-02-05Merge "uci-rust: add a test case for deinitialization"TreeHugger Robot
2022-02-05Merge "uci-rust: Verify the calling sequence of UwbAdaptation"Aka (Chih-Yu) Huang
2022-02-04uci-rust: add a test case for deinitializationChih-Yu Huang
This CL adds a new test case to verify deinitialization. Also, we extract the common setup to a dedicated function. Bug: 216552887 Test: atest --host libuwb_uci_rust_tests Change-Id: I1a79c820f18f5e875d5d774099030fe27038dc4c
2022-02-04uci-rust: Verify the calling sequence of UwbAdaptationChih-Yu Huang
In the previous CLs, we injected mock UwbAdaptation instance into the dispatcher. This CL verifies the calling sequence of the mock instance. Note that we allow the methods not in the sequence are called. Bug: 216552887 Test: atest --host libuwb_uci_rust_tests Change-Id: Icd799570d60ed77027a8282ec188e1f72f4b8f48
2022-02-03uwb(uci-rust): Log all UCI commands being sentRoshan Pius
We already log all UCI response/notifications received. Bug: 205730040 Test: Manual Change-Id: I5f23985b0653bc9387bc67bfbfc07e080d7fa4de
2022-02-02uwb(uci-rust): Don't crash on failure to convert to i32 session_idRoshan Pius
session_id is defined in the spec as 4 byte unsigned value. The HAL interface only allows signed values, so we need to just cast the received 4 byte value received via the UCI packet as i32 for the HAL call. The alternative is to declare session_id as long in the HAL interface and upconvert from u32 to i64. Bug: 216104681 Test: Compiles Change-Id: I050c1985b680246726c3a1328755aba487b72390
2022-02-02Merge "[lints] Make clippy compliant + enforced"Matthew Maurer
2022-02-02uwb(uci-rust): Fix multicast address sizeRoshan Pius
Addresses are 2 bytes long, fix the existing implementation to accept an array of shorts instead of array of bytes. Bug: 216104681 Test: Manual tests Change-Id: I1e3ce0a966817d50fe5998054916545c99416b55
2022-02-02[lints] Make clippy compliant + enforcedMatthew Maurer
Bug: 217415765 Test: build Change-Id: Ic4f33810349f44da8b683f32ada2c857b37eda82
2022-02-02[lints] Misc test lint fixesMatthew Maurer
Bug: 217415765 Test: build Change-Id: I41230d104bad13c74a93413ceb1dcfdf47f6f6c5
2022-02-02[lints] Handle all errorsMatthew Maurer
Also prevents errors in drive_once from stopping the whole driver Bug: 217415765 Test: build Change-Id: I405b615dc7f59ca69affb531ca9ec6bbd40206b5
2022-02-02[lints] Remove dead codeMatthew Maurer
Bug: 217415765 Test: build Change-Id: I6b42d3a85122c38aae4e7ec6b8673d1fbee0ee7e
2022-02-02[lints] Remove or tag unused variablesMatthew Maurer
Also caught issue where `env` was being recomputed rather than used from parameters. Bug: 217415765 Test: build Change-Id: I6d2d53b0d6f3b426bbc0c42246639e58eb08e1a7
2022-02-02[lints] Remove unreachable branchMatthew Maurer
All variants of the enum are exhaustively checked for. By removing this branch we ensure that the compiler will direct us to update the match if we add a new variant in the future. Bug: 217415765 Test: build Change-Id: I06cd1143fdd482ec74e3cf4e0cb8208b6b7e1fe7
2022-02-02[lints] Remove unused importsMatthew Maurer
Bug: 217415765 Test: build Change-Id: I2caa61854520609f37ae3013d04db3ef37bbcc47