Commit graph android_packages_modules_Co.../thread/tests/unit
Message SHA1
dataset selects a channel from channel 11 to 24
Many Thread radio chips need to reduce their transmit power on edge
channels to pass regulatory RF certification. This CL restrcits the
dataset to select a channel from channel 11 to 24.

Bug: b/331708479
Test: atest ThreadNetworkUnitTests
Change-Id: I758c9f33629a0cafcc39bb9fde0ad45ab2699db8

Zhanglong Xia   commited 2024-04-10 14:43:17 +08:00
dac352d489
set the country code when initializing the ot-daemon
The country code is lost after the ot-daemon is restarted. This
CL stores the country code to persistent settings and reads
out the previously stored country code to set the country code
when the ot-daemon is initialized.

Bug: b/326021472
Test: atest ThreadNetworkUnitTests

Change-Id: I6982a57ba4845f5a45f3366400c531398e82339e

Zhanglong Xia   commited 2024-03-28 10:36:24 +08:00
4eab54b40e
[mdns] support discovering and resolving services
Bug: 305866779
Test: atest ThreadNetworkIntegrationTests:android.net.thread.ServiceDiscoveryTest

Change-Id: I96ee5b835c90fa55136dbbde68d36bbf2044b420

Handa Wang   commited 2024-03-22 06:32:23 +00:00
abefbf0b9f
Merge "[Thread] fix ot-daemon state consistency issues" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-22 06:31:18 +00:00
3a9d363bdf
[Thread] fix ot-daemon state consistency issues
1. the OtDaemonState in OtDaemonCallbackProxy class is not cleared when
   ot-daemon dies
2. register ot-daemon state callback within the IOtDaemon#initialize API
   to avoid missing state changes between initialize() and
registerStateCallback()

Bug: 330441708
Change-Id: Ice58566582b40a6d25627cf01dec93da61ad3596

Kangping Dong   commited 2024-03-22 10:58:24 +08:00
0d22aded3d
[Thread] add system API setChannelMaxPowers
The `setChannelMaxPowers` allows privilege app to set the max
power of each channel. It is going to be used for controlling the
output power of the Thread radio chip.

Bug: b/320594263
Test: atest ThreadNetworkUnitTests && atest CtsThreadNetworkTestCases

Change-Id: Ic47eccd6de2da0e6cdb8f21d5b4df156b1f11747

Zhanglong Xia   commited 2024-03-22 10:49:09 +08:00
62abecc9b5
[Thread] add command to force stop ot-daemon
The Thread HAL supports only one client for a single Thread chip, so
ot-daemon needs to be force stopped in VTS tests because the testapp
needs to connect to the HAL service to perform tests.

Bug: 328538612
Change-Id: I5288e5747ab3957050d0e85c1ea684c6ead6c87d

Kangping Dong   commited 2024-03-21 19:02:39 +08:00
82599d3e21
[Thread] do not restart ot-daemon when Thread is disabled
Current implementation will auto-restart ot-daemon even when Thread
has been disabled by ThreadNetworkController#setEnabled(false). This
commit fixes this issue and also adds the "enable" / "disable" shell
command to ease testing.

Bug: 328538612
Change-Id: Icc9360ccf5d7daa6345def75d1860f046600b85b

Kangping Dong   commited 2024-03-20 23:49:53 +08:00
adb3c1ac62
[Thread] support customize meshcop txt via resourceoverlay
Currently support customizing the vendor name, vendor oui and model
name.

Bug: 311324956
Test: atest ThreadNetworkIntegrationTests:android.net.thread.ServiceDiscoveryTest#meshcopOverlay_vendorAndModelNameAreSetToOverlayValue
Change-Id: I3ad916112c73c3f8a7eef4e3fa8d421ab9bf8276

Kangping Dong   commited 2024-03-18 20:13:37 +08:00
ea4390cc4c
Add reset API for NsdPublisher
This is needed by `ot-daemon` to clear all registrations when
re-initializing the `ot-daemon`'s `Application` class.

Bug: 323301831

Change-Id: I5ed3d2d29b08f4187ac1f406052d362cf2249c19

Handa Wang   commited 2024-03-14 14:37:38 +00:00
da90deda1b
Check kernel version for multicast routing support.
Multicast routing is only supported on 14_5.15.0 and onwards. When sdk
version is 34+, thread is supported, if kernel version is e.g.
5.15.144-android13 then multicast routing is not supported so we need to
skip multicast routing tests.

Bug: 328133320

Test: atest ThreadNetworkIntegrationTests:android.net.thread.BorderRoutingTest
Change-Id: I5d67f4558b40ee3ec0569298c7c02726d5d19e98

Yang Sun   commited 2024-03-07 20:44:05 +08:00
734c626fea
[mdns] support regsitering hosts in NsdPublisher
This CL also adds an integration test case for the Advertising Proxy feature.
Currently the test case is disabled because it's unstable on some branches.
Will re-enable the test case when it's stable enough.

Bug: 318323473
Test: atest ThreadNetworkIntegrationTests:android.net.thread.ServiceDiscoveryTest
Change-Id: Ic88efb3b80640f95b53e4ec2428369e87be71649

Handa Wang   commited 2024-03-07 02:59:14 +00:00
c6037af2bf
Revert "[mdns] support regsitering hosts in NsdPublisher"
Revert submission 2943805-nsdpublisher-publish-host

Reason for revert: Test failures: b/328384504

Reverted changes: /q/submissionid:2943805-nsdpublisher-publish-host

Change-Id: I5919fea68cae0d3817319994f43eb47e912f9157

Vaibhav Devmurari   authored and   Gerrit Code Review   commited 2024-03-06 12:15:11 +00:00
ba1cc3886e
[mdns] support regsitering hosts in NsdPublisher
This CL also adds an integration test case for the Advertising Proxy feature.

Bug: 318323473
Test: atest ThreadNetworkIntegrationTests:android.net.thread.ServiceDiscoveryTest

Change-Id: I626aa6250bc2cb94aee09067b4f8e6b14bd90fcf

Handa Wang   commited 2024-03-05 06:56:52 +00:00
87c688df4b
Merge "Update the imports to androidx.test.filters.*" into main
Ram Peri   authored and   Gerrit Code Review   commited 2024-03-01 16:38:04 +00:00
64a8fa9d13
Update the imports to androidx.test.filters.*
Bug: 316941721
Test: mmma .
Change-Id: I113714afaeb99bf76ff4dc19304371ad0ec097e0

Fangqiu Su   commited 2024-02-29 17:56:14 +00:00
61a14ca475
Use a TAP test network for MeshCoP service test cases
Previously we were using TUN test network which is not eligible for mDNS
operations. The tests are flaky because we need to depend on other test
cases to connect to WiFi, which is not guaranteed. We'll use the TAP
test network to fix it.

Bug: 327306555
Bug: 327306158
Bug: 327306608
Test: https://android-build.corp.google.com/builds/abtd/run/L70000030002206431

Change-Id: Ie8ed0ee8b8208150efcd4424ed26e9ca7d85fd82

Handa Wang   commited 2024-02-29 04:49:56 +00:00
9f417260cf
Merge "Revert "Use a TAP test network for MeshCoP service test cases"" into main
Handa Wang   authored and   Gerrit Code Review   commited 2024-02-29 01:44:18 +00:00
e816bb776a
Revert "Use a TAP test network for MeshCoP service test cases"
This reverts commit 55648268de.

Reason for revert: DroidMonitor revert

Change-Id: Idd86b0ceb18fc425c39fe3c75603a472568eabe1

Joseph Murphy   authored and   Gerrit Code Review   commited 2024-02-28 21:56:27 +00:00
8f0e34be48
Merge "Use a TAP test network for MeshCoP service test cases" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-02-28 17:23:16 +00:00
5b3bf1adef
Use a TAP test network for MeshCoP service test cases
Previously we were using TUN test network which is not eligible for mDNS
operations. The tests are flaky because we need to depend on other test
cases to connect to WiFi, which is not guaranteed. We'll use the TAP
test network to fix it.

Bug: 327306555
Bug: 327306158
Bug: 327306608

Change-Id: Ia6de8a507578dbdeea4a7ceaf52f417acf35baa2

Handa Wang   commited 2024-02-28 14:30:22 +00:00
55648268de
[Thread] make Thread state customisable via resource overlay
Make the default Thread and Border Router enabled state customizable for
vendor via resource overlay.

Bug: 322734489
Change-Id: I278d6afa82aac8d1bb06ee79f22bae6fb0199386

Kangping Dong   commited 2024-02-28 16:54:02 +08:00
c8359f4eb1
[Thread] pre-grant all permissions for ThreadNetworkControllerServiceTest
Existing ThreadNetworkControllerService tests are using RunAsShell to
grant the permissions for indivitual APIs. Given the permission checks
are tested in the CTS tests, this is not very useful with the overhead
of complicating the testing code. Instead, this CL grants all the
permissions in setUp() with spy-ed Context.

This commit also fixes the issue in b/326793058 that the tests doesn't
run on a U device where the THREAD_NETWORK_PRIVILEGED permission doesn't
exist.

Bug: 326793058
Test: m ThreadNetworkUnitTests
Change-Id: I477cf30d737969ccf12180eae48d3b8fd6ed4a51

Kangping Dong   commited 2024-02-26 17:15:07 +08:00
a3c94d5273
Select Thread channel from preferred or supported channel mask
The API `createRandomizedDataset()` randomly selects a channel
between channel 11 and 26. But not all countries support channels
between 11 and 26.

This CL selects random channel from  the preferred channel mask if
the preferred channel mask is not 0, otherwise choose one from the
supported channel mask.

Bug:b/308310823
Test: atest ThreadNetworkUnitTests && atest CtsThreadNetworkTestCases

Change-Id: I6add3edc7e4fa888c46b57c4463ab18e0aa84e80

Zhanglong Xia   commited 2024-02-23 11:04:27 +08:00
d800ee41bf
[Thread] add MainlineModuleController for ThreadNetwotkUnitTests
Per comment in https://android-review.git.corp.google.com/c/platform/test/mts/+/2930711/comment/a88f14b1_a2fb9841/

Bug: 322142548
Change-Id: Id87c9f20be31cbead2062c08addc5995df143896

Kangping Dong   commited 2024-02-21 09:15:13 +00:00
9d2f1e8e9e
[Thread] disable Thread when user restriction is set
This commit follows the guideline in go/ae-v-thread-admin-control that
Thread radio should be disabled when the user restriction is set and
nobody can enable Thread again (it fails with
ERROR_FAILED_PRECONDIFITION).

This commit adds only unit tests, E2E CTS tests are tracked in b/319079428

Bug: 319077876
Change-Id: I8981aa9e71948c64ee79701427ac794880826327

Kangping Dong   commited 2024-02-20 15:56:42 +08:00
505b5ce45b
[Thread] check too large error code in unit tests
Per CTS review comment in aosp/2949385:
```
You might want to make this a bit larger, otherwise if some new error codes are added in the future in a mainline update, already released CTS test packages will start to fail.

That should be fixed by mCTS, but since mCTS is not in place yet, it's best to be safe
```

This commit moves the too-large error code check into unit test to avoid
potential CTS compatibility issues.

Bug: 323791003
Change-Id: If99191630e1044cb8f5ed189bf79567cd51c3905

Kangping Dong   commited 2024-02-05 15:53:43 +08:00
54d62cee14
[mdns] implement NsdPublisher AIDL service
For ot-daemon to perform mDNS operations, we need to implement an AIDL
service NsdPublisher. MdnsPublisher forwards the calls to NsdManager.

For now, only register & unregster a service without a custom host is supported.

Bug: 320211657
Bug: 318323473
Test: atest CtsThreadNetworkTestCases

Change-Id: Ia392a0f57046f53973ac6bd6043dec915d170666

Handa Wang   commited 2024-02-04 04:03:36 +00:00
0c99448af4
[DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
Merge "[Thread] add Thread tests to mts-tethering" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-31 05:45:12 +00:00
6c728aa1fa
Merge changes from topic "set-thread-enabled" into main
* changes:
  Add service implementation for ThreadNetworkController#setEnabled
  Add setEnabled API

Yang Sun   authored and   Gerrit Code Review   commited 2024-01-26 11:22:37 +00:00
8f9544539b
Add service implementation for ThreadNetworkController#setEnabled
ThreadNetworkControllerService handles setEnabled requests and
asks ot-daemon to enable/disable Thread. The desired Thread enabled state
is saved in thread persistent setttings, the setting is loaded at bootup.

Bug: 299243765

Test: atest CtsThreadNetworkTestCases:android.net.thread.cts.ThreadNetworkControllerTest

Change-Id: Ifd0135433df25d9c6cfd3f365dd06ec7908268e7

Yang Sun   commited 2024-01-26 15:53:43 +08:00
625353b5bf
Check whether the WiFi country code is a valid Thread country code
The Thread country code should be a 2-Character alphabetical country
code. The `00` is an invalid country code for Thread country code,
but it is the default country code for WiFi country code. If setiting
the `00` as the Thread country code, the ThreadCountryCode throws
an exception.

This CL checks whether the country code is a valid Thread country
code before setting the WiFi country code as the Thread country code.

Bug: b/322404467
Test: atest ThreadNetworkUnitTests
Change-Id: Ic5fd69fc254ee25ad1e75e17096a5f5310a9140f

Zhanglong Xia   commited 2024-01-26 11:51:44 +08:00
a888e726b3
[Thread] add Thread tests to mts-tethering
Bug: 322142548
Change-Id: I71af1787b23be4c27d26b30498408631c2955012

Kangping Dong   commited 2024-01-25 18:05:10 +08:00
974d3ed761
Add OEM country code to Thread country code sources
Bug: b/309357909
Test: Run `atest ThreadNetworkUnitTests`.
Change-Id: Ic3c9ef69fc77c44a50f6dc856e1af26c43be1aa2

Zhanglong Xia   commited 2024-01-25 16:08:04 +08:00
5c0d8a6603
Merge "[Thread] Add support for Thread persistent setting" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-03 13:01:53 +00:00
396cc5721e
[Thread] Add support for Thread persistent setting
The ThreadPersistentSetting class can be used to read/store key value
pairs in ThreadPersistentSetting.xml file.

Bug: 299243765

Test: atest ThreadNetworkUnitTests:com.android.server.thread.ThreadPersistentSettingTest
Change-Id: I564ce8373e6af8f5cdf066a579bec46bfffecb72

Yang Sun   commited 2024-01-03 19:09:47 +08:00
95f40d0c55
Merge "[Thread] add service unit test skeleton" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-03 10:06:47 +00:00
3deb5da6db
Add telephony country code to Thread country code sources
Bug: b/309357909
Test: Run `atest ThreadNetworkUnitTests`.
Change-Id: I51c297a5c30fb114a6e3fb8b54cdbfef142001b3

Zhanglong Xia   commited 2024-01-03 15:33:07 +08:00
a00bb3fad9
[Thread] add service unit test skeleton
Adds the Thread service unit test skeleton and make the services
testable.

Initially, a few trivial unit tests for existing APIs are added in
ThreadNetworkControllerServiceTest.java, and more tests will be added in
separate CLs later.

Bug: 317555104
Change-Id: I7b9e5f3663493d8da2448568de792e4272ee1df6

Kangping Dong   commited 2024-01-03 15:01:07 +08:00
276384042d
Add WiFi country code to Thread country code sources
Bug: b/309357909
Test: Run `atest ThreadNetworkUnitTests`.
Change-Id: I087cc0fc2b6c21fd9d3d4607f30c194214aeb37e

Zhanglong Xia   commited 2024-01-03 10:25:14 +08:00
69c370af8c
Add Thread resource overlay support
This CL adds resource overlay support to allow developers to
change the default configuration of using the location country code.

Bug: b/311324956
Test: Set the resource overlay in cuttlefish, check the default
      configuration via the command `dumpsys thread_network`.

Change-Id: Ide853975e8244f06a382b2eda4844e030539b95d

Zhanglong Xia   commited 2024-01-03 00:29:55 +08:00
125a43c12b
Set Thread Network country code from location country code
This CL selects the Thread country code from location country code.
If the location country code is not avaliable, the country code `WW`
will be selected as the default Thread country code.

This CL also adds Shell commands for developers to override the Thread
country code for testing.

Bug: b/309357909
Test: Run `atest ThreadNetworkUnitTests`.

Change-Id: Id87c293005f0e75922a72854b40c41837b74397f

Zhanglong Xia   commited 2024-01-03 00:27:50 +08:00
d385e7eec5
add hidden method setTestNetworkAsUpstream
`setTestNetworkAsUpstream` allows to specify a test network as the upstream of Thread network. This is going to be used in Thread integration tests. E.g. android.net.thread.BorderRoutingTest.

Bug: 295843010
Test: atest android.net.thread.BorderRoutingTest

Change-Id: I66474e2aa5b3434c4c66078a1d6bd6e522e32ae5

Handa Wang   commited 2023-12-25 16:47:23 +08:00
198a3d495a
[Thread] clear calling identity before invoking app-supplied callback
Per API council feedback and API guideline at
go/android-api-guidelines#provide-executor, it should call
Binder.clearCallingIdentity() before invoking the app-supplied callbacks
so that the app doesn't use the system-server's identity for permission
check in the callback.

Bug: 309952666
Test: atest ThreadNetworkUnitTests
Change-Id: I3cfbce29c0a516506bb76a44b151a583c8477806

Kangping Dong   commited 2023-11-22 01:54:34 +00:00
98015f3373
[Thread] add missing guava dependency in tests
Change-Id: I383e4a0c78dc3b29fc1aa80d16204166f84ae61b

Kangping Dong   commited 2023-11-09 07:55:00 +00:00
26639b1aff
[Thread] move createRandomDataset to ThreadNetworkController
This commit renames `createRandomDataset` to `createRandomizedDataset`
and moves this method to ThreadNetworkController class.

The reason for moving this method is that we rely on the service side to
know which channels are currently supported by this device and there is
no safe way for ActiveOperationalDataset to created a randomized full
dataset by its own. Moving this method to ThreadNetworkController also
allows us to support future platform-dependend configurations.

Bug: 308117328
Bug: 307939803
Change-Id: I0b0b7b727c3b326ab59bb1299ace15df1ff1ad5e

Kangping Dong   commited 2023-11-08 22:39:33 +08:00
af4f1f576c
[Thread] fix OperationalDatasetTimestamp#toTlvValue is not loss-less
OperationalDatasetTimestamp is saving the timestamp as an Instant
object, and this has the problem that when the dataset timestamp is
written to a TLV, it's going to loss precision as the nanoseconds
of the Instant is converted to "Ticks". This results in bug that
the dataset timestamp doesn't equal to the same value when it's
converted back from a TLV:

```
var timestamp1 = OperationalDatasetTimestamp.fromInstant(Instant.ofEpochSecond(100, 999938900));
byte[] tlv = timestamp1.toTlvValue();
timestamp2 = OperationalDatasetTimestamp.fromTlvValue(tlv);

assertThat(timestamp2).isEqualTo(timestamp1); // This fails!!!
```

Bug: 308408536
Test: atest ThreadNetworkUnitTests CtsThreadNetworkTestCases
Change-Id: I81b482a05337b6d1150edaa28b860034592a4347

Kangping Dong   commited 2023-11-07 13:13:06 +08:00
160b4d38f9
Clean up obsolete aliases for Truth.
Bug: 255714762
Test: presubmit
Change-Id: I1a6394f6ff1cd56fac0f7a340857fdaee92fcbab

Krzysztof Kosiński   commited 2023-10-26 07:13:22 +00:00
4656f54cdd
[Thread] add Thread Operational Dataset API
Design doc: go/thread-android-api
Android FR: b/235016403

Bug: 262683651
Change-Id: Icbd4ee4150e3fd78df627c2e726c259e7ee50871

Kangping Dong   commited 2023-10-25 18:13:07 +08:00
7fea5fa6a2