reserveNetwork allows a requestor to initiate the creation of a network
that requires the system to preallocate resources which can then be
advertised by the requestor on or off device in order to help create the
network.
For example, this API will be used to reserve a IP over L2cap server
network, which requires the system to first create a
BluetoothServerSocket and reserve a PSM (i.e. port). This information is
passed back to the requestor via onReserved() callback and subsequently
advertised via a BLE advertisement. The network is established as soon
as the client connects to the advertised PSM, which will trigger a call
to onAvailable(), just like a regular NetworkRequest.
onReserved() callbacks are exclusive to the reserveNetwork API and are
sent when an NetworkOffer is registered that matches the reservation ID
of an existing request. A reserved offer always follows the reservation
request as it is created in direct response. onReserved() can only be
called once. If for some reason the reservation gets cancelled by the
system (i.e. the NetworkOffer is retracted) or cannot be fulfilled,
onUnavailable() is called. It is up to the app to file a new
NetworkRequest when this happens.
An onReserved() callback is not queued, because
a) it cannot be called more than once for the same reservation,
b) it must always be the first callback, and
c) it only gets cancelled by onUnavailable().
This change does not handle NetworkOffer migrations, such as updating
the score, properly. This must be addressed before the feature can ship
as the yieldToBadWifi logic can update the score on all NetworkOffers.
API-Coverage-Bug: 372936361
Test: Very basic CSNetworkReservationTest; more to follow.
Change-Id: I9b349d469830bf28e006cf403c605574371db267
onReserved() is called in response to a successful Network reservation
with the NetworkCapabilities of the reserved network. onReserved is
called at most once. If the reservation is released, onUnavailable is
called.
Test: TH
API-Coverage-Bug: 372936361
Change-Id: Idcef572ab9d07981799efc349206aadb620e0e69
Advertise with a shorter hostname by default (can be disabled via a
chicken bit), instead of "Android_[32 characters]" as the hostname.
This should allow decreasing the size of APF programs necessary for
advertising offload, and make the advertiser compatible with Matter
use-cases. Some Matter implementations (notably CHIP) interpreted
the example in "4.3.1.1. Host Name Construction" of the spec as
if only 16 character hostnames needed to be supported, despite not
following the rule to construct the hostname based on link-layer
addresses.
The hostname changed once in T when migrating from mdnsresponder to the
current advertiser implementation, so changing the format again is
unlikely to create problems, especially since this keeps the "Android_"
prefix.
Bug: 341141476
Test: atest
Change-Id: Ic8311f41a1a943ec8230203fcd74eda7a26a691c
Instead of having query scheduling time split between MdnsQueryScheduler
and QueryTaskConfig, where QueryTaskConfig has the base run time and
MdnsQueryScheduler does backoff, consolidate it all in
MdnsQueryScheduler.
This allows QueryTaskConfig to only contain parameters used when the
task runs, and not scheduling info.
Test: atest
Change-Id: Ie060802ff2d13c1cea339955d8b609ba95f762f2
This populates the reservationId with the value of the requestId when a
new NetworkRequest is created. Conceptually, the reservationId is not
related to the requestId; however, the requestId fulfills the same
uniqueness requirements that are needed for the reservationId, so it can
just be reused for this purpose.
Test: atest NetworkRequestTest
Change-Id: Icecb889a5269554add5791587f1ce7319271fd9e
Timerfd can provide more accurate delayed callbacks than
Handler#postDelayed because it accounts for the time the device
spends in deep sleep. Using timerfd allows for more precise query
timing, which reduces the possibility of TTL expiration caused
by inaccurate delayed callbacks.
Bug: 366373064
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I980ec8fd43f63976ef5387bb57c7ed70a1b68d82
This is a test-only no-op refactor which only enables the
ability for follow-up changes to add more parameters without
exponentially increasing the number of parameter combinations.
Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.CSLocalAgentCreationTests
Bug: 349487600
Change-Id: I61bcabf7c93dab43984da0ade3e61a7117fe040a
This commit removes the redundant type and caller uid
checks in TrafficStats to address the review feedback at
aosp/3313055.
Test: TH
Bug: 343260158
Change-Id: I0ed6e850835136c9a324efd7271dd80a34160aa6
This is a no-op change since the config is not used yet, and
the feature flag will be gradually rolled out instead of enabled
by default.
However, this change is necessary for follow-up changes to enable
toggling the feature and configuring its behavior through device
configuration flags.
This change includes:
1. Disable the service-side cache flag if the client-side flag
is enabled.
2. Since the apps don't have enough permission to check the
feature flag from DeviceConfig. Provides a binder interface
for returning per-UID config,
which only returns cache enabled if the SDK level is V+
or the app's target SDK is V+.
Test: atest FrameworksNetTests:android.net.connectivity.android.net.TrafficStatsTest \
FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
CtsNetTestCases:android.net.cts.NetworkStatsBinderTest \
FrameworksNetIntegrationTests:com.android.server.net.integrationtests.NetworkStatsIntegrationTest
Bug: 343260158
Change-Id: Id9761e4aea65fabe6466c875b787e178317a1da2
Follow-up from aosp/3249945. If the system caller queries stats
for other UIDs, the caller would get UNSUPPORTED.
This follows the official documentation, where the API would
not return stats for all other UIDs.
However, partners or other legacy callers might already depend
on this undocumented behavior. Changing this behavior might
damage existing apps.
Thus, this change reverts the behavior change introduced at
aosp/3249945 and allows a system caller to query stats for
other UIDs.
Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.TrafficStatsTest
Bug: 372851500
Change-Id: Ia7ea051f7b0b6349ffcb890c300362bbfbdee3dc
Networks can use widely varying timeouts for their connections. Because
cellular modems use a lot of power, having this configurable is more
useful for tuning this to an optimal value for power drain.
Adding a similar configurable value for WiFi for parity.
Test: atest ConnectivityCoverageTests:\
android.net.connectivity.com.android.server.CSNetworkActivityTest
Bug: 373733012
Change-Id: I2418f09233b2e3fa4e9cdd8fbb6149a35106b735
Currently, if the app's target SDK is V+, the rate-limit cache is
enabled regardless of whether the kill switch is enabled or not.
This creates problems if there is a need to disable the feature
entirely.
Thus, this change makes the kill switch override the target SDK
level. This is necessary for follow-up changes to enable
the client-side cache and disable the service-side cache
simultaneously.
This change also removes the need of initializing/clearing the
caches when the cache is entirely disabled.
Test: atest FrameworksNetTests:android.net.connectivity.android.net.TrafficStatsTest \
FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
CtsNetTestCases:android.net.cts.NetworkStatsBinderTest \
FrameworksNetIntegrationTests:com.android.server.net.integrationtests.NetworkStatsIntegrationTest
Bug: 343260158
Change-Id: I38bdfe00220f59712ca4b095fe4e7a3731320708
This change includes:
1. Rename binder interfaces.
2. Use a dedicated class to pass the result of
get{Total|Iface|Uid}Stats, as it is 25% faster than passing
a NetworkStats object through the binder interface.
3. Remove the binder interface only used by the test.
4. Remove NetworkStatsBinderTest on R and S, since the binder
interface is removed, the mainlined service does not run on
those versions and the chance of breaking these tests on
R and S is low.
5. Remove useless TODO comments.
Test: atest FrameworksNetTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \
CtsNetTestCases:android.net.cts.NetworkStatsBinderTest \
FrameworksNetIntegrationTests:com.android.server.net.integrationtests.NetworkStatsIntegrationTest
Bug: 372851500
Bug: 343260158
Change-Id: Ibd79a17218f54f0117d8ef5d7b9ec6073356f923
aosp/3218864 fixed the crash when ranges are removed from a
destroyed network, but did not fix the case where the ranges are
added to a destroyed network.
This can happen if a multilayer request is filed when a network
has already been destroyed.
Fix: 368989698
Test: updated existing tests for this bug
Change-Id: I7184eaa01141f56b7ad774277c7dee03d5812298
Lorenzo Colitticommited 2024-10-22 11:41:21 +00:00
Move this utility method buildMdnsServiceInfoFromResponse from
MdnsServiceTypeClient to MdnsUtils so it can be used by other
classes.
Bug: 355421878
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I8ce1028de325da46f112a5ec58516453727151fe
The removeServices() is running on a different handler, which
might take some time to complete. Therefore, the verification
should include a timeout to wait longer and prevent test flake.
Bug: 367429622
Test: atest MdnsDiscoveryManagerTests#testRemoveServicesAfter\
SocketDestroyed --iteration
Change-Id: I79626bad680a62993c3e7d6b356acc10755257e3
The services in the cache are no longer useful after the network
is disconnected. Because either the Network object or the
interface index will change after the network is reconnected,
these cached services won't be used for any discovery/resolution/
service info callback requests. Therefore, these cached services
should be removed after the network is disconnected. Otherwise,
these useless cached services will occupy memory until the device
is rebooted.
In addition, the cached service may not be reliable after the
last listener is unregistered. Because the socket is
disconnected, the service type client won't receive any updates
for the services. Therefore, remove these cached services after
exceeding the keeping time.
Bug: 355421878
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I06ff320fec84f71dc2ed742c50fa46f25c284170
Rename TrafficStatsRateLimitCache related
variables to TrafficStatsServiceRateLimitCache.
This is needed since client side cache
would be added.
Test: TH
Bug: 343260158
Change-Id: I12ae977ce33cfb5815aa908d719543d5c8e46f11
Prepare for implementation of client side
TrafficStats rate limit cache.
1. Write Typeless versions of getIfaceStats,
getUidStats, getTotalStats in INetworkStatsService.aidl
that returns NetworkStats instead of Long.
This is needed because in follow-up changes,
the NetworkStats instead of indiviual numbers will
be stored as a cache entry
2. Move some utils from NetworkStatsService
to TrafficStats. This is needed because in the follow-up
changes, these utils would be both accessed by TrafficStats
and NetworkStatsService.
Test: CtsNetTestCases:android.net.cts.TrafficStatsTest
Test: CtsNetTestCases:android.net.cts.NetworkStatsBinderTest
Test: FrameworksNetIntegrationTests:com.android.server.net.\
integrationtests.NetworkStatsIntegrationTest
Test: FrameworksNetTests:android.net.connectivity.com.android.\
server.net.NetworkStatsServiceTest
Test: FrameworksNetTests:android.net.connectivity.\
android.net.TrafficStatsTest
Test: ConnectivityCoverageTests:android.net.connectivity.\
android.net.TrafficStatsTest
Bug: 343260158
Change-Id: Iace251e1495fd3b81e072526e92ca97cbc7246eb
This method can execute the task after the specified amount of
time elapses.
Bug: 355421878
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I9d749393bd5435cdba5072d48242cd0d17332b67
This is needed to cleanly flag on/off DDR and to ensure that
when it is flagged on, DnsResolver ignores the hardcoded list of
DoH providers and only uses DDR.
Bug: 240259333
Test: updated existing tests
Change-Id: I84c103a5a4d18294b6a4cc3301d0037d1a6673a4
Lorenzo Colitticommited 2024-08-23 18:23:42 +09:00
networkRemoveUidRangesParcel throws ServiceSpecificException if the
native network is already destroyed.
This can happen when
1) per-app default network request is satisfied by network1
2) unregisterAfterReplacement is called to the network1. This calls
netd.networkDestroy and network is removed from netd.
3) per-app default network request is removed. This calls
netd.networkRemoveUidRangesParcel but netd does not know about this
netid anymore.
This CL fixes this issue by skip calling networkRemoveUidRangesParcel if
the request satisfier is already destroyed.
Bug: 336961452
Bug: 357974842
Test: CSSatelliteNetworkTest
Change-Id: Id775cca6fffd03545f1c4bc5016d0de4813f17df
A service record exists in the cache, and a query transmission
with a long duration has been scheduled because the service
information was recently updated. However, the query will be sent
immediately if a new discovery/resolution/service info callback
listener is registered. Therefore, to reduce unnecessary queries
in aggressive query mode, if a service exists in the cache, the
query timing should either reuse the scheduled run or use a
backoff time if there is no scheduled run.
Fix: 345146854
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I3335a0f6e0018526a8677dfbfbf053dd0dc906e5
Add unit test to test feature
BROADCAST_NETWORK_STATS_UPDATED_RATE_LIMIT_ENABLED_FLAG.
When feature is on, broadcast message should be delivered
with the designated interval(b/343844995),
When feature is off, each message should be delivered
regardless of previous intent.
Test: atest FrameworksNetTests:android.net.connectivity.com.android\
.server.net.NetworkStatsServiceTest\
#testNetworkStatsUpdatedIntentSpam_rateLimitOn
Test: atest FrameworksNetTests:android.net.connectivity.com.android\
.server.net.NetworkStatsServiceTest\
#testNetworkStatsUpdatedIntentSpam_rateLimitOff
Bug: 343844995
Change-Id: I4b89497c336a310c6959db579ca9ae3c572ff70c
OEM VPNs might need to receive packets to VPN address via
non-VPN interface.
Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Ia9000bcbb5b3b9e1e0d396ba78946be36e2fc5ba