Commit graph android_packages_modules_Co.../tests/unit/java/com/android/server
Message SHA1
Avoid going over max service name length when renaming NSD services
As per  RFC 1034/1035, the max size of the label is 63 bytes. It should
also be guaranteed when the serviceName is renamed due to the conflict.

Bug: 265865456
Test: atest FrameworksNetTests
Change-Id: I077d8abdb91071db62b9618d9918e3a12682aaf4

Yuyang Huang   commited 2023-05-04 13:24:23 +09:00
de802c8dc4
Move ConnectivityResources to service-connectivity
The ConnectivityResources class is only usable with QUERY_ALL_PACKAGES
permission, so it is not generally usable in framework-connectivity. It
is also backed by the ServiceConnectivityResources APK, which is
intended as resources for service-connectivity.

Move the class to service-connectivity and update callers. CTS needs a
way to determine the supported keepalive count as it used the
resources from KeepaliveUtils as @hide API, so provide a
ConnectivityManager @hide API for testing.

Bug: 279108992
Test: atest
Change-Id: I3c9a77c580b5ab87c922c32778bce15dc33b4d1d

Remi NGUYEN VAN   authored and   Motomu Utsumi   commited 2023-04-28 19:18:39 +09:00
bee2ee14f3
Merge "Test the encap/timeout for the VCN"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-04-28 05:18:59 +00:00
e50f1464bb
Merge "Add some tests for packet wakeup logging changes"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-28 05:14:46 +00:00
915b32ea23
Add some tests for packet wakeup logging changes
Cellular networks are now supported for marking wakeup packets. As a
result onWakeupEvent now also reports data relevant to the cell
transport.

These unit tests should add coverage for these new behaviors.

Test: atest FrameworksNetTests

Bug: 276498460
Change-Id: I0b8a03fff6255e067b736f3dbfb53de56420f90b

Suprabh Shukla   commited 2023-04-27 19:29:38 -07:00
53e1639b7d
Merge "Refactor the ISocketNetLinkMonitor to AbstractSocketNetlink"
Yuyang Huang   authored and   Gerrit Code Review   commited 2023-04-28 02:02:12 +00:00
f410cca0e3
Merge "Make the MTU tests more realistic."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2023-04-27 06:02:08 +00:00
0c11c6d29d
Refactor the ISocketNetLinkMonitor to AbstractSocketNetlink
Test: atest CtsNetTestCases FrameworksNetTests
Bug: 279692201
Change-Id: Ie07603ea51dda1ffdeb15f753bda7892d9137766

Yuyang Huang   commited 2023-04-27 12:40:03 +09:00
508e508ca6
Merge "remove needless arguments to stopClatd"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2023-04-26 19:15:50 +00:00
a3c51eab56
Merge "Add MdnsServiceCache"
Paul Hu   authored and   Gerrit Code Review   commited 2023-04-26 14:00:28 +00:00
336121d021
Add MdnsServiceCache
Currently, the mDns discovery services will clear if no listener
registers to that MdnsServiceTypeClient. If an app does discover,
stop discover, resolve, at this point the listener was
unregistered, so the MdnsServiceTypeClient was deleted, and the
service is gone from cache. So this will actually restart
discovery without returning previous results from cache. Thus,
add MdnsServiceCache to store all services and reduce the
duplicated queries.

Bug: 265787401
Test: atest FrameworksNetTests
Change-Id: If3d4eb4e3dc5455f6f97cb782aa1b99b2a00f6e0

Paul Hu   commited 2023-04-26 07:37:51 +00:00
ade3f45956
Merge "Use InetDiagMessage.destroyLiveTcpSocket instead of netd.socketDestroy"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-26 04:49:20 +00:00
f3c1ef5408
remove needless arguments to stopClatd
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia786a198be336f48327b5e1b568b3e7c24d0dc59

Maciej Żenczykowski   commited 2023-04-25 14:56:41 -07:00
93b7631b31
Merge "Make lingering delay 2000ms in testMultipleLingering"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-25 09:11:42 +00:00
47b95be1c9
Make the MTU tests more realistic.
Currently, the MTU tests work on networks that have not yet been
connected. This is not very realistic because most MTU changes
(like most LinkProperties changes in general) happen after the
network has connected. Change these tests to use connected
networks instead.

To avoid losing coverage for setting the MTU before the network
is connected, add a test just for that.

Bug: 143158421
Test: test-only change
Change-Id: I7f808249722924a0b1253e402c5580bb104afd8e

Lorenzo Colitti   commited 2023-04-25 17:15:26 +09:00
b95ca556db
Make lingering delay 2000ms in testMultipleLingering
Phenotype is updating the flags while this test is running
and this DoS'es the device to such an extent that the test
process doesn't get the CPU for more that 300ms. That lets
the lingering timeout run its course and fails the test.

This won't necessarily fix all flakes (after all, if
Phenotype hogs the CPU for 2 seconds the same issue will
continue to happen), but it should help.

Bug: 277555492
Test: FrameworksNetTests
Change-Id: I78ab1573974427b10dd557c011fbbf64942fd09f

Chalard Jean   commited 2023-04-25 16:16:48 +09:00
aeadd47abc
Merge changes I727849fa,If31ccbc7
* changes:
  Refactor buildKeepaliveMetrics to return DailyKeepaliveInfoReported
  Create KeepaliveStatsTracker for Duration metrics.

Hansen Kurli   authored and   Gerrit Code Review   commited 2023-04-24 04:03:09 +00:00
22a0120260
Test the encap/timeout for the VCN
Bug: 269715746
Test: VpnTest
Change-Id: I8e5e7a7eb09ee4d2e0a88193c5a6b1f0580d5eb8

Chalard Jean   commited 2023-04-24 12:10:58 +09:00
12740c9ff0
Merge changes from topic "revert-2542434-revert-2535219-TAMNEZLAHT-VPTOBCYDEB"
* changes:
  Revert^2 "Put client logs into SharedLog and dump more logs"
  Revert^2 "Record Advertiser history logs for better debugging"
  Revert "Revert "Record SocketProvider history logs for better de..."
  Revert "Revert "Record DiscoveryManager history logs for better ..."

Paul Hu   authored and   Gerrit Code Review   commited 2023-04-21 14:35:45 +00:00
700de306ef
Remove unnecessary mocking in tearDown
The setup for the mocking object will be reset when each test
finishs the test. Reset the mocking value is actually no-op
but cause possible threading issue in Mokito.

Bug: 278979735
Test: atest com.android.server.connectivity.VpnTest \
      --rerun-until-failure 100
Change-Id: Ib8c3813e5dbcc9b7432a5548766d63e400b4ed0e

chiachangwang   commited 2023-04-20 09:43:40 +00:00
3dcfdd0642
Use InetDiagMessage.destroyLiveTcpSocket instead of netd.socketDestroy
Netd is not updatable since it's not mainlined.
To make socket destroy code updatable, the code was re-implemented in
java and moved to Connectivity.

Bug: 270298713
Test: atest FrameworksNetTests
Change-Id: I5439c0c76c42a9f738a1b25a1f62e701755cbd05

Motomu Utsumi   commited 2023-04-19 11:59:18 +09:00
93a2218e41
Revert^2 "Record Advertiser history logs for better debugging"
5f558683b3

Change-Id: I4292f3b8ecdfbcf90978cb2d27392802701c36c1

Paul Hu   commited 2023-04-18 14:52:19 +08:00
51ff70d98e
Revert "Revert "Record DiscoveryManager history logs for better ..."
Revert submission 2542434-revert-2535219-TAMNEZLAHT

Reason for revert: Prepare a fix for the original topic

Reverted changes: /q/submissionid:2542434-revert-2535219-TAMNEZLAHT

Change-Id: I718418e4499784255b177622e3c08a82d0b24640

Paul Hu   commited 2023-04-18 14:50:31 +08:00
24913d0e80
Merge changes from topic "revert-2535219-TAMNEZLAHT"
* changes:
  Revert "Record DiscoveryManager history logs for better debugging"
  Revert "Record SocketProvider history logs for better debugging"
  Revert "Record Advertiser history logs for better debugging"
  Revert "Put client logs into SharedLog and dump more logs"

Paul Hu   authored and   Gerrit Code Review   commited 2023-04-18 02:53:21 +00:00
f0f83b6fc3
Revert "Record DiscoveryManager history logs for better debugging"
Revert submission 2535219

Reason for revert: Build break

Reverted changes: /q/submissionid:2535219

Change-Id: I9c8486e95e0b28ec4206d1e69858ab401888895a

Paul Hu   commited 2023-04-18 02:45:34 +00:00
2f0e914375
Revert "Record Advertiser history logs for better debugging"
Revert submission 2535219

Reason for revert: Build break

Reverted changes: /q/submissionid:2535219

Change-Id: I19496223d6f54120c17d690fd760e6743e3877b8

Paul Hu   commited 2023-04-18 02:45:34 +00:00
5f558683b3
Merge changes I41743f47,I22577615,I46f806a8,Icaa1df2e
* changes:
  Put client logs into SharedLog and dump more logs
  Record Advertiser history logs for better debugging
  Record SocketProvider history logs for better debugging
  Record DiscoveryManager history logs for better debugging

Paul Hu   authored and   Gerrit Code Review   commited 2023-04-18 01:14:39 +00:00
0b39135e3e
Merge "Only send resolve callbacks for subscribed service"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-17 13:16:15 +00:00
8a54f204d6
Merge "Cleanup : don't mix seconds and milliseconds in retry delays"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-04-17 10:01:56 +00:00
52c215bbc7
Only send resolve callbacks for subscribed service
Resolve callbacks should only be sent for the service name that was
requested.

Bug: 267570781
Test: atest MdnsServiceTypeClientTests
Change-Id: I3d8eb5c06bcf54312e20a39b8575555d40528bca

Remi NGUYEN VAN   commited 2023-04-17 18:55:36 +09:00
8a41185ce6
Refactor buildKeepaliveMetrics to return DailyKeepaliveInfoReported
This also updates the tests and prepares them to assert the other fields
of DailyKeepaliveInfoReported. Currently, only DurationPerNumOfKeepalive
is asserted.

Bug: 273451360
Test: atest FrameworksNetTests
Change-Id: I727849fa8a08d66fe276909b353a75861c23d775

Hansen Kurli   commited 2023-04-17 08:15:28 +00:00
c25133a38b
Create KeepaliveStatsTracker for Duration metrics.
Create a new class to store duration metrics of AutomaticOnOffKeepalives
for the DurationPerNumOfKeepalive proto.
This tracks the duration of time that the AutomaticOnOffKeepaliveTracker
contains a given number of concurrent keepalives and the duration of
time that it contains a given number of active concurrent keepalives.

Bug: 273451360
Test: atest FrameworksNetTests
Change-Id: If31ccbc7b02e6ad3ff1646e92e55ca7c8662e47c

Hansen Kurli   commited 2023-04-17 08:14:29 +00:00
a27bc2c913
Record Advertiser history logs for better debugging
Log:
  2023-04-12T20:00:18.100961 - Removing service with ID 2
  2023-04-12T20:00:17.173904 - [wlan0] Probing finished for service 2
  2023-04-12T20:00:17.147089 - [testtap1] Probing finished for service 2
  2023-04-12T20:00:17.074575 - [testtap0] Probing finished for service 2
  2023-04-12T20:00:16.249636 - Adding service name: ^Nsd.Test|Non-#AsCiI\Characters&\ufffe テスト 測試, type: _nmt950580894._tcp, hostAddresses: , port: 12345, network: null, txtRecord:  with ID 2

Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Bug: 275004614
Change-Id: I22577615b0b2c212c0a4349a06ef3c75239a5651

Paul Hu   commited 2023-04-17 15:38:28 +08:00
1571df639a
Record DiscoveryManager history logs for better debugging
Log:
  2023-04-17T15:05:28.428369 - Unregistering listener for serviceType:_nmt274981618._tcp.local
  2023-04-17T15:05:28.228777 - [_nmt274981618._tcp.local-102] onServiceFound: ^Nsd.Test|Non-#AsCiI\Characters&\ufffe テスト 測試
  2023-04-17T15:05:28.227786 - [_nmt274981618._tcp.local-102] onServiceNameDiscovered: ^Nsd.Test|Non-#AsCiI\Characters&\ufffe テスト 測試
  2023-04-17T15:05:27.409364 - createServiceTypeClient for serviceType:_nmt274981618._tcp.local network:103
  2023-04-17T15:05:27.409104 - createServiceTypeClient for serviceType:_nmt274981618._tcp.local network:102
  2023-04-17T15:05:27.407701 - createServiceTypeClient for serviceType:_nmt274981618._tcp.local network:101
  2023-04-17T15:05:27.398075 - Registering listener for serviceType: _nmt274981618._tcp.local

Test: atest FrameworksNetTests android.net.cts.NsdManagerTest
Bug: 275004614
Change-Id: Icaa1df2e7019e5cce1b4eca7edcb4a761b7b20cf

Paul Hu   commited 2023-04-17 15:30:42 +08:00
d74697aa96
Merge "Test that VPN lockdown restarts the VPN agent."
Jean Chalard   authored and   Gerrit Code Review   commited 2023-04-17 05:38:54 +00:00
2c930437e9
Merge "Add test for updating IKE about IP address changes"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-04-17 05:36:35 +00:00
ca35653803
Merge "Adjust tests for delay in restarting/migrating IKE"
Jean Chalard   authored and   Gerrit Code Review   commited 2023-04-17 05:35:21 +00:00
6213d571a8
Merge "Separate events usage for starting socket keepalives"
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-04-17 02:32:00 +00:00
2cf6b2c4fd
Merge "Fix inexact argument type warning"
Chiachang Wang   authored and   Gerrit Code Review   commited 2023-04-17 01:48:31 +00:00
baefd61455
Handle downstream tethering interface addresses in MdnsSocketProvider
MdnsSocketProvider currently does not fill addresses of downstream
tethering interfaces in its callbacks. The interface addresses should be
properly updated by listening to the Netlink messages.

Test: atest FrameworksNetTests CtsNetTestCases
Bug: 267980538
Change-Id: I753e547a1b092703fe59c6c9e922ee8aca245f67

Yuyang Huang   commited 2023-04-15 21:55:51 +09:00
700778be70
Separate events usage for starting socket keepalives
This is a clean up commit to correct the javadoc of
NetworkAgent.CMD_START_SOCKET_KEEPALIVE. This event was used
between ConnectivityService/NetworkAgent, and also
ConnectivityService/KeepaliveTracker with different semantics.
This may confuse the developers to update the doc incorrectly,
so also separate the usage to different events.

Also move the event definitions together so that a new event
definition will not mis-use the existing values.

Test: atest FrameworksNetTests
Change-Id: I73ebd8abcc610531da3057da2d643a41befb2099

chiachangwang   commited 2023-04-14 07:43:56 +00:00
f1b1fb4b7f
Test that VPN lockdown restarts the VPN agent.
Bug: 246162564
Test: atest FrameworksNetTests:VpnTest
Change-Id: I35f08bf263cec19bbfb1d656d1d89dbb0acf8944

Chalard Jean   commited 2023-04-14 16:38:19 +09:00
23197121a1
Cleanup : don't mix seconds and milliseconds in retry delays
Test: VpnTest
Change-Id: I5ceda621ba96549a514ec98176b799e246e6d9a5

Chalard Jean   commited 2023-04-14 13:05:34 +09:00
7afb623223
Add test for updating IKE about IP address changes
Bug: 269715746
Test: VpnTest
Change-Id: I2c3a7f0f0af193b5497beaff38d54a80020a7aa0

Chalard Jean   commited 2023-04-14 12:22:46 +09:00
2b9bcb7830
Adjust tests for delay in restarting/migrating IKE
This patch only adjusts the existing tests for the change
in the companion patch. Actual tests will come as a followup
because this patch is already big enough.

Test: VpnTest
Bug: 269715746
Change-Id: I65542a8f4151b4857f1b3758b2cae887bfbfe261

Chalard Jean   commited 2023-04-14 12:22:46 +09:00
9d85c7aa4c
Fix inexact argument type warning
Assign the corresponding VpnProfileState for the null argument.

The varargs parameter has type "VpnProfileState...".  It needs
to decide whether the implementation want the argument to be
treated as a single-element of type VpnProfileState or no
arguement. Otherwise, it will confuse the compiler and cause
warning.

Test: atest VpnTest
Change-Id: Ic1dee696bb50cd78849de4812fb46fd764b23c6e

chiachangwang   commited 2023-04-14 01:58:18 +00:00
25c74bd250
Merge "Include/exclude mDNS interfaces based on transport"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-04-12 05:28:02 +00:00
5864b59462
Include/exclude mDNS interfaces based on transport
Regardless of IFF_MULTICAST (and IFF_BROADCAST), always include wifi
transport interfaces, and always exclude cellular transport interfaces.

Some interfaces do not have the multicast or broadcast flag set
properly. Use the transport to determine whether to use them, rather
than the interface flags.

Bug: 268138840
Test: atest MdnsSocketProviderTest
Change-Id: Idbddfa9d2cc05ce1850786aa634da4c38afd3fc0

Remi NGUYEN VAN   authored and   Yuyang Huang   commited 2023-04-12 12:43:00 +09:00
145b16cb5a
bpf network stats - remove dead code
only the test code ever passes in anything that isn't
a limit {UID_ALL, INTERFACES_ALL, TAG_ALL} (ie. no limit)

Test: TreeHugger, atest libnetworkstats_test FrameworksNetTests
Bug: 276296921
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ida489f25c4da4b12541c6001b41d9e4b30804eff

Maciej Żenczykowski   commited 2023-04-11 19:24:28 +00:00
b548e191de
Avoid creating a Network with INetd.LOCAL_NET_ID
INetd.LOCAL_NET_ID cannot be referred to by system SDK. To make the
MdnsSocketProvider built with system SDK, the reference to
INetd.LOCAL_NET_ID must be removed.

This network is created in MdnsSocketProvider.java and propagated
through MdnsSocketProvider.java -> MdnsMultinetworkSocketClient.java ->
MdnsDiscoveryManager.java -> MdnsServiceTypeClient.java ->
NsdService.java. In NsdService.java, it was used in
handleMdnsDiscoveryManagerEvent() -> buildNsdServiceInfoFromMdnsEvent()
-> setServiceNetworkForCallback(). The setServiceNetworkForCallback() is
updated to handle the NETID_UNSET the same as LOCAL_NET_ID.

Test: atest CtsNetTestCases FrameworksNetTests
Bug: 272392042
Change-Id: I07c573948e9dc6249325f0733807bb7a7ffc281c

Yuyang Huang   commited 2023-04-05 13:06:13 +09:00
3bee9d4099