Commit graph android_packages_modules_Co.../thread
Message SHA1
Add a test case that a Border Router sends a UDP message to Thread device
This test case lets the BR send a UDP message to Thread device using
socket API and verify the message is received on the Thread device via
ot-ctl udp command.

For now this only verifies the direction BR -> ED because the other
direction ED -> BR is depending on platform UDP feature which is not
enabled yet.

Bug: 321168973
Test:  atest ThreadNetworkIntegrationTests:BorderRoutingTest#unicastRouting_borderRouterSendsUdpToThreadDevice_datagramReceived

Change-Id: I590583dd818f3d72dec41184e5427a8b08f842bb

Handa Wang   commited 2024-02-19 03:24:38 +00:00
b5c6ac2fe7
Merge "Set the container field of aconfig flags" into main
Oriol Prieto Gascó   authored and   Gerrit Code Review   commited 2024-02-06 00:38:23 +00:00
108a2d6360
[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
Merge "[Thread] add CTS tests for ThreadNetworkException" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-02-04 09:58:33 +00:00
2fe1db6e49
[Thread] add CTS tests for ThreadNetworkException
Bug: 323464130
Test: presubmit
Change-Id: I67bde1506e99b42ff3806254aa8bbc6c98792e3e

Kangping Dong   commited 2024-02-04 12:58:10 +08:00
86a70b4992
[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
Set the container field of aconfig flags
Test: m
Bug: 312769710
Change-Id: I1eed7982b40d28947aa3f9575c568eac325dc832

Oriol Prieto Gasco   commited 2024-02-03 02:39:14 +00:00
6eec17aa97
Merge "[Thread] restarts when ot-daemon crashes" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-02-01 15:24:26 +00:00
fbaa7ea0bc
[Thread] restarts when ot-daemon crashes
This commit handles the ot-daemon crash by automatically restarting it
and rejoin the network if ever joined.

This also fixes the address not deleted issue in TunInterfaceContorller.

Bug: 321540728
Bug: 309792480
Change-Id: I3ed466eb70818974a1e57f01456363bdf82915d5

Kangping Dong   commited 2024-02-01 21:49:31 +08:00
3deddc7b3f
Add netlinkSocketForProto() without buffersize.
Test: atest NetworkStaticLibTests
atest FrameworksNetTests

Change-Id: I34a0a29eb7e78490701872229585e61f7a0c1dd3

Yang Sun   commited 2024-02-01 09:50:52 +08:00
1d8b7cc422
Merge "[DON'T BLOCK] Test ownership migration rules" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-01-31 23:38:03 +00:00
e7aa45cdf0
Merge "[Thread] refine border routing logging" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-01-31 13:27:26 +00:00
7f7135e29e
[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 "Pass buffer size to NetlinkUtils.netlinkSocketForProto" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-01-31 01:42:49 +00:00
2cb28ea360
Pass buffer size to NetlinkUtils.netlinkSocketForProto
Pass buffer size to netlinkSocketForProto to allow callers to specify
buffer size. The buffer size is not set if 0 is passed in.

Following callers of netlinkSocketForProto passes SOCKET_RECV_BUFFERSIZE
to keep same behavior as before:
 * OffloadHardwareInterface.createConntrackSocket()
 * NetlinkUtils.sendOneShotKernelMessage()
 * IpSecXfrmController.Dependencies.newNetlinkSocket()
 * InetDiagMessage.getConnectionOwnerUid()
Following callers pass 0 to not update the buffer size:
 * TunInterfaceController - it uses the socket only for writing
 * NetlinkUtils.createNetLinkInetDiagSocket() same behavior as before
Added a SOCKET_DUMP_RECV_BUFFERSIZE of 128k to be used by socket
requesting dump information from kernel:
 * NetlinkUtils.getAndProcessNetlinkDumpMessages() - sends dump request
   and expecting multiple reply messages.

Bug: 320420453

Test: atest NetworkStaticLibTests
atest FrameworksNetTests

Change-Id: I3dcb76963cf2646eb311602b50ab4e44b8ad3e8f

Yang Sun   commited 2024-01-30 21:54:48 +08:00
7934241c8f
Merge "Move the Thread proguard flags to ConnectivityService's proguard.flags" into main
Handa Wang   authored and   Gerrit Code Review   commited 2024-01-30 09:03:34 +00:00
96361bc4cd
Merge "[Thread] add ThreadNetworkIntegrationTests to mts-tethering" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-29 12:08:06 +00:00
e2021fde0c
Merge "Update name threadnetwork.country_code in comments" into main
Zhanglong Xia   authored and   Gerrit Code Review   commited 2024-01-29 07:34:42 +00:00
1553c4d350
Merge "[Thread] tests a single ThreadNetworkController" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-29 06:29:46 +00:00
9c712684b1
[Thread] tests a single ThreadNetworkController
Simplifies the CTS tests by testing only the first controller given
there is only one controller. No testing logic changes.

This commit also moves the helper methods to end of the file as they are
not the focus.

Bug: 321662734
Test: m CtsThreadNetworkTestCases
Change-Id: I4acf26e13ee112df2b7378b1005a1a14de4d783e

Kangping Dong   commited 2024-01-29 11:57:40 +08:00
44b8312033
Update name threadnetwork.country_code in comments
The properity `ro.boot.threadnetwork.country_code` has been renamed
to `threadnetwork.country_code` in aosp/2923770. This CL updates the
properity name in the comment.

Bug: b/309357909
Test: Run `atest ThreadNetworkUnitTests`.
Change-Id: I630f4d970452b17c3ee35fa8e9792ca907341ee8

Zhanglong Xia   commited 2024-01-29 11:13:47 +08:00
08bba8804a
[Thread] add Android.bp format to make-pretty.sh
There are sometimes gerrit warnings on Android.bp file format:
```
Analyzer Description: Formats Android.bp files.
Owner: soong-team@google.com

This file is not formatted.

Run prebuilts/build-tools/linux-x86/bin/bpfmt -w {filename} to format the file, or apply the suggested fix.
```

This commit adds the suggested format script to make-pretty.sh to avoid
the warning.

Change-Id: I8a691b1e6af873e8c43e34ed3168203d469eee1c

Kangping Dong   commited 2024-01-28 13:14:46 +08:00
c73dd5aa23
[Thread] add ThreadNetworkIntegrationTests to mts-tethering
Bug: 299853805
Change-Id: I567142a8bf8c735b65048d985e94d958a7feef03

Kangping Dong   commited 2024-01-28 13:10:52 +08:00
25bcfee4e3
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
Move the Thread proguard flags to ConnectivityService's proguard.flags
We needed this proguard flag because
ThreadNetworkService#onLocalNetworkInfoChanged will otherwise be
stripped. We need to keep the method to ensure the border routing
feature works.

Initially we put the flag in thread/service/proguard.flags. However,
this seems not working on udc-mainline-prod branch. After moving it to
Connectivity/service/proguard.flags, it works as desired.

Bug: 313539492

Change-Id: I33cb0602095a617dbb1cfe3d9002f9c68e93cccf

Handa Wang   commited 2024-01-26 09:14:53 +00:00
cca941a232
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
Add setEnabled API
setEnabled API is added to ThreadNetworkController, this
can be used by applications with privileged permission to set
Thread to enable/disabled state.

The Thread enabled state can be subscribed with
ThreadNetworkController#registerStateCallback.

When Thread is disabled, the join/scheduleMigration APIs will
fail with ERROR_THREAD_DISABLED.

When Thread is disabling, all commands will fail with ERROR_BUSY.

Bug: 299243765

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

Change-Id: Ifa7845bf1d5664ecd31ce74e24b3a839f92bba13

Yang Sun   commited 2024-01-26 15:53:33 +08:00
0797d9d501
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
Merge "Add OEM country code to Thread country code sources" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-25 09:39:13 +00:00
869394241e
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] remove thread_user_restriction_enabled" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-25 05:08:08 +00:00
670793d58e
Merge "Revert "[Thread] add Android.bp for Thread flags"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-01-24 11:46:00 +00:00
61a823471f
Revert "[Thread] add Android.bp for Thread flags"
This reverts commit a59a6e304b.

Reason for revert: this should not be added in the mainline module but in platform

Merged-In: I88c993680976d2e10d672bfdbf45119f2db13868
Change-Id: I680f23b5f8099b1ea4a316b768a56f1be5c78862

Kangping Dong   commited 2024-01-24 11:20:22 +00:00
2d238dd7f9
Merge "[Thread] create socket dev/socket/ot-daemon/thread-wpan.sock" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-24 10:08:28 +00:00
3457225fa3
[Thread] remove thread_user_restriction_enabled
this flag is moved to frmeworks/base.

Bug: 319044650
Bug: 321624552
Change-Id: Ic068eb5e3cd2a7b4898a4f9a33b24ed8eed661f3

Kangping Dong   commited 2024-01-24 17:18:54 +08:00
ee864ef51a
Merge "[Thread] add error code ERROR_UNKNOWN for forward compatibility" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-24 02:20:42 +00:00
649571ddf7
[Thread] refine border routing logging
Refine unicast & multicast routing log to be more descriptive and
provide more debugging info.

Bug: 321184406
Change-Id: I4d786cc2f84b4d90ba2367876b5bbf678c587559

Kangping Dong   commited 2024-01-22 02:43:44 +08:00
9deebcb513
[Thread] create socket dev/socket/ot-daemon/thread-wpan.sock
Creates the /dev/socket/ot-daemon/thread-wpan.sock socket from the
service init file. This is required for communication between ot-ctl
and ot-daemon service

Bug: 320451788
Test: verified that ot-daemon can create socket
/dev/socket/ot-daemon/thread-wpan.sock

Change-Id: Ib2111d67d2ce6726158f02a2cb2310c7ba9bf270

Kangping Dong   commited 2024-01-22 01:20:36 +08:00
9e69c46395
Make ThreadNetworkController.setTestNetworkAsUpstream require NETWORK_SETTINGS permission
This CL contains following enhancements:

- Enforce NETWORK_SETTINGS permission for ThreadNetworkController.setTestNetworkAsUpstream.
- Move the setTestNetworkAsUpstream in
  ThreadNetworkControllerService to make the order of methods more
logical.
- Update the test case name in BorderRoutingTest.

Bug: 295843010
Bug: 320842152

Change-Id: I82edac6c819dd637f4c98f31368a1b520338ce24

Handa Wang   commited 2024-01-19 08:15:58 +00:00
253b3fb6da
Ensure the Thread integration test only run on CuttleFish devices
This is because the test case relies on **simulation** Thread radio, which is currently only available on CuttleFish.

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

Change-Id: Icd29d91c9ec9912e27191e97fe7f58e9067c1d8c

Handa Wang   commited 2024-01-18 12:00:14 +08:00
d5e2ac94d1
Graduate ThreadNetworkIntegrationTests from postsubmit
Bug: 295843010

Change-Id: I47fe9f00dff804d5e9c112336c5972b6a80760cf

Handa Wang   commited 2024-01-17 09:00:16 +00:00
7cc1c37c5f
[Thread] add error code ERROR_UNKNOWN for forward compatibility
This is per the go/android-api-guidelines#return-error:
```
Make sure your chosen error handling option gives you the
flexibility to introduce new error types in the future. For
@IntDef, that means including an OTHER or UNKNOWN value - when
returning a new code, you can check the caller's targetSdkVersion
to avoid returning an error code the application doesn't know
about. For exceptions, have a common superclass that your
exceptions implement, so that any code that handles that type will
also catch and handle subtypes.
```

Bug: 320403080
Change-Id: I2ee663b75107dac6d84fa697f449fa0424128fde

Kangping Dong   commited 2024-01-16 16:07:53 +08:00
2c83e2fcc9
[Thread] add CTS test for registerNetworkCallback for Thread
To make sure that apps can register for Thread network by specifying
only TRANSPORT_THREAD.

This prevents regression given aosp/2873154 was considered a short-term
solution.

Bug: 313000440
Test: atest CtsThreadNetworkTestCases:android.net.thread.cts.ThreadNetworkControllerTest#threadNetworkCallback_deviceAttached_threadNetworkIsAvailable
Change-Id: I7860c50b092439f39e5d8c437de1863b0633b7a0

Kangping Dong   commited 2024-01-16 09:56:48 +08:00
b68cad4414
Merge "[Thread] define flag thread_user_restriction_enabled" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-01-09 10:15:51 +00:00
e32111c8fc
Merge "[Thread] add Android.bp for Thread flags" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-01-09 06:10:23 +00:00
e19a753182
[Thread] define flag thread_user_restriction_enabled
Define this flag for guarding UserManager#DISALLOW_THREAD_NETWORK

Bug: 307679182
Change-Id: I69c578d76f3aac250bb733aac74754c127ae453b

Kangping Dong   commited 2024-01-09 13:58:58 +08:00
856b7156d7
[Thread] add Android.bp for Thread flags
This is not required for code in the mainline module since the flag
infra is not supported for mainline. But we will need to write code
in UserManager and it needs to be guarded by new Thread flags.

Note that Merged-In is added to skip merging this CL into the
udc-mainline-prod branch because trunk stable flagging is not supported
there

Bug: 307679182
Test: m
Merged-In: I88c993680976d2e10d672bfdbf45119f2db13868
Change-Id: Id53fa3e7c9592b04f37f4cbd7dcd0499859e59ed

Kangping Dong   commited 2024-01-09 13:58:41 +08:00
a59a6e304b
Request Thread network at the initialize()
Currently requestThreadNetwork is called in registerThreadNetwork. This creates a new NetworkCallback for Thread every time when Thread is turned on. We'd better just use one callback to avoid potential issues.

Bug: 319179354

Change-Id: I96bad351f089b32a9acd919dea2e2b6b2aea68d2

Handa Wang   commited 2024-01-09 05:35:01 +00:00
90d2d0d0d9