Commit graph android_packages_modules_Co.../framework
Message SHA1
Use IntRange for setPsm
Configures an IntRange [0, 255] for the L2CAP BLE PSM. Note that L2CAP
over Bluetooth Classic uses PSM values that exceed this range though is
explicitly not supported.

This CL also changes the value for PSM_ANY from -1 to 0 to make the
IntRange continuous as 0 is not a valid PSM (in both BLE and Classic).

Bug: 388438641
Test: TH
Change-Id: I15a69cfb80545c4f3723d089afd3cf026eec0696

Patrick Rohr   commited 2025-01-08 15:48:16 -08:00
5b6e6b2a5a
Improve documentation of L2capNetworkSpecifier
Addresses comments in aosp/3429160.

Test: TH
Change-Id: I05588b7f0a3d22beae4ddb2237b9a6eebdd00d03

Patrick Rohr   commited 2025-01-08 15:48:16 -08:00
d10fa68a5c
Have setRemoteAddress accept a Nullable remoteAddress
Per API council feedback.

Bug: 388438641
Test: TH
Change-Id: Iba71c4944ebbd91df5fdbb3605fc9edcc2139af5

Patrick Rohr   commited 2025-01-08 15:48:16 -08:00
c7e388423a
Add L2capNetworkSpecifier
Adds the API surface of the L2capSpecifier. Matching will be implemented
in a follow up change.

Test is *very* basic and will be expanded in follow up (once API is
approved).

Test: atest L2capNetworkSpecifierTest
API-Coverage-Bug: 372936361
Bug: 372936361
Change-Id: I6d36b77c3ae05fb8d251da9e197e82af187ead0c

Patrick Rohr   commited 2025-01-07 13:38:41 -08:00
961528d1cc
Fix exception when unparcelling NetworkRequest with reservationId
This change adds a new private constructor that is called directly from
createFromParcel instead of using the public constructor used by CS.

The public constructor throws an exception when the passed
NetworkCapabilities specify a reservationId (to prevent apps from
passing in reservationIds). This means that it cannot be called from
createFromParcel.

Test: atest NetworkReservationTest
Change-Id: I1fe2411401623b0b01cbdbe040049b810fcbb48a

Patrick Rohr   commited 2025-01-07 12:59:21 -08:00
121ab15fdf
Add reserveNetwork API
reserveNetwork allows a requestor to initiate the creation of a network
that requires the system to preallocate resources which can then be
advertised by the requestor on or off device in order to help create the
network.

For example, this API will be used to reserve a IP over L2cap server
network, which requires the system to first create a
BluetoothServerSocket and reserve a PSM (i.e. port). This information is
passed back to the requestor via onReserved() callback and subsequently
advertised via a BLE advertisement. The network is established as soon
as the client connects to the advertised PSM, which will trigger a call
to onAvailable(), just like a regular NetworkRequest.

onReserved() callbacks are exclusive to the reserveNetwork API and are
sent when an NetworkOffer is registered that matches the reservation ID
of an existing request. A reserved offer always follows the reservation
request as it is created in direct response. onReserved() can only be
called once. If for some reason the reservation gets cancelled by the
system (i.e. the NetworkOffer is retracted) or cannot be fulfilled,
onUnavailable() is called. It is up to the app to file a new
NetworkRequest when this happens.

An onReserved() callback is not queued, because
a) it cannot be called more than once for the same reservation,
b) it must always be the first callback, and
c) it only gets cancelled by onUnavailable().

This change does not handle NetworkOffer migrations, such as updating
the score, properly. This must be addressed before the feature can ship
as the yieldToBadWifi logic can update the score on all NetworkOffers.

API-Coverage-Bug: 372936361
Test: Very basic CSNetworkReservationTest; more to follow.
Change-Id: I9b349d469830bf28e006cf403c605574371db267

Patrick Rohr   commited 2024-12-22 22:01:22 -08:00
73eee542a1
Do not allow any request to pass in reservationId
This change enforces that the reservationId can *only* be set by the
system. The reservationId is set by the system and the app must never be
able to change it.

Test: TH
Change-Id: I9f6a0dc6df1ec09ed2d87de09ce52cdda7611600

Patrick Rohr   commited 2024-12-22 22:01:22 -08:00
4cef67c008
Add NetworkCallback#onReserved
onReserved() is called in response to a successful Network reservation
with the NetworkCapabilities of the reserved network. onReserved is
called at most once. If the reservation is released, onUnavailable is
called.

Test: TH
API-Coverage-Bug: 372936361
Change-Id: Idcef572ab9d07981799efc349206aadb620e0e69

Patrick Rohr   commited 2024-12-20 15:15:28 -08:00
93136f13c6
Add app compat change ID for LNP
Bug: 369631245
Test: manual build and checking logcat
Change-Id: I34112b2d59b682426a45f7fbcdc5ce68996dde73

Jacque Li   commited 2024-12-13 13:43:26 +00:00
55726f17b9
Merge changes Icecb889a,Id06116ad into main
* changes:
  Set the reservationId when a new NetworkRequest is created
  Add reservationId to NetworkCapabilities

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-12-12 16:08:35 -08:00
3a5b37a87c
Set the reservationId when a new NetworkRequest is created
This populates the reservationId with the value of the requestId when a
new NetworkRequest is created. Conceptually, the reservationId is not
related to the requestId; however, the requestId fulfills the same
uniqueness requirements that are needed for the reservationId, so it can
just be reused for this purpose.

Test: atest NetworkRequestTest
Change-Id: Icecb889a5269554add5791587f1ce7319271fd9e

Patrick Rohr   commited 2024-12-12 14:23:47 -08:00
06fa57b206
Add reservationId to NetworkCapabilities
The reservationId is an internal field used for RESERVATION requests and
acts much like an internal, unique NetworkSpecifier value. A
NetworkRequest with a reservationId set can be satisfied by a Network /
Offer with the same reservationId or an Offer with the wildcard {@code
RES_ID_MATCH_ALL_RESERVATIONS}.

Regular requests do not set the reservationId and match any Network /
Offer (except the blanket offer) independent of their reservationId.

Test: NetworkCapabilitiesTest
Change-Id: Id06116adf776dbf09cb9f8ccb7f25ff51734e02e

Patrick Rohr   commited 2024-12-12 14:18:54 -08:00
cb91a25bb7
Merge changes Id723dc9e,I3665d843 into main
* changes:
  Treat RESERVATION requests the same as REQUEST types
  Adds a new RESERVATION request type

Patrick Rohr   authored and   Gerrit Code Review   commited 2024-12-12 13:51:32 -08:00
b960664fa8
Merge "CaptivePortal: implement setDelegateUid API." into main
Xiao Ma   authored and   Gerrit Code Review   commited 2024-12-11 22:43:58 -08:00
69aa3c5469
Merge "Conditionally include VCN in Tethering module" into main
Yan Yan   authored and   Gerrit Code Review   commited 2024-12-11 10:41:55 -08:00
1f277bbab7
Merge "Clean up getAttributionTag" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-12-11 07:21:28 -08:00
d7f747dd4a
CaptivePortal: implement setDelegateUid API.
This API is designed to set the UID of the app that is allowed to
perform network traffic for captive protal login, communication will
bypass network access restrictions such as VPNs and private DNS settings
when a portal page is launched by Android Custom Tabs and bind the
upcoming traffic to that portal network.

Bug: 373773542
Test: atest ConnectivityCoverageTests
Change-Id: I9992671634b8e88f5a647455811a6157fb15a44b

Patrick Rohr   authored and   Xiao Ma   commited 2024-12-11 20:27:10 +09:00
7d6dfd52b2
Add SkipNativeNetworkCreation flag in NetworkAgentConfig
This flag allows ConnectivityService to skip native network creation,
deferring this responsibility to Tethering. This is necessary because:

- ConnectivityService requires the NetworkAgent to be in the CONNECTED
  state to configure routing and invokes NetworkCallback#onAvailable
  once ready.
- Tethering requires lower-layer interactions to be completed before
  notifying applications.

This approach ensures proper synchronization between ConnectivityService
and Tethering during network setup.

Long-term, all netd operations should be handled by ConnectivityService
when it supports early native network creation in the CONNECTING state.

As a mid-term solution, this flag enables Tethering to manage native
network creation within the IpServer.

Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.NetworkAgentConfigTest
Bug: 349487600
Change-Id: I84da9c74dc4d40c7cd36c6657f17a158affed689

Junyu Lai   commited 2024-12-11 15:22:36 +08:00
fef111ce47
Clean up getAttributionTag
This method is not needed anymore.

Test: TH
Change-Id: If7b1e58b7c07fa9d6a7323ea951eed73be4d56aa

Patrick Rohr   commited 2024-12-10 13:28:08 -08:00
25f22a9249
Adds a new RESERVATION request type
RESERVATION requests allow supporting networks which require a two step
configuration mechanism, such as IP over L2cap networks. In the case of
IP over L2cap, the NetworkProvider must first create a
BluetoothServerSocket to generate a PSM. That PSM must then be
communicated back to the app to be included in a BluetoothAdvertisement
before the network can be established.
Using a RESERVATION request eliminates the need for the side-channel
APIs that have historically been used to solve this problem. RESERVATION
requests are handled by "blanket" NetworkOffers which generate a
NetworkOffer specific to the rservation in response. The requests
includes a reservationId (copied from the requestId) in its
NetworkCapabilities which is considered in matching.

Test: TH
Change-Id: I3665d843fc3fa6dd6a7223eb84d7cf2fdeeea0a1

Patrick Rohr   commited 2024-12-10 13:28:08 -08:00
517c2e319d
Conditionally include VCN in Tethering module
When the build system flag RELEASE_MOVE_VCN_TO_MAINLINE is true,
VCN framework lib will be included in the tethering boot classpath
fragment and the VCN service lib will be included in the
service-connectivity.jar

Bug: 375213246
Test: flag enabled: VCN libs are in the tethering module
      flag disabled: VCN libs are in the platform
Flag: RELEASE_MOVE_VCN_TO_MAINLINE
Change-Id: If0239eb1684b861b63794762915dab0d62379885

Yan Yan   commited 2024-12-09 12:04:12 -08:00
b4ccc6aff7
Merge "Add a new module-only API to preload HttpEngine" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-11-29 05:10:06 +00:00
c3a2764012
Merge "Expose Connectivity libraries to VCN and tests" into main
Yan Yan   authored and   Gerrit Code Review   commited 2024-11-27 00:34:33 +00:00
e0e0636fa9
Sort framework-connectivity-defaults libs alphabetically
Test: TH
Change-Id: I1ed2c8a023b79d044c82e5a0b52a96d0a535b996

Yuyang Huang   commited 2024-11-25 12:31:48 +09:00
ee0a07cfd9
Expose Connectivity libraries to VCN and tests
This patch exposes Connectivity libraries to allow migrating VCN to
its own non-updatable framework and service libraries. It also
creates a utility library for VCN.

Bug: 369703242
Test: atest FrameworksVcnTests && atest CtsVcnTestCases
Flag: EXEMPT no functional change
Change-Id: I1981f1cc824dcf426a76a0af8e4e3460fccb754e

Yan Yan   commited 2024-11-23 23:07:44 -08:00
587f996eb4
Add a new module-only API to preload HttpEngine
This is supposed to be used only from the Zygote during the
initialization phase to preload HttpEngine. Currently, the
implementation only preloads a single class which is used to initialize
the backend for HttpEngine.

Bug: 380349437
Change-Id: If3ebcb37e51104a69473491e9f230d1b043c7bd0

Mohannad Farrag   commited 2024-11-22 10:50:11 +00:00
5023143dcf
NetworkAgent: Log a metric if a message is queued before registration
It should not be valid to queue messages before
registering a NetworkAgent, but the current design
makes it possible in practice. Log a metric so
that we have a handle on whether or not anybody
is doing this in the field.

Bug: 296355968
Test: manual
Change-Id: I83ea92e39a860cebe58d1d82cb024313e244b9aa

Arjun Dhaliwal   commited 2024-11-21 05:41:16 -08:00
0b1a7b8c98
Add FrameworkConnectivityStatsLog for logging metrics
Introduced FrameworkConnectivityStatsLog within the
framework-connectivity module. This enables logging of metrics, such as
terrible error events, from components residing in the bootclasspath.

Test: manual
Change-Id: I478d957b06721b35135a45dbbcda72a2c3e9f9ce

Yuyang Huang   commited 2024-11-21 11:51:58 +00:00
1cc7769bbe
Merge "Fix comment" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2024-09-12 15:51:40 +00:00
fcfe907cb4
Merge "Make java_sdk_library dependencies explicit" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-10 19:12:45 +00:00
430a8ad33c
Make java_sdk_library dependencies explicit
modules should specify the submodule of java_sdk_library that the module
actually depends on

Test: CI
Bug: 358613520
Change-Id: I0367068c901df98483f6cf95160d3e7801881b0a

Jihoon Kang   commited 2024-09-10 00:01:31 +00:00
8401b6a9f0
Add NetworkStack to framework-connetivity and framework-tethering impl lib visibility
As NetworkStackApi*Shims modules defined in
packages/modules/NetworkStack depends on the impl libs of
framework-connectivity and framework-tethering

Test: m nothing
Bug: 358613520
Change-Id: I5c90d4ae6eeb51f42f1ae1c88dd726bfdcd093e8

Jihoon Kang   commited 2024-09-09 22:55:01 +00:00
e7cae17b3a
Skip TestDropPacketToVpnAddress if the feature is disabled
INGRESS_TO_VPN_ADDRESS_FILTERING is disabled due to b/352424251 and
testDropPacketToVpnAddress fails if the feature is disabled.
So skip testDropPacketToVpnAddress if the feature is disabled.

Bug: 362434644
Test: adb shell device_config put tethering
      ingress_to_vpn_address_filtering -1
Test: atest CtsHostsideNetworkTests

Change-Id: Ib16a7550dcf93dd9ecf29047b1c4f101ff6d610d

Motomu Utsumi   commited 2024-09-02 15:21:30 +09:00
9d5d7d0779
Use java_aconfig_library for android_core_networking flags
Connectivity repo now can use java_aconfig_library since this target is
available on all downstream branches.

This CL removes framework-connectivity-t-mdns-standalone-build-sources.
Files in this target use flags which won't be available in the
out-of-tree build but the next out-of-tree library import will not use
the classes in that filegroup anymore.
So the standalone build rule will still match the out-of-tree build.

Bug: 345121279
Test: TH
Change-Id: I2a9aa02bd0c9aa00d460f98cd51d5dec4098fb89

Motomu Utsumi   commited 2024-08-16 16:57:29 +09:00
2fc115491a
Add boilerplate code for CertificateTransparencyService
Flag: com.android.ct.flags.certificate_transparency_service
Bug: 319829948
Test: m
Change-Id: I69dd1b7346a013e9a990c9ae8cec1beb51be074d

Sandro Montanari   commited 2024-08-12 08:50:29 +00:00
9ffc0685d7
Merge "Support NetworkStats#addEntries API" into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-08-09 10:06:03 +00:00
a7511c2318
Support NetworkStats#addEntries API
Currently, NetworkStats#addEntry creates a new instance
containing the requested result instead of mutating the
original object. This creates a heavy memory footprint
when the caller invokes it in a loop because a new NetworkStats
instance is created whenever an addEntry is called.

This change introduces a new API that allows callers to
add a set of entries to a NetworkStats instance. This new
API will clone the instance only once, return the newly
created (and modified) instance, and ensure that the original
instance remains immutable.

Additionally, the change adopts config libraries for flagging
the API and corresponding CTS tests, since Android U-based
branches are no longer downstream of current development branches.

Test: atest FrameworksNetTests:android.net.connectivity.android.net.netstats.NetworkStatsApiTest
Test: atest CtsNetTestCases:NetworkStatsApiTest
Bug: 335680025
Fix: 357772271
API-Coverage-Bug: 357772271
Change-Id: I58513844e681c0621a6107ec4b198cd3957f289d

Junyu Lai   commited 2024-08-09 14:19:38 +08:00
d0e049455c
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
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
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
Add framework-connectivity-pre-jarjar-without-cronet
This is required to build cronet against ConnectivityManager hidden APIs
Since framework-connectivity contains cronet, cronet target can not
depend on framework-connectivity.
So this CL splits framework-connectivity-pre-jarjar.
Cronet target can depend on
framework-connectivity-pre-jarjar-without-cronet and use
ConnectivityManager hidden APIs.

Test: TH
Bug: 311792075
Change-Id: Ib7724e8e6bd0226b437ed6f0010658d45aaa1150

Motomu Utsumi   commited 2024-07-24 17:01:51 +09:00
4d25564865
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
Fix comment
framework-connectivity is in the bootclasspath on S+, while framework-connectivity-tiramisu is in the bootclasspath on T+.

This is consistent with the RequiresApi annotations in this class.

Change-Id: I619759aa1c714738f988f77fd8fcb9de4b1ffdbf
Test: comment only change

Patrick Rohr   commited 2024-07-10 17:16:56 +00:00
e7c1b6289c
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
Refactor staticlibs
This CL introduces net-utils-framework-connectivity, net-utils-tethering
and net-utils-service-connectivity as staticlibs.

- net-utils-framework-connectivity will be used by
  framework-connectivity-pre-jarjar.
- net-utils-service-connectivity and net-utils-tethering are the
  static liraries used by service-connectivity-pre-jarjar and Tethering
  respectively.

Bug: 350699020
Test: CI

Change-Id: I4dbb2b0de905a576cfcf24d2d5d1f1a261d2bd68

Handa Wang   commited 2024-07-05 05:26:46 +00:00
9b0df36ea4
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
Baseline Lint FlaggedApi violations
The Lint FlaggedApi checks are currently configured as warnings. Add
existing violations to baselines files to prepare for turning the
FlaggedApi checks into errors.

Bug: 303434307
Test: treehugger
Flag: EXEMPT not possible to flag baseline changes
Merged-In: I990ce57cd5cdac44ee8b93565b45aa15790ad697
Change-Id: I990ce57cd5cdac44ee8b93565b45aa15790ad697

Mårten Kongstad   commited 2024-06-20 09:05:51 +02:00
4ece737f4f
Update document for ApfCapabilities.hashCode()
Bug: 346468860
Test: TH
Change-Id: I608effa4b84fbd34461cbfd22afb5eef33bed139

Yuyang Huang   commited 2024-06-13 20:44:46 +09:00
bfe49e0844