Commit Graph

2762 Commits

Author SHA1 Message Date
Chiachang Wang
f9093389f5 Unify the verification for unregister a NetworkAgent
It's a follow up of aosp/1652210.

The tests may verify partial NetworkAgent callback behavior.
The existing expectCallback will always expect to see the first
callback in the callback queue, so if tests did not verify all
the happened callback. It cannot verify the callback after
unregister. Add eventuallyExpect to wait for a target callback
and skip the disinterest ones, and verify the unregister
behavior for NetworkAgent callback in one method.

Bug: 178725261
Test: atest android.net.cts.NetworkAgentTest
Change-Id: I66d8e5a0fa1e2245711e8ac90d9daca24802e399
2021-04-15 20:38:25 +08:00
Treehugger Robot
9675c9da0b Merge changes from topic "connectivitymanager-blockedreason-shim" am: bea56fbe11 am: 0cbabb7316 am: 6f7e10d3ef
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1676430

Change-Id: Icba8d6ffebafb907578e1893f0567eafdfc9dfd2
2021-04-15 10:58:31 +00:00
Treehugger Robot
333db9a5f0 Merge changes from topic "connectivitymanager-blockedreason-shim" am: bea56fbe11 am: 0cbabb7316
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1676430

Change-Id: I9f71c66d037a7e32b084951c01d46d9d01cc8f3a
2021-04-15 10:01:04 +00:00
Lorenzo Colitti
ddeb269ca0 Fix CtsNetTestCasesLatestSdk in AOSP.
This test suite is broken in AOSP due to a number of tests that
depend on S APIs. We attempted to prevent those tests running on
R builds with:

@IgnoreUpTo(Build.VERSION_CODES.R)

but this is not sufficient for them to pass when the test is
compiled against the R SDK (e.g., in CtsNetTestCasesLatestSdk).
This is because when compiling against the R SDK, the test uses
the API 30 shims, which throw UnsupportedApiLevelException even
though the method actually exists on device.

Fix this using:

    assumeTrue(shouldTestSApis());

This is not great, but at least it unbreaks the tests for now.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.ConnectivityManagerTest
Change-Id: Ifee0aea5afef6bd4bc762a4b1f25fc05e562d49a
2021-04-15 13:30:02 +09:00
Lorenzo Colitti
7ba366de0b Use the non-API static UserHandle.getUid method in tests.
The code was updated in AOSP to use the new non-static
UserHandle#getUid(int), which is only available in S or above.
This fails to build in mainline-prod. Instead of defining a shim
for this, simply use an older method that takes a userId.

Bug: 165835257
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Test: CtsNetTestCasesLatestSdk:android.net.cts.ConnectivityManagerTest
Change-Id: Id529f8b201cc871aa3155aef0f44574d88040c2d
2021-04-15 13:20:02 +09:00
Junyu Lai
19a7cda181 Merge "Add CTS to verify NetworkAgent#setLingerDuration" into sc-dev 2021-04-15 03:23:54 +00:00
Lorenzo Colitti
aa9db67edc Import ConnectivityManager.BLOCKED_REASON_* from ConstantsShim.
This is needed for the tests to compile in mainline-prod.

Bug: 165835257
Test: atest CtsNetTestCases:android.net.ConnectivityManagerTest
Change-Id: I32924824e9968996f379e31f1b28eb6a8f29bc5d
2021-04-15 10:25:46 +09:00
Lorenzo Colitti
52d0924665 Merge "Test ConnectivityManager module-lib APIs for VPNs and blocking." am: f6875cc583 am: 682cb315ee am: ddc265e884
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671528

Change-Id: I17293cdf47468d634c3a6c26ea1673aa3a799b57
2021-04-14 16:59:58 +00:00
Lorenzo Colitti
fcdf0c2894 Merge "Test ConnectivityManager module-lib APIs for VPNs and blocking." am: f6875cc583 am: 682cb315ee
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671528

Change-Id: Iaa2d6c4b497eba6a0340094294ba0c6f2ff74f04
2021-04-14 16:10:55 +00:00
junyulai
3a7d92513f Fix CTS fail to register network callback since lack of permission
Currently, NetworkCallbackTest gets the capabilities of current
active network to track the network used for the tests. And
construct the request with the capabilities gets from the
network. This causes test fails if the capabilities contain
signal strength, since it requires NETWORK_SIGNAL_STRENGTH_WAKEUP
to be declared.

Thus, this patch null out several fields from capabilities
of the current active network to construct the new request
in order to prevent over-specifying the requirement.

Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideNetworkCallbackTests
Bug: 182516128
Change-Id: Ib79b38e63ad2083c29fd71a24b8686b3f6f4e12f
2021-04-14 22:18:39 +08:00
junyulai
cfb2af8659 Add CTS to verify NetworkAgent#setLingerDuration
Test: this
Bug: 184227264
Fix: 184796264
Ignore-AOSP-First: prevent merge conflict
Change-Id: I77818685b2bfea499c0294874d205544161677c5
2021-04-14 20:46:20 +08:00
easoncylee
942a988249 Move CtsHostsideNetworkTests to group presubmit-large
The test config takes longer than 15mins to run. Move it to a dedicated
group for running slow presubmit Test Mapping test.

Some more context is in the referenced bug, e.g, b/174495337
The group will work exactly the same as presubmit for now.

Bug: 174654670
Bug: 174495337
Test: none
Change-Id: I7fe1286ed952a6058c56c36f28b4832947edb69f
2021-04-13 22:26:06 +08:00
Chiachang Wang
b014b5fdef Merge "Update the method based on API feedback" am: 0a5d964242 am: 80a70a3679 am: 807d7f2e41
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671535

Change-Id: I3e3c69bbef95a6a4303a94f69dfa4415bfc1d11c
2021-04-13 13:04:56 +00:00
Chiachang Wang
807d7f2e41 Merge "Update the method based on API feedback" am: 0a5d964242 am: 80a70a3679
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1671535

Change-Id: I13071221d470bd633ef8337889b803a388bcab05
2021-04-13 11:54:13 +00:00
Lorenzo Colitti
b84176e9f9 Test ConnectivityManager module-lib APIs for VPNs and blocking.
This CL adds tests for:
- ConnectivityManager#setsetLegacyLockdownVpnEnabled
- ConnectivityManager#setRequireVpnForUids
- NetworkCallback#onBlockedStatusChanged(Network, int)

Bug: 165835257
Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest
Change-Id: Ie9b73ec2a1634f3b3a3eb4d21acbe0803b77c70d
2021-04-13 17:30:49 +09:00
Paul Hu
247b7233b4 Merge "Replace FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT in Connectivity" into sc-dev 2021-04-13 02:05:21 +00:00
Chiachang Wang
a31a9b6218 Update the method based on API feedback
UserHandle.getUid() is updated to a non-static API based on API
review feedback. Update the usage accordingly.

Bug: 184735865
Test: atest VpnTest
Change-Id: I884f427fae85b2b26973a0315b1ccf3d6f0824c6
2021-04-12 19:35:56 +08:00
paulhu
e0f3796bbb Replace FIRST_SDK_INT to DEVICE_INITIAL_SDK_INT in Connectivity
Replace all FIRST_SDK_INT usage in Connectivity because it has
been renamed to DEVICE_INITIAL_SDK_INT.

Bug: 184735771
Test: m CtsNetTestCases
Ignore-AOSP-First: Some files are differnet between aosp and
                   sc-dev on frameworkrs/base.
Change-Id: I2f155592b08cdbf259a00b035cacb37ca9847e72
2021-04-12 01:55:33 +00:00
Lorenzo Colitti
c7f7f5ada8 Merge changes from topic "peruidcallback-cts" am: 65bba3f6bc am: ab98c8119d am: 89d260c039
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669609

Change-Id: I0a28ee62a63c4db0494cc51f69ab0b8468401f85
2021-04-09 17:12:08 +00:00
Lorenzo Colitti
a42e82e17f Ensure the HostsideVpnTests passes with keyguard locked. am: fd3b95c1f7 am: 16d841048e am: a8f8011851
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669608

Change-Id: I707386cd46c2070762d50254629829173be80510
2021-04-09 17:12:08 +00:00
Lorenzo Colitti
02e2380c8a Add CTS tests for registerDefaultNetworkCallbackAsUid. am: ed26ffe92d am: 6cbdc19b2c am: 97384c0121
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669267

Change-Id: If16f7076f47acec463cb288f5a88c0cb7ee6de03
2021-04-09 17:12:07 +00:00
Lorenzo Colitti
89d260c039 Merge changes from topic "peruidcallback-cts" am: 65bba3f6bc am: ab98c8119d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669609

Change-Id: Ifbd2f1615f9db9c499edc7d75d2bc3865043e1dc
2021-04-09 16:45:30 +00:00
Lorenzo Colitti
a8f8011851 Ensure the HostsideVpnTests passes with keyguard locked. am: fd3b95c1f7 am: 16d841048e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669608

Change-Id: I689f8a5e5028069753d377979eee14f97e611681
2021-04-09 16:45:29 +00:00
Lorenzo Colitti
97384c0121 Add CTS tests for registerDefaultNetworkCallbackAsUid. am: ed26ffe92d am: 6cbdc19b2c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669267

Change-Id: I6983acf968da429a0c036aa7e13a406f27ba7278
2021-04-09 16:45:27 +00:00
Lorenzo Colitti
16d841048e Ensure the HostsideVpnTests passes with keyguard locked. am: fd3b95c1f7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669608

Change-Id: Idabf4f50d54116d80dc349564bd9ab04cc7fd21a
2021-04-09 15:59:15 +00:00
Lorenzo Colitti
6cbdc19b2c Add CTS tests for registerDefaultNetworkCallbackAsUid. am: ed26ffe92d
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1669267

Change-Id: Id8d968130a52d419c65a628fb93e47e5ac48c81e
2021-04-09 15:59:13 +00:00
Lorenzo Colitti
65bba3f6bc Merge changes from topic "peruidcallback-cts"
* changes:
  Cleanups to VPN hostside tests.
  Ensure the HostsideVpnTests passes with keyguard locked.
  Add CTS tests for registerDefaultNetworkCallbackAsUid.
2021-04-09 15:16:47 +00:00
junyulai
2ece9db0de Fix NetworkCallback expecting wrong network am: 2e74377464 am: cfd7518bdc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1657299

Change-Id: I9f14fae14fcb7ed5b2e63b067e8ea14404b484a2
2021-04-09 09:38:26 +00:00
Remi NGUYEN VAN
0b137cb1aa Add back platform APIs to HostsideNetworkTestsApp
The "platform_apis: true" clause was removed by mistake and is actually
necessary.

Ignore-AOSP-First: original change not in AOSP
Fixes: 184844380
Test: atest HostsideVpnTests
Change-Id: I32bd4a7057a3eb167975fe9f51f1bc0d056c44a0
2021-04-09 04:51:16 +00:00
junyulai
2e74377464 Fix NetworkCallback expecting wrong network
By current wifi design, wifi will report disconnected and
re-connected when changing from non-metered to metered.
However, the cts test app listens for all network, which
will get mobile network as active network when wifi is
changing meteredness. This is not expected. And causes
test failures when DUT has both wifi and mobile connections.

Thus, this change pass request to track currently active
network to the test app and register only for transport
types of currently active network to prevent from getting
unexpected network.

Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideNetworkCallbackTests
Bug: 182516128
Merged-In: I2dce6035b13472bbdc2609009d690aac96280033
Change-Id: I2dce6035b13472bbdc2609009d690aac96280033
  (cherry-picked from ag/14029457)
2021-04-09 10:16:18 +08:00
Junyu Lai
3ec79f9919 Merge "Fix NetworkCallback expecting wrong network" into sc-dev 2021-04-09 02:06:50 +00:00
Lorenzo Colitti
08b33ff7fb Cleanups to VPN hostside tests.
Use TestableNetworkCallback instead of a hand-rolled class.
Remove unnecessary runWithShellPermissionIdentity around
unregisterNetworkCallback calls.

Bug: 165835257
Test: test-only change
Change-Id: I4557dfc64136f9c0b4bdaa1248c33b13e96ba3ed
2021-04-08 22:09:10 +09:00
Lorenzo Colitti
fd3b95c1f7 Ensure the HostsideVpnTests passes with keyguard locked.
The test app used in CtsHostsideNetworkTests already dismisses
the keyguard for its own activity, but that doesn't work for the
VPN tests. This is because as soon as the VPN dialog appears, the
test activity is no longer in the foreground and the keyguard
comes back. As a result, the test cannot click on the VPN dialog.

Test: test-only change
Change-Id: I7be1d7fb46a2f9547bc5325d75b5bd5546e6dc18
2021-04-08 21:50:15 +09:00
Lorenzo Colitti
ed26ffe92d Add CTS tests for registerDefaultNetworkCallbackAsUid.
Bug: 165835257
Test: test-only change
Change-Id: Ib3266665735ee587f3f8ae82dadd1e4ca7ce4353
2021-04-08 21:44:30 +09:00
junyulai
bed32ff530 Fix NetworkCallback expecting wrong network
By current wifi design, wifi will report disconnected and
re-connected when changing from non-metered to metered.
However, the cts test app listens for all network, which
will get mobile network as active network when wifi is
changing meteredness. This is not expected. And causes
test failures when DUT has both wifi and mobile connections.

Thus, this change pass request to track currently active
network to the test app and register only for transport
types of currently active network to prevent from getting
unexpected network.

Test: atest CtsHostsideNetworkTests:com.android.cts.net.HostsideNetworkCallbackTests
Bug: 182516128
Ignore-AOSP-First: merge conflict with ag/13615939 which cannot
                   be cherry-picked.
Change-Id: I2dce6035b13472bbdc2609009d690aac96280033
2021-04-08 18:37:26 +08:00
Chiachang Wang
f3066426bf Merge "Add framework-connectivity-test-defaults to hostside test" into sc-dev 2021-04-07 00:30:57 +00:00
Chiachang Wang
8cbbafef5e Merge "Update tests for onNetworkCreated and onNetworkDestroyed" am: 7d0e27bd7c am: d212efd8b0 am: e08cfe35ca
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652210

Change-Id: I3b80a8a8a68f6a1ef2cab32d59cf4aae71cca645
2021-04-06 13:02:08 +00:00
Chiachang Wang
a8cf72829c Merge "Update tests for onNetworkCreated and onNetworkDestroyed" am: 7d0e27bd7c am: d212efd8b0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652210

Change-Id: I00a93b5bf8c44ab5b05f27dc7312f2d996e1b501
2021-04-06 12:35:39 +00:00
Chiachang Wang
7d0e27bd7c Merge "Update tests for onNetworkCreated and onNetworkDestroyed" 2021-04-06 11:04:30 +00:00
Chiachang Wang
b3269df005 Merge "Ensure SSID is not exposed to apps without correct permission" am: 674a907cc4 am: c1c5f7f974 am: 0f60bf6013
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1655447

Change-Id: If7ac04aa2a7014d7154879f539b37bb12a3788ae
2021-04-06 10:04:05 +00:00
Chiachang Wang
0f60bf6013 Merge "Ensure SSID is not exposed to apps without correct permission" am: 674a907cc4 am: c1c5f7f974
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1655447

Change-Id: I7ddbfa9eaf0bb6b2e0375f48a17e0d96e49b6c7a
2021-04-06 09:38:26 +00:00
Chiachang Wang
674a907cc4 Merge "Ensure SSID is not exposed to apps without correct permission" 2021-04-06 08:58:50 +00:00
Frank Li
1502d841cf Merge "Add session ID to VpnTransportInfo" am: 320cd17220 am: 45d9b25a36
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1652217

Change-Id: I0011ffa4d24d9680e79241a120ea7c4904d88d67
2021-04-06 07:29:23 +00:00
Frank Li
320cd17220 Merge "Add session ID to VpnTransportInfo" 2021-04-06 06:50:48 +00:00
Remi NGUYEN VAN
9980f77bc2 Merge "Allow connectivity tests to use hidden APIs" into sc-dev 2021-04-02 02:18:51 +00:00
lifr
877fd475f5 Add session ID to VpnTransportInfo
- This will be visible only to apps with the NETWORK_SETTINGS
  permissions (signature), and will be redacted for all other callers.
- This string is expected to be the same as set by
  VpnService#setSession, and in general, VpnConfig.session. But it
  will be a general API that Vpn.java can call when setting the
  VpnTransportInfo.
- This string cannot be updated once the VPN NetworkAgent is connected.

Bug: 171872481
Ignore-AOSP-First: needed to prevent automerger race breaking build
Test: atest ConnectivityServiceTest
      atest VpnTransportInfoTest
      atest NetworkAgentTest
Change-Id: I883035262465238c35c5a931d89707f3e84feef8
Merged-In: I883035262465238c35c5a931d89707f3e84feef8
           (cherry-picked from ag/14008230)
2021-04-01 15:51:44 +08:00
Remi NGUYEN VAN
eeeed136e0 Allow connectivity tests to use hidden APIs
The tests have been building against hidden APIs to provide additional
coverage.

Test: m TetheringCoverageTests CtsNetTestCases
Bug: 182859030
Ignore-AOSP-First: needs manual cherry-picks
Change-Id: I37d748411a34f25834214a2412c49aed1423e526
2021-04-01 06:37:53 +00:00
Chiachang Wang
9a27925368 Update tests for onNetworkCreated and onNetworkDestroyed
Update test to:
1. verify onNetworkCreated callback called when network is
   created.
2. Verify onNetworkDestroyed callback called when agent
   updates its connection state to disconnect and native
   network is destroyed.

Bug: 178725261
Test: atest android.net.cts.NetworkAgentTest
Change-Id: Icd30440e0f553d0f97b860d0e69b4f3d4f0a2a1d
2021-04-01 11:13:42 +08:00
Chiachang Wang
3fec2f13e1 Add framework-connectivity-test-defaults to hostside test
The defaults follow the same pattern as framework-wifi-test-defaults
to allow unit tests to build against hidden API in Connectivity.

Bug: 171540887
Test: m
Change-Id: I1a77278aa458e309d2772dd6ad84f4412b6e9387
Ignore-AOSP-First: Necessary code in internal only now
2021-03-31 10:04:35 +00:00
Sudheer Shanka
83b66e64c7 Check and skip certain operations if they are unsupported. am: b0f50c579b am: 7695f293a7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1658759

Change-Id: I4ececd442b6fab3ad4e6aefd0937226831a7b87b
2021-03-30 23:48:22 +00:00