Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
Merge "Revert "Use bpf map based isUidNetworkingBlocked on V+"" into main
Patrick Rohr   authored and   Gerrit Code Review   commited 2024-04-11 19:37:46 +00:00
c6678bbd71
Revert "Use bpf map based isUidNetworkingBlocked on V+"
This reverts commit 9b272fa53a.

Reason for revert: possible root cause of b/333340911.

Change-Id: Ic4923fd19db7e4704a3ef02d79644b47c271e18e

Patrick Rohr   authored and   Gerrit Code Review   commited 2024-04-11 16:54:04 +00:00
a658220234
Merge "Report sent query count in resolution stop metrics" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-04-11 08:42:54 +00:00
cede6542da
Merge changes from topic "rate-limit-trafficstats" into main
* changes:
  Make cache duration and max entries configurable
  Create TestRule: SetFeatureFlagsRule
  Rate-limit on TrafficStats#get*[Bytes|Packets] API calls
  Clear TrafficStats cache before getting readings from TrafficStats

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-11 07:26:14 +00:00
47c819640d
Report sent query count in resolution stop metrics
In the reportServiceResolutionStop function, the sent query count
is not set. This means it's impossible to track how many queries
are sent when a service is not resolved successfully. To track
this information, add the sent query count to
reportServiceResolutionStop.

Fix: 333302084
Test: atest FrameworksNetTets NsdManagerTest
Change-Id: Ida2a33ea35e9bb7393fe860245eb5ad8578d5ff6

Paul Hu   commited 2024-04-10 09:21:29 +00:00
edaeecda7b
Make cache duration and max entries configurable
Field trials could be used to find ideal values.

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Bug: N/A
Change-Id: Ia1304d041a19a81f54b7fdfbbbf1871c7c58a57f

Junyu Lai   commited 2024-04-08 10:43:48 +08:00
233362bf28
Create TestRule: SetFeatureFlagsRule
This rule works by reading the annotation and dynamically
invoking a user-specified method before evaluation to handle the feature flag configuration.

Usage:
class MyTestClass {
  @get:Rule
  val setFeatureFlagsRule = SetFeatureFlagsRule(setFlagsMethod = (name, enabled) -> {
    // Custom handling code.
  })

  // ... test methods with @FeatureFlag annotations
  @FeatureFlag("FooBar1", true)
  @FeatureFlag("FooBar2", false)
  @Test
  fun testFooBar() {}
}

Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Bug: N/A
Change-Id: I439e8ee40b8e81b6eb3857925912a3b843e8dfa1

Junyu Lai   commited 2024-04-08 10:43:42 +08:00
5ed8003915
Use NsdServiceInfo ifIndex in MdnsDiscoveryManager
NsdServiceInfo may contain an interface index if it was obtained from a
previous discovery callback which found a service on an interface that
does not belong to any Network.

In that case, subsequent resolve or registerServiceInfoCallback queries
using that NsdServiceInfo should only be done on the matching interface.
Apps may otherwise receive replies from other networks, with different
interface addresses.

As a simple fix, still request sockets from all interfaces in that case,
but only create the MdnsServiceTypeClients on matching sockets.

The sockets are created / cleaned up based on the lifecycle of the
requests, which does not change.

Fixes: 332262554
Test: atest
Change-Id: I2bbb498d4a0d37725f019a4cf5e367fef76fa0e8

Remi NGUYEN VAN   commited 2024-04-03 12:58:51 +09:00
894f181c89
Merge "Allow HW address retrieval from EthernetNetworkFactory" into main
Chris Desir   authored and   Gerrit Code Review   commited 2024-04-02 16:27:09 +00:00
36061871d7
Merge "[mDNS] pretty print txt values in log" into main
Kangping Dong   authored and   Gerrit Code Review   commited 2024-04-02 08:15:34 +00:00
777b9ba0ca
Rate-limit on TrafficStats#get*[Bytes|Packets] API calls
This change put a rate-limit on TrafficStats getter APIs to
reduce the need of accessing bpf map. For any caller who calls
this method within 1 second, a stale result will be returned.

One expected outcome is this change would break any test which
relies on immediate change of the result of TrafficStats after
making network traffic. Thus, related tests are fixed in the
counter part CL accordingly.

Test: atest CtsNetTestCases:android.net.cts.TrafficStatsTest --rerun-until-failure 100
Test: atest CtsNetTestCases:android.net.cts.NetworkStatsManagerTest
Test: atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest
Bug: N/A

Change-Id: Ibd6ae92d7c806481bb8a5124dd231f8f5aa206f2

Junyu Lai   commited 2024-04-02 15:25:10 +08:00
3c9089c1d1
[mDNS] pretty print txt values in log
Without this commit, the Thread service logs look like:

```
03-27 14:50:07.033   739  1924 I NsdPublisher: Registering service. Listener ID: 1, serviceInfo: name: Android Thread Border Router #2CF8, type: _meshcop._udp, subtypes: , hostAddresses: , hostname: null, port: 49152, network: null, expirationTime: null, txtRecord: id=֞�"ҽD���.�j���nn=OpenThreadrv=1sb=������tv=1.3.0
03-27 14:50:07.033   739  1924 I NsdPublisher: vn=Android
                                                         xa=Q�;�P,�
                                                                   xp=ޭ��������

```

With this commit, the Thread service logs look like:

```
03-27 13:37:31.672   741  1925 I NsdPublisher: Registering service. Listener ID: 1, serviceInfo: name: Android Thread Border Router #7CE8, type: _meshcop._udp, subtypes: , hostAddresses: , hostname: null, port: 49152, network: null, expirationTime: null, txtRecord: {id=0x70A5AE087668D7522919F40D1684D182, mn=Thread Border Router, nn=OpenThread, rv=1, sb=0x00000021, tv=1.3.0, vn=Android, xa=0x06EC93E283A47CE8, xp=0xDEAD00BEEF00CAFE}
```

Bug: 329366417
Change-Id: I6b15e93ad117f4ebb5762df85e359a705bd65b7d

Kangping Dong   commited 2024-04-02 14:47:57 +08:00
aca202e4d9
Merge "Add a flag to disable the background firewall chain" into main
Suprabh Shukla   authored and   Gerrit Code Review   commited 2024-04-02 05:47:56 +00:00
aeacff5033
Add a flag to disable the background firewall chain
The BACKGROUND firewall chain has been recently added. We want to
be able to turn it off in case of contingencies with a device-config
flag flip.

The flag is assumed to be boot-stable and its value is read at boot.
When the flag is off, we ignore any operation on this firewall chain.

Additionally, this chain is always considered disabled on versions
upto UPSIDE_DOWN_CAKE.

Note: All firewall chains are in disabled state at boot by default.

Test: atest FrameworksNetTests
Test: Manually, using adb shell device_config commands.

Bug: 331484830
Change-Id: I9ccc483e02e27a584da6714931466a9f2ec95ca9

Suprabh Shukla   commited 2024-04-01 16:37:32 -07:00
724d8972e4
Allow HW address retrieval from EthernetNetworkFactory
Test: atest EthernetNetworkFactoryTest
Bug: 142259350
Change-Id: I160d8ffd02a1a520d245fbf2b41832d9b3951a89

Chris Desir   commited 2024-04-01 13:45:19 -07:00
e50dd30fc8
Merge "Changes to support satellite stats appear as TYPE_MOBILE" into main
Nagendra Prasad Nagarle Basavaraju   authored and   Gerrit Code Review   commited 2024-04-01 14:33:37 +00:00
ad48c49ee0
Changes to support satellite stats appear as TYPE_MOBILE
With satellite transport supported at device and satellite
network to appear under type mobile, considers cellular or
satellite, or combination of both interfaces under mobile interfaces.

Note: getUidStatsForTransport(TRANSPORT_SATELLITE) is not supported,
considering the same interface name could be used by cellular as well,
supporting this might lead to double counting problem.

Bug: 329003473
Test: atest FrameworksNetTests
Change-Id: I85465cedcc5550fa0555dc36b3be364ac90aade1

Nagendra Prasad Nagarle Basavaraju   commited 2024-04-01 10:53:02 +00:00
756ca07f80
Merge "Revert "Use Service handler thread for NetworkStatsObservers"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-04-01 10:20:27 +00:00
93c6bf6f84
Revert "Use Service handler thread for NetworkStatsObservers"
This reverts commit 8b1d824ad2.

Reason for revert: b/332214348


Fix: 332214348
Change-Id: Iac8b9a11fb5b1c2e704eada62869c8c8552b3804

Junyu Lai   commited 2024-04-01 09:06:55 +00:00
86edb59bd4
Merge "SatelliteAccessController enhancements to handle delete user scenario" into main
Nagendra Prasad Nagarle Basavaraju   authored and   Gerrit Code Review   commited 2024-04-01 06:19:52 +00:00
6cbb7cf3d5
SatelliteAccessController enhancements to handle delete user scenario
- Handle onRoleHoldersChanged is not triggered even if the user has a
  default app setup and gets deleted scenario.

- Adding ACTION_USER_REMOVED intent filter, to monitor for User
  removal. This to used to update satellite fallback uid list
  and to keep allowed uid range updated at multi layer request
  of track default and satellite transport with Internet
  restricted capability

Bug: 326373613
Test: atest FrameworksNetTests
Change-Id: I1f30cd129309486bccbc61802ed600c142077411

Nagendra Prasad Nagarle Basavaraju   commited 2024-04-01 04:19:12 +00:00
0668238d50
Address kotlin coding style erros
Test: m
Change-Id: Id2109a57d062df9629b6a41bc33d3a2f2662b2cd

Paul Hu   commited 2024-03-29 07:08:32 +00:00
48321f8d4a
Merge "Support multiple query packets" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-03-29 01:12:31 +00:00
e805c9a9ce
Merge "Add annotation in CSTest to set flag values before instantiating CS" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-28 13:02:22 +00:00
4a58e69e59
Merge "Use bpf map based isUidNetworkingBlocked on V+" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-03-28 12:23:49 +00:00
e7a49305ee
Support multiple query packets
If the query with known answer feature is enabled and the
MdnsPacket is too large for a single DatagramPacket, it
will be split into multiple DatagramPackets.

Bug: 312657709
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I831fb6035cc0ad03078fbd3b9c550b56ddca07fb

Paul Hu   commited 2024-03-28 07:58:31 +00:00
153fb92c16
Add annotation in CSTest to set flag values before instantiating CS
CSTest SetUp sets flag values based on annotations before
constructing ConnectivityService.
For flags that are loaded at ConnectivityService constructor, tests can
use this annotation to set flag values.

Test: TH
Change-Id: I5a995a3de4e433ac39e6ccc116b9d89da468b04b

Motomu Utsumi   commited 2024-03-28 16:09:55 +09:00
b4ed81aa5d
Merge "[mdns] re-announce services when adding addresses to the associated host" into main
Handa Wang   authored and   Gerrit Code Review   commited 2024-03-28 05:55:43 +00:00
82bdb9809e
Merge "Add MdnsUtils#createQueryDatagramPackets method" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-28 05:30:31 +00:00
b64edb10cd
Add MdnsUtils#createQueryDatagramPackets method
This method can generate query packets from an oversized
MdnsPacket.

Bug: 312657709
Test: atest FrameworksNetTests
Change-Id: I21c1e082e01e0a6421920692115b0afdca0c9f9c

Paul Hu   commited 2024-03-28 03:37:04 +00:00
8284f7360d
[mdns] re-announce services when adding addresses to the associated host
Similar to aosp/2988171, this CL restarts the announcement of services
when the services' host gets new addresses.

Bug: 327304356
Bug: 323712889
Change-Id: I1d9706d4721c216dacda203bf0445f557b008ebf

Handa Wang   commited 2024-03-27 05:53:54 +00:00
127e91a16e
Merge "Fix the test flakiness." into main
Ying Xu   authored and   Gerrit Code Review   commited 2024-03-26 16:06:22 +00:00
561b534227
Merge "Fix isUidNetworkingBlocked for system uids" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-26 11:45:16 +00:00
dc267df555
Use bpf map based isUidNetworkingBlocked on V+
NetworkPolicyManager#isUidNetworkingBlocked does not know about some
firewall chains status(e.g. FIREWALL_CHAIN_OEM_DENY_1)
So BpfNetMaps#isUidNetworkingBlocked is more correct but there could be
some behavior difference.
To avoid breaking devices and have longer verification time, this CL
updates to use BpfNetMaps#isUidNetworkingBlocked only on V+ devices.

Bug: 328732146
Test: TH
Change-Id: I60f84a5fff90386103692841dead465652249446

Motomu Utsumi   commited 2024-03-26 19:16:57 +09:00
9b272fa53a
Fix isUidNetworkingBlocked for system uids
Update isUidNetworkingBlocked to return false for system uids regardless
of firewall chain status since this is an actual behavior

Bug: 328732146
Test: TH
Change-Id: Ic4760b927f51a1229e9af09c79b5261f85fe89d1

Motomu Utsumi   commited 2024-03-26 19:16:54 +09:00
cb448f5c78
Fix the test flakiness.
Bug: 326387894
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest
Change-Id: I2fdb0913dcb2f110a40c9bc7307e9fea19fcce4f

Ying Xu   commited 2024-03-25 11:43:45 -07:00
ab00a8e4c8
[mdns] restart probing/announcing the services on host address removal
When some of a custom host's addresses are removed, the services which
are using the custom host should be updated accordingly:
- For the services being probed, the probing should be restarted with
  the updated address records.
- For the services which already finished probing, they should be
  re-announced with the updated address records.

For example, here is a scenario where the fix is necessary:
1. Register a host (host1) with addresses (addresses1)
2. Register a service (service1) using the host1.
3. Unregister the host1.
4. Re-register the host1 with different addresses (addresses2).

Then the probing messages of the second registration of host1 may
conflict with the announcements of service1 (which containing addresses
records of the addresses1). This is an undesired conflict. Restarting
the announcement of service1 when updating the addresses of host1
can get rid of this conflict.

Bug: 327304356

Change-Id: Ie97b72f1482c69fb5f24eab3ce9ed8f7cea957ec

Handa Wang   commited 2024-03-24 14:06:32 +00:00
734de7a1d5
Merge "Put known answers to query packets" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-03-22 04:18:38 +00:00
248424dc69
Merge "Use MdnsUtils helper methods to construct query packets" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-03-21 15:17:11 +00:00
c2f56d83c9
Merge "Use connectivityHandler in CarrierPrivilegeAuthenticator" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-03-21 07:22:41 +00:00
98eb360c0d
Merge "Correct the usage for running query task" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-03-20 01:32:53 +00:00
a404348bf3
clat bpf: add byte/packet counter
Bug: 285124667
Test: TreeHugger,
  atest FrameworksNetTests:android.net.connectivity.com.android.server.connectivity.ClatCoordinatorTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5b59f0c05d41030f99160f68058c61eadd24fbbd

Maciej Żenczykowski   authored and   KH Shi   commited 2024-03-19 07:54:36 +00:00
8b3f9d9e3e
Call getDataSaverEnabled from isUidNetworkingBlocked
This reduces unnecessary bpf map read

Bug: 328732146
Test: TH
Change-Id: I7652bee99c1d733bae38508d7d6092c90678dc42

Motomu Utsumi   commited 2024-03-19 04:20:54 +00:00
e1d536ba8a
Merge "Rename BpfNetMapsReader to NetworkStackBpfNetMaps" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-03-19 04:13:17 +00:00
7bfcd30e89
Rename BpfNetMapsReader to NetworkStackBpfNetMaps
BpfNetMapsReader is loaded to bootclasspath. So this class should not
contain unnecessary codes.
To make this clear, this CL renames to NetowrkStackBpfNetMaps and add
comments

Bug: 328732146
Test: TH
Change-Id: I557627c9fae087eb6119c2ae31d46526fa9e5d7e

Motomu Utsumi   commited 2024-03-19 04:12:29 +00:00
fc504042f6
Merge "Remove VpnProfileStore dependency from CSTest" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2024-03-19 01:21:10 +00:00
d02c00867e
Use connectivityHandler in CarrierPrivilegeAuthenticator
When request_restricted_wifi is enabled CarrierPrivilegeAuthenticator
calls CarrierPrivilegesLost callback passed from ConnectivityService.
But CarrierPrivilegeAuthenticator was using its own handler thread to
receive broadcast and callbacks so CarrierPrivilegesLost callback needed
to post a message to the CS handler.
This CL updates CarrierPrivilegeAuthenticator to use CS handler if
request_restricted_wifi is enabled, and remove the message post in
ConnectivityService.

Test: TH
Change-Id: Ib41304a30e3dd366b0f6f1d7df81145f0e05ece1

Motomu Utsumi   commited 2024-03-18 22:16:53 +09:00
4fcaa4e803
Remove VpnProfileStore dependency from CSTest
The last dependency in the vpn-jarjar-rules can be removed
after refactoring the test as the test does not really
rely on the content of VpnProfileStore.

Test: atest FrameworksNetTests
Change-Id: Ib665dd7c05cca1eae77bf4100c43911686aac0ea

Chiachang Wang   commited 2024-03-18 11:40:58 +00:00
3f87ba4def
Put known answers to query packets
To support known-answer suppression, the querier should include
its known answers within each query packet. This allows the
service to determine whether a response is necessary based on
the querier's existing knowledge.

Bug: 312657709
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I2fb421aff1ae150b310e1a44f50f098a3edb9992

Paul Hu   commited 2024-03-15 07:45:59 +00:00
541df66912
Use MdnsUtils helper methods to construct query packets
This no-op change uses MdnsUtils#createRawDnsPacket to construct
query packets instead of MdnsPacketWriter. This refactoring sets
the stage for future support of constructing multiple query
packets.

Bug: 312657709
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I404ec52e97635eed9d965d7c7ceaf6e726386d64

Paul Hu   commited 2024-03-15 07:44:25 +00:00
157af5515a