Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
Add expired services removal flag
The TTL check and removal of expired services is currently only
performed when a mDNS query is sent. This can result in expired
services remaining in the cache if no queries are sent. To
address this, the remaining TTL will be checked when retrieving
services from the MdnsServiceCache. Add a new flag to enable
the expired services removal feature. This feature will be
implemented in subsequent changes.

Bug: 265787401
Bug: 304649384
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I30f0eea568ee45d363cc02821de0921d6040f981

Paul Hu   commited 2023-10-18 17:48:46 +08:00
f3fe3333d3
Merge "Include A/AAAA records in probing packet" into main
Paul Hu   authored and   Gerrit Code Review   commited 2023-10-17 02:24:10 +00:00
4479bd9f27
Merge "Disable flaky NetworkStatsHistoryTest#testFuzzing in presubmit" into main
Patrick Rohr   authored and   Gerrit Code Review   commited 2023-10-16 22:06:40 +00:00
bc17f31426
Disable flaky NetworkStatsHistoryTest#testFuzzing in presubmit
Root cause not yet located, disable test to unblock TH.

Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.NetworkStatsHistoryTest
Bug: 302325928
Change-Id: I618090b67e428ab911ec88e7daab30c14cccbf64

Junyu Lai   commited 2023-10-16 17:21:06 +08:00
09ac34db85
Merge changes Ib7883f8a,I91ec59f7 into main
* changes:
  Mock Vpn.setUnderlyingNetworks()
  Mock Vpn.setLockdown()

Hansen Kurli   authored and   Gerrit Code Review   commited 2023-10-16 09:04:22 +00:00
6f3e8aa4a0
Merge "Add ServiceExpiredCallback" into main
Paul Hu   authored and   Gerrit Code Review   commited 2023-10-16 01:41:49 +00:00
1eeeb15f2e
Revert "Tell netd about local networks"
Revert submission 2777667

Reason for revert: DroidMonitor-triggered revert due to breakage, bug b/305187495

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: Icb46558d17b56f9f6fd402f1489de9ed2b8f7644

Anton Kulakov   commited 2023-10-13 15:23:59 +00:00
cc409153b4
Revert "Add LocalNetworkConfig"
Revert submission 2777667

Reason for revert: DroidMonitor-triggered revert due to breakage, bug b/305187495

Reverted changes: /q/submissionid:2777667

Bug: 305187495

Change-Id: Iae4ef936a4c111ae5668e539ce4cdbbb14c811f4

Anton Kulakov   commited 2023-10-13 15:18:55 +00:00
6eea22b18c
Merge changes I3b6ee1db,I70e13303,I6fb7dfe4 into main
* changes:
  Simplify addRoutesToLocalNetwork calls
  Add LocalNetworkConfig
  Tell netd about local networks

Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-13 09:57:18 +00:00
a6190bd658
Add ServiceExpiredCallback
This is a no-op change and refactors the design for subsequent
TTL expiration check changes.
- Add a ServiceExpiredCallback to notify expired services.
- To simplify the design, pass the CacheKey to MdnsServiceCache
  methods instead.

Bug: 265787401
Test: atest FrameworksNetTests CtsNetTestCases
Change-Id: I930a4f7baf9b8d3d0037dc6aefd717dbdd486520

Paul Hu   commited 2023-10-13 16:45:31 +08:00
d4dcb4bee8
Mock Vpn.setUnderlyingNetworks()
Override Vpn.setUnderlyingNetworks() to do a direct call on the
network agent instead of relying on the Vpn class.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Ib7883f8a81a22317616cae79ce57a30afdd2bed4

Hansen Kurli   commited 2023-10-13 15:37:08 +08:00
233ac9463b
Mock Vpn.setLockdown()
Call setRequireVpnForUids directly to enable lockdown instead of
calling the real Vpn method.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: I91ec59f7542d145e9250a7e7a414593db3d99424

Hansen Kurli   commited 2023-10-13 15:30:43 +08:00
39654c33cf
Add LocalNetworkConfig
This doesn't do anything at this patchset, but the whole
pipe from the agent to ConnectivityService is built.

LocalNetworkInfo will be the name of the public information
sent in callbacks to clients.

Test: CSLocalAgentTests
Change-Id: I70e133031ef3b0aaf6c3e59ccc2ad895c66d339c

Chalard Jean   commited 2023-10-13 14:40:45 +09:00
fa21cafc1c
Tell netd about local networks
This patch does the following :
• When a network is local but the system doesn't support it,
  throw in registerNetworkAgent.
• When a network is local, tell netd about it.
• Add tests for the above, as well as a test for callbacks
  being sent correctly when the caps are set and not when
  they aren't and that the new keep connected flag is
  respected.

Telling netd about the network being local has it add two
routes that do not exist if the network is not local :
• One at PRIORITY_LOCAL_NETWORK matching unmarked sockets
  and looking up the table for the interface.
20000: from all fwmark 0x0/0x10000 lookup xxxx
• One at PRIORITY_EXPLICIT_NETWORK matching explicitly on
  network 99, so that dnsmasq traffic and any OEM traffic
  marked for network 99 flowing there.
16000: from all fwmark 0x10063/0x1ffff iif lo lookup xxxx
IMPLICIT_NETWORK and EXPLICIT_NETWORK rules are installed
by connectivity service as a matter of course whether the
network is local or not.

See commit If8729fc6f3716a580c936584b851bc38000b5de5 for
implementation details of this mechanic.

There is no need to implement anything in particular for the
new connected reason, as the current implementation will
already keep it connected. A new test makes sure of that.

Test: FrameworksNetTests
      CtsNetTestCases
      FrameworksNetIntegrationTests
      NetworkStackTests
      NetworkStaticLibTests
      TetheringTests
      MtsTetheringTestLatestSdk
      TetheringIntegrationTests
Change-Id: I6fb7dfe4c232eea8cac9ac268897ddb36bb794d1

Chalard Jean   commited 2023-10-13 14:40:38 +09:00
774dc3cd51
Merge changes I22d67a7e,Ida4a4bc7,Ie8522862,Id55d8d6c into main
* changes:
  Ensure nri is satisfied before returning.
  Add testLockdownVpn that mocks platform VPN.
  Make variables in testLegacyLockdownVpn() final.
  Update testLegacyLockdownVpn to mock VPN.

Hansen Kurli   authored and   Gerrit Code Review   commited 2023-10-13 05:00:29 +00:00
ccfc52145b
Merge changes Ic490fee6,If78047c3 into main
* changes:
  Add hidden constants for communicating about local network agents
  Use isAtLeast* from deps

Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-12 11:01:36 +00:00
10353d5351
Ensure nri is satisfied before returning.
When a network preference is set, the highest priority nri will
be a managed default request that disallows default networking.
In the case where there is no satisfying network,
mNoServiceNetwork is used as the satisfier instead of null.
(see computeNetworkReassignment)

mNoServiceNetwork should not be returned in any public API.
Check for the nri being satisfied before returning the satisfier
to ensure mNoServiceNetwork is not returned.

Fixes: 301222648
Test: atest FrameworksNetTests
Change-Id: I22d67a7e8d0274d8ad4f6123fbedf6d37eed18e7

Hansen Kurli   commited 2023-10-12 18:48:57 +08:00
ed972a6fd2
Add testLockdownVpn that mocks platform VPN.
Add a test for lockdown vpn that uses TYPE_IKEV2_IPSEC_PSK and
mocks platform VPN by override in startLegacyVpnPrivileged().
In the context of ConnectivityService, setVpnDefaultForUids()
is the main interaction.

Refactor testLegacyLockdownVpn to take a VpnProfile and assert
behaviors with and without setVpnDefaultForUids().
This includes:
    1. Updating callback asserts and assertActiveNetworkInfo to
       reflect setVpnDefaultForUids().
    2. Adding TODOs where mCm.getActiveNetworkInfo() returns
       unexpected values.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Ida4a4bc745af5ba2fc251795b2ffca56ead79b7f

Hansen Kurli   commited 2023-10-12 18:48:24 +08:00
48c14686a3
Merge "Stop the created handler threads on the tests" into main
Paul Hu   authored and   Gerrit Code Review   commited 2023-10-12 07:13:30 +00:00
0b5d785096
Add hidden constants for communicating about local network agents
Test: FrameworksNetTests
Change-Id: Ic490fee6ee70d74acff0a290199b2946817173d0

Chalard Jean   commited 2023-10-12 13:30:49 +09:00
d6f4efb1a8
Use isAtLeast* from deps
CSTest and CSAgentWrapper need to agree on what the current
version is

Test: CSTest*
Change-Id: If78047c36ce213a531207d25b410e870691fbb98

Chalard Jean   commited 2023-10-12 13:30:49 +09:00
5efbcf7bab
Stop the created handler threads on the tests
The created handler thread will stay there for a while until
all the tests are finished. This is considered as a leakage
which will take the resource from the devices. In low end
devices, this may possibly impact the performance. The created
threads should be closed explicitly.

Test: atest ConnectivityCoverageTests ConntrackSocketTest
Change-Id: Ic1beb2a210e7c8c80c66fc9e0727c47599150672

Paul Hu   commited 2023-10-12 10:25:03 +08:00
ebbbf8f470
Merge changes Ibb8d33b7,Ie168fe1f,I9f699b63 into main
* changes:
  Prepare exposing Network{Request,Caps}.forbiddenCapabilities
  Add a keep connected for test reason
  Improvements to CSTest : legacy type, wait for LOST, permissions

Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-12 02:14:52 +00:00
02193c0cce
Merge changes Ib24809ec,Id9d26435 into main
* changes:
  Remove the fail case on IPv6 in testLockdownVpn
  Remove LockdownVpnTracker from testLegacyLockdownVpn

Hansen Kurli   authored and   Gerrit Code Review   commited 2023-10-11 12:03:37 +00:00
270813c4c5
Add a keep connected for test reason
This has been sorely needed for a while. Instead of filing requests
for each of your networks in a CSTest, which is fiddly at best and
sometimes almost impossible (because you can't single out the network),
you can now add this flag and be done with it.

Test: CSKeepConnectedTest
Change-Id: Ie168fe1f3a17de035fdf05e3d6580d3262a3448e

Chalard Jean   commited 2023-10-11 17:02:52 +09:00
c517fb1247
Improvements to CSTest : legacy type, wait for LOST, permissions
• Make sure all Agents have a legacy type. This is necessary to
  avoid crashes in LegacyNetworkTracker
• Wait for LOST when disconnecting a network
• Make sure the test package sees its own permissions (importantly
  it can't see background networks otherwise, because it lacks
  CHANGE_NETWORKING_STATE)

Test: in the followup
Change-Id: I9f699b6372a8fe0d5bcd5310d8f35f72e48a6c61

Chalard Jean   commited 2023-10-11 17:02:51 +09:00
026ca940d9
Reword a comment for accuracy
Test: none needed
Change-Id: I7e409827adc86fc13975f394100889a6bf0f1e50

Chalard Jean   commited 2023-10-10 20:12:40 +09:00
f70919fbec
Allow for mocking an SDK in the tests
Test: in followup patches
Change-Id: I540ce2a455c92be52eb94fbd4b54a2081d04d25e

Chalard Jean   commited 2023-10-10 14:57:22 +09:00
eb66389d6a
Merge "Expose the netd mock in CSTest to allow verifying calls on it" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-10 04:17:29 +00:00
4dec273ab4
Merge "Add missing copyright notices to tests" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-10-10 04:16:52 +00:00
e339c6b780
Merge "[mdns] exclude mDNS advertiser code from standalone build test" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2023-10-08 12:21:24 +00:00
4a8977c452
[mdns] exclude mDNS advertiser code from standalone build test
service-connectivity-mdns-standalone-build-test builds the mDNS
discovery and advertisement implementation against API level 21.
This stops the advertisement code from calling new NsdServiceInfo
public or private APIs which are required by Thread.

This commit removes the mDNS advertisement code from the standalone
build to loose the check given this will never be used by GMS Core.

Bug: 265095929
Test: verified that it can build with aosp/2608627
Change-Id: I32cfce7b994d51a4b4ec468e9f79ffc2be6635ff

Kangping Dong   commited 2023-10-08 17:22:14 +08:00
1a1beee654
Expose the netd mock in CSTest to allow verifying calls on it
Test: manual
Change-Id: Ib39dc4dbf534f14d94923bb0026f18e47edabba2

Chalard Jean   commited 2023-10-07 15:11:40 +09:00
ff7edd36eb
Add missing copyright notices to tests
Test: comment-only change
Change-Id: I63bada891757d7e991cc7538c56e4fc50074ee5d

Chalard Jean   commited 2023-10-07 15:09:21 +09:00
52afbf2634
Merge "Store transaction id in MdnsPacket" into main
Paul Hu   authored and   Gerrit Code Review   commited 2023-10-06 05:51:33 +00:00
87d128f43d
Include A/AAAA records in probing packet
Per RFC6762#8.1, a host can simultaneously probe for uniqueness
of its "A" record and all its SRV records [RFC6763] in the same
query message. Add a flag to include the A/AAAA records in the
probing packet if necessary.

Test: atest FrameworksNetTestCases NsdManagerTest
Change-Id: I365a938a6c481df755a0598b175069b94905fa3b

Paul Hu   commited 2023-10-05 14:14:56 +08:00
f286ed5be1
Make variables in testLegacyLockdownVpn() final.
Test: atest FrameworksNetTests
Change-Id: Ie852286275f0e377be582648f7766c077d9877e8

Hansen Kurli   commited 2023-10-04 16:50:05 +08:00
78b06ebe84
Update testLegacyLockdownVpn to mock VPN.
Override more VPN methods to mock the VPN interaction of
testLegacyLockdownVpn instead of relying on the Vpn class.
This includes:
    1. Overriding startLegacyVpnPrivileged() and avoid creating
       a VpnRunner.
    2. Removing expectStartLegacyVpnRunner() since it is not
       used when startLegacyVpnPrivileged() is overridden.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Id55d8d6cd03b84bca815cd331eb0f7d584eaed5f

Hansen Kurli   commited 2023-10-04 16:47:10 +08:00
b2764be9b6
Remove the fail case on IPv6 in testLockdownVpn
In testLegacyLockdownVpn, remove the fail check on IPv6 networks
and add coverage in VpnTest instead as this interaction relies
on the Vpn implementation, not ConnectivityService.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Ib24809ece2332c4c3d3e08c168e02ad859242eac

Hansen Kurli   commited 2023-10-04 16:45:45 +08:00
acb5205558
Remove LockdownVpnTracker from testLegacyLockdownVpn
The test coverage of LockdownVpnTracker has been moved to a
separate unit test file. testLegacyLockdownVpn now calls the Vpn
methods directly instead of creating a new LockdownVpnTracker.
Note this removes calls to expectStopVpnRunnerPrivileged since
stopVpnRunnerPrivileged is now directly called in the test so it
is already guaranteed to be called.

The expected calls/behavior of LockdownVpnTracker can be seen in
LockdownVpnTrackerTest.

Bug: 230548427
Test: atest FrameworksNetTests
Change-Id: Id9d26435bf62ffef954f6c7fa0558ce99540de1f

Hansen Kurli   commited 2023-10-04 16:44:09 +08:00
35f6fef389
Merge "Disable the remaining VPN CTS tests on watches." into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-10-03 16:39:31 +00:00
c8a42f6a39
Prioritize non-slices over slices
For general internet access, a specialized slice is generally
not preferable to a non-specialized network.

Test: new test in this patch
Change-Id: I052ce923300566807999b2f20f5911181fb761dd

Chalard Jean   commited 2023-10-03 21:30:49 +09:00
14499f0119
Disable the remaining VPN CTS tests on watches.
- Watches don't support VPN apps.
- The HostsideVpnTests CTS tests are already skipped on watches.
- The tests for VpnManager VPNs do run on watches, but there isn't
  actually a way to start a VpnManager VPN on a watch because there is
  no way to display the consent dialog to the user.
- The VpnService CTS tests verify the VpnService API on watches
  bypassing the consent dialogs.
- Because there is no way to start a VPN app on a watch, there's no
  point requiring the VPN CTS tests to pass.

This CL disables the remaining VPN CTS tests on watches. This allows
watches to disable the VPN service, reducing startup time and memory
usage.

Bug: 286240194
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Idb7110232ae7e45cafc265cd4f955c2a6b22361c

abdelrahmani   authored and   Lorenzo Colitti   commited 2023-10-02 06:29:46 +00:00
5bcbbc1ce9
Lower CLAT max MTU from 65536 to 1528.
Android's clat is for reaching the internet, which in general
never has an ipv4 L3 mtu higher than 1500.

(We could probably hit this on a jumboframe enabled IPv6-only
wifi network [ http://b/292057969#comment18 ] where RA claims
MTU of 9K [9170])

Bug: 292057969
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7a32455571458b8a3f1121ad980d54323b2ef06b

Maciej Żenczykowski   commited 2023-09-30 14:23:51 +00:00
9f94648b7f
Use carrier service changed callbacks when flag is on
Test: FrameworksNetTests
      Note that carrierPrivilegeAuthenticatorTest is already
      an @Parameterized test with flag = on and off, so it
      already tests both.
Change-Id: I52fcfd3f21a13d7a39952ba828464ce6ef4085c2

Chalard Jean   commited 2023-09-29 15:48:48 +09:00
361dad3243
Merge changes Ifd7abd8a,I39cab8ff,I6b3270d6,Ia28c6abc,If47d7e23 into main
* changes:
  Move the MULTI_SIM_ACTION receiver inline
  Inline registerForCarrierChanges
  Make mThread a local
  Introduce a flag for using the carrier service changed callbacks.
  Have DevSdkIgnoreRunner support @Parameterized parameters

Jean Chalard   authored and   Gerrit Code Review   commited 2023-09-29 06:46:08 +00:00
1d600f4300
Merge "Add more necessary infra to CSTest" into main
Jean Chalard   authored and   Gerrit Code Review   commited 2023-09-29 03:50:45 +00:00
21599869f7
Move the MULTI_SIM_ACTION receiver inline
This will be easier to read when this behavior is diverted
based on a flag

Test: FrameworksNetTests
Change-Id: Ifd7abd8ad82cb8307b1cd8535ac5fa82004404e6

Chalard Jean   commited 2023-09-28 21:37:32 +09:00
090b1f586b
Introduce a flag for using the carrier service changed callbacks.
Test: CarrierPrivilegeAuthenticatorTest
Change-Id: Ia28c6abca67866c1de953cb61953a0d2882cd7e2

Chalard Jean   commited 2023-09-28 21:37:32 +09:00
84dfa9f104
Store transaction id in MdnsPacket
The transaction id is a number that is used to identify a
specific query packet. But it's not necessary for probing
or announcing services, so the transaction id is not
currently used on advertising when creating a MdnsPacket or
decoding the response to a MdnsPacket. This means that it is not
possible to track which query packets have received
responses. Therefore, store the transaction id so that
it can be used for subsequent query packet changes.

Bug: 302269599
Test: atest FrameworksNetTests
Change-Id: I6734752b32b91678afb7df06e1fa51237cf70894

Paul Hu   commited 2023-09-27 18:20:28 +08:00
6df06daaec