Commit Graph

91144 Commits

Author SHA1 Message Date
Motomu Utsumi
5fce43e548 Use netId as idleTimer label on V+
Following CL adds idleTimer for multiple networks and track activities
including non default network on V+
Current LegacyNetworkActivityTracker uses transport type as an idleTimer
label but this makes it difficult to have multiple idleTimers.
So, this CL updates LegacyNetworkActivityTracker to support using netId
as an idleTimer label.

Bug: 267870186
Bug: 279380356
Test: atest FrameworksNetTests
Change-Id: I0039f5624ae1d142dbacba53aa90ca9bf6d43599
2023-11-14 13:43:45 +09:00
Mike Yu
d97fdbb3bc Merge changes from topic "dns_svcb" into main
* changes:
  Add tests for DnsSvcbRecord and DnsSvcbPacket
  Add DnsSvcbPacket
  Add DnsSvcbRecord
2023-11-09 05:24:17 +00:00
KH Shi
d6909dbec2 Merge "Avoid autoboxing overhead in hash calculation" into main 2023-11-09 05:18:52 +00:00
Maciej Żenczykowski
a9f88309e6 Merge "BpfMap.h - simplify error returns" into main 2023-11-09 05:02:18 +00:00
Maciej Żenczykowski
49c88a1d44 Merge "remove BPF_NET_MAPS_FORCE_DISABLE_JAVA_BPF_MAP" into main 2023-11-09 04:31:05 +00:00
Maciej Żenczykowski
73943e8eaa Merge "remove BpfNetMaps.cpp" into main 2023-11-09 03:04:22 +00:00
Maciej Żenczykowski
23912ee104 remove BPF_NET_MAPS_FORCE_DISABLE_JAVA_BPF_MAP
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I550357be83f946bf9f29b9f90037d6a6e66142d1
2023-11-09 03:00:09 +00:00
Kangping Dong
ac94d2cec6 Merge "[Thread] add documentation for Pending Dataset constructor" into main 2023-11-09 02:55:16 +00:00
Kangping Dong
0fce55c7fb Merge "Add Thread team to owners of the API files" into main 2023-11-09 02:47:24 +00:00
Maciej Żenczykowski
0ad252e03c BpfMap.h - simplify error returns
Returning the number of the file descriptor isn't actually useful since
it doesn't really tell you anything once the program has terminated.
(most logs we look at are long after the fact)

However, it does involve a fair bit of string processing to generate
the errors.  This is particularly an issue for things we constantly
call and sometimes expect to fail.  For example it is normal for
getNextKey() to fail with ENOENT at the end of iteration...

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib94037440b5fcaa34cc8aa01b165431efabeb377
2023-11-08 18:36:42 -08:00
Mike Yu
f5032571a8 Add tests for DnsSvcbRecord and DnsSvcbPacket
This change adds the test coverage for DnsSvcbRecord
and DnsSvcbPacket.

Bug: 240259333
Test: atest ConnectivityCoverageTests
Change-Id: I0b6328337fd61c5ac2e5f6b3737238f7d678245a
2023-11-09 02:14:29 +00:00
Mike Yu
8404b3c93e Add DnsSvcbPacket
DnsSvcbPacket will be used to parse DNS packet of type SVCB.

Bug: 240259333
Test: will add some tests in a follow-up change
Change-Id: Icb13d50f2d95a898b3b7ea373db876f41690723a
2023-11-09 02:14:29 +00:00
Mike Yu
9b96c83238 Add DnsSvcbRecord
This change is an initial implementation of DNS SVCB Record. It
can parse an SVCB Record in wire format.

The RDATA field of a SVCB Record is formatted as follows:
- SvcPriority: 2-byte field
- TargetName: a domain name that follows RFC1035 section 5.1
- SvcParams (optional): a list of SvcParam

This initial implementation focuses on the SvcParams related to DDR,
including alpn, port, ipv4hint, ipv6hint, and dohpath. For the other
SvcParams, such as mandatory and ech, this change doesn't check
whether their value is valid.

Bug: 240259333
Test: atest ConnectivityCoverageTests
Test: No test for DnsSvcbRecord for now. will add some tests in a
      follow-up change
Change-Id: Icfe9b623eda8390c40b106123a718cdd2af3af99
2023-11-09 02:14:29 +00:00
Jean Chalard
7cf6e5a3b0 Merge "Add test to make sure that unwanted local nets disconnect correctly" into main 2023-11-09 02:08:36 +00:00
Kangping Dong
7cca114efc Merge "[Thread] move createRandomDataset to ThreadNetworkController" into main 2023-11-09 02:05:04 +00:00
Kangping Dong
a925218c4f [Thread] add documentation for Pending Dataset constructor
Per API council review feedback in b/307939803

Bug: 307939803
Test: atest CtsThreadNetworkTestCases
Change-Id: Ia5fbb38e24d09c4a8d95ce0dfd6058a65d5d4614
2023-11-09 02:55:53 +08:00
Kangping Dong
0d600f2244 Merge "[Thread] add ThreadNetworkController APIs" into main 2023-11-08 15:56:36 +00:00
Kangping Dong
af4f1f576c [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
2023-11-08 22:39:33 +08:00
Suprabh Shukla
6bca8c1df8 Merge "New firewall chain for default background restrictions" into main 2023-11-08 14:06:50 +00:00
KH Shi
99b7e62b3c Avoid autoboxing overhead in hash calculation
Avoid passing primitive data types into Objects.hash() which will
convert them to their corresponding object wrapper types
automatically.

Test: atest TetheringTests
Bug: 261923493
Change-Id: I2efe7f3e50923ad2e33cfd58ae7e1e1cf7fd34bd
2023-11-08 12:44:42 +00:00
Kangping Dong
310b801b6e Add Thread team to owners of the API files
Similar to the Neary and RemoteAuth team, the Thread team will need to update the API files.

Change-Id: I488aae7610e337f14df01f1c6f51f042f11bd450
2023-11-08 12:43:05 +00:00
Kangping Dong
4a7c729a27 Merge "[Thread] add ServiceManagerWrapper" into main 2023-11-08 12:13:26 +00:00
Maciej Żenczykowski
6b3905c77e Merge "Remove service/native/include/Common.h" into main 2023-11-08 10:37:23 +00:00
Suprabh Shukla
2d893b68a9 New firewall chain for default background restrictions
A new firewall chain is needed to configure background network
restrictions for apps.
This change only adds the API stubs and traffic controller constants to
make the chain work. Policy changes using this chain will follow in
the framework code.

Test: atest CtsNetTestCases:ConnectivityManagerTest
Test: atest ConnectivityServiceTest

NO_IFTTT=The Lint rule along with the relevant code in Common.h is
being deleted in aosp/2819759

Bug: 304347838
Change-Id: I33e2db6671431f7c576fc931d9f96e684fc1e78a
2023-11-08 10:17:30 +00:00
Kangping Dong
b1c75dbe8c [Thread] add ThreadNetworkController APIs
The ThreadNetworkController class provides APIs for managing the Thread
network, for example, attach to a specific network, form a network with
given dataset or update/migrate an existing network.

Bug: 262683651
Test: atest CtsThreadNetworkTestCases
Change-Id: Ib3c267d2c81a8c3c7772ed3c9cd2092487cc941a
2023-11-08 17:56:16 +08:00
Kangping Dong
192e4b0289 [Thread] add ServiceManagerWrapper
Add a JNI wrapper of the NDK version of the ServiceManager which allows
us to retrieve the ot-daemon lazy service.

Bug: 262683651
Test: atest CtsThreadNetworkTestCases
Change-Id: I1d331d1ba06c2b88f156622d4ae864dae7b15dc3
2023-11-08 17:46:18 +08:00
Maciej Żenczykowski
bc4af4e1d0 Merge "Remove unused enums for firewall in Common.h" into main 2023-11-08 09:03:41 +00:00
Maciej Żenczykowski
9ff799122f Merge "remove dead register_com_android_networkstack_tethering_BpfUtils" into main 2023-11-08 08:19:07 +00:00
Motomu Utsumi
3b477129dd Remove service/native/include/Common.h
Move the remaining contents of Common.h to clatutils_test.cpp and remove
Common.h

Bug: 217624062
Test: TH
Change-Id: Ie0615b42a3a1bf4c07e9196128fe0850a448fb35
2023-11-08 16:58:59 +09:00
Maciej Żenczykowski
7b8f475e79 remove BpfNetMaps.cpp
Test: builds, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If192c17881736c9fe7f8346ad8c5d41d7164eb03
2023-11-08 07:12:46 +00:00
Motomu Utsumi
b51381e0e1 Remove unused enums for firewall in Common.h
They are used by TrafficController which was removed by aosp/2817123

Bug: 217624062
Test: TH
Change-Id: I561f135b43e7d15e6f45e95b502fc3c90c4b3ddf
2023-11-08 14:44:17 +09:00
Mark Chien
24eab1c274 Merge "Remove unnecessary dropShellPermissionIdentity" into main 2023-11-08 02:18:53 +00:00
KH Shi
f9e70f9bf3 Merge "[Refactor] move BPF tests to BpfCoordinatorTest" into main 2023-11-08 01:30:12 +00:00
Maciej Żenczykowski
0ba1d1cd0c remove dead register_com_android_networkstack_tethering_BpfUtils
Test: builds
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I369812e2f4ac7928a5754d747b4d3f8c0ca537a4
2023-11-07 17:23:11 -08:00
Maciej Żenczykowski
87f7f27ad0 Merge changes Ie1a36c3c,Id727cf7b,Ifba198d9 into main
* changes:
  Remove unnecessary check for skDestroyListener
  Remove TrafficController
  Remove native code path in BpfNetMaps.java
2023-11-07 19:32:51 +00:00
Kangping Dong
9efc28e6d0 Merge "[Thread] fix OperationalDatasetTimestamp#toTlvValue is not loss-less" into main 2023-11-07 19:20:44 +00:00
Jean Chalard
e28740f79b Merge changes I301bf032,I8caca97b into main
* changes:
  Rename TiramisuConnectivityInternalApiUtil
  Add LocalNetworkInfo and send callbacks when it changes
2023-11-07 13:29:00 +00:00
Chalard Jean
4fe2339f2c Add test to make sure that unwanted local nets disconnect correctly
Also add some toString() methods that were useful in debugging.

Test: new test in CSLocalAgentTests
Change-Id: Ife95815e39d92bbef84b1c5ea75a151882590d09
2023-11-07 22:28:25 +09:00
Motomu Utsumi
ffa6d6152b Remove unnecessary check for skDestroyListener
skDestroyListener is always running with Java code so removed the
unnecessary check.

Bug: 217624062
Test: TH

Change-Id: Ie1a36c3c736005ec4821c5e9c9983998f7042afa
2023-11-07 20:25:28 +09:00
Motomu Utsumi
424038fe25 Remove TrafficController
BpfNetMaps now updates bpf map by Java library and does not use
TrafficController.

Bug: 217624062
Test: TH
Change-Id: Id727cf7b79592e913c967156e6e224de338f5f65
2023-11-07 20:25:24 +09:00
Anton Hansson
e196e2f147 Merge "Connectivity: enforce FlaggedApi" into main 2023-11-07 10:21:22 +00:00
Motomu Utsumi
96b6c39229 Remove native code path in BpfNetMaps.java
BpfNetMaps uses java library for updating bpf map as the default code
path.
This is already released to 100% production without any issues.
So this CL removes the old code path from BpfNetMaps.

Note that native_init only opens the bpf maps if sEnableJavaBpfMap is
true.
But if sEnableJavaBpfMap is true, no native code in TrafficController
access the bpf map.
So this CL can remove native_init.

Following CL will remove the nativce codes for old code path.

Bug: 217624062
Test: NetworkStaticLibsTests
Change-Id: Ifba198d9e6f93b53fd1dbf3b2aafb644da0b147d
2023-11-07 17:45:32 +09:00
Adrian Roos
4126d9b793 Connectivity: enforce FlaggedApi
Bug: 297362755
Test: m checkapi
Merged-In: I25ad2cb4472e52297a455256b5749a90f31ca6b9
Change-Id: I25ad2cb4472e52297a455256b5749a90f31ca6b9
2023-11-07 08:39:55 +00:00
Chalard Jean
674f34702c Rename TiramisuConnectivityInternalApiUtil
This can be used from S. There is no point in having a
release name in the name of this class.

Test: builds
Change-Id: I301bf032f856dd4c30554e06013f31ee57208c4e
2023-11-07 17:29:39 +09:00
Chalard Jean
22350c93b4 Add LocalNetworkInfo and send callbacks when it changes
Test: CSLocalAgentTest
Change-Id: I8caca97b891081f9212a01d428a34ed1a08d5126
2023-11-07 17:29:38 +09:00
Mark Chien
f05b4475cd Remove unnecessary dropShellPermissionIdentity
The test doesn't explicitly call adoptShellPermissionIdentity anymore. Instead it use runAsShell everywhere. Remove the dead code.

Bug: 254183718
Change-Id: Ia949e0e315a3b3ae915752e95ef9fe896fdc0f5b
Test: TH
2023-11-07 08:25:53 +00:00
Motomu Utsumi
f652d2ca82 Merge "Make FlaggedAPI available to CtsThreadNetworkTestCases" into main 2023-11-07 07:29:13 +00:00
Kangping Dong
289ec28259 Merge "[Thread] add a script for make-pretty" into main 2023-11-07 06:15:40 +00:00
Chiachang Wang
9846b924b8 Merge "Remove @IgnoreUpTo(Q) annotation and isAtLeastR() check" into main 2023-11-07 05:21:12 +00:00
Kangping Dong
160b4d38f9 [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
2023-11-07 13:13:06 +08:00