Commit Graph

10985 Commits

Author SHA1 Message Date
Yuyang Huang
ac5a948d32 Merge "Remove NsdShim as it is not required" into main am: 92e1d5182d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2652744

Change-Id: Idb97e5074b596e649063da6ec9f1cdd91b7493a6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-11 14:30:36 +00:00
Yuyang Huang
92e1d5182d Merge "Remove NsdShim as it is not required" into main 2023-07-11 13:44:50 +00:00
Tommy Webb
41fdf38963 Allow VPN lockdown UID ranges to stack properly
When updating lockdown UID ranges, do not remove a UID from lockdown
if it is still present in any of the previously-supplied ranges that
have yet to be removed. This allows supplied lockdown ranges to stack
properly, providing an assurance that a UID will remain subject to
lockdown until all of the ranges including it have been removed.

Change-Id: Ia95724cd19040f83cea2c169a2585ab5dbdddbac
2023-07-11 09:34:35 -04:00
Yuyang Huang
c8d1ba9ef6 Remove NsdShim as it is not required
NsdShim is added to make the NsdManagerTest buildable in some old
branch. As a part of migrating to new branch, the nsdShim is not
needed anymore.

Test: atest CtsNetTestCases:android.net.cts.NsdManagerTest
Change-Id: Ia6a9663163a111aa070d88f585ab04918443cb8a
2023-07-11 18:44:27 +09:00
Junyu Lai
e0f33aabf6 Merge changes Ic20ea5a4,I1b32d9e0 into main am: 2407c9398f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2652743

Change-Id: Ib27ba0ae002ca31a78a7df50337237dd373425e0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-11 08:09:55 +00:00
Junyu Lai
2407c9398f Merge changes Ic20ea5a4,I1b32d9e0 into main
* changes:
  Wait in loop
  Read all response to generate enough traffic while testing
2023-07-11 07:07:29 +00:00
Junyu Lai
a22daeac98 Wait in loop
Follow-up from commit I1b32d9e069a7b10664065e138c75c6bfe7928f23,
the wait() not in a loop could be errorprone if the call to wait()
unblocks because of a spurious wakeup.

Test: atest CtsNetTestCases:NetworkStatsManagerTest
Bug: 289112440

Change-Id: Ic20ea5a42f3125668f80b13285b43146ae929cbc
2023-07-11 13:59:22 +08:00
Junyu Lai
b2d1a83adb Read all response to generate enough traffic while testing
Currently, testUidTagStateDetails relies on the test URL return
enough data (~100k) to ensure untagged traffic is not too much
to cause flaky. But aosp/2575590 change it to read only first few
bytes to speed up the test which would break this assumption.

Thus in this change:
1. Revert partical changes of aosp/2575590
2. Use BufferedInputStream to speed up test instead, which speed up
   testUidTagStateDetails from 2032ms to 902ms in local trials.

Test: atest CtsNetTestCases:NetworkStatsManagerTest
Bug: 289112440
Change-Id: I1b32d9e069a7b10664065e138c75c6bfe7928f23
2023-07-11 13:59:18 +08:00
Paul Hu
e855fa6171 Merge "Use a delayed message to schedule the query task" into main am: 8abd1be521
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2593666

Change-Id: I571c93b449b845b5a6117e0b57757308befa569c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-10 09:18:28 +00:00
Paul Hu
8abd1be521 Merge "Use a delayed message to schedule the query task" into main 2023-07-10 08:53:20 +00:00
Paul Hu
cd39d81fe1 Use a delayed message to schedule the query task
To reduce the multi-thread access to MdnsServiceTypeClient, the
query task scheduling should be replaced with a delayed message.
This will allow the synchronized lock to be removed in future
changes.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I340fe1a407947be860cdcd9c7c76829417a32e4c
2023-07-10 05:45:37 +00:00
Chiachang Wang
452c5c5599 Merge "Limit the translation code on NAT-T keepalive" into main am: 7f8015fe9e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2649939

Change-Id: I70e584caa7f8b79a8ff5d905a3390af63cf7f424
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-10 01:09:29 +00:00
Chiachang Wang
7f8015fe9e Merge "Limit the translation code on NAT-T keepalive" into main 2023-07-10 00:28:10 +00:00
chiachangwang
9d494ca5f7 Limit the translation code on NAT-T keepalive
Limit the translation code on NAT-T keepalive because the
intention of the translation is design for NAT-T keepalive.
The translated packets is also NAT-T packet data which should
not apply to TCP keepalive.

Bug: 196453719
Test: atest FrameworksNetTests
Change-Id: I0951621edc9f918199d82365a6f1c03617ddd806
2023-07-07 07:54:07 +00:00
Chiachang Wang
141a3220c1 Merge "Vertify the exact interactions with mocking object" into main am: f5025ba1a4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2649459

Change-Id: I7ae3bd00a7455f4e5278d82c60d1b863bdaf773b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-07 01:41:40 +00:00
Chiachang Wang
f5025ba1a4 Merge "Vertify the exact interactions with mocking object" into main 2023-07-07 01:12:13 +00:00
chiachangwang
a607674033 Vertify the exact interactions with mocking object
There are more than 1 interaction inside verifySetupPlatformVpn.
The original code does not actually wait for the target
interaction with Executor.schedule(). The interact may happen
after reset the mocking object. This will leave a unexpected
interaction in the follow up verification and cause a flaky
test.

This test was fine in the initial patch, but becomes failed
after the time unit used in Executor.schedule() was changed
to milliseconds for data stall recovery. Both interactions
for data stall ones and non-data stall ones will be captured
together after that.

Bug: 289961869
Test: atest VpnTest --rerun-until-failure 20
Change-Id: If24e323b366bb15b81fe9fa554fa7ccc852ba6f1
2023-07-06 09:16:04 +00:00
Paul Hu
37c6b51e4e Add a handler thread check to all public methods am: d5b24b4855
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2593665

Change-Id: I4c5da9d97fc55954c65f06bb59c5d659c7a62a01
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-05 11:15:01 +00:00
Paul Hu
bd5359529d Use SocketKey in MdnsServiceCache am: 775840e1b4
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2648319

Change-Id: Ie72151c0d878eab35c76b4d52b32f2c0653971a5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-05 10:12:12 +00:00
Paul Hu
d5b24b4855 Add a handler thread check to all public methods
To ensure that all access to the MdnsServiceTypeClient is done on
the handler thread, a handler thread check must be added to all
public methods in the MdnsServiceTypeClient. This will allow the
synchronized lock to be removed in future changes, and it will
also ensure that MdnsServiceTypeClient can access MdsServiceCache
properly.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I0206874eb0acdf0272b8ad23d29f3e764bfdec38
2023-07-05 07:46:36 +00:00
Treehugger Robot
682ff9559b Merge "Adjust query frequency based on remaining TTL" am: e59d30bc2a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2632294

Change-Id: I1f245f7d21172d7492c2d942ff30b0c809cda3ef
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-05 07:02:55 +00:00
Paul Hu
775840e1b4 Use SocketKey in MdnsServiceCache
The MdnsServiceTypeClient is now created using a SocketKey, so
the MdnsServiceCache should also use the SocketKey to deal with
the caching services.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: I6165ffd420a39e750c06778b4851142a3ba3cf44
2023-07-05 06:38:41 +00:00
Treehugger Robot
e59d30bc2a Merge "Adjust query frequency based on remaining TTL" 2023-07-05 06:19:38 +00:00
Treehugger Robot
e9b887d465 Merge "Migrate HostsideNetworkTestCase to use JUnit4" am: 1a59004c12
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2643291

Change-Id: If34fcd3dcb48068fa6aa9243afd1d2ea6cc45d3c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-05 04:35:37 +00:00
Treehugger Robot
1a59004c12 Merge "Migrate HostsideNetworkTestCase to use JUnit4" 2023-07-05 04:08:33 +00:00
Yuyang Huang
f56c92f3ff Adjust query frequency based on remaining TTL
After numOfQueriesBeforeBackoff query, the mDNS discovery logic will
enter backoff mode. In backoff mode,  the query frequency will be
updated to max(20, 0.8 * shortest remaining TTL) seconds. It will help
to reduce mDNS query frequency in certain use cases.

Bug: 284480315
Test: atest CtsNetTest FrameworksNetTests
Change-Id: Iac8baaaf58cf9b3b8e67e1cd80402fdecde1d3d4
2023-07-05 13:01:19 +09:00
Junyu Lai
dc075e33c6 Migrate HostsideNetworkTestCase to use JUnit4
This is no-op refactoring but allows subsequent
changes to use modern JUnit4 functionalities such
as @BeforeClass annotation.

Test: atest HostsideNetworkCallbackTests \
      HostsideConnOnActivityStartTest \
      HostsideSelfDeclaredNetworkCapabilitiesCheckTest \
      HostsideVpnTests HostsideNetworkPolicyManagerTests
Bug: 289002798
Change-Id: I503c13ffcb239c4535781ba5d660a3280b7a395b
2023-07-05 10:28:58 +08:00
Chiachang Wang
7eced64918 Merge "Add some timeout for waiting proxy being updated" am: 8c0cefc928
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2628997

Change-Id: Id362e59e8ca45507bb1a99b5ba36d7aaa7fe6a7b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-04 12:08:32 +00:00
Chiachang Wang
8c0cefc928 Merge "Add some timeout for waiting proxy being updated" 2023-07-04 11:40:13 +00:00
chiachangwang
3a323cf7cc Add some timeout for waiting proxy being updated
[MUST_SLEEP]ActivityThread may not have time to set the updated
proxy into properties yet and cause flaky. Wait for some time in
the test to deflake the test.

Bug: 286551100
Test: com.android.cts.net.HostsideVpnTests
Change-Id: I74d3d7378adcf12c094cb9c0706579d6e0b0826b
2023-07-04 09:37:57 +00:00
Chiachang Wang
ad099b29c3 Merge changes from topics "recoveryTimeUnit", "vpnRecovery" am: 537451ea67
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2648501

Change-Id: Id55a01d8a3cdea2dfb070eddab7cebfabd85b87f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-04 09:21:25 +00:00
chiachangwang
d34aac4123 Update tests to reflect the time unit change in Vpn
Test: atest FrameworksNetTests
Change-Id: I84a3f75bb527136bd0319f5af1bc43d2575495dd
2023-07-04 08:27:44 +00:00
chiachangwang
42ba18ca1e Update tests for VPN data stall recovery
Data stall recovery in VPN does not rely on the data stall
event now. Update the tests accordingly.

Bug: 289746779
Test: atest FrameworksNetTests
Change-Id: I4d2d96fe2f76706512325b6653b3e7cced10f207
2023-07-04 05:49:49 +00:00
Hansen Kurli
cceba5dcc0 Merge "Skip writing the metrics before T." am: 640c806e23
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2646562

Change-Id: Idbf393427a5a44263aca7e68a95459b4fdbb3cbc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-04 05:08:35 +00:00
Hansen Kurli
ab85de69b1 Skip writing the metrics before T.
Repeated fields are only supported on T+ and the metrics in
KeepaliveStatsTracker contains repeated fields. Hence, guard the write
with a T+ check.

Bug: 289344384
Test: Manual test
Change-Id: If3be75292b5a79aa753bddb772fe2c52c9dde994
2023-07-03 10:43:28 +00:00
Chiachang Wang
13773d1e79 Merge "Translate v4 keepalive packet on clat started network to v6" am: 7e1076e174
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2615629

Change-Id: I1b973b5fe6fef03583b1cf4fec3f50e1b8588007
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-03 09:54:01 +00:00
Chiachang Wang
7e1076e174 Merge "Translate v4 keepalive packet on clat started network to v6" 2023-07-03 09:14:09 +00:00
Paul Hu
fc4bdca6d5 Merge "Move NsdServiceInfoTest to common tests" am: f51a0139a2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2411134

Change-Id: Ia3706bc879d793f920897542bd074e39741758d3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-03 07:05:55 +00:00
Paul Hu
f51a0139a2 Merge "Move NsdServiceInfoTest to common tests" 2023-07-03 06:24:43 +00:00
Treehugger Robot
209dbf4585 Merge "RateLimitTest: temporarily dump ConnectivityThread if setUp fails" am: d5a2851ab6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2646300

Change-Id: I0701751b1a4b4b9f4c9b2f03b6bb824eac1e8dbd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-07-01 01:12:57 +00:00
Patrick Rohr
cbe1755826 RateLimitTest: temporarily dump ConnectivityThread if setUp fails
This will hopefully help provide more information for debugging b/272147742.

Bug: 272147742
Test: atest RateLimitTest
Change-Id: I58ca7ee62d34302eb96056fced5bbc2f9a3e2e72
2023-06-30 15:59:12 -07:00
Jean Chalard
6616e8d099 Merge changes Iab0ffbb5,I2cbe9906 am: 583d0d437a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2646561

Change-Id: I0c597edcb9563502dcb966b6a851bad1509884ed
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-30 12:23:11 +00:00
chiachangwang
c5c5c84f4c Translate v4 keepalive packet on clat started network to v6
This commit translates the address of keepalive packet to v6
in order to make NATT keepalive work on v6 only network.

Sending a v4 NATT keepalive on a v6 only network is bogus if
hardware does not translate the packet automatically. Network
may drop the packet or reject the attempt by hardware. This
results in ERROR_INVALID_IP_ADDRESS and stop the keepalive
request.

Bug: 196453719
Test: atest FrameworksNetTests
Test: Manually connect to v6 only network and check if the
      keepalive packets are sent
Change-Id: I798c5d48661d8151b19902435732f465b5aa725b
2023-06-29 12:43:59 +00:00
Chalard Jean
00489e8270 [DO NOT MERGE] Disable tests that depend on the prebuilt version in U am: a0e8ab4933
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/23851392

Change-Id: Ib16cba6b59e7bac4ed10641848026beb67df9385
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-29 03:56:16 +00:00
Motomu Utsumi
588a64587d Use destroyLiveTcpSocketsByOwnerUids for frozen apps
Bug: 284900338
Test: FrameworksNetTests
Change-Id: Ia10f3c3b01c42d6ae5ba7b18786b66ca3209b108
2023-06-29 11:41:06 +09:00
Chalard Jean
a0e8ab4933 [DO NOT MERGE] Disable tests that depend on the prebuilt version in U
This should be reverted as soon as it is merged into U
and the build request is submitted.

Bug: 286649301
Ignore-AOSP-First: udc-dev only change
Test: NetworkAgentTest, TH
Change-Id: I2cbe990675b109e4ba744101dd7dbbb20229376f
2023-06-29 01:35:34 +00:00
Chalard Jean
1214b90646 Never create native network immediately.
This patch flags off the functionality added by aosp/2162425
in the wake of b/286649301 where a race in ConnectivityService
breaks WiFi connectivity until reboot.

Bug: 286649301
Test: NetworkAgentTest
      ConnectivityServiceTest
(cherry picked from https://android-review.googlesource.com/q/commit:a16607f421ecfbf37ef8fb2fa96d4d285df9e77b)
Merged-In: I96d755445f6e1f88bb71a7d32742e87dae185250
Change-Id: I96d755445f6e1f88bb71a7d32742e87dae185250
2023-06-29 10:32:45 +09:00
Jean Chalard
2a2b911a31 Revert "Always disconnect agents immediately."
This reverts commit 4bc9fa6b8c.

Reason for revert: b/288450518

Some iterations over mNetworkAgentInfos result in networks being
disconnected, which removes them from mNetworkAgentInfos during
iteration. This crashes with NPE or OOB exceptions.

Bug: 286649301
Bug: 288149251
Bug: 288450518
(cherry picked from https://android-review.googlesource.com/q/commit:3160bc0825490353d79c6586e21a7fc5893c678d)
Merged-In: I6e0b5b614d9e88267db77cb807ae4bf09f88c0f6
Change-Id: I6e0b5b614d9e88267db77cb807ae4bf09f88c0f6
2023-06-29 10:32:31 +09:00
Treehugger Robot
ba5daa3e23 Merge "Never create native network immediately." am: 3b34d5e374
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2639693

Change-Id: Ia6c709d816c79bb6fb42df1429dfb8bab2615f74
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-27 13:49:20 +00:00
Treehugger Robot
3b34d5e374 Merge "Never create native network immediately." 2023-06-27 13:04:45 +00:00