When a terrible error occurs, this change ensures that it is both logged
using Log.wtf() and reported via a dedicated metric. This dual approach
provides comprehensive error information for debugging in dogfood
environments (Log.wtf()) and tracks the occurrence of these errors in
production (via metrics).
Test: TH
Change-Id: Ic376f3789ab0cc9b094e79301849492143ed777c
Currently EthernetTracker uses netd to interact with interfaces, such as
retrieving all interfaces, updating interface configurations etc.
However, the usage of netd can bring some unexpected side effects, such
as clearing v4 address when toggling on/off interface.
This change moves forward with one less usage of netd to use netlink
directly to set interface up/down in EthernetTracker.
This patch adds support in netlink utils to get/set interface flags and
added related unit test.
Bug: 379021505
Test: atest NetworkStaticLibTests
Change-Id: I5f82781663ba340588450cceea55caec4e3991a8
Introduced new helper methods to simplify common array operations:
* Concatenation: Combine multiple arrays into a single array.
* Prepend: Add elements to the beginning of an array.
* Append: Add elements to the end of an array.
Test: TH
Change-Id: I6d9e19d7152c2ae3e75c3d521b4ee994347c4d2e
* changes:
Introduce client-side rate limiting for TrafficStats APIs
Unit test for TrafficStats Rate Limit Cache
Add `putIfAbsent` method to LruCacheWithExpiry
Junyu Laiauthored and Gerrit Code Reviewcommited 2024-12-10 01:55:44 +00:00
This commit introduces a new `putIfAbsent` method to the
`LruCacheWithExpiry` class. The `putIfAbsent` method
creates a new entry if the key is absent or returning the
existing value if the key is already present. This addition
enhances the cache's functionality and flexibility.
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.LruCacheWithExpiryTest
Bug: 343260158
Change-Id: Iff03ce2b6c27fedd71510edaa6bd86885f6df122
Introduced ITask and its concrete implementations (e.g.
MessageTask, RunnableTask) for TimerFileDescriptor to enable more
flexible task scheduling.
Bug: 366373064
Test: atest NetworkStaticLibTests
Change-Id: I3a5177b66916f50f3f943d8b63b0c760bece60e4
Build a wrapper class that allows users to easily use the timerfd
object and trigger delayed callbacks through this class.
Bug: 366373064
Test: atest NetworkStaticLibTests
Change-Id: I8081d29e4874df8b9e59f7fc845b20cbd29aec40
Instead of reporting tryTest errors when the tryTest block throws,
report them in the cleanup block if no catch block has caught it.
This fixes a bug where tests that use tryTest/catch would collect
diagnostics in expected cases.
Test: atest
Change-Id: Ic53ae54f1945a2784becd50e5890fad8e7461474
Moved common handler thread check functions from MdnsUtils.java
to HandlerUtils.java within the staticlib to facilitate reuse by
both Connectivity and NetworkStack modules.
Test: TH
Change-Id: Id96f6558c32c44fbdf2d2ce3e57c14da0cbf3ed7
This CL adds the createGetLinkMessage() method at the
RtNetlinkLinkMessage class, that creates a link message to get the
information of a interface. The functionality is the same as
"ip link show $interface".
Bug: 364501824
Test: atest NetworkStaticLibTests
Change-Id: I87a120f488e5b6f7f24c663c68ba26835fa2157a
This CL mainly adds the createSetLinkNameMessage() method at the
RtNetlinkLinkMessage class, that creates a link message to rename the
network interface. The functionality is the same as
"ip link set $interface name NEW_NAME".
Bug: 364501824
Test: atest NetworkStaticLibTests
Change-Id: I6323bce1ece10f4437483214860d50cb7d29df8d
This CL mainly adds the createSetLinkStateMessage() method at the
RtNetlinkLinkMessage class, that creates a link message to set the
interface up or down. The functionality is the same as
"ip link set $interface up" or "ip link set $interface down".
Bug: 364501824
Test: atest NetworkStaticLibTests
Change-Id: Id9232851f6d9a7f99f857fd5b8d4eae506de2c7c
This CL marks all the fields of RtNetlinkLinkMessage class final. That
means once the instance is created, the instance is immutable.
Also, the CL adds a static create method that verifies the arguments,
and updates the nlmsg_len field of the header before creation.
Bug: 364501824
Test: atest NetworkStaticLibTests
Change-Id: I08af4a6e68df9aee8ae76d953fac5d81f0b02c84
Currently, checkLocationPermissionInternal throws if the package does
not exist or package name and uid doest not match.
This caused system server crash in ConnectivityService.
ConnectivityService is an only caller of checkLocationPermissionInternal
and ConnectivityService should consider uid does not have location
permission in this case.
So this CL updates checkLocationPermissionInternal return
ERROR_LOCATION_PERMISSION_MISSING instead of throwing exception.
Bug: 337473824
Test: LocationPermissionCheckerTest
Change-Id: Ic42d6203bafa95aea7e5428c490b0a298e3bd260
doReturn is less prone to races since when().thenReturn will fail if the
mock is used by other thread between when() and thenReturn()).
Bug: 337473824
Test: LocationPermissionCheckerTest
Change-Id: Ie07f3f3cf23b57296a7db4fb9296b84be5b57214
This is a no-op refactor to reduce complexity to prevent from
accessing trunk stable flags from static libs. Also it
makes more sense since statsd is the only caller.
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.NetworkStatsUtilsTest
Bug: 335680025
Change-Id: Ied563bd685bdba9d514414c05d58009304d5baa4
In the current design, NetworkStats.addEntry is used within a
loop to create a NetworkStats instance from entries. This results
in a large memory footprint because the addEntry() method clones
the original NetworkStats instance each time it is called.
This change utilizes the newly created API to add a list of
entries at once. This approach only clones the instance once,
thereby reducing the required memory footprint.
Test: atest NetworkStaticLibTests:com.android.net.moduletests.util.NetworkStatsUtilsTest#testPublicStatsToAndroidNetStats
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.NetworkStatsUtilsTest
(on S device)
Test: atest ConnectivityCoverageTests:com.android.testutils.NetworkStatsUtilsTest
(on S device)
Bug: 335680025
Change-Id: I5c635613ed3ba34d840ee71b6bef21d10105df0d
This change enables comparison of android.net.NetworkStats
instances even when their interface name is null. This scenario
arises when deriving a android.net.NetworkStats instance
from an app.usage.NetworkStats, which lacks interface name
information. However, the original utility method relies on
NetworkStats.Entry#equals, which is incompatible with null
interface names on T- devices, because they do not run
mainlined NetworkStats.
This change refactor assertEntryEquals and makes
assertNetworkStatsEquals to use it to compare android.net.NetworkStats
instances.
Test: atest NetworkStaticLibTests
Test: atest ConnectivityCoverageTests:com.android.testutils.NetworkStatsUtilsTest
(on S device)
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.net.module.util.NetworkStatsUtilsTest
(on S device)
Bug: 335680025
Change-Id: I25a685e4c2d4cf70132b2c4374b2bb8129c844cb
Since the testutils.NetworkStatsUtils is in Connectivity.
Move it to Connectivity git makes more senses.
Test: atest NetworkStaticLibTests
Bug: 335680025
Change-Id: Ia59cc8f74417b1dbbcccf12c5c79c3ed22454b78
"Shrinked" should actually be "shrunk" or "shrunken"; in any case
"minimized" is simpler and possibly more accurate (it's the minimum size
required to hold the values).
Test: atest
Change-Id: If787d3f3d6e1046338d4e89ed924bce183e74bd6
Updated methods in DnsUtils to convert DNS labels to uppercase instead
of lowercase to ensure compatibility with APF requirements.
Test: TH
Change-Id: I4b585f875b29b9e508d9a5eb73a073587510faab
Moved common DNS label comparison functions from MdnsUtils.java to
DnsUtils.java within the staticlib to facilitate reuse by both
Connectivity and NetworkStack modules.
Test: TH
Change-Id: Ie839c5621d2c4b74e41987a0c6d1141d0d6e24f8
Some tests reconnect wifi and don't wait wifi is validated.
So default network is changed while later tests are running.
This CL adds RestoreDefaultNetwork annotation to monitor default network
changes and wait to default network is restored to previous state.
If the default network is not restored within timeout, test fails.
Bug: 328870515
Test: atest MultinetworkApiTest NetworkAgentTest
Change-Id: I01e858109ac274ff60769bd558b91654298290ff
The class will be used to build memory-efficient objects (int arrays)
used to queue ConnectivityService callbacks while an app is frozen.
This is very similar to an ArrayList<Pair<Short, Short>>, but avoids
object boxing which would use a lot more memory.
This is intended to be used by ConnectivityService both as a builder,
and as a utility to read lists of callbacks that it stores. Long-lived
references to the CallbackQueue would not be kept to minimize memory
usage; only the array returned by toArray needs to be stored.
Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I187ea15d14dfd160e577e9e9e87b1aded27b1938