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
* changes:
Make function void and remove outdated TODOs
Remove mTetheringInterfaceHwAddr
Log mPort when restarting IpClient
s/getAllInterfaces/getAllEthernetPorts/g
Treehugger Robotauthored and Android (Google) Code Reviewcommited 2025-06-10 01:22:58 -07:00
b/236892130 has long been addressed and there is an existing integration
test (EthernetManagerTest#testRemoveInterface_whileInServerMode).
The second TODO is just wrong. removeInterface() does nothing when the
interface is currently in tethering/server mode which is expected.
EthernetTracker#removeInterface() correctly deals with both client and
tethering/server mode interfaces, and multiple tests exist that validate
the callback behavior.
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ib28a762e66997b31e2085cdda418a1e6b785dfcd
Since mTetheringInterface is now of type EthernetPort which contains the
MAC.
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I35d2f50e9a03459f1859f7754d999e21b8b2d351
Some devices are hitting limits, but these
maps are small.
Additionally one is indexed by app uid,
while the other by unix uid.
Where unix uid = nr Android users * nr app uids.
Give things a little bit more room for growth.
Also remove the useless constant from the .h,
most - if not all - of them should not be there.
Bug: 418664814
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I81227cc81e6a406120d669a1decef023df4590fe
Maciej Żenczykowskicommited 2025-06-09 15:17:01 -07:00
This adds a JNI function to retrieve an interface's driver name via
ethtool API, which will be used to identify USB NCM interfaces.
Unfortunately, SIOCETHTOOL (ETHTOOL_GDRVINFO in particular) does not
allow passing in the interface index, meaning that this operation is
racy, i.e. the interface might have been replaced when
getDriverNameForInterface() is called.
SICOETHTOOL is slowly being replaced by a netlink alternative that
allows querying by interface index but, unfortunately, does not support
ETHTOOL_GDRVINFO yet.
Test: verified manually; automated test will be added shortly.
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I8bec47e36a607e7d8fe2fac2eebcd8dff0360a02
(This is viable now that tethering prebuilt is from M-2025-07)
Test: TreeHugger
Flag: EXEMPT mainline
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6aa58dc052fb292080032ec21fc3a92d718407ca
Maciej Żenczykowskicommited 2025-06-09 08:23:06 -07:00
This is needed for counter-part modules to query data usage
with specified transport type.
Flag: com.android.net.flags.netstats_transport_type
Test: atest ConnectivityCoverageTests --test-filter \
'NetworkTemplate*' --update-device
Bug: 419123367
Bug: 420531377
Change-Id: I7778de815bec947be3e6abbd6269e1727de5c550
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
* changes:
Pass EthernetPort to EthernetNetworkFactory#updateInterfaceLinkState
Pass EthernetPort to updateInterfaceState
Remove spurious VisibleForTesting and change visibility to public
Pass EthernetPort to EthernetNetworkFactory#removeInterface
Pass EthernetPort to removeInterface
Pass EthernetPort to stopTrackingInterface
Add getEthernetPorts and use it in getAllInterfaces
Treehugger Robotauthored and Android (Google) Code Reviewcommited 2025-06-06 14:31:58 -07:00
* changes:
Rename getClientModeInterfaces to getClientModeInterfacesSorted
Rename getAvailableInterfaces to getInterfacesSorted
Pass EthernetPort into NetworkInterfaceState
Pass EthernetPort into EthernetNetworkFactory#addInterface
Patrick Rohrauthored and Android (Google) Code Reviewcommited 2025-06-06 12:17:33 -07:00
The visibility modifiers in this file are all over the place. In
general, I would like to get to private / public where possible so the
code becomes more readable.
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I2fb00abfd903083e0320fe33eeff2d40302440c7
This CL adds getEthernetPorts() to EthernetNetworkFactory which returns
an unsorted list of EthernetPorts tracked by the factory (including
restricted interfaces).
This method is then used inside getAllInterfaces(), which in turn is
called by setIncludeTestInterfaces() and setEthernetEnabled().
setIncludeTestInterfaces() is not used in production code, so the
interface order should not matter. However, with this change
setEthernetEnabled() will update the administrative state of the network
interfaces in unspecified order. It is hard to conceive that this could
break anything, given that when tracking multiple interfaces, link state
changes (which trigger the same InterfaceStateCallback) can already
naturally occur in any order.
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Iaf6810ec2fd784c16a9a09662282e81bc2070e37
The next change will add a getInterfaces() method which returns the
interfaces in any order.
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ic1a6e60d8a7e74a6d46e569f0d9045849fd0f8ed
This change includes:
1. addEvent Parameter Update: Added satisfied duration to
addEvent, making duration testable in CSTest.
2. CSDefaultNetworkRematchMetricsTest Refactor: Tests now use
expectAddEvent with argThat and InOrder for more deterministic
verification.
3. New Unit Test: Added a test to demonstrate a metrics reporting
issue during per-app default network request updates.
Test: atest ConnectivityCoverageTests --test-filter 'DefaultNetworkRematch*' \
--update-device
Flag: EXEMPT Test only refactoring
Bug: 419123367
Change-Id: I3c73b445674991f85e37b3f980fa80fb918713ac
mSatisfiedTime now initializes with the current time upon NRI
creation, or copied when the copy constructor is called.
Test: atest ConnectivityCoverageTests --test-filter 'NetworkRequestInfo*' --update-device
Flag: EXEMPT controlled by kill switch
Bug: 419123367
Change-Id: If707b96bf6ce5c6cb0287d5c2d6056591dd6769f
The netd dependency can be removed in a follow up change. Since the only
entrypoint to addInterface() is now EthernetNetlinkMonitor which calls
both addInterface() and updateInterfaceState(), the "IF_FLAG_RUNNING"
check inside addInterface() is no longer needed.
Also note that this change relies on the representation of
getMacAddress().toString() to match what netd returns. Configuration by
MacAddress is almost solely used by automotive devices which do not take
mainline, so making this change is relatively low-risk. In the unlikely
case automotive OEMs are broken by this, they have time to fix their
config overlays.
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I9a57bb8693568a1bbb1ade86c06613134b40532c
Note that the comparison is still solely based on interface name.
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: Ifbeb11872dc503957e08af0d8c18c3dfebb31703
This reverts commit a77d5ac126.
Reason for revert: Droidmonitor created revert due to b/422782308. Will be verifying through ABTD before submission.
Fix: 422782308
Change-Id: I00825e0f17a9a9e0d152ac8ebe767da3f267fbb1
Have TestableNetworkCallback adopt it, as a first client. It's also by
far the most complex.
Test: TH
Flag: EXEMPT test-only
Change-Id: Ifd636a09d0695f04b17330c4987f2b7b742508fa