Commit graph android_packages_modules_Co.../Tethering/tests/unit
Message SHA1
SyncSM05.1: add testMultiDepthTransition
Test: atest TetheringTests
Change-Id: I427360f6a106b001123442ccd4802290d4f13369

Mark   commited 2023-10-23 07:34:29 +00:00
c352f3cb4e
SyncSM05: add SyncStateMachineTest
A initial test for SyncStateMachine, will add more tests in the
following changes.

Test: atest SyncStateMachineTest
Change-Id: Ie6dbbe22bfef40b1675d50243d14d0a235df1e3a

Mark   commited 2023-10-23 07:29:09 +00:00
8f068a8a1e
Merge "Decouple Ipv6UpstreamRule with Ipv6DownstreamRule" into main
KH Shi   authored and   Gerrit Code Review   commited 2023-10-02 05:33:48 +00:00
2a6a7359b7
Decouple Ipv6UpstreamRule with Ipv6DownstreamRule
Currently, Ipv6UpstreamRule is added follows the adding of
Ipv6DownstreamRule when it is the first rule from a downstream
interface to the upstream interface.

This CL changed it to:
1. Upstream interface change updates both IPv6 upstream and downstream
   forwarding rules.
2. Neighbor events updates only IPv6 downstream forwarding rules.

Data limit setting on the upstream interface is now depend on the
upstream rules instead of the downstream rules. This CL also updates
corresponding test cases in IpServerTest and BpfCoordinatorTest.

Test: atest TetheringTests
Bug: 261923493
Change-Id: I5b4df64a3d276afb7a24bbef3a0432f53377e8b2

KH Shi   commited 2023-09-19 08:02:24 +00:00
701c3ca2f5
Remove unnecessary arguments from isTetheringFeatureEnabled
This CL also updates not to use isTetheringFeatureEnabled for
TETHER_FORCE_UPSTREAM_AUTOMATIC_VERSION which is wrongly configured in
Connectivity namespace.

Test: m
Bug: 279108992
Change-Id: If4f3a57c749bbaeb85454c31248c5bc5feaab936

Motomu Utsumi   commited 2023-09-08 16:11:28 +09:00
3e0be398a2
Remove duplicated bpf offload support check in IpServer
In current code, IpServer will ensure bpf offload is supported before
calling BpfCoordinator's APIs. But those APIs already have the same
checks inside the function. This CL removed duplicated checks in
IpServer.

After this change, the BPF offload support status is only determined
inside BpfCoordinator and it won't change during the life cycle of
Tethering. Tethering initializes mBpfCoordinator just once in the
constructor. After that point, the value of isUsingBpf can never
change, because mIsBpfEnabled is final and
mBpfCoordinatorShim.isInitialized() is either always true (api30) or
can either never change (api31).

Also fixed a bug in IpServerTest upon this change.

Test: atest TetheringTests
Bug: 261923493
Change-Id: I50f231a83bf678b90eae4fd9bfa6035e86978bb3

KH Shi   commited 2023-09-01 07:37:18 +00:00
e4d549ab11
Introduce Ipv6UpstreamRule to bpf tethering offload
Replaced startUpstreamIpv6Forwarding and stopUpstreamIpv6Forwarding
with add/remove Ipv6UpstreamRule. This is a preparation for following
CLs which will pass the upstream's prefixes to the bpf map. We might
have more than one upstream rules.

Also renamed Ipv6ForwardingRule to Ipv6DownstreamRule since we have
defined the Ipv6UpstreamRule.

No logic changes are being made in this CL.

Test: atest TetheringTests
Bug: 261923493
Change-Id: I022f97c2daf468bbd4a4279a069ccf498013e7e7

KH Shi   commited 2023-08-24 12:02:23 +00:00
59ad35ee19
Merge "Add tests for OffloadHardwareInterface" into main
KH Shi   authored and   Gerrit Code Review   commited 2023-08-14 02:13:23 +00:00
839cc0b455
Merge "Import RFC7421_PREFIX_LENGTH from NetworkStackConstants." into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-08-10 13:07:20 +00:00
b8ea09efd7
bpf tethering offload - add src subnet to upstream ipv6 direction
This patch is based on aosp/2535559 from maze@.

Add source prefix into the upstream key such that only packets which
source IPv6 address matches it will be forwarded to the upstream
interface.

In this patch, the source prefix is set to zero so there is no
behavior changes. Next CL in patch series will use the real source
prefixes retrieved from upstream interface.

Test: atest TetheringTests
Bug: 261923493
Change-Id: I43d068a29b937c7dfeb6fab632a8effb47ee2263

KH Shi   commited 2023-08-10 16:01:21 +08:00
c8fb1a2530
Add tests for OffloadHardwareInterface
NativeHandles shouldn't be closed in OffloadHardwareInterface after
passing them to initOffload() of AIDL service, because their owner
will be changed to ParcelFileDescriptor by libbinder.

Add test cases to verify that NativeHandles are closed correctly.
NativeHandles should be closed after initOffload if:
  - Init with HIDL HAL interface
  - Has null NativeHandle, any non-null NativeHandles should be closed

Bug: 277834236
Test: atest OffloadHardwareInterfaceTest
Change-Id: Icbe74da73d3bdc582d1816b314fdfce9661465fc

KH Shi   commited 2023-08-10 14:56:09 +08:00
f5390a9d8f
Import RFC7421_PREFIX_LENGTH from NetworkStackConstants.
Remove the dependency on services-connectivity-shared-srcs
filegroup gradually.

Bug: 290885904
Test: TH
Change-Id: I6474563a3a0b521945e6467a2832862764ad4770

Xiao Ma   commited 2023-08-09 20:02:15 +09:00
1f993309c6
Merge "Tethering: ignore duplicate upstream changed event"
Mark Chien   authored and   Gerrit Code Review   commited 2023-06-19 15:03:48 +00:00
c2e434bbc7
Tethering: ignore duplicate upstream changed event
Different network objects with the same network ID should be
treated as the same network.

chooseUpstreamType compares the current upstream and new upstream
by object (comparison operator) instead of network id
(Network#equals). This implies that different objects with the
same network id still trigger upstream changed report.

Since this commit, reportUpstreamChanged is only called when upsteam
has really changed (connected, switched or disconnected) in
chooseUpstreamType. In previous code, reportUpstreamChanged is also
called if EVENT_ON_CAPABILITIES is called when the upstream is the
same but its capabilities changed.

The NotificationUpdater#onUpstreamCapabilitiesChanged method only
needs to be called by chooseUpstreamType when it chooses a new
upstream. If the upstream remains the same but its capabilities
change, the EVENT_ON_CAPABILITIES will call
onUpstreamCapabilitiesChanged.

Bug: 243516306
Test: atest TetheringTest
Change-Id: I009383a61a5fabd249ba78fcffd524a5bbe4602e

Hungming Chen   authored and   Mark   commited 2023-06-19 06:51:03 +00:00
fc52868213
Add testIpv4AddressForSapAndLohsConcurrency test case
A test to verify that SAP and LOHS can use different IPv4
addresses if they are both enabled.

Bug: 233175023
Test: atest TetheringTest
Change-Id: I40f0f35221a76e6593cc8d04e9f2b25df8c27c87

Mark   commited 2023-06-17 04:04:14 +00:00
cb1fe1a622
Add testConnectedClientsForSapAndLohsConcurrency test case
A test to confirm that connected clients are updated when SAP
and LOHS are enabled simultaneously.

Bug: 233175023
Test: atest TetheringTest
Change-Id: I920f02e5b2ad137af529776141d51b6c83b8ea5b

Mark   commited 2023-06-16 09:09:10 +00:00
639866b45a
Support SAP and LOHS enabled at the same time
Use type + scope as key to build cached address map so that
SAP (key: TETHERING_WIFI + INTERNET) and LOHS
(key: TETHERING_WIFI + LOCAL) can use different address.

Bug: 233175023
Test: atest TetheringTests
Change-Id: I46a4b3ee919628092b7540202a43d79f407b09b6

Mark   commited 2023-05-25 08:31:33 +00:00
49649c9aea
Allow SAP and LOHS wifi clients exist at the same time
This change store localOnly wifi clients in its own field so that
tethered and localOnly hotspot clients can exist at the same time.

Currently, there are no tethered and localOnly hotspot clients at
the same time because PrivateAddressCoordinator does not support
SAP + LOHS. A follow-up change will be made to allow this.

When both SAP and LOHS are enabled, the SAP and LOHS clients from
TetheringEventCallback#onClientsChanged are all TETHERING_WIFI.
Currently, there is no way for the listeners to distinguish between
SAP and LOHS clients.

Bug: 233175023
Test: atest TetheringTests
Change-Id: I01b0a6abb084f7135f7825e0c5303e49c16a4c39

Mark   commited 2023-05-25 08:31:06 +00:00
ae3abdfa4b
Merge "Add verifyHotspotClientUpdate helper function"
Mark Chien   authored and   Gerrit Code Review   commited 2023-05-18 05:57:39 +00:00
adc6ab5c45
Merge "Fix entitlement recheck fail in U"
Mark Chien   authored and   Gerrit Code Review   commited 2023-05-17 05:54:39 +00:00
65a73dbf78
Fix entitlement recheck fail in U
Starting with U, only explicit intents will be allowed to
launch non-exported internal components. Set package name
to entitlement recheck intent so that the intent could be
delivered to tethering itself successfully.

Bug: 278482046
Test: atest TetheringTests
      manual verify entitlement recheck work in U
Change-Id: Ife30eee13fe39509ccb5786d2a76fbb7baa022a8

Mark   commited 2023-05-16 07:59:32 +00:00
e86fb5ef56
Add verifyHotspotClientUpdate helper function
This change centralized some common test codes to
verifyHotspotClientUpdate() to facilitate the following
commit for softap+lohs

Bug: 233175023
Test: atest TetheringTests
Change-Id: Iee3905084b244b91abdf7c562d77b5054d58ff6a

Mark   commited 2023-05-04 07:18:08 +00:00
c16645155f
Add a dependency object in TetheringConfiguration
Address a TODO in TetheringConfiguration to use a dependency object
instead of static mocking on DeviceConfig.

This avoids TetheringConfiguration dependencies on internal
implementation of DeviceConfigUtils, unblocking changes in
DeviceConfigUtils.

Bug: 279108992
Test: atest TetheringTests
Change-Id: I252eaadff85fa47b894e989b4f2527b00c5dca56

Remi NGUYEN VAN   authored and   Motomu Utsumi   commited 2023-04-28 19:18:43 +09:00
6d38c01852
Add tx_bytes and rx_bytes to UpstreamEvent message
This commit adds two new fields, tx_bytes and rx_bytes, to the
UpstreamEvent message. These fields provide information about the
amount of data transferred during the event, which can be useful for
network performance analysis. The current tx/rx usages are always
zero, but it will be updated in a later change to reflect the actual
usage. No changes were made to the existing fields upstream_type and
duration_millis.

Test: atest TetheringMetricsTest
Change-Id: I9e1043b3fff5aa3f548b8696bac7e5bc4271c77c

Wayne Ma   commited 2023-04-21 11:15:56 +08:00
b5ee365614
Address comment from aosp/2335004
Bug: 263681262
Test: atest TetheringMetricsTest
Change-Id: I7372b7717a903d43a543f82e31a0439725d02e3a

Wayne Ma   commited 2023-04-13 10:01:36 +08:00
fab745c8ae
Merge "Add new test for swtiching multiple upstream network."
Wayne Ma   authored and   Gerrit Code Review   commited 2023-03-21 08:51:42 +00:00
cd893e0825
Add new test for swtiching multiple upstream network.
Bug: 263681262
Test: atest TetheringMetricsTest
Change-Id: I70e88d36ecf4cac0f61ab54cc14efa46a4b5facb

Wayne Ma   commited 2023-03-21 11:38:16 +08:00
2bcd523745
Merge "Implement logging of upstream event type and duration."
Wayne Ma   authored and   Gerrit Code Review   commited 2023-03-20 16:50:37 +00:00
9d6b724887
Merge "Add Tetheroffload AIDL interface support"
KH Shi   authored and   Gerrit Code Review   commited 2023-03-20 03:58:42 +00:00
7b8568927e
Add Tetheroffload AIDL interface support
Add the AIDL HAL service interface support and abstract the HIDL/AIDL
interface implementations to allow OffloadController to talk to both
interfaces.

Bug: b/205762647
Test: atest com.android.networkstack.tethering
      atest ConnectivityCoverageTests
      atest ConntrackSocketTest
Change-Id: If7634a298d03668ed70b328f1ad6ca0ac0fe170b

KH Shi   commited 2023-03-17 16:56:47 +08:00
3d5e65cb48
Implement logging of upstream event type and duration.
Bug: 263681262
Test: atest TetheringMetricsTest
Test: statsd_testdrive 303
Change-Id: I80301ee035a9814920e3ce4b9eca6bcdc59350db

Wayne Ma   commited 2023-03-17 16:40:06 +08:00
c0e9e2901b
Connectivity Tests: join handler thread after calling quitSafely
Somewhat surprisingly, HandlerThread#quitSafely is *not* a synchronous
method, so the tearDown() method still needs to wait for the thread to
join.

Test: TH
Change-Id: I0433e2100adf9299a67af5c259a518cf44f4be57

Patrick Rohr   commited 2023-03-17 01:01:09 -07:00
98021b650b
Refactor TetheringMetricsTest, remove Pair.
Test: atest TetheringMetricsTest
Change-Id: I1b536ff198119b07e9313f081a8e02e515c67efd

Wayne Ma   commited 2023-03-15 17:34:12 +08:00
304e4f2af8
Refactor TetheringMetricsTest
Test: atest TetheringMetricsTest
Change-Id: Ic44f47460342300164fa6ad5c928a850ba28d1fb

Wayne Ma   commited 2023-03-14 13:14:50 +08:00
209ff1c3c3
TetheringTest: test upstream changes capabilities
Add more tests that upstream changes capabilities in the existing
tests:
- testUpstreamNetworkChanged
- testUpstreamCapabilitiesChanged

Bug: 243516306
Test: atest TetheringTest
Change-Id: Iba2f07404c78c9e8662e2f796a2ff1695123cab7

Hungming Chen   commited 2023-02-03 11:09:57 +08:00
8e8cd0fdaa
TetheringTest: verify onUpstreamCapabilitiesChanged explicitly
In testUpstreamCapabilitiesChanged, verify that
onUpstreamCapabilitiesChanged is called just after which function
triggered onUpstreamCapabilitiesChanged.

Bug: 243516306
Test: atest TetheringTest
Change-Id: Icd871654455033475092b9e7376b604cb0ba00eb

Hungming Chen   commited 2023-02-02 20:09:13 +08:00
2ebcf840ef
TetheringTest: demonstrate duplicated upstream change event
The duplicated upstream change event on the same network is a bug
which needs to be fixed.

Bug: 243516306
Test: atest TetheringTest
Change-Id: I7c70328d937877ec9832a2764cfb331561ee34b6

Hungming Chen   commited 2023-02-02 20:09:13 +08:00
9ca7fee6c9
Merge changes Ie2ba9805,I8f5b23f9
* changes:
  Move onUpstreamCapabilitiesChanged out of reportUpstreamChange
  TetheringTest: improve onUpstreamCapabilitiesChanged test

Treehugger Robot   authored and   Gerrit Code Review   commited 2023-02-01 06:35:13 +00:00
7acd206160
Merge "TetheringTest: replace upstream change check by event callback"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-02-01 05:59:53 +00:00
119e5adc14
BpfCoordinatorTest: add testUpdateUpstreamNetworkState
Bug: 258637850
Bug: 241106456
Test: atest ConnectivityServiceTest
Change-Id: I156398ef7ffaceb454dc187682238821da77c72b

Hungming Chen   commited 2023-01-31 16:35:09 +08:00
650cc9c0d3
TetheringTest: replace upstream change check by event callback
UpstreamNetworkMonitor#setCurrentUpstream is going to be removed
 because UpstreamNetworkMonitor#mTetheringUpstreamNetwork is unused.
 Use tethering event callback to check upstream change.

Bug: 243516306
Test: atest TetheringTest
Change-Id: I5773cfc80190b554a3b63b4f827c220b0e663427

Hungming Chen   commited 2023-01-18 15:13:49 +08:00
9e2c0f9df5
TetheringTest: improve onUpstreamCapabilitiesChanged test
This is a preparation for migrating the upstream change notification.

Changes:
1. Modify testUpstreamNetworkChanged
   - Add losing upstream test
   - Verify the capabilities on the explicit network
2. Modify testUpstreamCapabilitiesChanged
   - Verify the capabilities on the explicit network
3. Add testUpstreamCapabilitiesChanged_stopTethering
   - Test that TetherModeAliveState#exit sends the null upstream
     notification. Above tests only covers the notifications which
     are triggered by chooseUpstreamType or EVENT_ON_CAPABILITIES.

Bug: 243516306
Test: atest TetheringTest

Change-Id: I8f5b23f93c27b8c690b2fd275e3f636fbaeb4973

Hungming Chen   commited 2023-01-18 15:13:49 +08:00
9e9d74ca00
TetheringTest: correct the comment in chooseDunUpstreamTestCommon
Bug: 243516306
Test: atest TetheringTest
Change-Id: I642722498357dfb8f1582de50701f213c49f3077

Hungming Chen   commited 2023-01-13 17:53:59 +08:00
f2abe15fe7
Merge "TetheringTest: fix assert{*}Equals order in TestTetheringEventCallback"
Treehugger Robot   authored and   Gerrit Code Review   commited 2023-01-13 08:43:07 +00:00
8043d5d7af
Merge changes from topic "deprecate_connectivity_action_in_tethering"
* changes:
  Tethering: deprecate CONNECTIVITY_ACTION on U+ device
  Test: add tests to testChooseDunUpstreamByAutomaticMode_*
  TetheringTest: separate setup func from chooseDunUpstreamTestCommon

Treehugger Robot   authored and   Gerrit Code Review   commited 2023-01-13 08:41:20 +00:00
401f1ff2db
Merge "Fix TetheringServiceTest#testTetheringManagerLeak flaky"
KH Shi   authored and   Gerrit Code Review   commited 2023-01-13 05:44:17 +00:00
c91fbabd45
TetheringTest: fix assert{*}Equals order in TestTetheringEventCallback
TestTetheringEventCallback may use assertEquals(actual, expected)
but assertEquals(expected, actual).

It is confused while test is failed.

For example:

Code:
callback.expectUpstreamChanged(new Network[] {null} /* expected */);

Before:
java.lang.AssertionError: expected:<100> but was:<null>

After:
java.lang.AssertionError: expected:<null> but was:<100>

Bug: 243516306
Test: atest TetheringTest
Change-Id: I6a987e4dd1cccc5e79da7dda55f194291e0c4a60

Hungming Chen   commited 2023-01-12 17:48:04 +08:00
b4859d1ea1
Fix TetheringServiceTest#testTetheringManagerLeak flaky
This test relies on forceGc to free and finalize the TetheringManager
before perform validation checks. In some test suites, if there were
already too many unused objects accumulated in the system before
running the test, it might take more than 5 seconds to free them.
Increase the maximum retry time to 30 seconds to fix the flakiness.

Bug: 263335396
Test: atest TetheringServiceTest#testTetheringManagerLeak
      run the flaky test suite on ABTD with CL
Change-Id: I38bee3d43fbeb278993d113ccbe0645aedc5d75d

KH Shi   commited 2023-01-12 08:25:34 +00:00
0ed11f5a46
BpfCoordinator: publish upstream interface mtu to v4 offload rule
Respect the upstream interface mtu instead of always setting
mtu 1500.

Using upstream interface mtu is probably not the best solution
for tether offload pmtu but it at least respects the upstream
interface mtu which may be less than 1500.

Test: manual test
1. Connect to carrier Taiwan Star.
2. Enable tethering and check the mtu 1434 in dumpsys.
IPv4 Upstream: proto [inDstMac] iif(iface) src -> nat ->
dst [outDstMac] pmtu age
  udp [02:10:45:32:ef:35] 54(54) 192.168.72.125:39034
  -> 15(rmnet1) 100.83.189.11:39034
  -> 142.251.43.14:443 [00:00:00:00:00:00] 1434 69657ms
IPv4 Downstream: proto [inDstMac] iif(iface) src -> nat
  -> dst [outDstMac] pmtu age
  udp [00:00:00:00:00:00] 15(rmnet1) 142.251.43.14:443
  -> 54(54) 100.83.189.11:39034
  -> 192.168.72.125:39034 [9a:8a:4d:ec:a4:7c] 1434 69633ms

Bug: 262860312
Test: atest BpfCoordinatorTest
Change-Id: Ic6dcb95ed76d5306053e4645b6baebc67ff082cf

Hungming Chen   commited 2023-01-03 23:36:30 +08:00
5c985e2cdd
Merge "BpfCoordinatorTest: renumber the test interface indices"
Maciej Żenczykowski   authored and   Gerrit Code Review   commited 2022-12-30 20:46:16 +00:00
53e8697d39