Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
De-duplicate questions with multiple listeners
When multiple listeners are registered for a resolve query, they were
duplicated in servicesToResolve, so the A/AAAA/PTR/SRV queries would
appear multiple times in the question section of query packets.

Ensure that makeResponsesForResolve does not generate duplicate
responses for duplicate listeners to avoid the duplicate queries.

Bug: 288174267
Fixes: 285090822
Test: atest
Change-Id: Ie6f76de6bfc5018c4c479505f99fbe6d81b64434

Remi NGUYEN VAN   authored and   Paul Hu   commited 2024-02-21 03:41:05 +00:00
afab821347
Merge "Store the SubscriptionId together with the Carrier UID" into main am: 9a5aaaccf6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2956897

Change-Id: Id58458b8523d74d70ee2a9a2ed93195949c8a253
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Ying Xu   authored and   Automerger Merge Worker   commited 2024-02-20 22:21:32 +00:00
7d5d380a36
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 am: 13a0cc04f6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2954998

Change-Id: Iedfcf255b785b575a3e2a86a21d54f5b845abd0e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2024-02-13 06:39:42 +00:00
9f63dd7e7f
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
Merge "Update CSTest to start thread from setup to avoid thread leak" into main am: 141f7bbfa6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2956087

Change-Id: I25812dc9c3c572c6e4632e47a757016bc5ff16b6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2024-02-08 11:08:31 +00:00
03783acc09
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 am: 804aa2326d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2940525

Change-Id: Icdf081cc8be09db2d565c71df2c076fc51b76f7b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Nagendra Prasad Nagarle Basavaraju   authored and   Automerger Merge Worker   commited 2024-02-07 19:40:49 +00:00
efc6ab3a12
Add SatelliteAccessController class to support messaging on Satellite Internet am: 33c7da3661
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2939960

Change-Id: If8bd3b19cc92d535d0b0c54a4af02a16cfd869fa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Nagendra Prasad Nagarle Basavaraju   authored and   Automerger Merge Worker   commited 2024-02-07 19:40:45 +00:00
8527398178
add TRANSPORT_SATELLITE to NetworkCapabilities am: 1fa6f09019
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2940285

Change-Id: I6eb9f38409f77bcec70f5a491b98fb988864d58c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Nagendra Prasad Nagarle Basavaraju   authored and   Automerger Merge Worker   commited 2024-02-07 19:40:29 +00:00
656a3a3d55
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
add TRANSPORT_SATELLITE to NetworkCapabilities
This commit also updates to use V14 dnsresolver APIs which was V13.

Bug: 320514105
Test: m & atest FrameworksNetTests
Change-Id: I6e92f4d99e0eba3b5d1d5e45bf11e5e945ea43f1

Nagendra Prasad Nagarle Basavaraju   commited 2024-02-07 16:07:39 +00:00
1fa6f09019
Support bringing up restricted wifi am: 7cabd32bc5
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2917645

Change-Id: Id237ef42aec76d380a3d0d400a9a7943364de154
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Ying Xu   authored and   Automerger Merge Worker   commited 2024-02-07 16:05:31 +00:00
8a3f368be7
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 am: ef58a8a33a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2942985

Change-Id: Iccc4355f5581f839aac4cbbfa8ec28c02f1ee439
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Junyu Lai   authored and   Automerger Merge Worker   commited 2024-02-02 07:43:59 +00:00
4829747946
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 am: 84cc4e507e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2939460

Change-Id: I20bb3cc39f1059aa03a37863837dbe42a37bfc4a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Hansen Kurli   authored and   Automerger Merge Worker   commited 2024-02-02 05:56:24 +00:00
5d679377d4
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 am: 742588457a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2939001

Change-Id: Id980cc0e9ca88e611ac96eb0d6c0990dfdeb43fc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2024-02-01 07:54:56 +00:00
20c6c797c8
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
Merge "Simplify the burst time logic" into main am: a906743bc7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2938999

Change-Id: I0b19c2840199ac937904e75127ed96c788176b63
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>

Paul Hu   authored and   Automerger Merge Worker   commited 2024-01-31 10:06:35 +00:00
38a136719f
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 Android 24Q1 Release (ab/11220357)
Bug: 319669529
Merged-In: Iaaca422cb105c00ded1d84b40afd745abcd651b7
Change-Id: I4328f5086dfde8c49e4352895663cc7abccab7fa

Xin Li   commited 2024-01-30 10:38:09 -08:00
0d0b075a3a
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
Merge "NetworkUtilsTest.testSetSockOptBytes" into main
Yang Sun   authored and   Gerrit Code Review   commited 2024-01-30 01:43:05 +00:00
24563fa502
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
[mdns] add API support for custom hostname
This commit adds support of regsitering a service with a custom
hostname. This is required to enable Advertising Proxy feature for Thread
devices.

For example:
```
NsdServiceInfo info = new NsdServiceInfo();

info.setServiceName("My Service");
info.setServiceType("_test._tcp");
info.setHostname("MyHost");
info.setHostAddresses(List.of(address1, address2));

nsdManager.registerService(info, PROTOCOL_DNS_SD, listener);
```

This CL also adds two new error codes for service/host registration
conflict: `FAILURE_SERVICE_NAME_CONFLICT` and
`FAILURE_HOST_NAME_CONFLICT`.

Bug: 284904661
Test: atest CtsNetTestCases FrameworksNetTests

Change-Id: I2fb974c38d851ba99144a18c7047084bbd61b938

Handa Wang   commited 2024-01-29 06:46:43 +00:00
1c2be6b391
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
NetworkUtilsTest.testSetSockOptBytes
Use sec but not usec in the test. setsockopt TimeVal may lose precision
on usec when kernel rounds up the requested value based on the HZ setting:
val = tv.tv_sec * HZ + DIV_ROUND_UP((unsigned long)tv.tv_usec, USEC_PER_SEC / HZ);

Bug: 321577714

Test: atest FrameworksNetTests:android.net.connectivity.android.net.NetworkUtilsTest
Change-Id: I13a12319370ec2bebe0935f2acdef88bca4d963d

Yang Sun   commited 2024-01-29 13:30:53 +08:00
0cd8f7f44d
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
[mdns] add API for discovery with subtype
This commit adds support of discovering services with explicit subtype.

With this change, a service can be discovered with subtype with:
```
nsdManager.discoverServices(
        new DiscoveryRequest.Builder("_http._tcp", PROTOCOL_DNS_SD)
	        .setSubtype("_printer").build(),
	executor, listener);
```

Bug: 265095929
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Iba76283a003cf2d52a8c26e1de872c3e8e433350

Kangping Dong   commited 2024-01-25 20:15:21 +08:00
97d6aeb3a2
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