Commit graph android_packages_modules_Co.../framework
Message SHA1
Add MatchNonThreadLocalNetworks flag in NetworkCapabilities
This is for backwards compatibility. Apps targeting V or lower
SDK should not see Tethering network agent.

This restriction is still disabled to maintain no-op in this
change. Will be enabled when introducing ConnectivityService
part in the subsequent change.

Test: atest CtsNetTestCases:android.net.NetworkCapabilitiesTest \
      ConnectivityCoverageTests:android.net.connectivity.com.android.server \
      --update-device
Bug: 349487600
Change-Id: I99405ab62e82ff4b7fcebffd3a1a31ec6d8962a9

Junyu Lai   commited 2025-03-21 10:36:41 +08:00
f3ae766e8e
Remove the queue on the NetworkAgent side
Now that the system server has a queue doing this job,
the queue on the network agent side can be removed.

Test: ConnectivityCoverageTests, CtsNetTestCases
Change-Id: Idf0435f447cfdd28d829a867d1085771837c6f9b

Chalard Jean   commited 2025-03-18 19:23:57 +09:00
391ec5d99c
Reapply "Return the registry in registerNetworkAgent."
Now that faulty Telephony tests have been disabled temporarily
to allow for this bugfix, this can be reverted.
This reverts commit 653d5f1ef4.

Test: FrameworksTelephonyTests CtsNetTestCases
Change-Id: If6b1541981803dc84de57b48adb13d40c9997fa0

Chalard Jean   commited 2025-03-18 14:42:39 +09:00
8a97692638
Revert "Return the registry in registerNetworkAgent."
Revert submission 3535182

Reason for revert: <Droidmonitor created revert due to b/404070202.Will be verified through ABTD for standard investigation.>

Reverted changes: /q/submissionid:3535182

Change-Id: I2febd2ee7227d487d9cd69dcabd9c04f888fd2de

Pechetty Sravani (xWF)   commited 2025-03-17 00:48:05 -07:00
653d5f1ef4
Return the registry in registerNetworkAgent.
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

Chalard Jean   commited 2025-03-14 13:23:50 +09:00
80d4326d76
Add a method to help mocking registerNetworkAgent
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

Chalard Jean   commited 2025-03-14 13:23:37 +09:00
8fd6347d35
Revert "Return the registry in registerNetworkAgent."
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 Review   commited 2025-03-11 06:05:49 -07:00
846fb39e8a
Return the registry in registerNetworkAgent.
Also make the network agent registry two way to eliminate
reordering possibilities.

Test: ConnectivityCoverageTest, CtsNetTests
Change-Id: I0fd90716b9f5501bdcdc7ee5165321737a0076ae

Chalard Jean   commited 2025-03-11 16:26:17 +09:00
70ede3260c
Change NETWORK_BLOCKED_WITHOUT_INTERNET_PERMISSION ChangeId to target 37+
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

Sandeep Bandaru   commited 2025-03-05 02:38:22 -08:00
597a64fc23
Merge "Add method to get socket cookie from socket FileDescriptor" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-03-03 20:55:49 -08:00
c088b301a8
Add method to get socket cookie from socket FileDescriptor
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 Utsumi   authored and   Maciej Żenczykowski   commited 2025-03-03 17:23:04 -08:00
b9b8828bf5
Remove -stubs-including-flagged
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 VAN   authored and   Paul Duffin   commited 2025-02-28 10:47:40 +00:00
df5441508e
Merge "Revert "Add SkipNativeNetworkCreation flag in NetworkAgentConfig"" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-02-26 03:02:34 -08:00
689297411a
Revert "Add SkipNativeNetworkCreation flag in NetworkAgentConfig"
This reverts commit fef111ce47.

Reason for revert: Replaced by early native network creation

Change-Id: I692f716d8651badf6d0037e55a2385d0fb0049d1

Junyu Lai   authored and   Gerrit Code Review   commited 2025-02-26 01:30:20 -08:00
b04a8048a1
Merge "Move server reservation validation to L2capNetworkSpecifier" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2025-02-25 14:20:23 -08:00
3687f0e65e
Merge "Move client request validation to L2capNetworkSpecifier" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2025-02-25 14:18:19 -08:00
47669ff8e4
Move server reservation validation to L2capNetworkSpecifier
Test: TH
Change-Id: If0abf62bf008750d67d3687e5f59734421cce7cf

Patrick Rohr   commited 2025-02-25 09:26:08 -08:00
0508c94e14
Move client request validation to L2capNetworkSpecifier
Test: TH
Change-Id: Ied1af7edc60a0df01d820c2e81e16de980eb526f

Patrick Rohr   commited 2025-02-25 09:20:40 -08:00
bf65974835
Delete unused createTapInterface method
Test: TH
Change-Id: Ia273344ffa26feec78e400e2df3e890081a15a23

Patrick Rohr   commited 2025-02-24 09:19:44 -08:00
95d7f5b56b
Delete unused createTapInterface method
Test: TH
Change-Id: Iab107c5804204295e714775b3b026a8e64795378

Patrick Rohr   commited 2025-02-24 09:19:44 -08:00
d14f094e12
Replace createTapInterface() with new Builder API
Test: TH
Change-Id: I5d5bcafb2b91dd31b7d2aa71f62279ab79d971bf

Patrick Rohr   commited 2025-02-24 09:19:44 -08:00
2bef486f76
Replace createTapInterface() call with new Builder API
Test: TH
Change-Id: I0d96bfa39a378a8dcc03c2366c332ae5eb8e69d6

Patrick Rohr   commited 2025-02-24 09:19:44 -08:00
f8471445dc
Add configuration object and builder for creating tun/tap interfaces
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

Patrick Rohr   commited 2025-02-21 13:56:02 -08:00
fe058c60b4
Update lnp app compat to be enabled after cur development version
Bug: 376030323
Test: atest CtsNetTestCases

Change-Id: I7345ac2a08d21d1226ff8607ce1edf44f0946859

Jacque Li   commited 2025-02-19 08:40:49 -08:00
8331a79292
Revert https://r.android.com/3477936
The CL has caused a memory regression in the Zygote, See: b/396156852

Test: Compile
Bug: 396156852
Change-Id: I0ca4cd430a6537d689a1b04739656afc84c43ce1

Mohannad Farrag   commited 2025-02-18 18:32:23 +00:00
e0b119773c
Merge "Add metric to HttpEngine preload" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2025-02-11 15:13:22 -08:00
02574fa4dc
Adding access methods for local_net_access_map and
local_net_blocked_uid_map

Test: Manually tested this using dumpsys commands
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.BpfNetMapsTest
Bug: 392855578

Change-Id: I61522f3282aa502f20641d3c2692a66638edf706

Sarup Dalwani   authored and   Jacque Li   commited 2025-02-07 15:10:49 -05:00
448eb43f28
Add metric to HttpEngine preload
See the other CLs in the same topic for the details.

Test: See other CL
Bug: 380349437
Change-Id: I4b936e3d834462bba5a368d6dd1a1e262c17f0c9

Mohannad Farrag   commited 2025-02-06 15:27:57 +00:00
b09cd9e50c
Merge "Add toString to L2capNetworkSpecifier" into main
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2025-01-15 17:46:18 -08:00
074b213907
Disallow legacy tether() API starting in B
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 Luong   commited 2025-01-15 08:59:42 +09:00
30d8a25db3
Add toString to L2capNetworkSpecifier
Test: TH
Change-Id: Ie874fe7e54990e9dc94fe8e4a28034b5ec2a1bd4

Patrick Rohr   commited 2025-01-13 13:57:20 -08:00
080c91309f
Implement matching semantics for L2capNetworkSpecifier
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

Patrick Rohr   commited 2025-01-10 14:46:54 -08:00
74a8f475b2
Do not allow L2CAP specifier with ROLE_SERVER and remote address set
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

Patrick Rohr   commited 2025-01-10 08:57:03 -08:00
5e61925e51
Do not redact PSM from L2capNetworkSpecifier
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

Patrick Rohr   commited 2025-01-08 15:57:47 -08:00
7faa0b486c
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