Commit graph android_packages_modules_Co.../tests/unit/java/com/android
Message SHA1
Merge "Listen to onExternalApplicationsAvailable in SatelliteAccessController" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-04-28 06:37:49 -07:00
bc08a1ffcb
Listen to onExternalApplicationsAvailable in SatelliteAccessController
For maintaining constrained data satellite opt-in apps, this is
needed for tracking apps installed on the storage.

Flag: EXEMPT flagged with a kill switch
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
  --update-device
Bug: 410731080
Change-Id: I2a686a5a37747de97dcee6b78f66965cb4fd9942

Junyu Lai   commited 2025-04-28 16:35:36 +08:00
63dbd3ec93
Merge changes Iabc2fad0,I2078330b into main
* changes:
  Improve TestableNetworkOfferCallback
  Add a way to poll with a position for ReadHead

Jean Chalard   authored and   Android (Google) Code Review   commited 2025-04-27 23:25:04 -07:00
74dcb4637c
Merge "Add EthernetPort class" into main
Chuwei He   authored and   Android (Google) Code Review   commited 2025-04-27 22:56:01 -07:00
8e31d9d8e9
Merge changes I579b3cd9,Ib008e63c into main
* changes:
  Allow QuicConnectionCloser to close loopback QUIC connection
  Enable QUIC connection close by default in ConnectivityService

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-04-27 22:20:38 -07:00
5ae058b9d4
Enable QUIC connection close by default in ConnectivityService
This feature will be controlled by the caller.
Cronet calls the register/unregisterQuicConnectionClosePayload APIs only
when the Chromium experiment flag is enabled
(http://crrev.com/c/6421621/).

This CL also updates testRegisterQuicConnectionClosePayload
to be skipped on U or older releases since FIREWALL_CHAIN_BACKGROUND is
supported on V or higher releases.

Flag: EXEMPT guarded by chromium flag
Bug: 311792075
Test: TH
Change-Id: Ib008e63c585cfe8775b25783cd55b0873bb5e2f0

Motomu Utsumi   commited 2025-04-28 12:52:58 +09:00
2ea5939672
Add EthernetPort class
This patch adds EthernetPort class which is used to track configuration
of ethernet networks internally.

Bug: 397536853
Test: atest ConnectivityCoverageTests:android.net.connectivity.
      com.android.server.ethernet.EthernetPortTest
Flag: EXEMPT mainline

Change-Id: Iba1c4461ae7d666aa31c076baa33c32c2c1f7603

Chuwei He   commited 2025-04-27 20:52:26 -07:00
8092ae7d29
Pipe the satellite network opt-in UIDs down to ConnectivityService
Flag: EXEMPT flagged with a kill switch
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
  --update-device
Bug: 410731080
Change-Id: I76a57a3c42659b594cd541c55e0e179062461085

Junyu Lai   commited 2025-04-28 10:21:57 +08:00
2fd0d11db3
Improve TestableNetworkOfferCallback
Update it to follow the latest conventions and add support for
eventuallyExpect.

Test: ConnectivityCoverageTest
Flag: EXEMPT test-only change
Change-Id: Iabc2fad051b874e3e18a0645361409f0427891fb

Chalard Jean   commited 2025-04-27 15:54:34 +09:00
5f3997b6af
Add a basic test for network preferences
Test: this
Flag: EXEMPT test-only code
Change-Id: Ibd2e5adf2a18821a05b6b3a7baa22d4d750ec14f

Chalard Jean   commited 2025-04-27 10:27:28 +09:00
957799c672
File the per-app request for opted-in satellite-optimized apps
Test: ConnectivityCoverageTest
Bug: 410731080
Flag: EXEMPT controlled in counter-part change ag/33220291
Change-Id: I0307f697a441c2810cafd4643d381e66a0ac9243

Chalard Jean   commited 2025-04-27 02:12:44 +09:00
76a60c1654
Merge "Maintain a set self-certified apps in SatelliteAccessController" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-04-24 22:48:53 -07:00
2f92579f8a
Maintain a set self-certified apps in SatelliteAccessController
This is needed for tracking the applications which opted-in to
use the constrained data satellite network as its default by
adding the following property to the <application> tag of its
manifest:
  <property
   android:name="android.telephony.PROPERTY_SATELLITE_DATA_OPTIMIZED"
   android:value="<package name>" />

Flag: EXEMPT flagged with a kill switch
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
      --update-device
Bug: 410731080

Change-Id: I00c0ce5e0d7aac1192272e79a19fbab4e3a5e6f1

Junyu Lai   commited 2025-04-25 10:35:31 +08:00
fbe94c3b00
Merge "Add tests to verify OffloadEngine behaviors" into main
Paul Hu   authored and   Android (Google) Code Review   commited 2025-04-24 19:23:46 -07:00
66d60e5a90
Merge "Replace Message with related arguments in RealtimeScheduler" into main
Paul Hu   authored and   Android (Google) Code Review   commited 2025-04-24 19:06:40 -07:00
02af3afeee
Merge "Move package enumeration out of PermissionMonitor" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-04-23 22:43:39 -07:00
4aa806dc20
Merge changes Id6191d5a,I9ace3ed0,Ic79afc18 into main
* changes:
  Add light-weight DefferedBroadcastReceiver for handling broadcast events
  Move user intent reception out of SatelliteAccessController
  Move user/package intent reception out of PermissionMonitor

Jean Chalard   authored and   Android (Google) Code Review   commited 2025-04-23 21:50:19 -07:00
0d578113f7
Move package enumeration out of PermissionMonitor
The PackageManager#getInstallPackagesAsUser method is time
consuming (30~200ms) and blocks boot time while it executes.
This change moves the getInstallPackagesAsUser
method from PermissionMonitor. This is a performance-focused
refactoring to allow for efficient sharing of package enumeration
results in subsequent changes, avoiding redundant time-consuming
operations.

Flag: EXEMPT refactor
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
      ConnectivityCoverageTests: android.net.connectivity.com.android.server.ConnectivityServiceTest
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.PermissionMonitorTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.BroadcastReceiveHelperTest \
      --update-device
Bug: 410731080
Change-Id: I3929fa28ff9419329622f3abdf10336289730607

Junyu Lai   commited 2025-04-24 11:43:11 +08:00
830b579081
Add light-weight DefferedBroadcastReceiver for handling broadcast events
This commit introduces the DeferredBroadcastReceiver class, which
defers received Intent handling using a Handler. It prevents
Application Not Responding (ANR) errors by offloading potentially
time-consuming or blocking operations triggered by broadcast
event handling, even if `onReceive` takes a long time on the
handler thread.

Flag: EXEMPT refactor
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.PermissionMonitorTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.BroadcastReceiveHelperTest \
      --update-device
Bug: 410731080
Change-Id: Id6191d5ad9ae9f17fca3236110573340aa713048

Junyu Lai   commited 2025-04-24 10:50:44 +08:00
244f3e3df2
Move user intent reception out of SatelliteAccessController
This is a no-op refactoring that moves the reception of
user-related intents in SatelliteAccessController to
ConnectivityService.
It then dispatches these events to the SatelliteAccessController.

Flag: EXEMPT refactor
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
  ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest
Bug: 410731080
Change-Id: I9ace3ed09a161446dc92d40bc0d400e32051de32

Junyu Lai   commited 2025-04-24 10:50:44 +08:00
b14633ea2f
Move user/package intent reception out of PermissionMonitor
This is a no-op refactoring that moves the reception of
package and user-related intents in PermissionMonitor to
BroadcastReceiveHelper.
It then dispatches these events to the PermissionMonitor.
This change is necessary to centralize intent receivers
from other subclasses to ConnectivityService in
subsequent modifications.

This reverts the design change introduced in aosp/2183343, which
had PermissionMonitor listening to user change events instead
of ConnectivityService.

Flag: EXEMPT refactor
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.PermissionMonitorTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.BroadcastReceiveHelperTest \
      --update-device
Bug: 410731080
Change-Id: Ic79afc18a6e8603ddf8d48a1f78cf8d98f2447ae

Junyu Lai   commited 2025-04-24 10:50:44 +08:00
8b1fe1976b
Add tests to verify OffloadEngine behaviors
Bug: 410734687
Test: atest ConnectivityCoverageTests
Flag: EXEMPT test only update
Change-Id: If7a15e181a185e4c1a55b252d57d7f464aa6baac

Paul Hu   commited 2025-04-24 02:44:15 +00:00
7a8f4b9da5
Improve the tests for the fallback network shell command.
- Also verify the netd operations that add and remove UID ranges.
- Don't set the network to keep connected, since that is not
  representative of what happens on a real device.

Test: test-only change
Bug: 410731080
Flag: TEST_ONLY
Change-Id: Ib4305748b5f1627546b7a63fb9596308b14155e0

Lorenzo Colitti   commited 2025-04-23 12:03:57 +09:00
c9baec4101
Add a shell command to set an app's fallback default network.
This adds two new shell commands to ConnectivityService that sets
a given UID to fall back to a given transport type if there is no
system default network. The syntax is:

  cmd connectivity set-debug-fallback-network-for-uid <uid> <transport>
  cmd connectivity clear-debug-fallback-network-for-uid <uid>

This works only on debug builds and should be used only for
manual testing.

Test: none yet
Bug: 410731080
Flag: TEST_ONLY
Change-Id: I9e0ac0713dbb95e59b22faa7cd45bdc8c1070f08

Lorenzo Colitti   commited 2025-04-22 22:46:34 +09:00
4a8e41d2ae
Simplify and correct isNetworkPotentialSatisfier.
This makes the code clearer, and also fixes a bug: currently, a
TRACK_DEFAULT request in a multilayer request can cause a network
to remain needed. This is incorrect: only requests should be able
to keep a network up.

This prevents satellite networking from disconnecting when the
default network reappears (see changes in unit test).

This CL removes the code before the loop that special-cases
non-multilayer listens because it is not very useful. Any
non-multilayer listen will either:
- Immediately return false, if it's the active request, or:
- Cause the code to continue (because it's not the active
  request), and because mRequests only has one element, will
  hit the "return false" statement after the loop.

Flag: EXEMPT bug fix
Test: covered by existing tests
Change-Id: I7295ce469335af924aa20b7976cc4a9136ef5d61

Lorenzo Colitti   commited 2025-04-22 22:02:40 +09:00
dd577efdde
Add a test for NetworkCallbacks for fallback satellite networks.
Bug: 410731080
Flag: TEST_ONLY
Test: test-only change
Change-Id: If74f461bca2bc34b1defa841e05237849f4c1c4a

Lorenzo Colitti   commited 2025-04-22 22:01:59 +09:00
eda7af89fe
Replace Message with related arguments in RealtimeScheduler
This change ensures that the Message object is created and
obtained within RealtimeScheduler, preventing modification
by the caller.

Fix: 386274963
Test: atest ConnectivityCoverageTests NetworkStaticLibTests
Flag: EXEMPT bug fix
Change-Id: I4c919857bcaa2d49717859dca9c88a243cbb7a41

Paul Hu   commited 2025-04-22 01:45:13 -07:00
1dea0d630e
Merge "Ignore IPv6 temporary addresses in mDNS advertising." into main
Yuyang Huang   authored and   Android (Google) Code Review   commited 2025-04-21 00:48:54 -07:00
6df77e382d
Ignore IPv6 temporary addresses in mDNS advertising.
This commit modifies the mDNS advertising process to ignore IPv6
temporary addresses. These addresses are ephemeral and can lead to large
advertising packets and negatively impact mDNS offload(as RAM for doing
mDNS offload is limited), especially on devices with long internet
connections and multiple temporary addresses.  Ignoring them provides a
more stable and efficient mDNS advertising
experience.

Flag: EXEMPT mainline
Test: TH
Change-Id: I79c7f331eb29ecdd7ade4ccde1d1a22d0dbf1400

Yuyang Huang   commited 2025-04-21 14:57:12 +09:00
2184846d35
Merge "Update enforceMeteredApnPolicy to follow the compat flag" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-04-20 22:15:06 -07:00
2c8f7b5608
Merge changes Id3a9d374,If67ebaa2 into main
* changes:
  Fix a callback leak in tests using CSAgentWrapper.
  Make dumpAllRequestInfoLogsToLogcat accessible to tests.

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-04-20 20:56:03 -07:00
ae1b72bd80
Update enforceMeteredApnPolicy to follow the compat flag
On V+, ConnectivityService uses uid blocking state in BpfMap instead of
asking NetworkPolicyManager.
But, there was one behavior difference because NetworkPolicyManager
considers the network is always not blocked for apps without Internet
permission.
To ensure backward compatibility, the
NETWORK_BLOCKED_WITHOUT_INTERNET_PERMISSION flag was introduced in
aosp/3076606, aosp/3088285.

This CL updates enforceMeteredApnPolicy to respect this flag for
backward compatibility.

Test: CSEnforceMeteredApnPolicy
Bug: 404428733
Bug: 370383309
Flag: EXEMPT bugfix
Change-Id: I631f4f840818e1d40f20fccae1ec1a2cbbb6a166

Motomu Utsumi   commited 2025-04-21 12:19:45 +09:00
5759bf45a5
Merge "Format MdnsRecordRepositoryTest with ktlint" into main
Yuyang Huang   authored and   Android (Google) Code Review   commited 2025-04-20 19:49:05 -07:00
eae525f200
Fix a callback leak in tests using CSAgentWrapper.
The method above this one (connect) unregisters the callback, but
disconnect doesn't. Looks like it was just missed in code review.

Flag: TEST_ONLY
Test: test-only change
Change-Id: Id3a9d3748554275fd28d8bf2ff2b6fa42be24ddc

Lorenzo Colitti   commited 2025-04-21 11:20:24 +09:00
7a0a9dd096
Format MdnsRecordRepositoryTest with ktlint
Test: TH
Flag: EXEMPT test only
Change-Id: I9d39a2927df5d09183c30140ed2e2b22f457a5bf

Yuyang Huang   commited 2025-04-20 14:50:12 +09:00
ecdc5d7743
CSTest: overload Agent with the given parameters.
CSTest already has an Agent function helper. Instead of using a new
function to create a network agent based on the given parameters,
it's better to overload the existing Agent function.

Flag: EXEMPT test-only change
Bug: 368416967
Test: atest ConnectivityCoverageTests
Change-Id: I134a96f564111ba65ddd5f8ec7878aeeab340dee

Xiao Ma   commited 2025-04-17 17:28:45 +09:00
926df9a9ab
CSTest: move nc function helper to CSTestHelpers.
Flag: EXEMPT test-only change
Bug: 368416967
Test: atest ConnectivityCoverageTests
Change-Id: I022bb5ab026fefec82a4b2a260b9167ef7891e96

Xiao Ma   commited 2025-04-17 15:56:43 +09:00
4eb7a669e5
Rename FdWrapper to TunWrapper
For clarity, as it doesn't support wrapping any fd. If the fd is a
connected socket, it must be shutdown() to interrupt blocking
operations. Tun doesn not require shutdown(), so TunWrapper is a better
name.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I2f7af95ef8d9ebceefdfc479c04e0272b2cb7311

Patrick Rohr   commited 2025-04-16 15:16:05 -07:00
18ec5811ec
Remove unnecessary shutdown() calls
For some reason, I used to believe shutdown() was required for tun
interface fds. As it turns out, it isn't and throws an error every time
it is called:

    shutdown failed: ENOTSOCK (Socket operation on non-socket)

This change removes all calls to shutdown() including the shutdownRead()
and shutdownWrite() interface methods.

Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I5a1716f82426b24db9e05367f82dc4080762e288

Patrick Rohr   commited 2025-04-16 15:16:05 -07:00
48ac9543c3
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