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
Inet4Address#isLinkLocalAddress can also return true if the address is
in the 169.254.0.0/16 range.
The code should also only consider directly-connected routes for
guessing, as default routes would match any address.
This is not used in platform code. This code path is only used when the
mDNS stack is used as a library.
Bug: 415483522
Test: atest
Flag: EXEMPT dead code in the platform
Change-Id: I53d8ad7f96368d4609b1baa804cd75aa65628c0c
This commit adds the implementation in NsdService to support offloading
only advertisement requests. This is a temporary solution to facilitate
the migration of TV devices to APF-based mDNS offload.
Test: TH
Flag: EXEMPT bug fix
Change-Id: I7b8535956e701a34fca31908b8b21e9ab731505c
Skip including the subtype PTR query for both announcement and offload
packets. This is necessary because devices like Googlecast have
numerous subtypes. Including these subtypes in the packets can easily
exceed the MTU limit. Furthermore, the Wi-Fi firmware has limited RAM
available for hardware offload, and including subtypes would consume
excessive memory resources needed for the offload code.
Test: TH
Flag: EXEMPT bug fix
Change-Id: I2575659983579da0bbf4ff104ba5b8111ee9585e
Currently, if the value of opt-in meta-data is not a String,
calling Bundle#getString would result in flooding the system
log with Bundle warning log and callstacks, but without
useful information like the package name.
Thus, a manual type check is performed, and the package name
is logged if a mismatch occurs.
Flag: EXEMPT flagged with a kill switch
Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideSatelliteDataOptInTest \
ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
--update-device
Bug: 416351099
Change-Id: Iae8e26f657e009edb8630dbbe64c7e3e958abc43
As a follow-up to ag/33089478 and ag/33101784, the intent
receiving and dispatching logic was refactored and centralized
within the newly introduced BroadcastReceiveHelper.
However, due to the potential risks associated with this
refactoring, a kill switch is being added specifically for the
PermissionMonitor refactoring. This will allow for reverting
to the previous implementation (potentially involving code
duplication) to mitigate risks if issues arise.
Flag: EXEMPT flagged with a kill switch
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.PermissionMonitorTest \
ConnectivityCoverageTests:android.net.connectivity.com.android.server.ConnectivityServiceTest \
--update-device
Bug: 410731080
Change-Id: I7889ef457d841c750da60a80e50ed6208c45448f
Thread doesn't use mDNS and we should prevent NsdService from sending any mDNS traffic to Thread.
Bug: 414258735
Test: CI
Flag: EXEMPT bugfix
Change-Id: I62299769cd44d2984b81b273adea7ce459d3d773
Currently, isSatelliteDataOptimizedApp utilizes the PackageManager
from the primary user's context. However, if the added package is
not visible to the primary user, the satellite controller will
fail to parse the required information from the AndroidManifest.
Therefore, the corresponding PackageManager should be used when
a package is being checked.
Flag: EXEMPT flagged with a kill switch
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
--update-device
Test: Manual:
1. Create and setup 2nd user.
2. adb install --user 10 CtsHostsideSatelliteDataOptimizedWithMetaData.apk
3. adb shell dumpsys connectivity
4. adb uninstall com.android.cts.net.hostside.satellitedataoptin.testapp
Bug: 410731080
Change-Id: I7adadb3449ec2ff984e6672ffb97919a2418e9b7
Currently, the SatelliteAccessController checks if apps are
opt-in via a property tag under the application. This is
incorrect because PROPERTY_SATELLITE_DATA_OPTIMIZED is an
existing, released meta-data usage for Android B and needs
to be preserved.
Flag: EXEMPT flagged with a kill switch
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
--update-device
Bug: 410731080
Change-Id: If09890faf5d208d007179ecc29b7cf16f6fe6ebb
This is a no-op refactoring that ensures events are handled
on the handler thread. While this is already the case in
production code, it's not consistently true in the tests.
This change adds the necessary methods for faking events
on the handler thread while maintaining readability in the
tests.
Flag: EXEMPT refactor
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.connectivity.SatelliteAccessControllerTest \
--update-device
Bug: 410731080
Change-Id: I816233a823314c4c276138438bbaf33f781eccfe