Commit graph android_packages_modules_Co.../staticlibs
Message SHA1
Merge changes I332c8d43,I340bcb77 into main
* changes:
  Simplify APF IGMPv3 general query offload test
  refactor: Lazy load IP addresses for APF tests

Jimi Chen   authored and   Android (Google) Code Review   commited 2025-07-16 07:38:59 -07:00
5904ce1431
refactor: Lazy load IP addresses for APF tests
Previously, IPv4 and IPv6 addresses were retrieved in `ApfTestBase.setup_class`,
which meant all APF tests assumed the presence of both.

This change refactors `ApfTestBase` to introduce dedicated methods:
- `get_and_expect_ipv4_addresses_exist()`
- `get_and_expect_ipv6_addresses_exist()`

These methods now handle the retrieval and assertion of IP addresses.
Individual test cases in `ApfV6Test` are updated to call these methods
only when the respective address type is required for the specific test
scenario.

This improves test robustness by ensuring tests only depend on the
necessary IP addresses, allowing for more precise test setup and failure
reporting. Additionally, the doze mode activation is reordered to occur
after initial network setup.

Flag: EXEMPT mainline
Bug: 419427388
Test: atest CtsConnectivityMultiDevicesTestCases:ApfV6Test
Change-Id: I340bcb77fe66cc9927dcd58e5899cdf9a4375daa

Jimi Chen   commited 2025-07-16 04:31:40 +00:00
419e088796
Ignore RtNetlinkMessage with null or empty interface names
This patch checks if interface name is null or empty for
RtNetlinkMessage and ignores the message if it is.

Bug: 429497348
Test: build
Flag: EXEMPT bugfix
Change-Id: I6000f5442f341f152b7fbd235affded0fa56fe50

Chuwei He   commited 2025-07-15 18:43:07 -07:00
16c8fd1166
Merge "Prepare to move VCN: Define utility lib for framework VCN" into main
Yan Yan   authored and   Android (Google) Code Review   commited 2025-07-15 11:34:09 -07:00
1867ae1471
Merge "Pass bluetoothUseRandomAddress via RoutingCoordinator constructor" into main
Motomu Utsumi   authored and   Android (Google) Code Review   commited 2025-07-14 22:47:19 -07:00
1cdb0a5609
Pass bluetoothUseRandomAddress via RoutingCoordinator constructor
This refactoring changes how the bluetoothUseRandomAddress flag is
accessed.

PrivateAddressCoordinator is in a library used by multiple mainline
modules(Tethering, NetworkStack, CaptivePortal, WiFi) and cannot
directly read a Tethering mainline beta flag.

To fix this, the flag's value is now passed down through constructors.

An alternative solution would be to split the Java library for each module,
but with this solution, a single utility class cannot be shared.

This commit is a no-op as the passed value is hardcoded to false.

Test: TH
Flag: EXEMPT refactor
Bug: 287177081
Change-Id: I5f2174ee94b55e7a7298b9742221d6e6c3c5cac5

Motomu Utsumi   commited 2025-07-15 11:20:01 +09:00
323d22a497
Remove wrong comment
Test: TH
Flag: EXEMPT comment only change
Change-Id: Ifba2528aaa9bfb1ecdd982462f451d92bbd85cf2

Yuyang Huang   commited 2025-07-14 08:56:35 -07:00
75cf08972f
Prepare to move VCN: Define utility lib for framework VCN
This is a preparation CL before moving VCN code from frameworks/base
to p/m/Connectivity/

This CL defines a utility lib so that the VCN framework code can
use HexDump. With HexDump, VCN will define another lib for the IPsec
module.

Bug: 379938062
Flag: EXEMPT; pure refactoring
Test: FrameworksIkeTests, CtsIkeTestCases
Change-Id: I9bc8b37779315841c2a93328942d073b6bf40808

Yan Yan   commited 2025-07-10 20:46:41 +00:00
aa2f53143e
Merge "Prepare to move VCN: Add visibilities" into main
Yan Yan   authored and   Android (Google) Code Review   commited 2025-07-10 10:25:00 -07:00
9fc98e3318
Merge "Refactor: Add RestoreEthernetRule for ethernet tests" into main
Junyu Lai   authored and   Android (Google) Code Review   commited 2025-07-10 03:58:40 -07:00
f693a0f9bf
Refactor: Add RestoreEthernetRule for ethernet tests
This is a no-op, test only refactoring.
Move ethernet state management logic from EthernetManagerTest into a
dedicated JUnit test rule, RestoreEthernetRule. This new rule is
responsible for saving the initial ethernet state, allowing tests to
enable or disable it, and restoring the original state upon test
completion.  This refactoring simplifies EthernetManagerTest and
promotes code reuse.

Flag: EXEMPT EXEMPT test only refacotring
Test: atest NetworkStaticLibTests:com.android.testutils.RestoreEthernetRuleTest \
      CtsNetTestCases:android.net.cts.EthernetManagerTest --update-device
Bug: 410731080
Change-Id: If3dd869d6af4e0c659386621fb5d92012aa574d1

Junyu Lai   commited 2025-07-10 15:25:15 +08:00
9f6a566d89
Prepare to move VCN: Add visibilities
Before moving VCN code, add the new code locations to the
"visibility" fields of Connectivity dependencies.

Bug: 379938062
Flag: EXEMPT; visibility changes
Test: presubmit
Change-Id: I904c601de2b17a9c0460eebde90622963f233567

Yan Yan   commited 2025-07-10 01:26:14 +00:00
7c75e441a0
Merge changes I65fecdcd,I0acc9fcb into main
* changes:
  Add pre-test check for APF offload status
  Add util to get APF offload config

Jimi Chen   authored and   Android (Google) Code Review   commited 2025-07-08 20:24:46 -07:00
df4c09fe3a
Add pre-test check for APF offload status
This commit introduces a verification step that runs before APF
offload tests.

It uses the `cmd network_stack apf <iface> config` shell command
to dump the list of enabled offloads. By checking this list first,
we can ensure that the specific offload under test is actually
enabled, avoiding misleading failures and improving test reliability.

Flag: EXEMPT mainline
Bug: 419427388
Test: ./cts-tradefed run commandAndExit cts -m CtsConnectivityMultiDevicesTestCases -t ApfV6Test --shard-count 2
Test: atest CtsConnectivityMultiDevicesTestCases:ApfV6Test
Change-Id: I65fecdcd4f2f9e9586da2684bf68cec215d0f359

Jimi Chen   commited 2025-07-08 04:11:22 +00:00
af1e460e26
Add util to get APF offload config
Adds a new helper function `get_apf_config_from_cmd` to retrieve the
list of enabled APF offloads for a given network interface.

Flag: EXEMPT mainline
Bug: 419427388
Test: atest NetworkStaticLibHostPythonTests
Change-Id: I0acc9fcbf2e8bc6f4d8f309c2ec64c003c325c42

Jimi Chen   commited 2025-07-08 04:10:41 +00:00
7c190ecb78
Refactor: Introduce TestableCallback for EthernetStateListener
The monolithic EthernetStateListener has been refactored and split
into two specialized test classes:

- TestInterfaceStateListener: For interface state callbacks.
- TestEthernetStateListener: For ethernet state callbacks.

Both new classes now extend TestableCallback, providing a standardized
and more robust way to manage and verify listener interactions in
unit tests. This improves testability and clarity of test code.

This is a no-op, test-only change.

Flag: EXEMPT refactor
Test: atest CtsNetTestCases:android.net.cts.EthernetManagerTest
Bug: 410731080
Change-Id: I667e3607954dcb073b2732b16bedfbc71a70bb39

Junyu Lai   commited 2025-07-06 23:39:42 -07:00
4c7ba24f57
Refactor: Move EthernetStateListener to a standalone file
This is a no-op, test-only change.
Move EthernetStateListener from EthernetManagerTest.kt to a new
standalone file in testutils.
This refactoring makes the listener reusable across other tests and
decouples it from its dependency on EthernetTestInterface.

Flag: EXEMPT refactor
Test: atest CtsNetTestCases:android.net.cts.EthernetManagerTest
Bug: 410731080
Change-Id: Iacd9236f758011da0714884040aebe3e42ef1646

Junyu Lai   authored and   Chalard Jean   commited 2025-07-04 13:03:55 +09:00
bb75ed8900
Merge "Add a ContentResolverWithFakeSettingsProvider class to testutils." into main
Lorenzo Colitti   authored and   Android (Google) Code Review   commited 2025-07-01 04:13:49 -07:00
7e5665ae44
Support AutoReleaseBluetoothRule
This change introduces a utility class to disable
Bluetooth before testing, in case it was previously connected
as the default network.

Flag: EXEMPT test only
Test: atest NetworkStaticLibTests:com.android.testutils.AutoReleaseBluetoothRuleTest \
      --update-device
Bug: 410731080
Change-Id: I95afc6174698bf73b21d95a85c02e107ee0d59f7

Junyu Lai   commited 2025-07-01 17:52:22 +08:00
c5c80cc9ab
Add a ContentResolverWithFakeSettingsProvider class to testutils.
This makes it a bit easier to use FakeSettingsProvider and
get settings change notifications. It's still difficult because
the ContentResolver#registerContentObserver methods are final and
cannot be subclassed, but at least it removes the need for some
boilerplate code.

Bug: 397521796
Flag: TEST_ONLY
Test: tests updated in next CL
Change-Id: I43b45eca964b103ad65d0db82682aa8644fcacaf

Lorenzo Colitti   commited 2025-06-28 11:06:53 +09:00
86625b4734
Merge "Optionally remove legacy bluetooth tethering address cache on T+" into main
Lorenzo Colitti   authored and   Android (Google) Code Review   commited 2025-06-26 03:33:56 -07:00
5eaf3aab02
Optionally remove legacy bluetooth tethering address cache on T+
After T, Bluetooth tethering could use a random address. But if we keep
putting the legacy Bluetooth address in the cache, the coordinator will
always assign the legacy address first until it runs into a conflict.

This change in itself does not do anything. Once we have a
trunk-stable namespace for mainline beta, we will add a flag for
this change, and check the flag in PrivateAddressCoordinator.

Bug: 287177081
Test: new unit tests
Flag: EXEMPT no behaviour changes
Change-Id: I56810b5b0e1098a5f89cbb1ad665d2b8652e860c

Yuyang Huang   authored and   Lorenzo Colitti   commited 2025-06-26 15:14:47 +09:00
acd7366b65
Fix crash in LocationPermissionChecker when app is not installed.
AppOpsManager#noteOp can throw SecurityException in some cases (for
example, if the app is not installed). Don't crash the system when
this happens.

Test: None
Fix: 416189588
Flag: TEST_ONLY
Change-Id: Idf017ccf6b033ec80f4c4f3397cf4e417af7ad11

Lorenzo Colitti   commited 2025-06-25 17:25:53 -07:00
e988ae3208
Fix typo
Still not sure whether the log message is 100% correct. Technically, it
means no callback was received between now and the last successful poll
operation that incremented the track record position.

Test: TH
Flag: EXEMPT trivial
Change-Id: I57e9600321cb4a79d035d64d488af09b17a50706

Patrick Rohr   commited 2025-06-24 08:33:51 -07:00
a36b89c5b0
Merge "Migrate CSAgentWrapper to TestableCallback." into main
Jean Chalard   authored and   Android (Google) Code Review   commited 2025-06-22 18:43:23 -07:00
3cbf1e3b94
Merge "DHCPv6 addr reg: remove the mAddrRegEnable member." into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-20 15:19:35 -07:00
1fccee32d9
Migrate CSAgentWrapper to TestableCallback.
This makes it much more powerful as well as consistent with
other use cases of this paradigm.

Test: TH
Flag: EXEMPT test-only
Change-Id: I4f5b86bfdd16d8bfe21b79235444817a13bc3c49

Chalard Jean   authored and   Jean Chalard   commited 2025-06-20 01:08:25 -07:00
6fe5d13b3a
Merge changes from topic "avoid-bad-wifi-api-update" into main
* changes:
  Enable per-subId 'avoid bad Wi-Fi' setting storage
  Use ConnectivitySettingsManager API for avoid bad Wi-Fi updates

Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-20 00:42:48 -07:00
553054fcee
Merge "Don't blame a non-existent test for not restoring default networking" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-20 00:37:37 -07:00
b37483f3ca
Don't blame a non-existent test for not restoring default networking
RestoreDefaultNetwork is a virtual test, causing a lot of confusion among
testers who can't reproduce or run this test.
Instead, blame the test that actually failed to restore the default network.

Before :
```
[1/2] android.net.cts.MultinetworkApiTest#testFoo: PASSED (253ms)
[2/2] android.net.cts.MultinetworkApiTest#RestoreDefaultNetwork: FAILED (54ms)

STACKTRACE:
java.lang.IllegalStateException: testFoo does not restore the default network. Default network has caps null ; expected a network with transports = WIFI
        at com.android.testutils.DefaultNetworkRestoreMonitor$listener$1.testFinished(DefaultNetworkRestoreMonitor.kt:64)
```

After :
```
[1/2] android.net.cts.MultinetworkApiTest#testFoo: PASSED (353ms)
[2/2] android.net.cts.MultinetworkApiTest#testFoo: FAILED (54ms)

STACKTRACE:
java.lang.IllegalStateException: testFoo does not restore the default network. Default network has caps null ; expected a network with transports = WIFI
        at com.android.testutils.DefaultNetworkRestoreMonitor$listener$1.testFinished(DefaultNetworkRestoreMonitor.kt:64)
```

Test: this
Flag: EXEMPT test-only
Bug: 413188127
Change-Id: Ia17bc9ddeedbd9303e5788ef79fb190e6e9dca1e

Chalard Jean   commited 2025-06-20 15:12:31 +09:00
00275e3f44
Enable per-subId 'avoid bad Wi-Fi' setting storage
Breaks out the `network_carrier_aware_avoid_bad_wifi` setting from a single
string key into individual `Global.Settings` entries per subscription ID.

Flag: EXEMPT mainline
Bug: 424330991
Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.ConnectivitySettingsManagerTest
Change-Id: Ida673c1b8b915719b8e64ea85a66c2b98862e5f5

Jimi Chen   commited 2025-06-19 11:30:06 +00:00
1bfe086299
Merge changes If072a5bc,I1c48ebba,I389fe6c5,I6699b147,Ia16ba2b5 into main
* changes:
  DHCPv6 addr reg: get the DHCPv6 message type.
  DHCPv6 addr reg: add a function helper to create ADDR_REG_REPLY message.
  DHCPv6 addr reg: add ADDR_REG_REPLY packet class.
  DHCPv6 addr reg: add a function helper to create ADDR_REG_INFORM message.
  DHCPv6 addr reg: build an IA Address option inside Dhcp6AddrRegInform.

Xiao Ma   authored and   Android (Google) Code Review   commited 2025-06-18 21:24:01 -07:00
cbe860cc22
DHCPv6 addr reg: remove the mAddrRegEnable member.
For the current implementation we don't use the addr reg option yet, so
remove it.

Flag: EXEMPT guarded by an legacy experiment flag
Bug: 293393743
Test: TH
Change-Id: I91a6a81010f11ad2e7db48ed10e777bc42d002d5

Xiao Ma   commited 2025-06-19 11:16:49 +09:00
a915249504
DHCPv6 addr reg: get the DHCPv6 message type.
Flag: EXEMPT guarded by an legacy experiment flag
Bug: 293393743
Test: TH
Change-Id: If072a5bce0c8516af3fa4f7f9b63137de86b7500

Xiao Ma   commited 2025-06-19 11:15:29 +09:00
307112f889
DHCPv6 addr reg: add a function helper to create ADDR_REG_REPLY message.
Flag: EXEMPT guarded by an legacy experiment flag
Bug: 293393743
Test: TH
Change-Id: I1c48ebba71bd49d0164442929d3c5eb9fa96ac90

Xiao Ma   commited 2025-06-19 11:15:29 +09:00
cfa1f11bad
DHCPv6 addr reg: add ADDR_REG_REPLY packet class.
Flag: EXEMPT guarded by an legacy experiment flag
Bug: 293393743
Test: TH
Change-Id: I389fe6c54da3d4443d85b6fa87f915aa6809d21e

Xiao Ma   commited 2025-06-19 11:15:24 +09:00
64baf9aba5
DHCPv6 addr reg: add a function helper to create ADDR_REG_INFORM message.
Flag: EXEMPT guarded by an legacy experiment flag
Bug: 293393743
Test: TH
Change-Id: I6699b1479eec0958610b533af135f163681438df

Xiao Ma   commited 2025-06-19 11:12:59 +09:00
270672310e
DHCPv6 addr reg: build an IA Address option inside Dhcp6AddrRegInform.
Flag: EXEMPT guarded by an legacy experiment flag
Bug: 293393743
Test: TH
Change-Id: Ia16ba2b5ca9af3810506548085c995eed172b772

Xiao Ma   commited 2025-06-19 11:12:46 +09:00
8b1f9c1772
Have TestableNetworkAgent implement Expectable
This will make these agents testing a lot easier.

Also fix a small bug where waiting for callbacks that
are not expected would take a lot longer than it should.

Also trivial improvements to logging that I needed to stabilize
this.

Test: TH
Flag: EXEMPT test-only
Change-Id: I654d63eb226990ad1c5087cade7cf0a82d8526a1

Chalard Jean   commited 2025-06-16 17:28:57 +09:00
7bff7b2455
Merge "Remove the unused param id from the IaAddressOption#build API." into main
Patrick Rohr   authored and   Android (Google) Code Review   commited 2025-06-12 17:05:50 -07:00
b75ee7c26a
Merge "Introduce carrier-aware avoid bad Wi-Fi APIs" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-06-12 00:09:38 -07:00
1f7cecbcc8
Remove the unused param id from the IaAddressOption#build API.
Flag: EXEMPT guarded by an legacy experiment flag
Bug: 293393743
Test: TH
Change-Id: I524011cafd2bd97c0064b09d2bb80cb59b709bb1

Xiao Ma   commited 2025-06-12 11:47:53 +09:00
4e68970347
Merge "Make a base class for testable callbacks" into main
Jean Chalard   authored and   Android (Google) Code Review   commited 2025-06-10 16:48:00 -07:00
7f7c597328
Merge "Compare InetAddress to update mIpNetworksMap" into main
Sewook Seo   authored and   Android (Google) Code Review   commited 2025-06-10 05:25:06 -07:00
0b2f3895e7
Introduce carrier-aware avoid bad Wi-Fi APIs
This commit introduces new system APIs to manage "avoid bad Wi-Fi" settings,
leveraging both global system settings and carrier configurations. This
enhancement allows for more granular control and visibility into how Wi-Fi
networks are managed, especially in multi-SIM environments.

The new `setNetworkAvoidBadWifi(Context, int subId)` method provides
the ability to programmatically control this setting based on carrier-specific
policies or user preferences. This complements `getNetworkAvoidBadWifi(Context, int subId)`,
which allows querying the setting for a specific subscription ID, ensuring the
system can accurately determine the avoid bad Wi-Fi status.

Additionally, `shouldShowAvoidBadWifiToggle(Context, int subId)` is introduced.
This method determines whether the 'Avoid Bad Wi-Fi' user interface toggle
should be displayed. It considers both global settings and carrier configurations,
allowing for dynamic UI adjustments based on carrier requirements or user preferences.

These changes provide greater flexibility for managing Wi-Fi network selection
and improve the user experience by offering more context-aware control over
cellular behavior.

Deprecated APIs:
- `setNetworkAvoidBadWifi(Context, int value)`
- `getNetworkAvoidBadWifi(Context)`
New APIs:
- `setNetworkAvoidBadWifi(Context, int subId, int value)`
- `getNetworkAvoidBadWifi(Context, int subId)`
- `shouldShowAvoidBadWifiToggle(Context, int subId)`

Flag: com.android.net.flags.carrier_aware_avoid_bad_wifi
Bug: 410976315
Test: atest ConnectivityCoverageTests:android.net.connectivity.android.net.ConnectivitySettingsManagerTest
Change-Id: I79469cfe865a585593219d226c8198206c06b589

Jimi Chen   commited 2025-06-10 12:18:35 +00:00
92e23acebb
Compare InetAddress to update mIpNetworksMap
Since we update network lists mapped to InetAddress(mIpNetworksMap) for
socket destruction, compareAllAddresses should compare InetAddress list
instead of LinkAddress one.

Bug: 373280981
Flag: android.net.platform.flags.connectivity_service_destroy_socket
Test: atest ThreadNetworkIntegrationTests
Change-Id: I2ea0cce3cc2be648b142e3e9b17e9260f0d4ef96

Sewook Seo   commited 2025-06-10 09:14:45 +00:00
af5eba5be2
Make a base class for testable callbacks
Have TestableNetworkCallback adopt it, as a first client. It's also by
far the most complex.

Test: TH
Flag: EXEMPT test-only
Change-Id: Ie58d051b4478c901b7f0f54e89a67d22f1ee2ce2

Chalard Jean   commited 2025-06-10 17:22:01 +09:00
2db96977db
Merge "Add getInterfaceMtu method in ProcfsParsingUtils" into main
Jimi Chen   authored and   Android (Google) Code Review   commited 2025-06-10 00:31:57 -07:00
b91b3afcd0
Merge "Replace String.split() with precompiled regex" into main
Treehugger Robot   authored and   Android (Google) Code Review   commited 2025-06-09 21:15:55 -07:00
8f93c27ff9
Add getInterfaceMtu method in ProcfsParsingUtils
Flag: EXEMPT mainline
Bug: 406085682
Test: atest NetworkStackTests:com.android.networkstack.util.ProcfsParsingUtilsTest
Change-Id: I62e129c3903e0c432f4a4d84c7024cfb4e140dd5

Jimi Chen   commited 2025-06-10 03:07:10 +00:00
991a628dfe