Commit graph android_packages_modules_Co.../tests/unit/java/com/android
Message SHA1
Merge "Make the idle timer for network data tracking configurable" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-31 21:15:37 +00:00
cf3b26e3bf
Merge "Add config for client-side traffic stats rate-limit cache." into main
Junyu Lai   authored and   Gerrit Code Review   commited 2024-10-31 07:22:36 +00:00
30ff675df5
Merge changes Ia7ea051f,I38bdfe00 into main
* changes:
  Fix system caller cannot query stats for other uids
  Use device config to enable/disable the rate-limit cache feature

Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-31 06:23:58 +00:00
05be25b8ba
Merge "Address review comments at aosp/3249945" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-31 06:23:56 +00:00
457b54a1ae
Add config for client-side traffic stats rate-limit cache.
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

Junyu Lai   commited 2024-10-30 23:02:59 +08:00
b9071f8512
Make the idle timer for network data tracking configurable
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

Suprabh Shukla   commited 2024-10-29 19:06:42 -07:00
c623c946f5
Use device config to enable/disable the rate-limit cache feature
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

Junyu Lai   commited 2024-10-28 14:43:15 +08:00
24fcc3668a
Address review comments at aosp/3249945
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

Junyu Lai   commited 2024-10-28 10:59:35 +08:00
9fb574d0c3
Merge changes I7184eaa0,I2c5951ab into main
* changes:
  Do not crash when adding UID ranges to a destroyed network.
  Test that UID ranges can incorrectly be added to a destroyed network.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2024-10-23 04:39:07 +00:00
6bf2ce44e4
Do not crash when adding UID ranges to a destroyed network.
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 Colitti   commited 2024-10-22 11:41:21 +00:00
dfe98fc5be
Test that UID ranges can incorrectly be added to a destroyed network.
This will likely crash the system.

Bug: 368989698
Test: test-only change
Change-Id: I2c5951ab4ccb2c17c4e87912053130377b9941ba

Lorenzo Colitti   commited 2024-10-22 11:40:09 +00:00
a81bfafda5
Move buildMdnsServiceInfoFromResponse to MdnsUtils.
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

Paul Hu   commited 2024-10-15 03:00:58 +00:00
f311b43bef
Fix the test flake in testRemoveServicesAfterSocketDestroyed
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

Paul Hu   commited 2024-09-26 05:56:28 +00:00
78bd66003a
Merge "Remove cached services when the network is disconnected or unrequested" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-13 11:40:45 +00:00
6a7e703f17
Remove cached services when the network is disconnected or unrequested
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

Paul Hu   commited 2024-09-13 06:13:37 +00:00
079c77c296
Rename Service Side TrafficStats Cache
Rename TrafficStatsRateLimitCache related
variables to TrafficStatsServiceRateLimitCache.
This is needed since client side cache
would be added.

Test: TH
Bug: 343260158
Change-Id: I12ae977ce33cfb5815aa908d719543d5c8e46f11

Yun-Chen Cheng   commited 2024-09-12 07:06:32 +00:00
a8746d5a92
Merge "No-op refactoring for TrafficStats APIs" into main
Yun-Chen Cheng   authored and   Gerrit Code Review   commited 2024-09-11 01:56:42 +00:00
05fb57ea97
No-op refactoring for TrafficStats APIs
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

Yun-Chen Cheng   commited 2024-09-10 14:36:25 +00:00
69b83606ca
Merge changes Id9799762,I9d749393 into main
* changes:
  Introduce FlagOverrideProvider#getIntValueForTest
  Add DiscoveryExecutor#executeDelayed

Paul Hu   authored and   Gerrit Code Review   commited 2024-09-06 05:59:02 +00:00
70896174e2
Add DiscoveryExecutor#executeDelayed
This method can execute the task after the specified amount of
time elapses.

Bug: 355421878
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I9d749393bd5435cdba5072d48242cd0d17332b67

Paul Hu   commited 2024-09-05 15:33:58 +00:00
61a220eaf8
Merge "Inform DNS resolver whether DDR is enabled." into main
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2024-08-26 06:43:19 +00:00
ea68942848
Inform DNS resolver whether DDR is enabled.
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 Colitti   commited 2024-08-23 18:23:42 +09:00
7cde306fa3
Merge "Check network destroy status before networkRemoveUidRangesParcel" into main
Motomu Utsumi   authored and   Gerrit Code Review   commited 2024-08-20 07:02:34 +00:00
5dcee89808
Check network destroy status before networkRemoveUidRangesParcel
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

Motomu Utsumi   commited 2024-08-19 16:25:39 +09:00
471f20142f
Merge "Shedule task with current run if there is a service in the cache" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-08-16 06:59:24 +00:00
435ca438bb
Shedule task with current run if there is a service in the cache
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

Paul Hu   commited 2024-08-15 09:37:36 +00:00
89abf5331c
Merge "Pass DoH information to DnsResolver" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-08-14 07:50:42 +00:00
af569157d5
Unit test for intent spam
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

Yun-Chen Cheng   commited 2024-08-09 08:38:30 +00:00
fecc2ec193
Skip adding ingress discard rule to OEM VPN
OEM VPNs might need to receive packets to VPN address via
non-VPN interface.

Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Ia9000bcbb5b3b9e1e0d396ba78946be36e2fc5ba

Motomu Utsumi   commited 2024-08-06 19:02:33 +09:00
c14288f7c7
Merge changes If787d3f3,I6de357ac into main
* changes:
  Rename getShrinkedBackingArray to getMinimized*
  Suspend callbacks for frozen apps

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-08-05 00:15:39 +00:00
057369c840
Merge "Skip adding ingress discard rule to legacy VPN" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-08-02 23:44:47 +00:00
c4b4feed19
Merge "Add removeServices method in MdnsServiceCache" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-08-02 12:46:54 +00:00
73889ed954
Add removeServices method in MdnsServiceCache
This method can remove all services that match the given
CacheKey.

Bug: 355421878
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I83e1a0cbdd4355d92510b5f9a550f96ef0154682

Paul Hu   commited 2024-08-02 11:32:12 +00:00
d90f31884b
Rename getShrinkedBackingArray to getMinimized*
"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

Remi NGUYEN VAN   commited 2024-08-02 19:27:41 +09:00
dfb159289b
Suspend callbacks for frozen apps
To avoid filling the binder buffers, and sending unnecessary callbacks
when apps are unfrozen (for example successive LinkProperties changes or
onAvailable+onLost are not useful), queue and aggregate callbacks for
apps that are suspended.

Test: atest
Bug: 327038794
Bug: 279392981
Change-Id: I6de357ac2834f1f7e960dfbaa63adfc3825f2a82

Remi NGUYEN VAN   commited 2024-08-02 19:24:17 +09:00
2d78124348
Skip adding ingress discard rule to legacy VPN
Some legacy VPNs need to receive packets to VPN address via
non-VPN interface.

Bug: 352424251
Test: CsIngressDiscardRuleTest
Change-Id: Iad06dc69c5bf5ccda476e89ed9b0fc1bc63d2ebe

Motomu Utsumi   commited 2024-08-02 19:15:59 +09:00
1b376f0fc4
Merge "Fix ktlint errors" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-08-02 08:40:23 +00:00
c759b039ac
Merge "Do not send empty TXT records" into main
Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-07-31 08:54:14 +00:00
141aac3b73
Fix ktlint errors
Obtained with:
    prebuilts/ktlint/ktlint.py --format --no-verify-format --file FILE

--no-verify-format is used to ignore checks that are performed by ktfmt
(see ktlint.py).

Test: m
Change-Id: Ief2c146833e43492d0333b05f1c2b67bbfbc16e0

Remi NGUYEN VAN   commited 2024-07-31 12:01:08 +09:00
89b87e143d
Do not send empty TXT records
Empty TXT records should not be sent when advertising as per RFC 6763
6.1, although it also specifies that in case they are sent, they must be
treated the same as TXT records with an empty String.

Some recent discovery implementations seem to not be able to find
services that send empty TXT records; ensure MdnsAdvertiser sends TXT
records with an empty attribute instead.

Test: atest
Bug: 351250155
Change-Id: If928e5f7c371faa456535160f10880adb1449b92

Remi NGUYEN VAN   commited 2024-07-31 12:01:05 +09:00
9ecc57021b
Fix to return BLOCKED_REASON_NONE for system uids
Bug: 289439578
Test: BpfNetMapsTest
Change-Id: Ib50c2755bc8642cc0dc4e95384d35e38be400a2c

Motomu Utsumi   commited 2024-07-30 16:56:52 +09:00
29c0d2aea7
Merge "Update the QueryTaskConfig constructor" into main
Paul Hu   authored and   Gerrit Code Review   commited 2024-07-22 02:02:31 +00:00
6ade6e2042
Update the QueryTaskConfig constructor
This is a no-op refactor. Move some parameters from
QueryTaskConfig to QueryTask, or bring them from public methods.

Bug: 345146854
Test: atest FrameworksNetTests NsdManagerTest
Change-Id: I47d420842c4f9cec3fe25b5e2febc84a1e495f40

Paul Hu   commited 2024-07-18 06:16:57 +00:00
8c5dc514bf
Consolidate DNS label comparison functions in DnsUtils
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

Yuyang Huang   commited 2024-07-18 12:00:59 +09:00
d851a04db4
Merge changes I6cc2507d,I187ea15d into main
* changes:
  Add flag for QUEUE_CALLBACKS_FOR_FROZEN_APPS
  Add a CallbackQueue class

Remi NGUYEN VAN   authored and   Gerrit Code Review   commited 2024-07-16 08:46:11 +00:00
16828bdeba
Add flag for QUEUE_CALLBACKS_FOR_FROZEN_APPS
Add a flag to be used for an optimization to queue callbacks while apps
are frozen, instead of filling the binder buffer.

Bug: 327038794
Bug: 279392981
Test: atest
Change-Id: I6cc2507de88fae3d0866f9831e1e9026200297e4

Remi NGUYEN VAN   commited 2024-07-16 13:36:51 +09:00
48d2527e43
Add a CallbackQueue class
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

Remi NGUYEN VAN   commited 2024-07-16 13:36:49 +09:00
c3621e6012
Merge "Ensure all DatagramPackets with the same destination address" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-10 01:37:51 +00:00
51dc24ad0b
Refactor RoutingCoordinator
- This CL puts RoutingCoordinator into staticlibs to make it usable by
both Tethering and ConnectivityService on R.
- This CL also changes the return type of
  ConnectivityInternalApi#getRoutingCoordinatorManager() to IBinder so
  it has fewer dependencies.

Bug: 350699020
Test: CI

Change-Id: Iba096e940795cd33e61c5141721394ad39e5ce6d

Handa Wang   commited 2024-07-05 05:26:54 +00:00
8f2c30664d
Merge "Improve NetworkCallback declared methods toString" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-04 04:11:52 +00:00
5289382f04