Commit Graph

2456 Commits

Author SHA1 Message Date
Sarah Chin
db1cde3f50 Merge "Add tests for NetCapability#getCapabilityCarrierName" am: 45fa6bd811 am: 4d9f226837
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1683350

Change-Id: I306e0ba0bb52de4a408e21a26a81a327905c7d59
2021-04-27 18:35:59 +00:00
Sarah Chin
45fa6bd811 Merge "Add tests for NetCapability#getCapabilityCarrierName" 2021-04-27 17:58:12 +00:00
Chiachang Wang
d4d930f937 Merge "Update APIs based on API review feedback" am: 5d4e9ee83d am: ccaf092fc0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1679670

Change-Id: Ifd55469fe2ea875345ce0b078e47ba5476310e9a
2021-04-26 01:13:03 +00:00
Chiachang Wang
5d4e9ee83d Merge "Update APIs based on API review feedback" 2021-04-26 00:22:27 +00:00
Chiachang Wang
878ad503a9 Update APIs based on API review feedback
Update the usage in callers side for
  - Rename NetworkAgent#setTeardownDelayMs to
    NetworkAgent#setTeardownDelayMillis
  - Use getters instead of fields in VpnTransportInfo
  - Rename registerDefaultNetworkCallbackAsUid to
    registerDefaultNetworkCallbackForUid in ConnectiivityManager

Bug: 183972850
Bug: 185246410
Fix: 184735863
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Change-Id: Ie542e5ad631388d9948dd27de21bc218b5b5b8f2
Merged-In: Ie542e5ad631388d9948dd27de21bc218b5b5b8f2
2021-04-23 02:44:07 +00:00
Chiachang Wang
81fa7cc8d6 Merge "Update doc in TestUtils" am: 8027d24eaf am: 3b5fd3154a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1684726

Change-Id: Ic43358e6d0670f07acc2a5ca6e79ba346f43675f
2021-04-23 01:17:58 +00:00
Chiachang Wang
8027d24eaf Merge "Update doc in TestUtils" 2021-04-23 00:35:27 +00:00
Sarah Chin
bae0fb30f9 Add tests for NetCapability#getCapabilityCarrierName
Test: atest ConnectivityManagerTest
Fix: 183553812
Change-Id: I60801bb86302b57f6d72ea903d98a8249fae4555
2021-04-22 17:00:57 -07:00
Treehugger Robot
367e8bdc75 Merge "Fix testKeepaliveWifiUnsupported failure" am: 3b55c68cc2 am: c856c57a92
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1684429

Change-Id: I3d81d13647a923c3c37121bc99d5238b14d94e62
2021-04-22 15:34:04 +00:00
Treehugger Robot
3b55c68cc2 Merge "Fix testKeepaliveWifiUnsupported failure" 2021-04-22 14:40:40 +00:00
Remi NGUYEN VAN
285d3a5da7 Fix testKeepaliveWifiUnsupported failure
As a temporary measure to get the test to pass, use the
QUERY_ALL_PACKAGES permission when calling getSupportedKeepalives.
This is helps as getSupportedKeepalives obtains the configuration
from resources in the connectivity resources package, which
recently got its own non-platform certificate and is now not
visible from the test anymore.

getSupportedKeepalives is only used by tests and ConnectivityService
which has all permissions.

The actual fix should make sure getSupportedKeepalives does not require
such a permission (although getSupportedKeepalives is not a formal API),
but this will take more time and the test needs to stay green in the
meantime.

Bug: 186093901
Test: atest CtsNetTestCases
Change-Id: I288ec13a6f0840b184f1c919785724733ca56adf
2021-04-22 21:35:34 +09:00
Chiachang Wang
1230993fb4 Merge "Add test for NetworkRequest.Builder(NetworkRequest)" am: 28f3e69a25 am: 44f9593f24
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1650232

Change-Id: Id1368ca84be2b04b7d3356ecdf11d40ab21bba20
2021-04-22 10:48:51 +00:00
Chiachang Wang
d514b53eca Update doc in TestUtils
Follow up commit from aosp/1650232 to update the doc

Bug: 186061922
Test: m
Change-Id: Icb622516bc41de5cbe3112d7abd3df9d83448b32
2021-04-22 18:19:58 +08:00
Chiachang Wang
28f3e69a25 Merge "Add test for NetworkRequest.Builder(NetworkRequest)" 2021-04-22 09:58:54 +00:00
Chiachang Wang
93b807718b Add test for NetworkRequest.Builder(NetworkRequest)
Build NetworkRequest using builder from an existing
NetworkRequest is exposed to API surface, so add a test to
verify its behavior works as expectation.

Also, create a TestUtils in the cts to put the multiple
reference methods(shouldTestSApis) to prevent duplication.

Bug: 186061922
Test: atest CtsNetTestCases:android.net.cts.NetworkRequestTest
      in current sdk
Test: atest CtsNetTestCasesLatestSdk:android.net.cts.NetworkRequestTest
      in R and current sdk
Test: atest android.net.cts.ConnectivityManagerTest#\
      testRegisterNetworkCallback
Change-Id: I46318e212d51e4e13efa86e8b9c3ca7326d62b77
2021-04-22 02:30:26 +00:00
Treehugger Robot
45a26a4aa2 Merge "Move CtsHostsideNetworkTests to group presubmit-large" am: c3bac64a94 am: b0e2855252
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1674227

Change-Id: I2ff565e0a753cd133972f34eff2fb9fc9bd27678
2021-04-19 03:53:58 +00:00
Treehugger Robot
c3bac64a94 Merge "Move CtsHostsideNetworkTests to group presubmit-large" 2021-04-19 03:05:59 +00:00
Junyu Lai
34006332a1 Merge "[VCN20.2] Change requestBackgroundNetwork argument order" am: afd18ddd57 am: d1c84ae89c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1676442

Change-Id: I68ab7fc43774c3ea977219261857930c703f6ea9
2021-04-16 16:52:15 +00:00
Junyu Lai
afd18ddd57 Merge "[VCN20.2] Change requestBackgroundNetwork argument order" 2021-04-16 16:04:31 +00:00
junyulai
989cf46ba0 [VCN20.2] Change requestBackgroundNetwork argument order
Test: atest FrameworksNetTests FrameworksVcnTests
Fix: 185215095
Merged-In: I09ff7461b655cbfc6ed5a7db07e02a388cd3d079
Change-Id: I09ff7461b655cbfc6ed5a7db07e02a388cd3d079
  (cherry-picked from ag/14185520)
2021-04-16 00:29:20 +08:00
Treehugger Robot
9e7affed67 Merge "Fix CTS fail to register network callback since lack of permission" am: f7d188c8c9 am: 9da7347603
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1674237

Change-Id: I76e3e4536e592f61243e1afa46811a8992996bb5
2021-04-15 16:05:01 +00:00
Treehugger Robot
f7d188c8c9 Merge "Fix CTS fail to register network callback since lack of permission" 2021-04-15 15:03:15 +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
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
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
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
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
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
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
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
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
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
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
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