The existing NetworkCapabilities class redacts only TransportInfo and
leaves NetworkSpecifier as it is. This is counter-intuitive and the
specifier should be redacted along with TransportInfo as well.
Bug 374037595
Flag: NONE this has no behavior change for all existing
NetworkSpecifier subclasses because they are not overriding the
new NetworkSpecifier redaction methods
Change-Id: I73c880add1604afc8b56190647305a54e89e8e53
Add a new hidden inner class NetworkCapabilities.RedactionHelper for
accessing conditionally available NetworkSpecifier methods via
reflection.
Reflection is necessary because NetworkSpecifier is platform code. So
it's possible for a mainline update to define a
getApplicableRedactions() or redact(long) method in a subclass of
NetworkSpecifier (e.g., EthernetNetworkSpecifier), and then to run
that mainline module on an Android release where the
NetworkSpecifier base class does not have those methods. On such a
device, ConnectivityService must still call those methods if they
exist, otherwise it would fail to redact information that needs to
be redacted. Another way to do this would be for ConnectivityService
to just call the method and catch NoSuchMethodError, but this code
runs fairly often and constructing exceptions is expensive.
This class is not used in this CL but will be used for NetworkSpecifier
redaction in ag/34242202 and ag/34242203
Bug 374037595
Flag: NONE new code nerver used
Change-Id: I8f88c6bb105ebf8d485e18cd214bebf2abe67e63
This reverts commit f2cb190a73.
Reason for revert: This is the integration test CL, it will break due to ag/34545776 reverted.
Change-Id: I5fc66fab409989479078dfcffea7793b9d6dd749
Yuyang Huangauthored and Android (Google) Code Reviewcommited 2025-07-13 22:23:21 -07:00
This will allow portal operators to opt-in to custom tabs in
captive portal, either across the board with "true" or with
a version of the module above which it wants to opt-in.
Ideally there could be a separate key to also list opted-in
browsers and their versions, but this would become a lot
more complex. To start with, there is no place in
CaptivePortalData to store this kind of info, and that would
mean adding API which would have to be supported forever.
The constant inside the source represents a capport source that
contains the custom tabs opt-in. This is not a great place to put
this information in, but it has the characteristics of a benign and
useful hackĀ :
- Time to market is 0
- It's easy to remove once we have a better API
- It's not a large problem if it's never cleaned up
Also, allowing to choose the browsers and the versions would
be uncomfortable since the choice of the browser is the user's
choice. On the one hand it does make some sense that the
operator could test with a given browser, see the UX is not
well adapted, and reject it, but on the other hand giving the
operator the choice of what browser the user can choose to
use on their portal is disputable, as this should generally be
under the control of the user.
In any case even if we decided to add a per-browser version
check it should be done in some other change.
Test: manual
Flag: EXEMPT opt-in feature
Change-Id: I540f4fcb6fb26f7f18077d9c8d06e5f7df206056
The test cases were incorrectly attempting to reset "network_carrier_aware_avoid_bad_wifi"
instead of "network_carrier_aware_avoid_bad_wifi/1" for specific subIds.
This commit corrects the key.
Flag: EXEMPT mainline
Bug: 425170385
Test: atest CtsNetTestCases:android.net.ConnectivitySettingsManagerTest --iterations 100
Change-Id: Iee9273faa77a68af2a75fe3c37ee6f3b2435cbf1
Breaks out the `network_carrier_aware_avoid_bad_wifi` setting from a single
string key into individual `Global.Settings` entries per subscription ID.
Flag: EXEMPT mainline
Bug: 424330991
Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.ConnectivitySettingsManagerTest
Change-Id: Ida673c1b8b915719b8e64ea85a66c2b98862e5f5
This commit introduces new system APIs to manage "avoid bad Wi-Fi" settings,
leveraging both global system settings and carrier configurations. This
enhancement allows for more granular control and visibility into how Wi-Fi
networks are managed, especially in multi-SIM environments.
The new `setNetworkAvoidBadWifi(Context, int subId)` method provides
the ability to programmatically control this setting based on carrier-specific
policies or user preferences. This complements `getNetworkAvoidBadWifi(Context, int subId)`,
which allows querying the setting for a specific subscription ID, ensuring the
system can accurately determine the avoid bad Wi-Fi status.
Additionally, `shouldShowAvoidBadWifiToggle(Context, int subId)` is introduced.
This method determines whether the 'Avoid Bad Wi-Fi' user interface toggle
should be displayed. It considers both global settings and carrier configurations,
allowing for dynamic UI adjustments based on carrier requirements or user preferences.
These changes provide greater flexibility for managing Wi-Fi network selection
and improve the user experience by offering more context-aware control over
cellular behavior.
Deprecated APIs:
- `setNetworkAvoidBadWifi(Context, int value)`
- `getNetworkAvoidBadWifi(Context)`
New APIs:
- `setNetworkAvoidBadWifi(Context, int subId, int value)`
- `getNetworkAvoidBadWifi(Context, int subId)`
- `shouldShowAvoidBadWifiToggle(Context, int subId)`
Flag: com.android.net.flags.carrier_aware_avoid_bad_wifi
Bug: 410976315
Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.ConnectivitySettingsManagerTest
Change-Id: I79469cfe865a585593219d226c8198206c06b589
This is needed for counter-part modules to query data usage
with specified transport type.
This is kept hidden and will be exposed in follow-up
CLs.
Flag: EXEMPT controlled in the counter-part CL
Test: atest ConnectivityCoverageTests --test-filter \
'NetworkTemplate*' --update-device
Bug: 419123367
Bug: 420531377
Change-Id: I503b4d7307d008a64a14aa713d9714428e399809
This change verifies that:
1. For a given match rule, if transports are specified, a deduced
transport type should be included. For example, if MATCH_WIFI
is specified, TRANSPORT_WIFI should be included if at least one
transport is specified.
Flag: EXEMPT implemented in the counter-part CL
Test: atest ConnectivityCoverageTests --test-filter \
'NetworkTemplate*' --update-device
Bug: 419123367
Change-Id: Ic8375e50c3587ef2b757d1c3241f97482d93808b
This class doesn't actually serve a purpose, it only makes
TestableNetworkCallbck more complex.
Test: CtsNetTestCases ConnectivityCoverageTests
Flag: EXEMPT test-only
Change-Id: I39a598b82a3215384bdfe04980f4b280ab2c2716
Though all versions will parcel this, the behavior will not change
before B. Starting with B, this flag is parceled and handed over
to apps.
Test: ConnectivityCoverageTests, CtsNetTestCases
Flag: EXEMPT no behavior change before B
Change-Id: I7e9ae9011c74b80c208d8f297aa3b7d1aea176f2
Chalard Jeanauthored and Xiao Macommited 2025-04-07 11:46:38 +09:00
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
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
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
When new capability is introduced and added to capaility or
forbiddenCapability by default, module rollback could cause system
server crash since JobScheduler persists network request that contains
new capability that is invalid for old code.
This CL updates capability validation not to throw exception to avoid
system crash in this case.
Bug: 343823469
Bug: 313030307
Test: NetworkCapabilitiesTest
Change-Id: I5708c475f3b4974284531212b77f9788ca9f497e
This commit adds support of registering a public key for a host/service.
This is required to enable Advertising Proxy feature for Thread devices.
For example:
```
NsdServiceInfo info = new NsdServiceInfo();
info.setServiceName("My Service");
info.setServiceType("_test._tcp");
info.setHostname("MyHost");
info.setHostAddresses(List.of(address1, address2));
info.setPublicKey(/* KEY RDATA */);
nsdManager.registerService(info, PROTOCOL_DNS_SD, listener);
```
Bug: 317946010
Change-Id: I367ebff8119d5c1dff0410c85e6fb86dca6c66b8
- Allow adding two non test transports i.e. satellite and cellular
at setNetworkSpecifier, to receive network requests related to
satellite transport capabilities
Bug: 324347502
Test: atest FrameworksNetTests
Change-Id: I03a3d701e214792184bacfe5b5b59cdef61d555e
This commit adds support of regsitering a service with a custom
hostname. This is required to enable Advertising Proxy feature for Thread
devices.
For example:
```
NsdServiceInfo info = new NsdServiceInfo();
info.setServiceName("My Service");
info.setServiceType("_test._tcp");
info.setHostname("MyHost");
info.setHostAddresses(List.of(address1, address2));
nsdManager.registerService(info, PROTOCOL_DNS_SD, listener);
```
This CL also adds two new error codes for service/host registration
conflict: `FAILURE_SERVICE_NAME_CONFLICT` and
`FAILURE_HOST_NAME_CONFLICT`.
Bug: 284904661
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: I2fb974c38d851ba99144a18c7047084bbd61b938
This commit adds support of advertising and discovering services
with subtypes.
With this change, client can publish a new service with subtypes with
code:
```
NsdServiceInfo info = new NsdServiceInfo();
info.setServiceName("My Service");
info.setServiceType("_meshcop._udp");
info.setSubtypes(Set.of("_abc"));
nsdManager.registerService(info, PROTOCOL_DNS_SD, listener);
```
Bug: 265095929
Test: atest CtsNetTestCases FrameworksNetTests
Change-Id: Ia83182e2d43002243d1ef4357d14a8056d7da14b
Remove the Q test annotation/check since mainline updates does
not push to Q anymore. This annotation is unnecessary now.
Test: atest FrameworksNetTests
Change-Id: Iba4f38731db9f369f99ba12a3ab7ef3f3b1630b8
The platform doesn't allow overwriting compat flags that have target SDK
lower than the platform SDK in release build. Ignoring the test cases
that need compat flag overwrite up to S_V2 makes the MTS pass on S
device.
Bug: 296248982
Test: TH
Change-Id: Iab102725004c39b4dc3c0200c9bc673dd6be1302
Fix kotlin nullable errors that were exposed by setting the retention
of android.annotation.NonNull and android.annotation.Nullable to
class retention.
Bug: 294110802
Test: builds
Change-Id: Id49e4a2ee0b7b463d99bce6eb22919b84c21443a
Tests verifies the behavior with v4 mapped v6. The
taken parameter should be a v6 address. However,
InetAddresses.parseNumericAddress() will translate a v4
mapped v6 address into v4. This does not actually test
the behavior. The constant should be created via
Inet6Address.getByAddress() so that it will be an
expected Inet6Address.
Bug: 291869581
Test: atest NattKeepalivePacketDataTest
w/ and w/o aosp/2626269
Change-Id: I2f086f0fe7d1dd038f5d850f2281deb807c837cf
The testConstructor_afterR is a new added test which should be
run with latest connectivity module, but some test combinations
do not contain latest connectivity module which will fail the
test. Add ConnectivityModuleTest annotation to skip combinations
without latest connectivity module.
Bug: 287226038
Bug: 196453719
Test: atest ConnectivityCoverageTests
Change-Id: I16dfa8f86f77bb3561a24684e7823f8d45b7613d
chiachangwangauthored and Chiachang Wangcommited 2023-06-15 02:20:44 +00:00
This is a part of preliminary work for sending a v6 NAT-T
keepalive packet in a v6 only network. This commit
release the constraint on constructing a v6 NAT-T keepalive
packet.
Bug: 196453719
Test: Manually connect to v6 only network and check if the
keepalive packets are sent with subsequent commit
Test: atest FrameworksNetTests with the updated test
Change-Id: I9dc96e840265c5dee6b9e3ef2b3901a0aeb4ff9e