Commit graph android_packages_modules_Co.../tests/unit/java/com/android/server
Message SHA1
Add methods to support verifying captive portal launch
Test: atest FrameworksNetTests
Bug: 325984919
Change-Id: If76a216eca8527b4a7a7f7776d09f66e62daea06

Chiachang Wang   commited 2024-02-26 03:08:22 +00:00
82b6839c02
Add start activity method override method
Add helper methods to support verifying startActivityAsUser().

Test: atest FrameworksNetTests
Bug: 325984919
Change-Id: Id512ba6b1181974dde799ece64b263ce7a2f88f7

Chiachang Wang   commited 2024-02-22 02:35:44 +00:00
6b95876228
Add permission control methods override
Bug: 325984919
Test: atest FrameworksNetTests
Change-Id: Ib57a4a936538295a6df10ae7e334bc969ea455d1

Chiachang Wang   commited 2024-02-22 01:36:39 +00:00
692727b84e
Store the SubscriptionId together with the Carrier UID
Always store the corresponding SubscriptionId together with the Carrier
uid so that when the carrier loses the Privilege, both the uid and
SubscriptionID will be used in the onCarrierPrivilegesLost callback

Bug: 324357121
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.CarrierPrivilegeAuthenticatorTest
      atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest
Change-Id: I28e51c583261a67d4441c6f825ade6781b862ee4

Ying Xu   commited 2024-02-20 08:58:31 -08:00
0d06b9460a
Merge "Raise the max listener per client limit to 200" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-02-13 06:01:47 +00:00
13a0cc04f6
Raise the max listener per client limit to 200
Raise the max listener per client limit from 10 to 200.

A frequent use-case for NsdManager is to file a DiscoveryListener,
and try to resolve/listen for every service using a ServiceInfoCallback.

The current limit of 10 callbacks is easy to hit in that case, since it
would happen if there are at least 10 devices on the network.

Raise the limit to 200 to avoid such problems. In practice it is very
unlikely that there would be more than 200 services on a network; if
advertised by different devices, they would barely fit in a /24 IPv4
prefix, so a limit of 200 should generally be high enough.

Note that for discovery 200 listeners does not mean that batches of 200
queries will be sent: listeners on the same service type are grouped
together so only one query is sent for the type, and results are
distributed to matching listeners.

Note also that the limit is currently only checked when registering
discovery or advertising requests. This should be also checked when
registering other kinds of listeners in a future change.

Bug: 324377460
Test: atest
Change-Id: I86fc00777e9dea3e5192b575581ba562e7401e42

Remi NGUYEN VAN   commited 2024-02-13 11:41:58 +09:00
12a0c6a17d
Update CSTest to start thread from setup to avoid thread leak
Starting thread from constructor could cause thread leak when assumption
fails and teardown is not called.
This CL moves initialization that starts thread to the setup.

Test: TH
Bug: 322659435
Change-Id: I8e84c12600a98d8019b7759103032c7d668cecd1

Motomu Utsumi   commited 2024-02-08 16:53:31 +09:00
f6045b43d9
Support Satellite Network Preferred uid's multi layer request
- Implement handleSetSatelliteNetworkPreference() at ConnectivityService
  to create multi layer request with preference order
  PREFERENCE_ORDER_SATELLITE_FALLBACK.
- unit test coverage

Bug: 320514105
Test: m and atest FrameworksNetTests
Change-Id: I3f71104f8c3c998599eaab71ae4076985f4bed77

Nagendra Prasad Nagarle Basavaraju   commited 2024-02-07 16:16:42 +00:00
804aa2326d
Add SatelliteAccessController class to support messaging on Satellite Internet
- create SatelliteAccessController class to identify role sms and
  satellite communication enabled uid's, to keep track of role changes
  through OnRoleHoldersChangedListener and to request to create
  multi layer request to ConnectivityService.
- unit test coverage

Bug: 320514105
Test: m and atest FrameworksNetTests
Change-Id: I95086f7a4fd6fe1261f432e605d792204ff5310b

Nagendra Prasad Nagarle Basavaraju   commited 2024-02-07 16:10:20 +00:00
33c7da3661
Support bringing up restricted wifi
This CL allows the Carrier Config app to request restricted WiFi nework
by setting the correspoding subscription ID in the network request.

Bug: 315835605
Test: atest android.net.cts.NetworkRequestTest
      atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.CarrierPrivilegeAuthenticatorTest
      atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest

Change-Id: I237e692d092ff5f969ce4b7962f6d58099a6f3a9

Ying Xu   commited 2024-02-07 04:24:38 -08:00
7cabd32bc5
Merge "Rename check*Permission* to has*Permission" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-02-02 07:07:31 +00:00
ef58a8a33a
Merge "Increase max metrics duration deviation to 2 hours" into main
Hansen Kurli   authored and   Gerrit Code Review   commited 2024-02-02 05:29:54 +00:00
84cc4e507e
Merge "Fix querying of multiple subtypes" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-02-01 07:25:40 +00:00
742588457a
Rename check*Permission* to has*Permission
The check*Permission methods are a bit error-prone because people
can forget to check the return value and expect that they behave
like the enforce* methods. This was pointed out before in some bugs.

This change adds @CheckResult annotation to enforce linter warning
and rename methods accordingly.

Test: TH
Fix: 279691948
Change-Id: Ibb0df6540fe0ed40289bb190b790130daaa2f763

Junyu Lai   commited 2024-02-01 15:24:35 +08:00
71b5153898
Increase max metrics duration deviation to 2 hours
A lot of WTF logs reported were barely 1 second over the 1 hour
limit. AlarmManager has a maximum window of 1 hour so these cases
are possible and expected.
Increase the max metrics duration deviation to 2 hours to avoid
this log.

Bug: 297292877
Test: Manual test
Change-Id: I9a476e8061944c6499fe1b1d6e9ad1e19e6ce2b9

Hansen Kurli   commited 2024-01-31 20:09:27 +08:00
d85482534c
Fix querying of multiple subtypes
Previously only the subtypes of the last registered listener would be
included in the discovery queries.

This fixes that by combining the subtypes of all registered listeners,
to be included in the queries. By moving the queried subtypes from the
QueryTaskConfig to the QueryTask, they are now recalculated before each
send (like the existing servicesToResolve), so are always in sync with
the registered listeners.

Fixes: 322918399
Test: atest
Change-Id: I9a4c94189f997e3a9f92e46b5eb1762e9925cf4c

Remi NGUYEN VAN   commited 2024-01-31 17:01:59 +09:00
2c607bd8cd
Simplify the burst time logic
Address the remaining comments in aosp/2874718 to simplify the
burst time logic.

Bug: 271067818
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I619f45189b10da3e09759ee1d57a898173a9fff8

Paul Hu   commited 2024-01-31 02:34:21 +00:00
2a6be8e30a
Merge "Fix service found callback on subtype update" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-01-30 07:48:13 +00:00
57ead48b11
Merge "Add aggressive query mode" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-01-30 07:37:41 +00:00
b4fba147cd
Add aggressive query mode
The current query scan modes, active and passive, have
limitations. Unicast queries only originate from the first query
session, multicast queries should be sent simultaneously with
unicast, and both modes suffer from infrequent scans. To
address these shortcomings, a aggressive query mode is proposed.

Bug: 271067818
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I87100e03a5b6306dcae79f05c034f000e6dc2889

Paul Hu   commited 2024-01-30 03:34:11 +00:00
11a883dc92
Fix service found callback on subtype update
If a service is found without a requested subtype, then updated to have
that subtype, onServiceUpdated would be sent instead of onServiceFound.

Fix this by tracking which services have been found by each listener, as
whether a service is newly found or updated depends on the options (in
this case the subtype filter) of each listener.

Fixes: 317167170
Test: atest
Change-Id: If8dbe04d858082a872c0f068433a3680331c670b

Remi NGUYEN VAN   commited 2024-01-29 18:48:56 +09:00
296e38e779
Merge changes from topic "nsd-custom-host" into main
* changes:
  [mdns] service-side impl for custom host
  [mdns] add API support for custom hostname

Handa Wang   authored and   Gerrit Code Review   commited 2024-01-29 08:36:56 +00:00
a90737dc23
Merge "Use an integer for query mode" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-01-29 08:08:58 +00:00
22827c3814
[mdns] service-side impl for custom host
This CL adds the service-side implementation of the custom host support
added in aosp/2890957.

Bug: 284904661
Bug: 320838284
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: I92c774ead4778870ff7358ccb28d6ad6e266f1b5

Handa Wang   commited 2024-01-29 06:46:43 +00:00
096e32e065
Use an integer for query mode
This is a no-op change. Currently, the query mode employs a
boolean value to toggle between passive and active modes. To
accommodate a broader range of query modes for different
requirements, switch to an integer value that facilitating
the addition of new modes more seamlessly.

Bug: 271067818
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: Ia9a12d4581246c3a5776cd241755a10994e32454

Paul Hu   commited 2024-01-29 06:19:24 +00:00
05086bde2d
clean up lint warnings
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If51a297f4fd6b39584d08ed43816167becdc14c8

Maciej Å»enczykowski   commited 2024-01-26 15:24:19 -08:00
ff474baf75
rename InterfaceMapUpdater to InterfaceMapHelper
since it doesn't actually update any more...

Done via:
  git grep InterfaceMapUpdater | cut -d: -f1 | sort -u | while read i; do sed -i -r 's@InterfaceMapUpdater@InterfaceMapHelper@g' "$i"; done
  git mv ./tests/unit/java/com/android/server/net/BpfInterfaceMapUpdaterTest.java ./tests/unit/java/com/android/server/net/BpfInterfaceMapHelperTest.java
  git mv ./service-t/src/com/android/server/net/BpfInterfaceMapUpdater.java ./service-t/src/com/android/server/net/BpfInterfaceMapHelper.java

Test: TreeHugger
  atest libnetworkstats_test
  atest FrameworksNetTests:android.net.connectivity.com.android.server.net.BpfInterfaceMapHelperTest
  atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
  atest --iterations=100 NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I07b57158347757f3f8dc4f24803a9bbf30445f7d

Maciej Å»enczykowski   commited 2024-01-26 15:24:19 -08:00
9c82d9e693
remove BpfInterfaceMapUpdater async update functionality
This is no longer needed due to being done synchronously via nativeRegisterIface()

Test: TreeHugger
  atest libnetworkstats_test
  atest NetworkStackIntegrationTests:android.net.NetworkStatsIntegrationTest
  atest FrameworksNetTests:android.net.connectivity.com.android.server.net.BpfInterfaceMapUpdaterTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9c0c79d23657fb5cb5296fb918f76f1fc896baa1

Maciej Å»enczykowski   commited 2024-01-26 15:24:19 -08:00
8035dbc881
Merge "Implement offload priority" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-01-25 06:09:19 +00:00
0b29cbf114
Merge "Support mDns Multipacket Known-Answer Suppression" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-01-25 03:00:45 +00:00
eeb79c6937
Merge "Add test for SkDestroyListener::dump()" into main
Ken Chen   authored and   Gerrit Code Review   commited 2024-01-24 11:37:48 +00:00
c930f3e8e5
Support mDns Multipacket Known-Answer Suppression
When a query packet is truncated, the responder should defer
the generation of a response until all packets have been received
and processed. If an answer present in the query packet's answer
section also appears in the responder's response, and the
known-answer's TTL exceeds half of the original TTL, suppress
the corresponding response.

Bug: 312657709
Test: atest FrameworksNetTests NsdManagerTest
      Passed DISTRIBUTED DUPLICATE SUPPRESSION and \
      MULTIPLE QUESTIONS - DISTRIBUTED DUPLICATE SUPPRESSION \
      test cases of BCT
Change-Id: I781cd813d46f7d0db267f3fe23a15a81ae319e51

Paul Hu   commited 2024-01-24 08:54:58 +00:00
3aaa285293
Add test for SkDestroyListener::dump()
A simple unit test for the SkDestroyListener::dump().
(The follow-up of aosp/2916465)

Bug: 306919485
Bug: 319348954
Test: atest FrameworksNetTests:android.net.connectivity.com.android.serv
er.net.SkDestroyListenerTest

Change-Id: Ica70b2b344ffb2df8047cd936e8edc583e636ceb

Ken Chen   commited 2024-01-24 13:26:50 +08:00
8b33caa55e
Merge "Do not check active socket from other callbacks" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-01-24 03:15:16 +00:00
95d380fefd
Do not check active socket from other callbacks
Not all SocketTypeClients are cleaned up when their corresponding
sockets are closed. This occurs because the active socket check
for each callback examines the socket from all callbacks, even
those scheduled for removal in later notifications. To fix this,
check the active socket from the current callback only.

Fix: 317461509
Test: atest FrameworksNetTests NsdManagerTest
      Manually test with multiple discovery requests and
      Wifi on/off.
Change-Id: I2f81bb8e75f2c038d5e9dc025b208dcc6b441112

Paul Hu   commited 2024-01-23 10:31:08 +00:00
01d2f643be
Implement offload priority
Implement the TODO to assign priority to services based on an
overlayable configuration.

This changes the default priority from 0 to MAX_VALUE, as higher
priority values are less prioritized, so services not in the priority
list should have a high value. There is currently no user of the API
depending on the priority, so the change should not affect clients.

Test: atest
Change-Id: I3aae9b5fa7756de64c63974c192e4c96b632ce4e

Remi NGUYEN VAN   commited 2024-01-23 19:03:55 +09:00
5c9d6cbf16
Merge "Add SkDestroyListener log in dumpsys netstats" into main
Ken Chen   authored and   Gerrit Code Review   commited 2024-01-22 10:25:50 +00:00
65b4c3f0f1
Add SkDestroyListener log in dumpsys netstats
When sockets are destroyed, the SkDestroyListener receives a
NETLINK_INET_DIAG message informing it to delete the socket cookie from
the BPF CookieTagMap. However, under unknown conditions, all 10,000
spaces on the map were still observed to be filled. SkDestroyListener
and its parent classes, NetlinkMonitor, and FdEventsReader will log
errors. But due to the time required to fill the 10,000 fields is long,
traces in the device log are likely to have been overwritten and cannot
be observed.
This commit enables dumpsys netstats to print the last 20 traces of the
SkDestroyListener. If the issue is caused by the SkDestroyListener,
this will help in obtaining further clues when the issue is reported
again.

Bug: 306919485
Bug: 319348954
Test: atest FrameworksNetTests:android.net.connectivity.com.android.serv
      er.net.NetworkStatsServiceTest#testDumpSkDestroyListenerLogs
Test: manually add mLog.e(...) in
      SkDestroyListener#processNetlinkMessage and check dumpsys netstats
Change-Id: I5bbfe07e05cf959f809f28a7633ee5f99e29f641

Ken Chen   commited 2024-01-22 13:48:34 +08:00
375d780c8e
Merge "Apply multicast routing configs" into main
Yang Sun   authored and   Gerrit Code Review   commited 2024-01-22 00:57:42 +00:00
cc23753288
Merge "Support multicast routing" into main
Yang Sun   authored and   Gerrit Code Review   commited 2024-01-22 00:55:10 +00:00
bcc245d5bf
Apply multicast routing configs
Applies multicast routing configs when they are updated in
LocalNetworkConfig, or when local network/upstream network
status changes.

Bug: 281217735

Test: atest CSLocalAgentTests
Change-Id: Ib1c43c645a367d0f91e5cf0a0d9f8e5883be2c40

Yang Sun   commited 2024-01-20 21:32:20 +08:00
29037f6046
Support multicast routing
Added support to apply multicast routing config between network
interfaces in MulticastRoutingCoordinatorService.

Bug: 281217735

Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.connectivity.MulticastRoutingCoordinatorServiceTest

Change-Id: If608b79d4e62a20d2e01755a83a901f6e274d9a2

Yang Sun   commited 2024-01-20 21:32:11 +08:00
baa50fa478
Merge "Remove the UID range check for TCP sockets" into main
Chiachang Wang   authored and   Gerrit Code Review   commited 2024-01-19 02:53:29 +00:00
26aab9b0d9
Remove the UID range check for TCP sockets
The original patch (aosp/2891011) incorrectly counted TCP
sockets with keepalive enabled for VPNs. This issue was
caused by the UID range verification. On bypassable VPNs,
the socket mark is always correct. It's possible for an
app that is not in the UID ranges to establish a socket
on the VPN. But that socket should be counted for the
purposes of keepalive. The old code would correctly count
it and the new code will incorrectly not count it. Also,
the UID range verification does not help on non-bypassable
VPNs since the socket mark is always the mark of default
network, not the socket mark of the VPN.

Instead of reverting the entire patch, this commit
removes the UID range mechanism. The code refactoring from
the original commit (which used structured classes to read
socket information) has been kept as it is a valuable
improvement.

Bug: 320842519
Test: atest FrameworksNetTests
Change-Id: I00731796144c982b9fd4d9771f3d0db1f1529a89

Chiachang Wang   commited 2024-01-19 02:50:35 +00:00
ac2e8f354d
Fix NetworkRequestReceivedRemoved test
Test: atest FrameworksNetTests
Bug: 320588833
Change-Id: I8f80dee7b90a499bf761fdcccbc33182df259332

Danuta Brotikovskaya   commited 2024-01-18 09:32:32 +00:00
065ccfab8c
Merge "Implement NetworkRequestsState atom" into main
Danuta Brotikovskaya   authored and   Gerrit Code Review   commited 2024-01-17 01:33:06 +00:00
d6aae95da7
Implement NetworkRequestsState atom
Bug: 278833398
Test: atest FrameworksNetTests
Change-Id: I95a8c8dddd2d8f6863fe64cd4a65ef48dfb5153a

Danuta Brotikovskaya   commited 2024-01-16 21:50:12 +00:00
878fd25d84
Merge "Use MonitorThreadLeak in CSTest related tests" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-01-16 08:36:36 +00:00
d54613fd4e
Use MonitorThreadLeak in CSTest related tests
Fix current leaks in CSTest related tests, which leaked the
ConnectivityService and AlarmManager handler threads, and enable
the checks.

Using @DevSdkIgnoreRunner.MonitorThreadLeak ensures that tests properly
cleanup threads (in particular handler threads), as many leaked threads
could affect other tests.

Fix: 308520131
Test: atest ConnectivityCoverageTests
Change-Id: Ia6fb2c97f7a1740bafc0ab549440fdbeb1d5fad6

Paul Hu   commited 2024-01-16 06:56:34 +00:00
8792a72e8e
Fix replying to queries via unicast
Instead of (wrongly) looking at the DNS message flags for the Query
Unicast bit, look at the flag in the question record.

The previous bug means that all queries would be replied multicast
instead of sometimes unicast. The fix is flagged off as this is a
behavior change that may affect performance and latency.

Bug: 289482497
Test: atest
Change-Id: I08e30c4ffa747c9073d631e8addca1278ea40648

Remi NGUYEN VAN   commited 2024-01-15 20:26:28 +09:00
0ca094b577