This is a resubmit of
I0fd90716b9f5501bdcdc7ee5165321737a0076ae
which did not account for testing of this private method
in Telephony tests.
Also make the network agent registry two way to eliminate
reordering possibilities.
Test: ConnectivityCoverageTest, CtsNetTests
Change-Id: I9ca025b1369dcb1202f906d5cff79e3d935b40da
This is a trick to help mocking registerNetworkAgent without
having to import its return type. In the near future the
return type will be changed to a non-public class, which
can't be seen in CTS.
Really this shouldn't be necessary because only Connectivity
tests should mock ConnectivityManager, but the practice is
different and other mockers need this support.
See also aosp/3538922
Test: NetworkAgentTest
Change-Id: I3ac63d95d3830a3b413f9ad12b84ac426b63dd08
This reverts commit 70ede3260c.
Reason for revert: Likely culprit for b/402365566 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.
Change-Id: If72cc264c5e505348309c6c11dbbfd11adeaf31b
Chaitanya Cheemala (xWF)authored and Gerrit Code Reviewcommited 2025-03-11 06:05:49 -07:00
Also make the network agent registry two way to eliminate
reordering possibilities.
Test: ConnectivityCoverageTest, CtsNetTests
Change-Id: I0fd90716b9f5501bdcdc7ee5165321737a0076ae
This was causing issues with jobs execution using JobScheduler, in apps that don't request INTERNET permission.
Bug: 397348342
Flag: EXEMPT changes a compat flag
Change-Id: I1c421cbaff815ed761ec4c0da3ead942ddc55d5c
aosp/3502915 use this method from ConnectivityService to get socket
cookie that is required for closing QUIC connection.
Bug: 311792075
Test: m, boot
Change-Id: I17d8a4dd24cfb84e9b008b8eb87eedec67b29020
Motomu Utsumiauthored and Maciej Żenczykowskicommited 2025-03-03 17:23:04 -08:00
These were added to allow tests to build against flagged off APIs, in
legacy downstream branches that did not support the flagging
infrastructure and stripped out flagged off APIs from the stubs.
Flagged off APIs are part of the regular stubs in branches used today,
so this is not needed anymore.
Bug: 399365344
Test: atest
Change-Id: Ica7df0c5c9be39d9dca49e0114711a7c43125c3d
Remi NGUYEN VANauthored and Paul Duffincommited 2025-02-28 10:47:40 +00:00
This change is finally (!) adding a builder class for creating tun/tap
interfaces for testing.
The various create*Interface() methods which are not marked as
@SystemApi can be removed after moving existing tests over to the new
API.
Bug: 237694424
Test: TH
Change-Id: I10eff755ebda4e2ef2550a50a3bfd1543a21e5b0
The CL has caused a memory regression in the Zygote, See: b/396156852
Test: Compile
Bug: 396156852
Change-Id: I0ca4cd430a6537d689a1b04739656afc84c43ce1
As part of the major tethering refactor to associate every IpServer with
a TetheringRequest, tether()/untether() APIs should be completely
removed in B and all tethering should go through startTethering() (with
the exception of Wifi LOHS and Wifi P2P, which will move to
startTethering() in a future CL).
Bug: 216524590
Test: atest CtsTetheringTests TetheringTests
Change-Id: If7981f1ee7d80ff0a1cc0069ba7a4ebf79144160
Quang Anh Luongcommited 2025-01-15 08:59:42 +09:00
A server network is created by using ConnectivityManger#reserveNetwork,
in which the app passes a specifier that sets:
reservationRequest = {
role = server
headerCompression = 6lowpan
remoteAddr = any (null)
psm = any
}
This specifier must subsequently match the blanket reservation offer,
and the reserved offer that is generated as a response:
blanketOffer = {
role = server
headerCompression = any
remoteAddr = any (null)
psm = any
}
reservedOffer = {
role = server
headerCompression = 6lowpan
remoteAddr = any (null)
psm = 0x81
}
And not the client network offer or a client network:
clientOffer = {
role = client
headerCompression = any
remoteAddr = any (null)
psm = any
}
clientNetwork = {
role = client
headerCompression = 6lowpan
remoteAddr = 01:02:03:04:05:06
psm = 0x81
}
Similarly the client request must match both the clientOffer and
clientNetweork, but not the reservedOffer (and technically
blanketOffer):
clientRequest = {
role = client
headerCompression = 6lowpan
remoteAddr = 01:02:03:04:05:06
psm = 0x81
}
Note, a request for TRANSPORT_BLUETOOTH with no specifier matches *any*
specifier per specifier matching semantics in NetworkCapabilities.
Test: L2capNetworkSpecifierTest
Change-Id: Ia16926b463a54530ae6e88278466e92ed82bf852
This is an invalid combination that never seems useful. Note that this
still allows ROLE_ANY in combination with a remote address. This still
doesn't seem particularly useful, but there is no good reason to
disallow it.
Test: TH
Change-Id: Ib0b7284cb99ee92f14113f8184af978eeb2318e7
Per discussion on aosp/3429160.
"It doesn't look like knowing the PSM of an L2CAP network would give
other apps any sort of useful information. They don't have the MAC, and
there are only 128 ephemeral PSM values anyway."
Test: TH
Change-Id: Ia81c97dd2e31611fd2d13d5899390fc0c67b6c0f
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
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
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
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
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
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
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
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
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 Rohrauthored and Xiao Macommited 2024-12-11 20:27:10 +09:00
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
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