* 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 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
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
This change introduces the `DefaultNetworkRematchMetrics`
class to collect and log data about default network reassignments.
The primary motivation is to monitor the behavior of satellite
networks when they act as a default network fallback. This class
records an event whenever a default network request with the
`PREFERENCE_ORDER_SATELLITE_FALLBACK` preference is moved from
one network to another.
For each reassignment, a `DEFAULT_NETWORK_REMATCH` atom is logged
to ConnectivityStatsLog. This atom includes detailed `NetworkDescription`
protos for the old and new networks, capturing their transport
types, capabilities, and metered/validated states. It also logs
the duration the device spent on the previous network.
Sample metrics:
event_metrics {
data {
aggregated_atom_info {
atom {
default_network_rematch {
session_id: 1099094483789245667
rematch_reason: RMR_UNKNOWN
default_network_rematch_info_list {
default_network_rematch_info {
old_network {
transport_types: 1
metered_state: METERED_YES
validated_state: VS_VALID
score_policies: -4575657221408423932
capabilities: 137711448064
enterprise_id: 0
}
time_duration_on_old_network_sec: 9
uid_ranges {
uid_range {
begin: 10137
end: 10137
}
}
}
}
}
}
elapsed_timestamp_nanos: 73821951490
}
}
}
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.metrics.DefaultNetworkRematchMetricsTest \
--update-device
Test: Manual:
1. Change code to use TRANSPORT_CELLULAR
2. m statsd_testdrive && statsd_testdrive -e 525
3. Turn off mobile data.
Flag: EXEMPT controlled by kill switch
Bug: 419123367
Change-Id: I40ba78d81cd30b2dc783e855aa76e776f76ace98
Test interface tracking is already covered by EthernetManagerTest (in
fact, that test relies heavily on this functionality), so it does not
need to be part of EthernetTrackerTest. Additionally, both
isValidTestInterface() and setIncludeTestInterfaces() are trivial
functions that do not improve coverage significantly. Long-term, the
ethernet unit tests should be reimagined as more of a module-wide unit
test, rather than testing individual classes. This will make the tests
much more valuable and could allow testing scenarios that are not
possible in a end-to-end integration test.
Test: TH
Flag: EXEMPT mainline
Bug: 1000001
Change-Id: I94540b6e7b94b1de00965f4e54393d573788c59a
The previous implementation used a fixed start timestamp for
querying network usage statistics, initialized based on the
device's boot time. This caused the query window to grow
indefinitely as the device uptime increased, leading to
inefficient queries that fetched and processed a large
ever-expanding amount of historical data.
This change refactors the logic to use a rolling start
timestamp. The `mStartTime` is now updated after each
usage report is generated (in `onLost`). By resetting
the start time to a more recent point (current time
minus one bucket duration), we ensure that subsequent
queries for usage snapshots are performed over a small,
manageable time window.
This optimization prevents fetching excessive data
from the NetworkStatsManager, improving the efficiency
of the metrics collector. Dependencies for time and
duration have also been abstracted for better testability.
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.metrics.SatelliteCoarseUsageMetricsCollectorTest \
--update-device
Flag: EXEMPT controlled with kill switch
Bug: 419123367
Change-Id: I49d3b044f0a038093060f5541ea263d2d0d253a2
* changes:
Destroy sockets lacking permission at CS.
Destroy sockets with nlmsg RTM_DELADDR
Destroy sockets with NetworkAgent update event
Add a Map to NetworkAgent list for IP address
Add socket destroying methods to InetDiagMessage.
Sewook Seoauthored and Android (Google) Code Reviewcommited 2025-05-30 16:00:11 -07:00
Destroy sockets that matched to netId less than MIN_NET_ID for the non
link local address in RTM_DELADDR.
Destroy sockets on link local address with the corresponding interface
ID.
Bug: 373280981
Bug: 331139818
Flag: android.net.platform.flags.connectivity_service_destroy_socket
Test: atest ConnectivityCoverageTests
Test: device test
Change-Id: I4d8127fc693f8b32f815c5cddbae0b64deeb23e5
Destroy platform managed sockets on the removed IP address based on NetworkAgent update.
Bug: 373280981
Bug: 331139818
Flag: android.net.platform.flags.connectivity_service_destroy_socket
Test: atest ConnectivityCoverageTests
Test: device test
Change-Id: I6a1d2d0c25c130c2747d66bee203b0408e2fa0da
Keeping a map from IP addresses to the list of NetworkAgentInfos that have
that IP address in their LinkProperties.
Bug: 373280981
Bug: 331139818i
Flag: android.net.platform.flags.connectivity_service_destroy_socket
Test: atest ConnectivityCoverageTests
Test: device test
Change-Id: I1e39ce00d8bc49252df8088efc768804ae9ee0a8
Moves the parameterized variable into the test class constructor for cleaner initialization
and improved test flexibility.
Flag: EXEMPT mainline
Bug: 410976315
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.MultinetworkPolicyTrackerTest
Change-Id: Iab1388850d3a7c1f8872ad5a561023a8487f006f
This change updates NetworkIdentity to have NetworkCapabilities
transport types for improved network identification, and updates
NetworkIdentitySet for backward compatibility with older data.
Flag: EXEMPT implemented in the counter-part CL
Test: atest ConnectivityCoverageTests --test-filter \
'NetworkIdentity*' --update-device
Test: atest ConnectivityCoverageTests --test-filter \
'NetworkStats*' --update-device
Bug: 419123367
Change-Id: I26cc770d90b4687d832dd029d9a11db03404db39
When the packet is too large to be sent it may cause the socket to throw
an error. This commit truncates the additional records in this case.
Bug: 407609792
Test: CI
Flag: EXEMPT bugfix
Change-Id: I77a979d7f8799f05cbcb14857061a18aecfef657
This reverts commit 7b7cfa45a6.
Reason for revert: prevents crash with no carrierConfigManager support
Test: atest ConnectivityCoverageTests
Change-Id: I9e91d2d25d16c0c2a39388f08a49bef7b17fda42
This reverts commit b936f0c5fd.
Reason for revert: Droidmonitor created revert due to b/418898788. Will be verifying through ABTD before submission.
Fix: 418898788
Change-Id: Ia47f0cc9a33ed33f9d53064878992081a792f1ad
Currently, the CarrierConfigManager is null on several non-phone
projects, e.g. tv, wear devices. This is because CarrierConfigManager
is not supported on these devices.
This change checks whether it is null and improve error handling.
Flag: android.net.platform.flags.avoid_bad_wifi_from_carrier_config
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.MultinetworkPolicyTrackerTest \
--update-device
Fix: 416654774
Change-Id: I40fa7139a349472b1d5cbd36b5bff286309aebc5
This class doesn't actually serve a purpose, it only makes
TestableNetworkCallbck more complex.
Test: CtsNetTestCases ConnectivityCoverageTests
Flag: EXEMPT test-only
Change-Id: I39a598b82a3215384bdfe04980f4b280ab2c2716
This patch adds EthernetPortInfo class which represents information of
an EthernetPort object.
This class is mainlt used in network callbacks.
Bug: 397536853
Test: atest ConnectivityCoverageTests
Flag: EXEMPT mainline
Change-Id: I8ab9fa934a710080163d951bb6619050ca38a2ee