summaryrefslogtreecommitdiff
path: root/src/rust
AgeCommit message (Collapse)Author
2022-05-06Merge "Fuzz some UciNotifications sending back from HAL to UCI layer." into ↵TreeHugger Robot
tm-dev
2022-05-05Fuzz some UciNotifications sending back from HAL to UCI layer.ziyiw
Three of seven notifications are fuzzed. Additionally, fixed the bug that calling Enable and Disable commends would cause panic. Test: manual Bug: 202531943 Change-Id: I9a40f6aaa797646f3bccab9650f37dde67273760
2022-05-04uci(pdl): Fix session_init_cmd unit test gid value Roshan Pius
GID should be 0x1 for session commands. Bug: 231223218 Change-Id: I49a80c1254cfe7b496a227da7317fe5a2eeeb625 Test: atest libuwb_uci_packet_tests
2022-05-03Merge "uwb(native): Adding host tests for libuwb_uci_rust, ↵Roshan Pius
libuwb_uci_packet" into tm-dev
2022-05-02uwb(native): Adding host tests for libuwb_uci_rust, libuwb_uci_packetAlain Michaud
A specific device only configuration is not needed since all existing tests can be ran on the host. Bug: 216784920 Test: atest --host libuwb_uci_packet_tests Test: atest --host libuwb_uci_rust_tests Change-Id: Ia58586c984abe1523ac786de6d59a86544e219d6
2022-04-29Merge "uwb_core: group UciNotification to core, session, and vendor" into tm-devTreeHugger Robot
2022-04-28Merge "uwb_core: send SessionRangeData to SessionManager's caller" into tm-devTreeHugger Robot
2022-04-28Merge changes Ia6007bef,Ifba9819a into tm-devTreeHugger Robot
* changes: uwb_core: polish the struct of the ranging data notification uwb_core: add update_controller_multicast_list() method
2022-04-22Merge "Add some unit tests for uci packet logger." into tm-devTreeHugger Robot
2022-04-22uwb_core: group UciNotification to core, session, and vendorChih-Yu Huang
This CL groups the enum UciNotification into 3 sub-group: core, session, and vendor. UciManager will send the notifications through 3 channels in the future. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: I28bc5bd4b14d7455f8541865fd5a7bb28e37c049
2022-04-22uwb_core: send SessionRangeData to SessionManager's callerChih-Yu Huang
This CL adds the sender of SessionRangeData at SessionManager's init_session() method. The SessionManager's caller could use the channel to receive the SessionRangeData. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: Ie435a2e578bafd379e431ea86349806a52045aa9
2022-04-22uwb_core: polish the struct of the ranging data notificationChih-Yu Huang
Originally, we missed several fields of RANGE_DATA_NTF when converting the packet to the UciNotification enum. This CL adds all of the fields properly. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: Ia6007befca5cc2f25eb5d6005bf2d714afcce56b
2022-04-22uwb_core: add update_controller_multicast_list() methodChih-Yu Huang
This CL adds update_controller_multicast_list() method at SessionManager. It calls UciManager's session_update_controller_multicast_list() method, and waits for the notification of the multicast list update status. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: Ifba9819a85ed25adb13e22803484f64527c311ad
2022-04-21Add some unit tests for uci packet logger.ziyiw
Added a LogFileFactory to create new real file and mock file. Test: atest libuwb_uci_rust_tests Bug: 216512326 Change-Id: I9aaa90b2bc95a600b75b58604777bb8b977d2745
2022-04-20uwb_core: add reconfigure() method at SessionManagerChih-Yu Huang
This CL adds reconfigure() method at SessionManager. Using this method, the caller could reconfigure the app configuration after initializing the session. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: I7ee293ec866c0b3cc6806f75a656b4e55d4d3bca
2022-04-19uwb_core: Remove unnesaccery clone at session_manager's testsChih-Yu Huang
SessionId and SessionType derives Copy trait, so we don't need explicit clone. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: I4905b2033502aad9d12b3cbde9b13434ed2f5959
2022-04-19uwb_core: add start/stop ranging method at SessionManagerChih-Yu Huang
This CL adds start_ranging() and stop_ranging methods at SessionManager. The methods call UciManager's methods and wait for the session status notification. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: I6ff52eb00544e8595962db051c0aac431426eb4c
2022-04-18uwb_core: add timeout for waiting notificationChih-Yu Huang
If the UciManager doesn't send session status notification when initializing session, UwbSession's initialize() method will be stuck forever. This CL handles this kind of situation by adding timeout. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: Ic5841254b5a4f2f5026550f37923317c943ca3e6
2022-04-18uwb_core: pass AppConfigParams when initiating sessionChih-Yu Huang
This CL completes the flow of session initialization: 1. call session_init() 2. wait for SessionStatusInit notifcation 3. call session_set_app_config() 4. wait for SessionStatusIdle notifcation In order to wait for the notification during the initialization process, this CL adds UwbSession struct and delegates the process to another tokio task. Then use tokio::sync::watch to pass the session status to UwbSession. Bug: 228136039 Test: cargo test Change-Id: I10b46d4d02b42bb94d0da308dfd3943ebbb55007
2022-04-15uwb_core: verify the equality of TLV list by HashMapChih-Yu Huang
Two list of TLV with the same items but different order should be considered equal. This CL verifies the equalilty of AppConfigTlv and DeviceConfigTlv list by converting the list to HashMap, then comparing the HashMap. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: Ib8f86bce0b9520ce1c3c30f29d68f58cffa77345
2022-04-15uwb_core: make FiraAppConfigParams generate tlvs for every fieldChih-Yu Huang
At ag/17750782, FiraAppConfigParams supports to generate the updated tlvs from the difference of the old parameters. To avoid the difference algorithm doesn't handle the situation that a key was set before but unset after, this CL makes FiraAppConfigParams generate tlvs for every field. With this CL, the set of keys are always the same, so we won't encounter the situation. Bug: 228136039 Test: cargo test Change-Id: I623adf61ed5866fe1cd2e6aedd07fc5fdde6b0a8
2022-04-15uwb_core: FiraAppConfigParams generate updated TLV listChih-Yu Huang
When updating the AppConfig, we only need to generate the different parameters. This CL adds generate_updated_tlvs() methods that only generates the tlvs that value is different from the previous one. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: Id4fea8115d025106c1783362b275443031319bee
2022-04-15Merge changes Ie83857bd,Ia0821a01 into tm-devAka (Chih-Yu) Huang
* changes: uwb_core: FiraAppConfigParams generate TLV list via HashMap uwb_core: Fix the range of uwb_initiation_time_ms field
2022-04-15uwb_core: FiraAppConfigParams generate TLV list via HashMapChih-Yu Huang
At the following CL we need to generate the difference of the TLV list. Using HashMap is easier to find out the difference. So this CL generates the result as HashMap first, then convert it to the Vec. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: Ie83857bdc74b4c2f465b4609ffdd08d7c31ba34e
2022-04-15uwb_core: Fix the range of uwb_initiation_time_ms fieldChih-Yu Huang
This CL fixes the range of uwb_initiation_time_ms field from 1~10000 to 0~10000. Bug: 228136039 Test: cargo test Change-Id: Ia0821a0138e1f5173f253dbc76727b7ebbc3238d
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-14uwb(uci-rust): Fix error checking in build_set_app_config_cmdRoshan Pius
Len of app_configs should be checked against the parsed tlv len, not |no_of_params|. Bug: 229246228 Test: Manual Tests Change-Id: I20d1e7711be076327a2ef8b8b9aa1dfcc7deb914
2022-04-13Merge changes from topics "presubmit-am-08ebbe811915468cbf8be553b85630e9", ↵Aka (Chih-Yu) Huang
"presubmit-am-bb24494caaa74180a118ff2dad220600", "presubmit-am-e3733b1685264f2f9dbcdd3bbc71e8ae" into tm-dev * changes: uwb_core: add builder_field macro to generate the setter method uwb_core: add unit test for FiraAppConfigParams uwb_core: validate the Android-specific fields at FiraAppConfigParams
2022-04-13Merge changes from topics "presubmit-am-3215e807c6e444928f1f50b4b32102c6", ↵TreeHugger Robot
"presubmit-am-91d751cbe97a4d929b3ec27913f6c8e4" into tm-dev * changes: Set the max buffer size to 10 kb. Handle file permissions to avoid symlink attack.
2022-04-13Merge "Add more test cases for fuzzing & handle errors that should not ↵TreeHugger Robot
crash." into tm-dev
2022-04-13Set the max buffer size to 10 kb.ziyiw
When the buffer size reaches its limit, flush the contents to to file to save memory. Test: UwbManagerTest, manual Bug: 224891049 Change-Id: I3c37f0a1763e5f4959faa6333263b2c363a72a0e
2022-04-13Handle file permissions to avoid symlink attack.ziyiw
Test: atest UwbManagerTest, manual Bug: 224891049 Change-Id: I4bba0676f6b491e581762fc85e7153e098b5d9c1
2022-04-13uwb_core: add builder_field macro to generate the setter methodChih-Yu Huang
Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: Iaa442f922b2a01852611959863bb1616e130652b
2022-04-13uwb_core: add unit test for FiraAppConfigParamsChih-Yu Huang
This CL adds a test case that successfully builds a FiraAppConfigParams from the FiraAppConfigParamsBuilder. Then verify the TLV generated from the params instance. Besides, this CL has some minor changes: - Move the default value of each field to constants - Rename the struct "RangingDeviceRole" to "DeviceRole" for consistency - Make the builder's setter method accepts T instead of Option<T> Bug: 228136039 Test: none Change-Id: I7d7f20ccc5dbb298e69bd56e61697d63b7262431
2022-04-13uwb_core: validate the Android-specific fields at FiraAppConfigParamsChih-Yu Huang
This CL ports FiraOpenSessionParams.java's checkInterleavingRatio() method that validates the Android-specific fields. Bug: 228136039 Test: cargo test Test: cargo clippy Change-Id: Ic05a1717f763107e1b4c1cebc8550e987aa60adc
2022-04-13uwb_core: add FiraAppConfigParamsBuilderChih-Yu Huang
This CL adds FiraAppConfigParamsBuilder for building the FiraAppConfigParams using the builder pattern. The builder guarantee that the client could only generate a valid FiraAppConfigParams. Bug: 228136039 Test: cargo test -p uwb_core Change-Id: Ifd3f50c783291d1190994bc09ceb8028a7214897
2022-04-13uwb_core: generates TLV from FiraAppConfigParamsChih-Yu Huang
This CL generates the TLV data, which is needed by the UCI stack, from the FiraAppConfigParams. Bug: 228136039 Test: cargo test -p uwb_core Change-Id: I7dd83afd0f3748c2c018fbb3a4d04ee6cd93d7b9
2022-04-13Merge changes from topics "presubmit-am-1b55dd285a724096aa6f36af2a304ae9", ↵Aka (Chih-Yu) Huang
"presubmit-am-44283d6f4c91442d99cae8465c26c99a", "presubmit-am-a00970ec4dfa4e4eb9367981af69fcbf" into tm-dev * changes: uwb_core: add FiraAppConfigParams uwb_core: UciManager close UciHal when dropped uwb_core: verify the mock instance at the current thread
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-12uwb_core: add FiraAppConfigParamsChih-Yu Huang
This CL adds the FiraAppConfigParams struct. It contains all of the fields defined at the FiRa UCI spec "Application Configuration Parameters" section, and the Android-specific parameters. Bug: 228136039 Test: cargo test -p uwb_core Change-Id: Ifbb69c82a6672e25ee358157d2956f976556bb02
2022-04-11Add more test cases for fuzzing & handle errors that should not crash.ziyiw
Test: manual Bug: 202531943 Change-Id: Iefa68905ec3a7fe4899c48a27682807f66ae2e3e
2022-04-11Merge changes from topics "presubmit-am-555d3b4da8e042caa53312c30788900e", ↵Roshan Pius
"presubmit-am-76e01c792533415fbce3709f84f2e776", "presubmit-am-ec4b83d1ba994f918fd924ae0f90dd9c" into tm-dev * changes: uwb(uci-rust): Add more unit tests uwb(uci-rust): Cleanup MockUwbAdaption uwb(uci-rust): Add more unit tests
2022-04-11uwb_core: UciManager close UciHal when droppedChih-Yu Huang
This CL makes UciManager to close the UciHal if the UciHal is opened when UciManager is dropped. With this CL, we could guarantee the UciHal must be closed when dropped because UciManager is the only owner of UciHal. Bug: 227264247 Test: cargo test -p uwb_core Change-Id: Id7fff42117f78886874b7d50573517be90505409
2022-04-11uwb_core: verify the mock instance at the current threadChih-Yu Huang
Originally, we verify the mock instance that all the expected calls are called when the mock instance is dropped. However, the mock instance are dropped at different thread. The panic doesn't propagate to the testing thread correctly. This CL changes the expected calls to Arc<Mutex<T>>, and adds MockInstanceVerifier struct to share the expected callls. With this struct, we could verify the mock instance at the current thread. Bug: 228136039 Test: cargo test -p uwb_core Test: Add unnecessary expected calls and make sure "cargo test" fails Change-Id: I7f4579a4f9ca2fb3007791bfc7e466741c49ad1a
2022-04-11Merge changes from topics "presubmit-am-1eb5de007d9d4ef7b1ed7e83aaca8dfc", ↵TreeHugger Robot
"presubmit-am-502c507ca1394544bebf3885b52f2896", "presubmit-am-e54a8a9f31be4632af4e50dd9811d424" into tm-dev * changes: uwb_core: remove module prefix from Error and Result type uwb_core: Add UwbService uwb_core: add session module
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-08Merge "Create basic fuzz tests." into tm-devRoshan Pius