Commit Graph

29122 Commits

Author SHA1 Message Date
Nucca Chen
34fc8d990d Refresh conntrack entry timeout am: fadd7b7a33
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15114804

Change-Id: I87229a3c9ecd63987e10ae76b05c755eb3b31580
2021-06-26 16:06:02 +00:00
Nucca Chen
3cf0c93a3c Clear IPv4 offload rules when tethering stopped am: 01785d7eff
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15114803

Change-Id: I1a73e28f9ac418bc0a8c8dc2524ea0ab322f788f
2021-06-26 16:05:51 +00:00
Nucca Chen
fadd7b7a33 Refresh conntrack entry timeout
Needed because the BPF maps offloads IPv4 traffic. The kernel can't
trace the offloaded traffic to keep the conntrack entry.

Bug: 190783768
Test: atest TetheringCoverageTests
Original-Change: https://android-review.googlesource.com/1566871
Merged-In: Idbcf686c9b2124b192944156ac5111be741744fb
Change-Id: Idbcf686c9b2124b192944156ac5111be741744fb
2021-06-26 08:48:52 +00:00
Nucca Chen
01785d7eff Clear IPv4 offload rules when tethering stopped
The condition for deleting IPv4 forwarding rules.
1. When the tethering client has gone, deletes the client and its
   rules.
2. When the upstream has gone, deletes all rules.
3. When the upstream has changed, deletes all rules.

Test: atest TetheringCoverageTests and check IPv4 offload rules
via dumpsys tethering in the following test cases.

Bug: 190783768

Test cases:
a. Loss upstream interface while tethering
  1. Enable WIFI tethering
  2. Disable upstream interface
  3. Check the rules are removed.
b. Loss downstream interfaces while tethering
  1. Enable WIFI tethering
  2. Enable BT tethering
  3. Disable BT tethering
  4. Check the BT tether rules are removed.
  5. Disable WIFI tethering
  6. Check the WIFI tether rules are removed.
c. Switch upstream interface while tethering
  1. Enable WIFI tethering
  2. Enable BT tethering
  3. Switch upstream interface from cellular to wifi.
  4. Check all rules are removed.
d. Enable NAT failure (manual)

Log:
The rule deletion in each case.
- IpServer#stopIPv4: case b and case d.
- BpfCoordinator#updateUpstreamNetworkState: case a and case c.

Test case a
06-23 09:58:59.245  [...] Tethering: [BpfCoordinator]
    updateUpstreamNetworkState tetherOffloadRule4Clear wlan2

Test case b
06-07 22:17:51.886  [..] Tethering: [bt-pan] cleanupUpstream bt-pan
06-07 22:17:51.888  [..] Tethering: [bt-pan] stopIPv4 bt-pan
06-07 22:18:23.769  [..] Tethering: [wlan2] cleanupUpstream wlan2
06-07 22:18:23.772  [..] Tethering: [wlan2] stopIPv4 wlan2

Test case c
06-08 11:11:48.277  [..] Tethering: [BpfCoordinator]
    updateUpstreamNetworkState tetherOffloadRule4Clear bt-pan
06-08 11:11:48.396  [..] Tethering: [BpfCoordinator]
    updateUpstreamNetworkState tetherOffloadRule4Clear wlan2
06-08 11:11:48.579  [..] Tethering: [wlan2] cleanupUpstreamInterface
    wlan2
06-08 11:11:48.808  [..] Tethering: [bt-pan] cleanupUpstreamInterface
    bt-pan

Enabling NAT failure
06-08 13:04:18.117  [..] Tethering: [wlan2] Exception enabling NAT [..]
06-08 13:04:18.234  [..] Tethering: [wlan2] cleanupUpstream wlan2
06-08 13:04:18.246  [..] Tethering: [wlan2] stopIPv4 wlan2

Original-Change: https://android-review.googlesource.com/1579873
Merged-In: Id505a3deb277bbe0f44403234d8ca8bbf01eec80
Change-Id: Id505a3deb277bbe0f44403234d8ca8bbf01eec80
2021-06-26 08:45:39 +00:00
Remi NGUYEN VAN
c990d821f9 Merge "Add back tethering to mainline-postsubmit" into sc-dev am: d5532eac04
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15076672

Change-Id: I57cc02aef4bad5f1e17d7b5065dc755c389196e2
2021-06-25 00:52:43 +00:00
Remi NGUYEN VAN
d5532eac04 Merge "Add back tethering to mainline-postsubmit" into sc-dev 2021-06-25 00:42:10 +00:00
Lorenzo Colitti
b0a55740ab Add CTS for BatteryStatsManager new API am: 9d3a5ede58
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15082047

Change-Id: Ie217e2bec3c63284f73cedabb035f7d079fa8121
2021-06-24 09:44:07 +00:00
Lorenzo Colitti
9d3a5ede58 Add CTS for BatteryStatsManager new API
Bug: 189308158
Test: This test and
      run testReportNetworkInterfaceForTransports
      with --rerun-until-failure 500
Original-Change: https://android-review.googlesource.com/1722770
Merged-In: I654b8920d6ea1dada782a618776b13870f7f98df
Change-Id: I654b8920d6ea1dada782a618776b13870f7f98df
2021-06-24 03:15:03 +00:00
Yan Yan
aa5e681d92 Merge "Test updating underlying network of IpSecTunnelInterface" into sc-dev am: dfc9b497fd
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15068514

Change-Id: I9d2a9a3d806cc6cf76994b0762dab31771166045
2021-06-24 01:27:53 +00:00
Yan Yan
dfc9b497fd Merge "Test updating underlying network of IpSecTunnelInterface" into sc-dev 2021-06-24 01:05:26 +00:00
paulhu
85b11cfd19 Add test for CSM#[get|set]UidsAllowedOnRestrictedNetworks am: 342ee18b57
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15081393

Change-Id: I0d23b667251e1372d76601805bb55d90dc916739
2021-06-23 19:35:04 +00:00
Paul Hu
341971c0e1 Merge "Add ConnectivitySettingsManagerTest" into sc-dev am: a244f13f21
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15079711

Change-Id: I621d54f7290c45d73db9369364a19f544915943c
2021-06-23 16:47:11 +00:00
paulhu
342ee18b57 Add test for CSM#[get|set]UidsAllowedOnRestrictedNetworks
Bug: 185149952
Test: atest ConnectivityManagerTest
Original-Change: https://android-review.googlesource.com/1740740
Merged-In: Ie9391d9332ded58cf1e63c8c5c6f5ba85c950bc6

Change-Id: Ie9391d9332ded58cf1e63c8c5c6f5ba85c950bc6
2021-06-23 16:34:01 +00:00
Paul Hu
a244f13f21 Merge "Add ConnectivitySettingsManagerTest" into sc-dev 2021-06-23 16:29:20 +00:00
TreeHugger Robot
e89ecee138 Merge changes I77dc5556,If772078c,Idb19b0f7 into sc-dev am: e7ac3ffec5
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15079710

Change-Id: I3bb589deffd64544931966e94502a658f3945d10
2021-06-23 16:24:57 +00:00
Chiachang Wang
8bb531f3af Provide a way to override the avoid bad wifi configuration am: fad30e3d84
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15068262

Change-Id: I918e3af3e637cfa20c0943c197780411f99e41f1
2021-06-23 16:24:55 +00:00
Remi NGUYEN VAN
3e19171609 Remove ConnectivityServiceTest signature perms use am: ff55aeb916
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15076673

Change-Id: I82e8d3473fab1c5190b18e123f6ced4ad9a7bc1d
2021-06-23 16:24:52 +00:00
TreeHugger Robot
30ebf987bb Merge "Add basic tests for InvalidPacketException" into sc-dev am: 06b27811c8
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15076675

Change-Id: I028a47e25820a13a2ebfb4354f52618564a954e7
2021-06-23 16:23:50 +00:00
TreeHugger Robot
c0459cdcb8 Merge "Move ConnectivityDiagnosticsManagerTest to common" into sc-dev am: ac6a28907a
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15076674

Change-Id: I593327a7edc6327e3f0277b08d204ec4474579c9
2021-06-23 16:23:36 +00:00
Remi NGUYEN VAN
feda9bfeaa Added tests for QosCallback am: 763f3a0fb3
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15076670

Change-Id: Ib0d640796639efd7c95fed7cec1bf798b0f22dc4
2021-06-23 16:23:21 +00:00
Remi NGUYEN VAN
798e8c2747 Add tests for duplicate PendingIntent requests am: 3674367bcc
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15068269

Change-Id: Icb70a514e3a0650932351eb7abd86e569c010bf4
2021-06-23 16:23:12 +00:00
TreeHugger Robot
e7ac3ffec5 Merge changes I77dc5556,If772078c,Idb19b0f7 into sc-dev
* changes:
  Add test for CM#setAvoidUnvalidated
  Provide a way to override the avoid bad wifi configuration
  Remove ConnectivityServiceTest signature perms use
2021-06-23 16:16:03 +00:00
TreeHugger Robot
06b27811c8 Merge "Add basic tests for InvalidPacketException" into sc-dev 2021-06-23 16:09:25 +00:00
TreeHugger Robot
ac6a28907a Merge "Move ConnectivityDiagnosticsManagerTest to common" into sc-dev 2021-06-23 16:09:23 +00:00
paulhu
0903f73e1f Add ConnectivitySettingsManagerTest
- Add tests for ConnectivitySettingsManager.
- Also address leftover javadoc comments.

Bug: 182538166
Test: atest FrameworksNetTests
Test: atest CtsNetTestCases
Original-Change: https://android-review.googlesource.com/1738353
Merged-In: I8161c1bca84b41964578d59ee5d6ab07b2380707
Change-Id: I8161c1bca84b41964578d59ee5d6ab07b2380707
2021-06-23 20:02:27 +08:00
Chiachang Wang
79f6827d45 Add test for CM#setAvoidUnvalidated
Bug: 186061922
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCasesLatestSdk
Original-Change: https://android-review.googlesource.com/1733789
Merged-In: I77dc5556458c2e824f7abd5a7b79e8aeed8dabf3
Change-Id: I77dc5556458c2e824f7abd5a7b79e8aeed8dabf3
2021-06-23 10:31:17 +00:00
Remi NGUYEN VAN
bdd448e641 Add basic tests for InvalidPacketException
The test simply verify the constructor. They only apply on S+ as
InvalidPacketException is not updatable before S.

Bug: 187935317
Test: atest InvalidPacketExceptionTest
Original-Change: https://android-review.googlesource.com/1742076
Merged-In: I33f1ee1702672204a46063e6e75c3880d5e7600b
Change-Id: I33f1ee1702672204a46063e6e75c3880d5e7600b
2021-06-23 09:16:59 +00:00
Remi NGUYEN VAN
b5f0819d35 Move ConnectivityDiagnosticsManagerTest to common
The tests are also useful in CTS to ensure that the
ConnectivityDiagnosticsManager class API is implemented properly
(including behavior of the DataStallReport class for example).

Bug: 187935317
Test: atest ConnectivityDiagnosticsManagerTest
Original-Change: https://android-review.googlesource.com/1742075
Merged-In: I86f39238054f43403f9a1e383dd2a935de84f06f
Change-Id: I86f39238054f43403f9a1e383dd2a935de84f06f
2021-06-23 09:16:53 +00:00
Chiachang Wang
fad30e3d84 Provide a way to override the avoid bad wifi configuration
ConnectivityManager.setAvoidUnvalidated only works if the
config_networkAvoidBadWifi configuration is set to 0 and the
NETWORK_AVOID_BAD_WIFI setting is unset. There is no easy way
for a testing app to temporary set a test value to verify the
behavior of the API. Thus, add a mechanism to allow test app
to set a period of time to temporary unstrict the resource
configuration, i.e. Temporary simulate config_networkAvoidBadWifi
configured to 0.

Bug: 186061922
Test: atest CtsNetTestCases FrameworksNetTests
Original-Change: https://android-review.googlesource.com/1733788
Merged-In: If772078c61a9b12926f104d5dfc9c9071e844732
Change-Id: If772078c61a9b12926f104d5dfc9c9071e844732
2021-06-23 08:42:47 +00:00
Remi NGUYEN VAN
ff55aeb916 Remove ConnectivityServiceTest signature perms use
To allow unit tests to run without platform certificates, remove
signature permission usage in ConnectivityServiceTest.

This mocks permission checks done in ConnectivityService for which the
test assumed that the permission was held, and mocks calls to
BatteryStatsManager. Calls to ActivityManagerService (through
PendingIntent) are done with shell permissions as the test uses real
PendingIntent mechanics.

Bug: 187935317
Test: atest FrameworksNetTests
Merged-In: If309d653ac2e9bbcf1b94bcee6336367289df359
Change-Id: If309d653ac2e9bbcf1b94bcee6336367289df359

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1736615

(cherry picked from commit 595dda3604)

Change-Id: Idb19b0f7cb87bb4d9de7a0b1a0e4128c2d6b9c6d
2021-06-23 08:39:38 +00:00
Remi NGUYEN VAN
109fd92b3d Add back tethering to mainline-postsubmit
Tethering was removed from mainline-postsubmit while Connectivity was
being added to it, but it can run in postsubmit again now.

If the runs are successful, it can be added to presubmit as well.

Ignore-AOSP-First: Partial revert of change that did not go to AOSP
Bug: 177290955
Test: TH needs to test postsubmit

Change-Id: I5d5dbccd8d14be573104947412a76578b2d7a6c1
2021-06-23 08:19:45 +00:00
Remi NGUYEN VAN
763f3a0fb3 Added tests for QosCallback
Tests for the newly added QosCallback functionality

Bug: 155176305
Test: Added to cts/NetworkAgentTest
Original-Change: https://android-review.googlesource.com/1558648
Merged-In: I29769fc8be074a5105bfe4ac34e30980c5f8744a
Change-Id: I29769fc8be074a5105bfe4ac34e30980c5f8744a
2021-06-23 07:15:31 +00:00
Remi NGUYEN VAN
3674367bcc Add tests for duplicate PendingIntent requests
Add tests for requestNetwork and registerNetworkCallback with
PendingIntents that are equal as per PendingIntent.intentFilterEquals.

In such situations, the first request is documented to be automatically
unregistered. This means that the PendingIntent should only be fired
once, instead of being fired for both requests.

Currently this behavior is broken for network callbacks (not for network
requests).

Test: atest ConnectivityManagerTest
Bug: 174237997
Original-Change: https://android-review.googlesource.com/1742073
Merged-In: Ic636c731c71474ef09043d7a26ccfd6e2bb5c39f
Change-Id: Ic636c731c71474ef09043d7a26ccfd6e2bb5c39f
2021-06-23 07:15:24 +00:00
Frank Li
a94b8e1489 Ignore some ConnectivityManagerTest CTS tests that can't be run in the instant app mode am: e7d085e87d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15068259

Change-Id: I20baa5a6730b594679ff558bbf218c478dda1517
2021-06-23 05:45:41 +00:00
Remi NGUYEN VAN
34611d0cf3 Merge "Initialize TetheringManager lazily" into sc-dev am: 7579035ac9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15044616

Change-Id: If37fbd985758dd58de1f9d8619a96a295b2794e3
2021-06-23 02:38:16 +00:00
Frank Li
e7d085e87d Ignore some ConnectivityManagerTest CTS tests that can't be run in the instant app mode
1. testIsPrivateDnsBroken: It requires the
   permission:android.permission.WRITE_SECURE_SETTINGS. But the
   WRITE_SECURE_SETTINGS permission can't be granted to instant
   apps.
2. testSetOemNetworkPreferenceForTestOnlyPref: Instant apps can't
   create test networks.
3. testSetOemNetworkPreferenceForTestPref: Instant apps can't
   create test networks.

Bug: 191678254
Bug: 191680108
Test: atest android.net.cts.ConnectivityManagerTest --instant
      atest CtsNetTestCasesLatestSdk:ConnectivityManagerTest --instant
Original-Change: https://android-review.googlesource.com/1743373
Merged-In: Ice43bcf7a1dc34f4a54fefba7f408767f0a4341e
Change-Id: Ice43bcf7a1dc34f4a54fefba7f408767f0a4341e
2021-06-23 02:24:55 +00:00
Remi NGUYEN VAN
7579035ac9 Merge "Initialize TetheringManager lazily" into sc-dev 2021-06-23 02:17:34 +00:00
Lorenzo Colitti
2f329557bd Merge changes from topic "connectivity-cts-cherrypicks" into sc-dev am: 77fb999ed0
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057280

Change-Id: I197cb49c4f4515fd652ee1056120abf01088ed56
2021-06-22 23:29:53 +00:00
Lucas Lin
22d513f17b Add CTS for systemReady() & getIpSecNetIdRange() am: 03a1a97bf9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14185507

Change-Id: Ib2f17932bd37c65bc693ae06aa2af53d82a9e920
2021-06-22 23:29:51 +00:00
Lucas Lin
c948e1e561 Call ConnectivitySettingsUtils to set/get private DNS related settings am: 611bc021e6
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14728963

Change-Id: I00d62fe6df6b229050de2cd5dfbad28aa843923d
2021-06-22 23:29:48 +00:00
Lucas Lin
a42cb345fc Add CTS for isUidNetworkingBlocked & isUidRestrictedOnMeteredNetworks am: 77cb456671
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057281

Change-Id: Ic269ff69cda4d9c340ad66530a5987b0c79bde02
2021-06-22 23:29:46 +00:00
Paul Hu
eff0815504 Add test for CSM#[get|set]MobileDataPreferredUids am: e4a2abad44
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057278

Change-Id: I9afce730c6748f9d90263e3e2087b6be7b982262
2021-06-22 23:29:44 +00:00
Treehugger Robot
58b926dc3d Add test for setHttpProxyConfiguration am: 34c8be9ac7
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057277

Change-Id: Ic340a982573775b663dae427dee20bcb9d15f6ae
2021-06-22 23:29:42 +00:00
Aaron Huang
c129f703af CTS test for PacProxyManager am: 1eb05790a2
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15044628

Change-Id: Icbaa52b423f9472b95852d5f12c60e50b82331fd
2021-06-22 23:29:39 +00:00
Chiachang Wang
122ffec057 Add test for CM#setAcceptUnvalidated am: 1981466747
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057289

Change-Id: If5696613a1dcee18dd6c46fd5469f31f92f48194
2021-06-22 23:29:37 +00:00
Chiachang Wang
efd3529957 Add test for CM#setAcceptPartialConnectivity am: b9c9e07fe2
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057288

Change-Id: I9d537261dad7cfee3dd2405a68ef965d25046c5e
2021-06-22 23:29:35 +00:00
Treehugger Robot
9efcf648b4 Skip CaptivePortalTest for wearables am: ecad16cf28
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057282

Change-Id: Id05181a78898e9ea081ee9f9d309dced6f37a314
2021-06-22 23:29:33 +00:00
Treehugger Robot
a7f700db74 Improve handling of invalid private DNS settings am: 4a15140077
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/15057279

Change-Id: Ia40a4a43c5d9df8f3974d0fc079a8067cf0a35d9
2021-06-22 23:29:29 +00:00
Lorenzo Colitti
77fb999ed0 Merge changes from topic "connectivity-cts-cherrypicks" into sc-dev
* changes:
  Use assertEquals instead of assertTrue to compare the vpn type
  Add CTS for systemReady() & getIpSecNetIdRange()
  Call ConnectivitySettingsUtils to set/get private DNS related settings
  Add CTS for isUidNetworkingBlocked & isUidRestrictedOnMeteredNetworks
  Add test for CSM#[get|set]MobileDataPreferredUids
  Add test for setHttpProxyConfiguration
  CTS test for PacProxyManager
  Add test for CM#setAcceptUnvalidated
  Add test for CM#setAcceptPartialConnectivity
  Skip CaptivePortalTest for wearables
  Improve handling of invalid private DNS settings
2021-06-22 22:53:26 +00:00
Yan Yan
0271dc24ce Test updating underlying network of IpSecTunnelInterface
This CL adds tests to verify that after setting
IpSecTunnelInterface to use a different undelying network and
re-applying IpSecTransforms with matching addresses, traffic
can be routed to/from the new underlying network.

All these new tests will be skipped if SDK < S

Bug: 169855650
Test: atest IpSecManagerTunnelTest (new tests added)
Original-Change: https://android-review.googlesource.com/1488296
Merged-In: Iab26159e5e070574e552d62e4f0780059a51a9c7
Change-Id: Iab26159e5e070574e552d62e4f0780059a51a9c7
2021-06-22 20:44:14 +00:00