Commit graph android_packages_modules_Co.../tests/unit/java/com/android
Message SHA1
Merge "Fix a bug where non-VPN networks would update VPN uids." into main
Jean Chalard   authored and   Android (Google) Code Review   commited 2025-04-13 17:24:59 -07:00
8a7ea6fde6
Fix a bug where non-VPN networks would update VPN uids.
Previously, non VPNs would not be created when updateVpnUids()
is called inside handleRegisterNetworkAgent. Because the network
is not created, netd would refuse to set the UIDs with an error.
Now that networks are created immediately with the
QUEUE_NETWORK_AGENT_EVENTS_IN_SYSTEM_SERVER flag,
the network is created and netd does set the UID for any
network as if they were a VPN. This results in the UID having
the wrong default network, which in turns prevents it from
accessing Internet.

Test: new test in this patch
Bug: 408717088
Flag: EXEMPT bugfix
Change-Id: If68ea7d60919c0c7e177480f6167196381e00f35

Chalard Jean   commited 2025-04-12 09:33:54 +09:00
97e6901697
Fix/Suppress issues for errorprone update
When updating errorprone to 2.27.0, it finds new issues that cause the build to fail.

Flag: EXEMPT refactor
Bug: 253827323
Test: RUN_ERROR_PRONE=true m javac-check
Change-Id: I9c70d64e1f1e43be3bc1d9af8413548d10c8d490

Cole Faust   commited 2025-04-11 13:58:06 -07:00
8995a1fb73
De-duplicate the createWifiAgent func in the CS unit test.
Flag: EXEMPT test-only change
Bug: 368416967
Test: atest ConnectivityCoverageTests
Change-Id: Id51f39c1f2043474632b07a462fc23238115a33f

Xiao Ma   commited 2025-04-09 11:20:17 +09:00
dd9c3d3beb
De-duplicate the nc func in the CS unit test.
Flag: EXEMPT test-only change
Bug: 368416967
Test: atest ConnectivityCoverageTests
Change-Id: Idc02d6fce816ccf7aa3512d5b8f1f7a55cf1a676

Xiao Ma   commited 2025-04-09 11:20:17 +09:00
a118d86378
De-duplicate the lp func with the default lp.
Flag: EXEMPT test-only change
Bug: 368416967
Test: atest ConnectivityCoverageTests
Change-Id: I59436a257bea3b0e50b2b532b64f21ca5102f610

Xiao Ma   commited 2025-04-08 02:03:48 -07:00
f41687cae1
Merge "Delete TextStrings, only keep TextEntries" into main
Remi NGUYEN VAN   authored and   Android (Google) Code Review   commited 2025-04-07 23:28:02 -07:00
ceef633a80
Delete TextStrings, only keep TextEntries
TextStrings was kept for backwards compatibility when the code was used
outside of Android, but is not necessary in the Android version as only
TextEntries are used.

Test: atest
Flag: EXEMPT refactor
Change-Id: If70fe1512570dd55019eac06cfce91639fd04b11

Remi NGUYEN VAN   commited 2025-04-08 12:43:57 +09:00
937cab001a
Merge "Ensure PacketHandler is removed from sockets" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-04-06 19:37:26 -07:00
a45c2e8cda
Ensure PacketHandler is removed from sockets
When MdnsMultinetworkSocketClient stops using a socket (when
isSocketActive starts returning false), the packet handler should be
removed from that socket. The code only removed it from the
mSocketPacketHandlers map without clearing it from the socket.

This caused packets to be handled potentially many times, affecting
performance.

Bug: 406623719
Bug: 408324621
Test: atest
Flag: EXEMPT bugfix
Change-Id: I3d1117a4b847f3b95a01fc8a5997a53655ef608a

Remi NGUYEN VAN   commited 2025-04-04 13:34:45 +09:00
b5fbc0143a
Allow tagging sockets with a specified tag
Address the TODO to allow tagging sockets, which was done before the
code was imported to the Android codebase.

Also remove the comment in MdnsSocket, as the tagging is already done by
setting the thread tag, and tagSocket in the original code actually did
nothing for DatagramSockets.

The option is unset in the Android repository, so this code is unused
there.

Test: atest
Flag: EXEMPT unused in Android repo
Change-Id: Ifccc4ec2f0b63bf2caabe1d9ef4f57f08731a2b1

Remi NGUYEN VAN   commited 2025-04-04 09:30:36 +09:00
766451a785
Merge "Temporarily raise the number of system requests to 375" into main
Jean Chalard   authored and   Android (Google) Code Review   commited 2025-04-03 16:57:15 -07:00
48c667e43a
Merge "Avoid unnecessary lost callbacks" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-04-03 04:15:34 -07:00
0da2789931
Merge changes from topic "Optimized ESR" into main
* changes:
  Optimized Expired Service Removal
  Exclude expired services in response retrieval
  Update cached service first query time

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-04-03 04:13:22 -07:00
6fa69e9935
Merge "De-duplicate the keepScore func in the CS unit test." into main
Xiao Ma   authored and   Android (Google) Code Review   commited 2025-04-03 04:03:01 -07:00
933e62d145
Avoid unnecessary lost callbacks
The lost callback should be skipped if the service has not been
previously notified. Otherwise, the listener could inadvertently
initiate the service removal process for the incorrect service.

Bug: 387910548
Test: atest ConnectivityCoverageTests NsdManagerTest
Flag: EXEMPT legacy flag nsd_optimized_expired_service_removal
Change-Id: I7fdf31f0b15f19becc10fcb35c7b1f47dcc38c27

Paul Hu   commited 2025-04-03 09:32:28 +00:00
1cba7f04ca
Optimized Expired Service Removal
This commit introduces a new feature to optimize the removal of
expired services. After the query is sent, a task is scheduled
with a 2-second delay to wait for responses. During this delay,
if a service response is received, the service information is
updated, and the service is removed from the removal list. After
the delay, services that are expired, have sent a query, and for
which the query time was 2 seconds ago are removed, and listeners
are notified.

Bug: 387910548
Test: atest ConnectivityCoverageTests NsdManagerTest
Flag: EXEMPT legacy flag nsd_optimized_expired_service_removal
Change-Id: I498747839664eed8fe5b73a6f6d002deb9167271

Paul Hu   commited 2025-04-03 09:32:01 +00:00
1fd85ef1db
Exclude expired services in response retrieval
Update MdnsServiceCache to enhance its ability to retrieve
responses and manage expired services effectively. Introduce an
argument `excludeExpiredServices` to control whether expired
services should be excluded when retrieving responses. And add a
new method `markExpiredServices` to mark services as expired
based on their TTL and current time.

Bug: 387910548
Test: atest ConnectivityCoverageTests NsdManagerTest
Flag: EXEMPT legacy flag nsd_optimized_expired_service_removal
Change-Id: Ifa30fbe75a72ea400a69ab258d67381a54faf9b5

Paul Hu   commited 2025-04-03 09:27:14 +00:00
14c515562a
Update cached service first query time
Updated the MdnsServiceCache to maintain the first query time
after the last update of cached services, allowing for more
accurate expired service management.

Bug: 387910548
Test: atest ConnectivityCoverageTests NsdManagerTest
Flag: EXEMPT legacy flag nsd_optimized_expired_service_removal
Change-Id: I6da0691ece239b3b2e5dc5198a656cf21b30e953

Paul Hu   commited 2025-04-03 09:27:01 +00:00
60488fea83
Only flush records with matching rrtype
MdnsResponseDecoder flushed all address records when receiving an
address record with the the cache-flush bit is set. However as per
RFC6762 10.2, only records with a matching rrtype should be
flushed, which means that AAAA records should not be flushed when an A
record is received, and vice-versa.

Fix the logic and include a default-on flag to allow turning it off if
needed.

Test: atest
Flag: EXEMPT bugfix
Bug: 407698496
Change-Id: I6142f9996362dd7c16b4e80c8019f0cb1caef174

Remi NGUYEN VAN   commited 2025-04-03 15:14:46 +09:00
d66c016ca1
Temporarily raise the number of system requests to 375
This is a stopgap to palliate a bad interaction between
ConnectivityService and JobScheduler.

To help developers find request leaks and protect against OOMs
in the system server, ConnectivityService is enforncing a maximum
number of network requests/callbacks per UID. It has a higher
value for system UIDs because some system components need to
file requests on behalf of apps, most prominently JobScheduler.

The count is increased on entry in ConnectivityService, on the
Binder thread ; this is when CS can throw TooManyRequestsException
to the caller, it could not do that later when the request is
actually registered on the handler thread.
Conversely it only decreases the count on the handler thread,
because until then it doesn't know whether the request was
actually registered, and it can't look at that data structure on
the Binder thread.
This leads to a slightly confusing result where a UID can register
a request immediately after it unregisters one, and it will receive
TooManyRequestsException, because the unregister hasn't been
processed yet and the count not decremented yet.
This is arguably a bug, but if your app is treading on that last
request, you almost certainly had a leak anyway, and you should
not be trying to play with the exact count of requests either.
The remaining case is when an app would unregister and register
requests again in a tight loop, but there is no valid use case for
that, right ? Right !?

Enter JobScheduler. Because the limit for system UIDs is 250
requests but there can be more than 250 UIDs (especially on
devices with multiple users), JobScheduler has its own limit of
requests (which is set to 125). It has heuristics to choose which
are the most important 125 UIDs to file requests for.

When the request count exceeds 125, or when something
happens that may change which are the most important 125
UIDs, JobScheduler will re-evaluate which are the most important
ones. Upon doing this, it will unregister all requests and file
again the important ones in a tight loop. At worst, it will
therefore remove 125 requests and add 125 requests again,
taking up at most all 250 requests allowed for system UIDs ;
if the system server has any other request outstanding (and
it does), it may hit the issue where CS doesn't know yet that
requests have been unregistered, and crashes and hilarity ensue.

To palliate the issue above, this patch increases the allowed
request count for system UIDs by 125. This immediately should
fix the issue where all 250 requests are taken up by JobScheduler.

For a long-term fix, we should instead make at least one of the
following fixes :
- Have JobScheduler be smarter, and make sure it only unregisters
  the requests that it no longer needs instead of all of them.
- Make CS only throw when the requests are really full, by using
  some combination of locking, making the caller wait or similar.
- Have a separate pool of requests for JobScheduler that is
  dimensioned so it knows it can file all the necessary requests
  and no longer has to limit itself, and simplify the JS code.

Flag: EXEMPT bugfix
Bug: 391114053
Test: ConnectivityServiceTest
Change-Id: I4c4702e2d0c5d03eb5f3d6fe0f1578a210b188e8

Chalard Jean   commited 2025-04-03 15:02:20 +09:00
ff3222ce51
Merge "Let MdnsSocket guess networks of incoming packets" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-04-01 17:05:14 -07:00
c4ed32bc86
Let MdnsSocket guess networks of incoming packets
When using MdnsSocketClient (unused in the platform, may be used as a
library), allow guessing the Network of incoming packets based on their
source address.

This is flawed as there may be races between LinkProperties updates,
interfaces going up/down, and packets being received, and the source
address can not always be mapped 1:1 to an interface prefix, but it
should improve the situation for legacy code that currently assumes the
Network is the last one that was used for sending, which is often wrong.

Test: atest
Flag: EXEMPT: dead code in Android repo
Change-Id: I885c741d3d40b1b128a06b6d7a7aff8e0551ffea

Remi NGUYEN VAN   commited 2025-04-02 09:02:36 +09:00
bdc48fcc63
Clean up allowMultipleSrvRecordsPerHost
This is hardcoded to true, and there is no use-case for setting it to
false.

Test: atest
Flag: EXEMPT refactor
Change-Id: I1c1b8f8ac4015adfa9900012c576312b5193433a

Remi NGUYEN VAN   commited 2025-04-01 18:43:29 +09:00
ce737da8af
De-duplicate the keepScore func in the CS unit test.
Flag: EXEMPT test-only change
Bug: 368416967
Test: atest CSSatelliteNetworkTest
Test: atest CSCaptivePortalAppTest
Test: atest CSLocalAgentTests
Change-Id: I0739f4524e5dd5ec0d5f3c170c82120ca30e8730

Xiao Ma   commited 2025-04-01 17:02:42 +09:00
315cf7110c
Merge "Move responseMatchesOptions() to MdnsUtils" into main
Paul Hu   authored and   Android (Google) Code Review   commited 2025-03-28 03:29:30 -07:00
1f1b6995fa
Move responseMatchesOptions() to MdnsUtils
Move utility method responseMatchesOptions() to MdnsUtils, where
it can be used by other mDNS classes.

Bug: 387910548
Test: atest ConnectivityCoverageTests NsdManagerTest
Change-Id: Idecd5e7d4c2c4dcf108c42e07a7befd97b68b5a7

Paul Hu   commited 2025-03-28 01:47:06 +00:00
3dc5357c0b
Merge changes from topic "revert-3561690-revert-3538339-SNUWWZJNJZ-BUWEOGUTIT" into main am: 2519a78731
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3563843

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

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-03-27 01:14:42 -07:00
480d443869
Merge changes from topic "revert-3561690-revert-3538339-SNUWWZJNJZ-BUWEOGUTIT" into main
* changes:
  Add TargetApi annotation to ConnectivityService and QuicConnectionCloser
  Revert "Revert "Remove unnecessary ifindex arg from destroyUdpSo..."
  Revert "Revert "Add hidden API to register/unregister QUIC conne..."

Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-27 00:41:36 -07:00
2519a78731
Merge "Fix transport override" into main am: c20c1224bc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3561446

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

Patrick Rohr   authored and   Automerger Merge Worker   commited 2025-03-26 19:38:19 -07:00
29b3dfebd0
Revert "Revert "Add hidden API to register/unregister QUIC conne..."
Revert submission 3561690-revert-3538339-SNUWWZJNJZ

Reason for revert: NewAPI error will be fixed by separate CL

Reverted changes: /q/submissionid:3561690-revert-3538339-SNUWWZJNJZ

Change-Id: Ia7367e9332f4d376bd0be4c03c095ee00de9177a

Motomu Utsumi   commited 2025-03-27 08:49:00 +09:00
e8e28f6236
Fix transport override
The EthernetConfigParser was adding the transportType on top of the
TRANSPORT_ETHERNET of DEFAULT_CAPABILITIES, causing multiple transport
types to be added.

This was causing an IllegalStateException when trying to set the
NetworkSpecifier within the EthernetNetworkFactory.

This only applies for when isAtLeastB && capabilitiesString.equals("*")
is true (as the parsed capability is equal to DEFAULT_CAPABILITIES).

Flag: TEST_ONLY
Bug: 405172885
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.ethernet.EthernetTrackerTest
Change-Id: I6678a52ddc87b8ad66c602c68335f3e2073d7231

Chris Desir   authored and   Patrick Rohr   commited 2025-03-26 15:51:04 -07:00
65a26519c0
Merge changes from topic "revert-3538339-SNUWWZJNJZ" into main am: 86961c4b73
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3561690

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

Chaitanya Cheemala (xWF)   authored and   Automerger Merge Worker   commited 2025-03-26 04:08:27 -07:00
3d3b87b4f9
Merge changes I0eb70c12,I6cd727bd into main am: ebdcd9e199
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3538339

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

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-03-26 03:11:15 -07:00
fdb5ac536f
Revert "Add hidden API to register/unregister QUIC connection cl..."
Revert submission 3538339

Reason for revert: Likely culprit for b/406432012 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Reverted changes: /q/submissionid:3538339

Change-Id: I61b02f2b1b667e9a41b677f8062e8e96aac09f6e

Chaitanya Cheemala (xWF)   commited 2025-03-26 03:07:07 -07:00
947b53b0d3
Add hidden API to register/unregister QUIC connection close payload
QUIC stack running on the app process will call this API and register
QUIC UDP socket and UDP payload that can close QUIC connection.

When the app loses network access (e.g. due to freezer or firewall
chain), ConnectivityService 1)destroys the registered UDP socket by
sending a SOCK_DESTROY netlink message and 2)sends the registered UDP
payload to the server. This prevents unnecessary modem wakeups caused
by packets from the server after the apps lose network access.

Additionally, to close QUIC connection for apps that crash or are
killed, ConnectivityService sends the registered UDP payload when it
receives a socket destroy diag message for the registered socket.

Bug: 311792075
Test: CSDestroySocketTest CtsNetTestCases
Change-Id: I6cd727bd8bb0fe1d17360edfa395f73d24da6920

Motomu Utsumi   commited 2025-03-26 16:48:28 +09:00
627b8c6d34
Merge "Delete unused function" into main am: 45173f74d3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3561187

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

Patrick Rohr   authored and   Automerger Merge Worker   commited 2025-03-25 15:56:25 -07:00
2b0899c009
Merge "Delete unused function" into main
Patrick Rohr   authored and   Gerrit Code Review   commited 2025-03-25 15:36:12 -07:00
45173f74d3
Merge "Move static IpConfiguration parsing into EthernetConfigParser" into main am: 43e8226877
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3561186

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

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-03-25 13:54:16 -07:00
66d75a648c
Merge "Move static IpConfiguration parsing into EthernetConfigParser" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-25 13:31:32 -07:00
43e8226877
Delete unused function
Test: TH
Change-Id: I1f81032ea14d87736e2c8890e9259f20aace4a0b

Patrick Rohr   commited 2025-03-25 11:56:41 -07:00
074c4934cd
Move static IpConfiguration parsing into EthernetConfigParser
For consistency.

Test: TH
Change-Id: Idefd43d5b22b8f5e02561601f3bc4142ce8a783e

Patrick Rohr   commited 2025-03-25 11:56:41 -07:00
5030594287
Merge "Removing interfaces from the InterfaceTracker when network is destroyed." into main am: 45a95e4b99
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3543880

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

Sarup Dalwani   authored and   Automerger Merge Worker   commited 2025-03-25 08:04:51 -07:00
f2500c577f
Merge "Removing interfaces from the InterfaceTracker when network is destroyed." into main
Sarup Dalwani   authored and   Gerrit Code Review   commited 2025-03-25 07:40:41 -07:00
45a95e4b99
Merge "Format MdnsUtilsTest" into main am: f0dcda3be3
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3556293

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

Treehugger Robot   authored and   Automerger Merge Worker   commited 2025-03-24 21:44:10 -07:00
bdb6c117af
Merge "Format MdnsUtilsTest" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-24 21:16:34 -07:00
f0dcda3be3
Removing interfaces from the InterfaceTracker when network is destroyed.
Bug: 400681214
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.InterfaceTrackerTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivityservice.CSInterfaceTrackerTest
Change-Id: Ifb3388800dec6ed208ca28dba080c5b736f09d35

Sarup Dalwani   commited 2025-03-25 01:34:05 +00:00
28c0533bf0
Format MdnsUtilsTest
Use the ktlint.py script to correct Kotlin code formatting errors.

Test: m
Change-Id: Ic3b4ff16fcaa465836c5b6653f1ab8dcc1b718b9

Paul Hu   commited 2025-03-24 10:06:56 +00:00
a16f8b8126
Merge "Fix SSID in notification for RTL languages" into main am: e1564ce3c8
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3235925

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

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2025-03-23 19:06:39 -07:00
878d5c1577
Merge "Fix SSID in notification for RTL languages" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2025-03-23 18:35:59 -07:00
e1564ce3c8