Commit graph android_packages_modules_Co.../tests/unit/java
Message SHA1
Merge "Pass DoH information to DnsResolver" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-08-14 07:50:42 +00:00
af569157d5
Unit test for intent spam
Add unit test to test feature
BROADCAST_NETWORK_STATS_UPDATED_RATE_LIMIT_ENABLED_FLAG.
When feature is on, broadcast message should be delivered
with the designated interval(b/343844995),
When feature is off, each message should be delivered
regardless of previous intent.

Test: atest FrameworksNetTests:android.net.connectivity.com.android\
	.server.net.NetworkStatsServiceTest\
	#testNetworkStatsUpdatedIntentSpam_rateLimitOn
Test: atest FrameworksNetTests:android.net.connectivity.com.android\
	.server.net.NetworkStatsServiceTest\
	#testNetworkStatsUpdatedIntentSpam_rateLimitOff
Bug: 343844995
Change-Id: I4b89497c336a310c6959db579ca9ae3c572ff70c

Yun-Chen Cheng   commited 2024-08-09 08:38:30 +00:00
fecc2ec193
Skip adding ingress discard rule to OEM VPN
OEM VPNs might need to receive packets to VPN address via
non-VPN interface.

Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Ia9000bcbb5b3b9e1e0d396ba78946be36e2fc5ba

Motomu Utsumi   commited 2024-08-06 19:02:33 +09:00
c14288f7c7
Merge changes If787d3f3,I6de357ac into main
* changes:
  Rename getShrinkedBackingArray to getMinimized*
  Suspend callbacks for frozen apps

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-08-05 00:15:39 +00:00
057369c840
Merge "Skip adding ingress discard rule to legacy VPN" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-08-02 23:44:47 +00:00
c4b4feed19
Merge "Add removeServices method in MdnsServiceCache" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-08-02 12:46:54 +00:00
73889ed954
Add removeServices method in MdnsServiceCache
This method can remove all services that match the given
CacheKey.

Bug: 355421878
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I83e1a0cbdd4355d92510b5f9a550f96ef0154682

Paul Hu   commited 2024-08-02 11:32:12 +00:00
d90f31884b
Rename getShrinkedBackingArray to getMinimized*
"Shrinked" should actually be "shrunk" or "shrunken"; in any case
"minimized" is simpler and possibly more accurate (it's the minimum size
required to hold the values).

Test: atest
Change-Id: If787d3f3d6e1046338d4e89ed924bce183e74bd6

Remi NGUYEN VAN   commited 2024-08-02 19:27:41 +09:00
dfb159289b
Suspend callbacks for frozen apps
To avoid filling the binder buffers, and sending unnecessary callbacks
when apps are unfrozen (for example successive LinkProperties changes or
onAvailable+onLost are not useful), queue and aggregate callbacks for
apps that are suspended.

Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I6de357ac2834f1f7e960dfbaa63adfc3825f2a82

Remi NGUYEN VAN   commited 2024-08-02 19:24:17 +09:00
2d78124348
Skip adding ingress discard rule to legacy VPN
Some legacy VPNs need to receive packets to VPN address via
non-VPN interface.

Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Iad06dc69c5bf5ccda476e89ed9b0fc1bc63d2ebe

Motomu Utsumi   commited 2024-08-02 19:15:59 +09:00
1b376f0fc4
Merge "Fix ktlint errors" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-08-02 08:40:23 +00:00
c759b039ac
Merge "Do not send empty TXT records" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-07-31 08:54:14 +00:00
141aac3b73
Fix ktlint errors
Obtained with:
    prebuilts/ktlint/ktlint.py --format --no-verify-format --file FILE

--no-verify-format is used to ignore checks that are performed by ktfmt
(see ktlint.py).

Test: m
Change-Id: Ief2c146833e43492d0333b05f1c2b67bbfbc16e0

Remi NGUYEN VAN   commited 2024-07-31 12:01:08 +09:00
89b87e143d
Do not send empty TXT records
Empty TXT records should not be sent when advertising as per RFC 6763
6.1, although it also specifies that in case they are sent, they must be
treated the same as TXT records with an empty String.

Some recent discovery implementations seem to not be able to find
services that send empty TXT records; ensure MdnsAdvertiser sends TXT
records with an empty attribute instead.

Test: atest
Bug: 351250155
Change-Id: If928e5f7c371faa456535160f10880adb1449b92

Remi NGUYEN VAN   commited 2024-07-31 12:01:05 +09:00
9ecc57021b
Fix to return BLOCKED_REASON_NONE for system uids
Bug: 289439578
Test: BpfNetMapsTest
Change-Id: Ib50c2755bc8642cc0dc4e95384d35e38be400a2c

Motomu Utsumi   commited 2024-07-30 16:56:52 +09:00
29c0d2aea7
Merge "Update the QueryTaskConfig constructor" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-07-22 02:02:31 +00:00
6ade6e2042
Update the QueryTaskConfig constructor
This is a no-op refactor. Move some parameters from
QueryTaskConfig to QueryTask, or bring them from public methods.

Bug: 345146854
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I47d420842c4f9cec3fe25b5e2febc84a1e495f40

Paul Hu   commited 2024-07-18 06:16:57 +00:00
8c5dc514bf
Consolidate DNS label comparison functions in DnsUtils
Moved common DNS label comparison functions from MdnsUtils.java to
DnsUtils.java within the staticlib to facilitate reuse by both
Connectivity and NetworkStack modules.

Test: TH
Change-Id: Ie839c5621d2c4b74e41987a0c6d1141d0d6e24f8

Yuyang Huang   commited 2024-07-18 12:00:59 +09:00
d851a04db4
Merge changes I6cc2507d,I187ea15d into main
* changes:
  Add flag for QUEUE_CALLBACKS_FOR_FROZEN_APPS
  Add a CallbackQueue class

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-07-16 08:46:11 +00:00
16828bdeba
Add flag for QUEUE_CALLBACKS_FOR_FROZEN_APPS
Add a flag to be used for an optimization to queue callbacks while apps
are frozen, instead of filling the binder buffer.

Bug: 327038794
Bug: 279392981
Test: atest
Change-Id: I6cc2507de88fae3d0866f9831e1e9026200297e4

Remi NGUYEN VAN   commited 2024-07-16 13:36:51 +09:00
48d2527e43
Add a CallbackQueue class
The class will be used to build memory-efficient objects (int arrays)
used to queue ConnectivityService callbacks while an app is frozen.

This is very similar to an ArrayList<Pair<Short, Short>>, but avoids
object boxing which would use a lot more memory.

This is intended to be used by ConnectivityService both as a builder,
and as a utility to read lists of callbacks that it stores. Long-lived
references to the CallbackQueue would not be kept to minimize memory
usage; only the array returned by toArray needs to be stored.

Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I187ea15d14dfd160e577e9e9e87b1aded27b1938

Remi NGUYEN VAN   commited 2024-07-16 13:36:49 +09:00
c3621e6012
Merge "Ensure all DatagramPackets with the same destination address" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-10 01:37:51 +00:00
51dc24ad0b
Refactor RoutingCoordinator
- This CL puts RoutingCoordinator into staticlibs to make it usable by
both Tethering and ConnectivityService on R.
- This CL also changes the return type of
  ConnectivityInternalApi#getRoutingCoordinatorManager() to IBinder so
  it has fewer dependencies.

Bug: 350699020
Test: CI

Change-Id: Iba096e940795cd33e61c5141721394ad39e5ce6d

Handa Wang   commited 2024-07-05 05:26:54 +00:00
8f2c30664d
Merge "Improve NetworkCallback declared methods toString" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-04 04:11:52 +00:00
5289382f04
Improve NetworkCallback declared methods toString
Instead of printing the flags as hex, use flag names for known flags.

Bug: 327038794
Bug: 279392981
Test: atest
Change-Id: I11ba4de1e8e60d5468a72b275cd724be669b32bc

Remi NGUYEN VAN   commited 2024-07-03 19:09:51 +09:00
baf7c1184f
Merge "Refactor enforceMeteredApnPolicy" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-06-28 02:24:06 +00:00
9f3b991a7a
Refactor enforceMeteredApnPolicy
Address review comment on aosp/3027487
This CL also adds test for enforceMeteredApnPolicy

Test: CSBlockedReasonsTest
Bug: 344800107
Change-Id: Ib531bf5b34566fc91fec9f977c5257b332189706

Motomu Utsumi   commited 2024-06-27 22:25:47 +09:00
e9c07ffd72
Ensure all DatagramPackets with the same destination address
The MdnsSocketclient#sendMdnsPacket() uses the address of the
first packet only. Since there's no guarantee that all packets
have the same address, skip sending packets if any have a
different address.

Fix: 335125073
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: Ief0fd81eacf46b33bb2e8c0fcc4da7981ac2972d

Paul Hu   commited 2024-06-26 14:50:48 +00:00
2bbcc34ea1
Merge "Only send callbacks when overridden" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-26 07:35:45 +00:00
e1c10b08a2
Only send callbacks when overridden
Most users of NetworkCallback do not override all methods, so callbacks
from ConnectivityService end up being unused by the app.

To save resources, check which callback methods are overridden in
ConnectivityManager, and inform ConnectivityService so it can skip
preparing and sending the corresponding binder calls when the callback
is not used by the app.

This is flagged off by default.

Test: flag enabled: atest CtsNetTestCases ConnectivityCoverageTests
Bug: 327038794
Bug: 279392981

Change-Id: Iaf490f416fb6e1437d40497fba1a40a899a9f523

Remi NGUYEN VAN   commited 2024-06-26 12:39:47 +09:00
2fd3823cbc
Make firewall bpf code multi-user aware
The check is_system_uid should mirror the definition of core_uids in
UserHandle.isCore until it is available to be read from mainline code.
isUidNetworkingBlocked should also do the same.

Test: All existing tests should pass.
Test: atest CtsHostsideNetworkPolicyTests
Test: atest FrameworksNetTests

Bug: 348316140
Change-Id: Id5e01289b301a725b162ef249062e0f2806876dc

Suprabh Shukla   commited 2024-06-25 00:21:27 -07:00
3d00262fe7
Merge changes I76b0a7ba,If7308f1a,Ica8faced,Ia8f42ed0,I975afb45, ... into main
* changes:
  Add some documentation to EthernetInterfaceStateMachine
  Add support for link state tracking
  Add unit test class for EthernetInterfaceStateMachine
  Add missing call to add states to state machine
  Make class testable
  Log.wtf if block times out
  Wait on IpClient#onQuit in StartedState#exit
  Use TAG instead
  Introduce CMD_ON_NETWORK_NEEDED and CMD_ON_NETWORK_UNNEEDED messages
  Clean up and document state lifecycle
  Add convenience method for processMessage with no arguments
  Implement NetworkOffer in EthernetInterfaceStateMachine
  Add boilerplate to represent interface states in state machine
  Fix typo in SyncStateMachineTest
  Move SyncStateMachine to staticlibs

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-21 19:01:38 +00:00
58526e4d96
Add support for link state tracking
Currently, TetheringState just ignores these callbacks (though it must
return HANDLED, otherwise a wtf is logged). This is in line with what
EthernetTracker currently does.

Test: EthernetInterfaceStateMachineTest
Change-Id: If7308f1aa4b333552a79dfe05864c5cef1621582

Patrick Rohr   commited 2024-06-21 08:25:26 -07:00
0129a7a11e
Add unit test class for EthernetInterfaceStateMachine
This currently just invokes the constructor and does nothing else.
EthernetInterfaceStateMachine does not currently provide a way to
transition out of LinkDownState.

Test: run test
Change-Id: Ica8faced0abe33bb70ec5e3f950bc0af75f78f16

Patrick Rohr   commited 2024-06-21 08:25:26 -07:00
7bd5e6dca6
Merge "Do not display "null" in sign-in note details" into main am: 488d40d122
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3130956

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

Treehugger Robot   authored and   Automerger Merge Worker   commited 2024-06-13 09:59:20 +00:00
d700a20d74
Merge "Do not display "null" in sign-in note details" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-13 09:50:15 +00:00
488d40d122
Do not display "null" in sign-in note details
For non-telephony, non-wifi networks, both extraInfo and SSID are likely
to be null, in which case
getString(network_available_sign_in_detailed, null) would be used for
the notification contents, which would just print "null" (by default the
string template is just "%1$s").

Use an empty string instead, as there is no string identifier for the
network. This should still be better than having text that says "null".

Test: atest
Bug: 334926818
Change-Id: I19bdba186d2402b40549b1ad5f97864b7c38ca10

Remi NGUYEN VAN   commited 2024-06-13 17:10:36 +09:00
05aa33ccec
Merge changes I62c990d0,I413bdb76,I020ba48e into main am: 3e07102814
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3036454

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

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2024-06-07 09:45:54 +00:00
20fb6a4061
Merge changes I62c990d0,I413bdb76,I020ba48e into main
* changes:
  Update NetworkRequestTest#testDefaultCapabilities
  Allow default messaging app to use constrained satellite network
  Introduce NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED

Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-06-07 09:29:06 +00:00
3e07102814
Merge "waitForIdle to avoid stubbing mocked bpfNetMaps while CS is accessing" into main am: 65bb6527cd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3117159

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

Treehugger Robot   authored and   Automerger Merge Worker   commited 2024-06-07 04:08:21 +00:00
1e0f207b4e
Merge "waitForIdle to avoid stubbing mocked bpfNetMaps while CS is accessing" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-06-07 03:51:14 +00:00
65bb6527cd
Allow default messaging app to use constrained satellite network
On V+, there could be satellite network which is not restricted but
bandwidth constrained.
These satellite network has NET_CAPABILITY_NOT_RESTRICTED but does not
have NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED.
Since NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED is set by default, this
CL remove this capability from per-app default network request for the
default messaging app.

Test: CSSatelliteNetworkTest
Bug: 343823469
Change-Id: I413bdb764ead42d67ce1315c365500dbb8508eb3

Motomu Utsumi   commited 2024-06-07 09:26:19 +09:00
ab750abf29
waitForIdle to avoid stubbing mocked bpfNetMaps while CS is accessing
Bug: 343302460
Test: TH
Change-Id: I74683b20ce581206c47a153b0e2f348295363ecb

Motomu Utsumi   commited 2024-06-06 18:04:08 +09:00
986dd36e65
Introduce NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED
On V+, this capability is set by default.
Constrained satellite networks never become the system default network.

Test: CSSatelliteNetworkTest
Bug: 343823469
Change-Id: I020ba48e74f1f180e1807cbe1c066209bedb0454

Motomu Utsumi   commited 2024-06-06 15:49:21 +09:00
154ce6381a
Merge "Add config flag for useDeclaredMethodsForCallbacks" into main am: 9d88333273
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3105881

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

Remi NGUYEN VAN   authored and   Automerger Merge Worker   commited 2024-06-06 02:57:00 +00:00
241f7eaa97
Add config flag for useDeclaredMethodsForCallbacks
Add a DeviceConfig flag that will be used to control whether callbacks
should be sent selectively based on whether the receiving method has
been overridden (will be implemented in a future change).

This adds utilities to allow ConnectivityManager to check whether a
ConnectivityService flag is enabled, as that feature will work across
ConnectivityManager and ConnectivityService. ConnectivityManager runs in
app process and does not necessarily have permissions to use
DeviceConfig. Also if it checked DeviceConfig separately from
ConnectivityService, values may be out-of-sync.

Test: atest, and see change using this
Change-Id: I204fa719cc627e84edc5c1e043d947f5ef3f8dee

Remi NGUYEN VAN   commited 2024-06-05 15:54:49 +09:00
aa355ac875
Merge "Update CSSatelliteNetworkTest to use restricted satellite network" into main am: 08137f6e40
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3109162

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

Motomu Utsumi   authored and   Automerger Merge Worker   commited 2024-06-05 02:16:20 +00:00
48dc4ca0e2
Merge "Update CSSatelliteNetworkTest to use restricted satellite network" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-06-05 01:57:55 +00:00
08137f6e40
Update CSSatelliteNetworkTest to use restricted satellite network
Currently, satellite network should be restricted network.
But CSSatelliteNetworkTest uses non restricted satellite network.
This CL updates CSSatelliteNetworkTest to use restricted satellite
network.
This is a preparation to upcoming CLs that supports non restricted but
constrained satellite network.

Test: CSSatelliteNetworkTest
Bug: 343823469
Change-Id: Ia4f75ad525499bffbedd2f3b5d63edd1c216520e

Motomu Utsumi   commited 2024-06-04 18:43:59 +09:00
1e31ad3dff
Merge changes If3dbe234,Ia1299759 into main am: 67b67908a1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3093805

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

Junyu Lai   authored and   Automerger Merge Worker   commited 2024-06-04 07:11:09 +00:00
6587d6c31f