Commit graph android_packages_modules_Co.../thread/tests/unit
Message SHA1
Add unit test for ThreadNetworkControllerService#SetEnabled
Bug: 321853291
Test: atest ThreadNetworkUnitTests
Flag: TEST_ONLY

Change-Id: Ifa74a629a20c87bf45d3d3e0693033d8e28b4e8f

Yang Sun   commited 2025-04-15 09:44:12 +00:00
3fa3ca8e5b
[Thread] add vendor & model name support for net diag
1. allow OEMs to default the vendor and model name to system properties.
2. use the vendor & model name for net diag TLVs

Change-Id: I30e988ba3e9cb9f9c5dc3a096f162d5dbcdfbc11

Kangping Dong   commited 2025-03-21 17:20:15 +08:00
6303c84ef5
[Thread] add country code overlay to enable/disable setting Thread country code
Some android devices call the API `setChannelMaxPowers()` to set the
Thread radio output power. Then there is no need for these devices
to set the Thread country code.

This commit adds an overlay configuration `config_thread_country_code_enabled`
to enable/disable setting the Thread country code.

Bug: b/402276117
Test: atest ThreadNetworkUnitTests:ThreadNetworkCountryCodeTest#initialize_countryCodeDisabled_defaultCountryCodeIsUsed
Change-Id: I215c64757d0277853f8d4625ace363a4d7bb974b

Zhanglong Xia   commited 2025-03-19 05:23:13 +00:00
7356171339
[Thread] unregister all country code callbacks when CountryCode is not needed
This commit unregisters all country code callbacks (WiFi, Telephony and
Location) when the CountryCode module detects that the co-processor
doesn't support setting the country code.

Bug: b/402276117
Test: atest ThreadNetworkUnitTests:ThreadNetworkCountryCodeTest#setCountryCodeNotSupported_returnUnsupportedFeatureError_unregisterAllCallbacks
Change-Id: I65d57e0e826202ad696335200645bf6d78c8b87c

Zhanglong Xia   commited 2025-03-18 03:04:21 +00:00
fe54478761
[Thread] do not set the country code again if the co-processor doesn't support it
Some the co-processors do not support setting the country code. This
commit enables the CountryCode module doesn't set the country again
after it knows that the co-processor doesn't support setting the
country code.

Bug: b/402276117
Test: atest ThreadNetworkUnitTests:ThreadNetworkCountryCodeTest#setCountryCodeNotSupported_returnUnsupportedFeatureError_countryCodeNotSetAgain

Change-Id: I8ca1f7aed3774a086e114e91d8100fb7fe9e3664

Zhanglong Xia   commited 2025-03-18 03:01:59 +00:00
f6187b99c7
[thread] refactor the settings module
The current settings APIs have a few issues:
1. It doesn't support default value which is derived from resource
   overlays
2. It exposes the default values of settings entries as public APIs
   while they shouldn't be

Bug: 401654864

Change-Id: I1bbe3f14507a497320401f02fa6da512558fe385

Kangping Dong   commited 2025-03-11 17:09:29 +08:00
d9bbec2fa1
[thread] Support non-BR mode
This commit adds a resource overlay config for OEMs to disable the
Border Router feature by default. Also updates the tests to cover both
BR and non-BR use cases

Bug: 401654864
Change-Id: I7dd4363836269a08853b58304f62fe52f9021a9e

Kangping Dong   commited 2025-03-11 17:09:29 +08:00
82988c3d98
[Thread] allow disabling border router auto-join
Test: verified that when the config is set to `false`, thread won't start up after reboots:
```
➜  main-aosp-2 adb shell ot-ctl state
leader
Done
➜  main-aosp-2 adb reboot
➜  main-aosp-2 adb shell ot-ctl state
/system/bin/sh: ot-ctl: inaccessible or not found
➜  main-aosp-2 adb root
➜  main-aosp-2 adb shell ot-ctl state
disabled
Done
```

Bug: 378587036
Change-Id: I4d1c90ab3121f39219cbaf795879a7ba91db02a3

Kangping Dong   commited 2025-01-10 00:09:06 -08:00
d2fc66d4bb
[Thread] allow disabling SRP server wait for border routing
It's default enabled that it waits for border routing establishment
before starting the SRP server. But there are also use cases where
the user may want to know what are the devices in the Thread network
before actually reach to the devices, or it doesn't depend on border
routing to reach to a Thread device.

Given that, this commit adds the support of starting SRP server
without waiting for border routing by adding a new
Runtime Resource Overlay configuration parameter:
config_thread_srp_server_wait_for_border_routing_enabled

Test: it's difficult to assert on the SRP server starts up timing. But manually verified that the SRP server starts without waiting for the routing manager when the RRO config is flipped:

```
01-09 20:18:35.835  7555  7555 I ot-daemon: [I] RoutingManager: RsSender: Sent RS 1/3
01-09 20:18:35.835  7555  7555 I ot-daemon: [I] RoutingManager: Received RS from fe80:0:0:0:98af:44ff:fe2e:fa80 on infra netif 17
01-09 20:18:35.835  7555  7555 I ot-daemon: [I] RoutingManager: Will evaluate routing policy in 00:00.150 (150 msec)
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] NetDataPublshr: DNS/SRP service - State: Adding -> Added
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] SrpServer-----: Start listening on port 53536
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] NetworkData---: Sent ServerData
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] NetworkData---: Received ServerData
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] NetworkData---: Allocated Service ID = 1
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] NetworkData---: Sent ServerData ack
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] Notifier------: StateChanged (0x00000200) [NetData]
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] Mle-----------: Send Data Response (ff02:0:0:0:0:0:0:1)
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] BbrLeader-----: PBBR state: Unchanged
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] BbrLeader-----: Rloc16:0x8800, seqno:69, delay:5, timeout:3600
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] RoutingManager: Will evaluate routing policy in 00:03.558 (3558 msec)
01-09 20:18:35.926  7555  7555 I ot-daemon: [I] NetDataPublshr: DNS/SRP service (state:Added) in netdata - total:1, preferred:0, desired:2
```

Bug: 378587036
Change-Id: Ib768014f3c44dca89390cec823a1c2acac38ab0d

Kangping Dong   commited 2025-01-09 04:23:17 -08:00
fad62be2d2
Add WRITE_ALLOWLISTED_DEVICE_CONFIG when modifying DeviceConfig
Bug: 380648508
Test: atest ThreadNetworkControllerServiceTest
Change-Id: I36908316f5eef6a3712c98f5901a5c162db3471c

Yang Sun   commited 2024-11-25 10:00:32 +08:00
4b43c079ff
Configure TREL feature from feature flag.
Bug: 354868035
Bug: 359089751

Test: atest ThreadNetworkIntegrationTests:ServiceDiscoveryTest#trel_servicePublished

Change-Id: Ib545df6bf5ce20f35914b4695dbd2e3c1e1232e4

Yang Sun   commited 2024-11-18 20:13:00 +08:00
bb7efba754
[Thread] add private API ThreadNetworkSpecifier
Bug: 374037595
Change-Id: I8d63a742ec2a03a1cf2f023711696379c975ff80

Kangping Dong   commited 2024-11-05 13:36:44 +08:00
2967cfaf4e
[Thread] add private API for disabling border router
Bug: 374036806
Change-Id: Ib8ca8bbd2b3018c39c9250e1b3ce70b193273c1b

Kangping Dong   commited 2024-10-31 14:30:25 +08:00
56449db1be
[Thread] request/release the NAT64 CIDR
This CL implements the logic to maintain the NAT64 CIDR at ThreadNetworkControllerService. When NAT64 is enabled, the service needs to request a CIDR via RoutingCoordinatorManager#requestDownstreamAddress(). When NAT64 is disabled, the service needs to release the CIDR via RoutingCoordinatorManager#releaseDownstreamAddress().

Bug: 350699020

Change-Id: I16397fd48c2925efd9d4833a335cf73832b4f4d6

Handa Wang   commited 2024-10-23 01:31:43 +00:00
a7318da774
[Thread] add CLI commands for getting/setting config
Bug: 364237115

Change-Id: Ice42d7d02cfefd733042282939635502c259d9d5

Handa Wang   commited 2024-10-17 07:40:42 +00:00
7eb1bbd369
[Thread] add unit test cases for Configuration API at
ThreadNetworkController

Bug: 368456504
Change-Id: I67b57f658c35b2b6e2045903d035d0f925b9b333

Handa Wang   commited 2024-10-14 02:34:49 +00:00
9a302c1e7a
[Thread] implement the ThreadNetworkController#setConfiguration at
service

This CL implements the ThreadNetworkController#setConfiguration. When
the ThreadNetworkControllerService receives this call, the configuration
is passed to ot-daemon and triggers according OT APIs. On success, the
configuration is persisted to the local storage and triggers
OutcomeReceiver#onSuccess. On failure, it triggers
OutcomeReceiver#onError.

Bug: 368456504

Change-Id: I570ec3fead204cd3b6c05629ef409967245350b8

Handa Wang   commited 2024-10-10 05:36:06 +00:00
ed15725987
[Thread] Add unit test for ephemeral key API
Bug: 348323600

Test: atest ThreadNetworkUnitTests
Change-Id: I8148b20b02010d57020b2d5d2eb9a3e79e68b10f

Yang Sun   commited 2024-09-29 02:35:51 +00:00
018f163cc9
Merge "[Thread] refactor setInfraLinkState" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-20 09:51:58 +00:00
adc778d038
Merge "Allow ot-ctl command under ADB Thread Network Service : support of non-interactive mode" into main
Yang Song   authored and   Gerrit Code Review   commited 2024-09-20 07:32:01 +00:00
2d17714c24
[Thread] refactor setInfraLinkState
This CL integrates the refactoring of aosp/3264051.

Bug: 365892457
Change-Id: I77788c06db02abbf2275fda3015b0f3fa63920e0

Handa Wang   commited 2024-09-20 06:34:51 +00:00
e24b215bf2
Merge "Let NsdPublisher pass the interface index when a service is resolved." into main
Yang Sun   authored and   Gerrit Code Review   commited 2024-09-20 05:13:43 +00:00
631ded17fc
Allow ot-ctl command under ADB Thread Network Service : support of non-interactive mode
Bug: 351721329

Test: atest ThreadNetworkUnitTests

Change-Id: Id7443c24ea380d200e73cca4ead2284249f2052f

Yang Song   commited 2024-09-20 03:58:14 +00:00
ffceaae1b8
Let NsdPublisher pass the interface index when a service is resolved.
The mapping from network to interface name is passed from
ThreadNetworkControllerService to NsdPublisher, so that NsdPublisher can
send interface index to mdns subscribers when a service is resolved.

Bug: 321883491

Test: presubmit
Change-Id: I401c38ba3fbc7b2a2de5cbc9ab1132c657518f32

Yang Sun   commited 2024-09-20 11:09:54 +08:00
9bf8e48c2a
Make java_sdk_library dependencies explicit
modules should specify the submodule of java_sdk_library that the module
actually depends on

Test: CI
Bug: 358613520
Change-Id: I0367068c901df98483f6cf95160d3e7801881b0a

Jihoon Kang   commited 2024-09-10 00:01:31 +00:00
8401b6a9f0
changes the API setChannelMaxPowers from hide API to system API
This CL changes the hiden API `setChannelMaxPowers` to system API
to allow the privilege app to set the max power of each Thread channel.

Bug: b/346686506
Test: atest CtsThreadNetworkTestCases
Change-Id: I1089a4a315971c3bca8ec688a02143ddec93d039

Zhanglong Xia   commited 2024-08-26 10:07:36 +08:00
5bbfd91b04
[Thread] add a test case to validate the default upstream network request
This CL adds a test case to verify the upstream network request has
desired transport types and network capabilities.

Bug: 356346764
Test: CI
Change-Id: Id81b5f60ce2ca574582aaf106840eab0b7aca927

Handa Wang   commited 2024-08-05 14:02:24 +00:00
89a81a15be
Merge "[Thread] fix upstream network selector to exclude VPN" into main
Handa Wang   authored and   Gerrit Code Review   commited 2024-08-01 03:20:46 +00:00
50644b75b8
[Thread] fix upstream network selector to exclude VPN
Previously the upstream network selector wrongly cleared the default
network capabilities so there's a risk of choosing VPN as the upstream
network, which is undesired.

Bug: 356346764
Test: atest ThreadNetworkIntegrationTests
ThreadNetworkControllerServiceTest

Change-Id: Ic1762775734d734f1974a753f100814b61d66589

Handa Wang   commited 2024-08-01 03:20:11 +00:00
4641f69608
[Thread] Make ThreadConfiguraiton a system API
This CL adds 3 things as @SystemApi:
- The ThreadConfiguration class except the Builder nested class.
- The ThreadNetworkController#registerConfigurationCallback method.
- The ThreadNetworkController#unregisterConfigurationCallback method.

Bug: 342519412
Test: CtsThreadNetworkTestCases

Change-Id: I8d3e48b73d471af1515f251451a1259a4bde69af

Handa Wang   commited 2024-07-29 08:07:17 +00:00
5fc74b9fd8
[Thread] disable handling of airplane mode
This is basically a revert of aosp/3079292 to disable the handling of
the airplane mode. The cause is that there are a few reported ANR issues
on real devices and they points to the handlers here in Thread module.

Before we figure out the root cause, let's disable the airplane mode
handler in Thread to recover the presubmit tests.

Bug: 353115531
Bug: 352484437
Bug: 350586929
Bug: 352316041
Change-Id: I569ced2855658f965ddf51242600ee3c325781a7

Kangping Dong   commited 2024-07-15 15:48:15 +08:00
14da81bc17
Merge "[Thread] add config_thread_mdns_vendor_specific_txts" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-10 11:03:52 +00:00
9365e728e5
Merge "Revert "[Thread] post broacast receivers on the handler thread"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-10 09:43:16 +00:00
4866872a4d
[Thread] add config_thread_mdns_vendor_specific_txts
per offline discussion, it's better to provide support of customizing
any vendor-specific TXTs to make the solution more generic. The preivous
defined "vgh" TXT entry is deprected.

Bug: 343671003
Change-Id: I6e2804e346d04078b7d28bfdc18ed6c23c5c10e6

Kangping Dong   commited 2024-07-10 17:36:13 +08:00
29918c1d45
Revert "[Thread] post broacast receivers on the handler thread"
This reverts commit f8aaac0dd0.

Reason for revert: see b/350586929

Change-Id: I34f3a87664992e5324f89bcf49e56707d0143743

Kangping Dong   authored and   Gerrit Code Review   commited 2024-07-10 08:45:09 +00:00
65b4f5fa53
Merge "Thread: fill in ticks in active timestamp" into main
Yakun Xu   authored and   Gerrit Code Review   commited 2024-06-26 09:33:38 +00:00
4355dae9d8
Thread: fill in ticks in active timestamp
This commit fills in the ticks of active timestamp of randomly generated
dataset as defined in Thread spec.

Bug: 347838683
Change-Id: I5d8ba3ca7728e1890996fdd64198f7bc90bfb1fa

Yakun Xu   commited 2024-06-26 15:56:57 +08:00
e2ab96f3c7
Merge changes from topic "thread-configuration-api" into main
* changes:
  [Thread] support ThreadConfiguration API at ThreadNetworkControllerService
  [Thread] add support for configuration at ThreadNetworkController

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-24 10:03:18 +00:00
bc9c0e2b03
[Thread] support ThreadConfiguration API at ThreadNetworkControllerService
Bug: 342519412
Test: atest CtsThreadNetworkTestCases

Change-Id: I7b84a64d24e513bd6ba07bb26e3801b72c250810

Handa Wang   commited 2024-06-24 07:50:37 +00:00
4688910810
[Thread] post broacast receivers on the handler thread
It turns out context.registerReceiver(receiver, intentFilter,
permission, flags, handler) is not posting the receiver on the handler
and will result in ANR in activity manager if the receiver is blocked

This commit makes it safer by posting the receiver body to mHandler
explicitly.

Bug: 340368050
Change-Id: Ib6b8c0a8952ce43c935f39b0978f47268b108a79

Kangping Dong   commited 2024-06-24 11:52:14 +08:00
f8aaac0dd0
[Thread] add annotations for unit test NsdPublisherTest
Change-Id: Ic4e12b21bb888f0e4f892e9a368a64d769120cc1
Test: atest NsdPublisherTest

Handa Wang   commited 2024-06-18 00:51:03 +00:00
89c32ea0c8
[Thread] add the "vgh" TXT entry
Allows vendors to specify whether the Thread network is managed by
Google or not.

Bug: 343671003

Change-Id: Ie4d4050add0485643ea3eff0c576868b086f848c

Kangping Dong   commited 2024-06-12 23:19:34 +08:00
151275359f
Use DeviceFeatureModuleController to run tests only if the device has the required feature.
This is to avoid running tests on devices that do not support Thread. Otherwise, the tests will fail with ClassNotFoundException when the test classes are loaded

Change-Id: I286394ae925ad7258aa82cd308ac963ee334992c

Kangping Dong   commited 2024-06-05 19:32:59 -07:00
67586d188e
Merge "[Thread] support resolving a host for NsdPublisher" into main
Handa Wang   authored and   Gerrit Code Review   commited 2024-06-05 10:23:26 +00:00
a22aa7777d
[Thread] support resolving a host for NsdPublisher
This CL lets NsdPublisher support resolving an mDNS host via one-shot
mDNS query. Because NsdManager not yet responds to such a query
properly, we cannot add an integration test for this. I've verified the
Discovery Proxy use case work properly on real devices.

Bug: 322434640
Test: atest NsdPublisherTest

Change-Id: Ie67f2fb9dd012408c123c354fc29f1a943280780

Handa Wang   commited 2024-05-28 11:18:10 +00:00
1a6ca28ae0
Merge "Thread: use network time for generating dataset" into main
Yakun Xu   authored and   Gerrit Code Review   commited 2024-05-24 09:18:21 +00:00
f987ceba35
Merge "[Thread] add more Thread shell commands" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-05-24 09:16:06 +00:00
20e06e28ce
Thread: use network time for generating dataset
This commit tries to use network time as authoritative time source for
generating Thread operational dataset. If the time is get successfully,
the authoritative bit will be set in the dataset.

Bug: 340130726
Test: presubmit
Change-Id: Ibaca1f866be0be121763fdb63e02621809484b17

Yakun Xu   commited 2024-05-24 14:29:10 +08:00
6420ccf4a8
[Thread] add more Thread shell commands
A summary of changes in this commit:
1. add new commands mirroring the java APIs: "join", "migrate" and
   "leave"
2. Use THREAD_NETWORK_TESTING for guarding access to shell commands
   which are for testing
3. Refactor ThreadNetworkShellCommand for readability

Bug: 329368792
Change-Id: Ibdb256674533704dc1d000a15c162f41cec5047f

Kangping Dong   commited 2024-05-24 14:11:40 +08:00
abe19f9628
[Thread] run ThreadNetworkControllerServiceTest tests in a single thread
@Test annotated methods are running in threads like
"Thread[Time-limited test,5,main]" which is created by FailOnTimeout.java,
while @Before annotated setUp() is running in thread
"Thread[Instr: androidx.test.runner.AndroidJUnitRunner,5,main]" which is
created by AndroidJUnitRunner.

The issue is that there are code in ThreadNetworkControllerService
checking all its methods runs on the thread associated to the provided
handler. This constraint doesn't hold in this unit test because
TestLooper runs all the posted tasks on the current thread rather than
the thread associated to its backed looper. So the tests will fail with
Log.wtf() which terminates the process on eng build.

This commit fixes this issue by annotating the test class with
@UiThreadTest to force methods annotated with @Before, @After and @Test
to run on the main / UI thread.

Test: run this test class on aosp_cf_x86_64_phone-trunk_staging-eng
Bug: 342092067
Change-Id: I7d75de5ac31234f3051e9ed332da33c1da6a8c98

Kangping Dong   commited 2024-05-23 03:04:59 +00:00
4d0afab8fe