summaryrefslogtreecommitdiff
path: root/tests/net
Commit message (Collapse)AuthorAgeFilesLines
* Move net unit tests to packages/ConnectivityRemi NGUYEN VAN2021-05-13146-42957/+0
| | | | | | | | | | | | | | Move the tests together with packages/Connectivity code, so both can be moved to packages/modules/Connectivity together. Also reorganize unit tests in a unit/ directory, as other tests (integration/, common/ etc.) have been added in tests/net since they were created. This makes the directory structure consistent. Test: atest FrameworksNetTests Bug: 187814163 Ignore-AOSP-First: needs per-branch move for merge conflicts Change-Id: I254ffd1c08ec058d594b4ea55cbae5505f8497cc
* Merge "Add testVpnTypesEqual to verify consistency" am: 785dc4871c am: ↵Ken Chen2021-05-131-0/+16
|\ | | | | | | | | | | | | | | 3ae939569e am: 233682e675 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1705385 Change-Id: I53d58c5b2277ba2d88a848ed3e6d6269b4b886b3
| * Merge "Add testVpnTypesEqual to verify consistency"Ken Chen2021-05-131-0/+16
| |\
| | * Add testVpnTypesEqual to verify consistencyKen Chen2021-05-121-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | VPN types are defined in both VpnManager.java and NativeVpnType.aidl. The definitions on both sides should match (except TYPE_VPN_NONE). VpnManager.java: TYPE_VPN_NONE = -1 TYPE_VPN_SERVICE = 1 TYPE_VPN_PLATFORM = 2 TYPE_VPN_LEGACY = 3 TYPE_VPN_OEM = 4 NativeVpnType.aidl: SERVICE = 1 PLATFORM = 2 LEGACY = 3 OEM = 4 Bug: N/A Test: atest android.net.VpnManagerTest#testVpnTypesEqual Change-Id: Ie618e227d861100c5318da696140e486af1093a0
* | | Merge "Switch from networkCreate[Physical/Vpn] to networkCreate" am: ↵Ken Chen2021-05-132-19/+39
|\| | | | | | | | | | | | | | | | | | | | | | | c9d5cd9fbc am: 62258932ff am: a4d53bfa6d Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1669648 Change-Id: I3475e674c3914c4c61fd0a4246c9ee3e7e02c4fb
| * | Merge "Switch from networkCreate[Physical/Vpn] to networkCreate"Ken Chen2021-05-132-19/+39
| |\|
| | * Switch from networkCreate[Physical/Vpn] to networkCreateKen Chen2021-05-112-19/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | networkCreatePhysical and networkCreateVpn are non-extensible. In order to pass OEM requested VPN type to Netd, we need to migrate to networkCreate API. Modify test code accordingly since networkCreatePhysical and networkCreateVpn have been deprecated on Netd. Bug: 171872481 Test: atest FrameworksNetTests atest atest HostsideVpnTests Change-Id: I50ab8615346c49559c16e815482e7804a1e765c8
| * | Merge "Update PrivateDnsMode from StringDef to IntDef"Lucas Lin2021-05-122-17/+15
| |\ \
| | * | Update PrivateDnsMode from StringDef to IntDeflucaslin2021-05-052-17/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update PrivateDnsMode from StringDef to IntDef because IntDef is the normal way of representing multiple choices in public API. Also update other related files. Bug: 185311744 Test: 1. make update-api 2. atest FrameworksNetTests CtsNetTestCases CtsNetTestCasesLatestSdk 3. atest FrameworksServicesTests:DevicePolicyManagerTest Change-Id: I23e7ec140066979726d769cabc5f7057bb2167e6 Merged-In: I23e7ec140066979726d769cabc5f7057bb2167e6 (Cherry-picked from ag/14227609)
| * | | Merge "Remove sendNetworkConditionsBroadcast"Chiachang Wang2021-05-121-2/+1
| |\ \ \
| | * | | Remove sendNetworkConditionsBroadcastlucaslin2021-05-111-2/+1
| | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sendNetworkConditionsBroadcast is removed, so TestNetworkStackService.kt cannot override it anymore, otherwise there will be a build break when running this test. Also add a comment for NETWORK_CONDITIONS_MEASURED in AndroidManifest.xml. Bug: 124415874 Test: atest FrameworksNetIntegrationTests Change-Id: I7b43940dc32826c70fa82f471b35bc5cb8394aad Merged-In: I7b43940dc32826c70fa82f471b35bc5cb8394aad
| * | | Merge "Rename unwanted capabilities to forbidden capabilities."Lorenzo Colitti2021-05-121-60/+73
| |\ \ \
| | * | | Rename unwanted capabilities to forbidden capabilities.Lorenzo Colitti2021-05-111-60/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Addresses API council feedback. Bug: 184890428 Test: atest FrameworksNetTests CtsNetTestCases Test: atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest on R device Change-Id: Id7c68fbf56ee08fcad8e8e3aacf037fa1885936b
* | | | | Merge changes from topic "transportinfo-explicit-redaction" into sc-devLorenzo Colitti2021-05-122-18/+75
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * changes: Immediately redact VcnTransportInfo. Do not automatically redact TransportInfo objects.
| * | | | | Do not automatically redact TransportInfo objects.Lorenzo Colitti2021-05-112-18/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, NetworkCapabilities always redacts the TransportInfo objects it contains whenever a defensive copy is made. This makes it impossible to make a defensive copy on a TransportInfo parcelled from another process without redacting it. Stop redacting by default; instead rely on ConnectivityService explicitly calling NetworkCapabilities' redacting constructor when it returns a NetworkCapabilities object to an app via a callback or synchronous call. This is currently done by - createWithLocationInfoSanitizedIfNecessaryWhenParceled, which is called from callCallbackForRequest, getNetworkCapabilities, and getDefaultNetworkCapabilitiesForUser. - getNetworkCapabilitiesWithoutUids, which is used when sending ConnectivityDiagnosticsManager callbacks. In this method, unconditionally redact all information, which is what the code did previously due to the default redaction setting for empty NetworkCapabilities objects being REDACT_ALL. Bug: 183938194 Test: atest NetworkCapabilitiesTest Test: atest FrameworksNetTests CtsNetTestCases HostsideVpnTests Change-Id: I3108ee94cb0930958e071ba678c3554525b0db82
* | | | | | Merge "Add MATCH_ANY_USER flag to PackageInfo queries" am: 68301eb7cb am: ↵Paul Hu2021-05-122-12/+15
|\ \ \ \ \ \ | | |/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 2b0351ce1e am: 168172c2c0 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1689207 Change-Id: Ie3dd72aa4b8166198884f348f59c77befc229dc0
| * | | | | Merge "Add MATCH_ANY_USER flag to PackageInfo queries"Paul Hu2021-05-122-12/+15
| |\ \ \ \ \ | | |_|/ / / | |/| | | |
| | * | | | Add MATCH_ANY_USER flag to PackageInfo queriespaulhu2021-04-262-12/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Querying PackageInfo should have MATCH_ANY_USER flag because some apps are only installed for specific users. If no flag, it will get NameNotFoundException. - Also add missed break on switch case. Bug: 186382373 Test: atests FrameworksNetTests Change-Id: I37c8c42352a9a84ccbe9a37248febcd62b8f59e4
* | | | | | Merge changes from topic "vcn-fwd" am: d7d2d2a15b am: f980436b32 am: 600401154aBenedict Wong2021-05-111-15/+85
|\| | | | | | |_|/ / / |/| | | | | | | | | | | | | | | | | | | Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1682047 Change-Id: I745687f69366657dc33bfdacd878e06affd6a8ec
| * | | | Add internal support for IPsec forward policiesBenedict Wong2021-05-071-15/+85
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change adds support for IPsec forward policies, which are necessary for packets to be allowed to be forwarded to another interface, as is the case with tethering. This is necessary and useful only within the system server, and as such is not exposed as a public API. This change is safe, since the addition of a FWD policy on IPsec tunnel interfaces will by default block forwarded traffic (as would be the case without this patch). In the event that the (system) owner of the tunnel requires support for forwarded packets (eg tethering), this patch allows application of transforms in the FWD direction as well. This will be used to ensure that the VCN can be used as the underlying network for the purposes of tethering. Bug: 185495453 Test: atest IpSecServiceTest Test: atest IpSecServiceParameterizedTest Test: manual testing with tethering over VCN Change-Id: I74ecea71f1954029f6fbdbe34598c82e0aac386b
| * | | Merge "Add getters to NetworkStateSnapshot"Treehugger Robot2021-04-291-3/+3
| |\ \ \
| | * | | Add getters to NetworkStateSnapshotAaron Huang2021-04-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Address API council feedback, add getters to NetworkStateSnapshot instead of exposing the bare fields directly. (cherry picked from ag/14233655) Bug: 183972826 Test: FrameworksNetTests Merged-In: Id1707753b42ae88d2b95e4bd00a792609434e4f5 Change-Id: Id1707753b42ae88d2b95e4bd00a792609434e4f5
| * | | | Merge "Add getters to UnderlyingNetworkInfo"Treehugger Robot2021-04-292-9/+10
| |\ \ \ \
| | * | | | Add getters to UnderlyingNetworkInfoAaron Huang2021-04-222-9/+10
| | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Address API review feedback, add getters to UnderlyingNetworkInfo instead of exposing fields. Instead of wasting memory by converting this into an array, have migrateTun take a List<String>. In turn, tunAdjustmentInit should also take a List<String>. (cherry picked from ag/14211075) Bug: 183972554 Test: atest android.net.UnderlyingNetworkInfoTest Merged-In: Id59744097208d91298a25ef110ade91a9cf291a1 Change-Id: Id59744097208d91298a25ef110ade91a9cf291a1
| * | | | Merge "Rename getAllNetworkStateSnapshot which should be pluralized"Treehugger Robot2021-04-291-7/+7
| |\ \ \ \
| | * | | | Rename getAllNetworkStateSnapshot which should be pluralizedAaron Huang2021-04-221-7/+7
| | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Address API review feedback, ConnectivityManager#getAllNetworkStateSnapshot should be pluralized so rename the method to getAllNetworkStateSnapshots (cherry picked from ag/14221105) Bug: 183972554 Test: make, FrameworksNetTests FrameworksServicesTests Merged-In: Ic18d17d05984fa2466c962c7843c0ef7183ce77c Change-Id: Ic18d17d05984fa2466c962c7843c0ef7183ce77c
* | | | | Merge "Rename unwanted capabilities to forbidden capabilities." into sc-devLorenzo Colitti2021-05-091-60/+73
|\ \ \ \ \
| * | | | | Rename unwanted capabilities to forbidden capabilities.Lorenzo Colitti2021-05-081-60/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Addresses API council feedback. Bug: 184890428 Test: atest FrameworksNetTests CtsNetTestCases Test: atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest on R device Change-Id: Id7c68fbf56ee08fcad8e8e3aacf037fa1885936b
* | | | | | Merge "Remove sendNetworkConditionsBroadcast" into mainline-prod am: 8a9e884d02Lucas Lin2021-05-071-2/+1
|\ \ \ \ \ \ | |/ / / / / |/| | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14271579 Change-Id: I394ab3ceee1685c4fdabd27f8377a2f3227c33be
| * | | | | Remove sendNetworkConditionsBroadcastlucaslin2021-04-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sendNetworkConditionsBroadcast is removed, so TestNetworkStackService.kt cannot override it anymore, otherwise there will be a build break when running this test. Also add a comment for NETWORK_CONDITIONS_MEASURED in AndroidManifest.xml. Bug: 175213041 Test: atest FrameworksNetIntegrationTests Change-Id: I7b43940dc32826c70fa82f471b35bc5cb8394aad
| * | | | | Merge changes I6ec246a6,If7eb8857,Id3d12b23,Ia52f9caf,I21028457, ... into ↵TreeHugger Robot2021-03-171-19/+10
| |\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rvc-dev am: 65eb4a4332 Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425320 Change-Id: Id5810e50b56389fe53f739f84ad79d8ef878e4f6
| | * | | | | Fix legacy APIs when VPN switches to suspended underlying network.Lorenzo Colitti2021-01-281-19/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, when the VPN underlying network changes from a network that is not suspended to one that is suspended (or vice versa), some of the legacy APIs return incorrect results. This is because the VPN's NetworkInfo can get into SUSPENDED state even though the capabilities have the NOT_SUSPENDED capability. This happens because the code in updateCapabilities that checks for changes in NOT_SUSPENDED and NOT_ROAMING (which are the capabilities that can affect the NetworkInfo state) is only run when the capabilities change in a certain way. Fix this by always checking for changes in these capabilities, regardless of what else has changed. This results in sending a lot more SUSPENDED and RESUMED callbacks than the code sent previously. This should hopefully not impact apps because those callback methods have never been public API, though because they're just callbacks, it's possible that apps found out via code inspection that the callbacks existed and implemented them. Bug: 172870110 Test: changes to existing tests in ConnectivityServiceTest Change-Id: I6ec246a6a4e61f634956a165797fbb80296efd6a Merged-In: I6ec246a6a4e61f634956a165797fbb80296efd6a
| * | | | | | Backport test coverage from aosp/1547496. am: 1255ddbc76Lorenzo Colitti2021-03-171-10/+18
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425319 Change-Id: I559be41c77cc6348e745324ab675c603b1f3ad1d
| | * | | | | Backport test coverage from aosp/1547496.Lorenzo Colitti2021-01-281-10/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This test coverage is necessary to fix an upcoming bug in R. Backport it from the change that added it. The non-test portion of that change is not necessary in R because it fixes a bug that was introduced in S. Bug: 172870110 Test: accompanying unit test shows lots of bugs removed Change-Id: If7eb8857474d8b4f774f5fa5db2a3112e85c9cae Merged-In: Ibf376a6fa4b34d1c96f8506fa8abbb7595a8c272
| * | | | | | Backport some helpers in ConnectivityServiceTest. am: be317557feLorenzo Colitti2021-03-171-0/+14
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425318 Change-Id: I7ffa0faf61ccc7238b65e0f9ed863939e5089f06
| | * | | | | Backport some helpers in ConnectivityServiceTest.Lorenzo Colitti2021-01-281-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These were added in aosp/1527378, which is impractical to backport. Bug: 172870110 Test: test-only change Change-Id: Id3d12b23034b284c8f7dffb5167244e1e43987e2 Merged-In: I827543751dbf5e626a24ec02cd6f50b423f5f761
| * | | | | | Test for bugs with suspended VPN underlying networks. am: 9687fd7c3bLorenzo Colitti2021-03-171-0/+115
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425317 Change-Id: I28f2b0f682d8ee2982b8669267efe43ae0805778
| | * | | | | Test for bugs with suspended VPN underlying networks.Lorenzo Colitti2021-01-281-0/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 172870110 Test: atest --rerun-until-failure 100 ConnectivityServiceTest#testVpnSwitchFromSuspendedToNonSuspended Change-Id: Ia52f9cafef3f49ae70ad135d017e207eb57fddfe Merged-In: Ia52f9cafef3f49ae70ad135d017e207eb57fddfe
| * | | | | | Add a test for getDefaultNetworkCapabilitiesForUser. am: cb2feba0fbLorenzo Colitti2021-03-171-2/+31
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425316 Change-Id: Ic3b3584c25a0703aa273b47d042b2b339f1de2e7
| | * | | | | Add a test for getDefaultNetworkCapabilitiesForUser.Lorenzo Colitti2021-01-281-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 172870110 Test: test-only change Test: new test passes 100 times in a row Change-Id: I210284578e38cd25b8b95235d3390d5bd66a5a70 Merged-In: I210284578e38cd25b8b95235d3390d5bd66a5a70
| * | | | | | Improve testing of CONNECTIVITY_ACTION broadcasts. am: 4a66aedf09Lorenzo Colitti2021-03-171-156/+181
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425315 Change-Id: I889026eec095745be2e88f0c38392619c8ae6cfd
| | * | | | | Improve testing of CONNECTIVITY_ACTION broadcasts.Lorenzo Colitti2021-01-281-156/+181
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently test CONNECTIVITY_ACTION broadcasts by directly registering BroadcastReceivers with BroadcastInterceptingContext, and making the receivers unregister themselves when all the broadcasts they expect have been received. This works for current test cases, but does not work if anything registers another receiver for CONNECTIVITY_ACTION. In that case, when we unregister the receiver in the receiver's onReceive method, BroadcastInterceptingContext will throw a ConcurrentModificationException because the list of receivers is being modified during iteration. Fix this by adding an ExpectedBroadcast class that stores the receiver and unregisters the receiver only when the test checks that the broadcast was received, which happens after the receiver runs. This is easier to use and also guarantees that the receiver is unregistered even if the test is expecting that the broadcast is never fired. Accordingly, remove mRegisteredReceivers and the code that uses it; it's no longer necessary now that ExpectedBroadcast always unregisters its receivers. Also add a convenience expectConnectivityAction method to expect a CONNECTIVITY_ACTION broadcast with specific contents. This makes the test easier to read and more detailed. Convert some existing tests to this method. While I'm at it, fix a test that was using "mCellNetworkAgent" to represent a wifi network. R backport notes: added import for NetworkInfo.DetailedState. That was added in aosp/1527378, which is impractical to backport. Bug: 172870110 Test: test-only change Change-Id: Ibada8b4215625e1016d9fd170526206920af76f5 Merged-In: Ibada8b4215625e1016d9fd170526206920af76f5
| * | | | | | Test passing an underlying network array with null network in it. am: 1a05734c87Lorenzo Colitti2021-03-171-3/+24
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425314 Change-Id: I7c78a186187db9c77c8980b670f802f9fd2e42ce
| | * | | | | Test passing an underlying network array with null network in it.Lorenzo Colitti2021-01-281-3/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current code treats these nulls as if they weren't there. Bug: 172870110 Test: test-only change Change-Id: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac Merged-In: Id4632e1b004c09910b4b7613f7233d2c19e2f0ac
| * | | | | | Make testVpnNetworkActive more deterministic. am: d2adbfbf40Lorenzo Colitti2021-03-171-10/+4
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425313 Change-Id: I5b7901958bf96b0cee80c6124e004e57da0992cd
| | * | | | | Make testVpnNetworkActive more deterministic.Lorenzo Colitti2021-01-281-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This test is a bit brittle because it sets the underlying networks while the VPN is undergoing validation by NetworkMonitor. The test does attempt to disable validation, but that's not actually possible - the only thing that's possible is to tell NetworkMonitor to validate immediately without sending any probes. So the underlying network change races with the validation. I'm not sure why the test isn't flaky. It might be because both the network change and the validation result in a capabilities change, and the test expects "a capabilities change" without expressing what change that should be. Make this a bit more predictable by ensuring that the network validates before the underlying networks are set. This is useful because an upcoming CL will change the way underlying network capabilities are propagated. With this test CL, both the old and the new code pass. Bug: 172870110 Test: test-only change Change-Id: I319858228e8d097c0b60a107029f296385f91269 Merged-In: I319858228e8d097c0b60a107029f296385f91269
| * | | | | | Make MockVpn more realistic and easier to use. am: f3d35fdeaaLorenzo Colitti2021-03-173-291/+220
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425312 Change-Id: I0e1ff975206ed180744c4c7a6f42e00b95589424
| | * | | | | Make MockVpn more realistic and easier to use.Lorenzo Colitti2021-01-283-291/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MockVpn is very difficult to use because it requires the test caller keeping track of both the MockVpn object and an accompanying TestNetworkAgentWrapper. It's also not very realistic: for example, connect() doesn't actually connect anything, it just makes it so that if ConnectivityService tries to update the capabilities, the attempt will not be ignored. Also, unlike the real code in Vpn, it connects with empty NetworkCapabilities (in particular, with empty UID ranges). Make this easier to use and a bit more realistic by: - Allowing TestNetworkAgentWrapper to take a "NetworkCapabilities template" that will form the initial capabilities sent when the agent registers with ConnectivityService. This allows the VPN to register its agent with its UID ranges already set, like the production code does. - Providing separate methods to register the NetworkAgent and mark it connected for cases where the test needs to make changes to the NetworkAgent before connecting (e.g., poking NetworkMonitor). - Putting the TestNetworkAgentWrapper inside MockVpn and driving it through MockVpn's methods. In order not to have too many wrapper functions (and because we can't delegate like in Kotlin), there's still an agent() method that returns the TestNetworkAgentWrapper. Bug: 172870110 Test: test-only change Change-Id: I749ff325bc13ac96f512270b86d1f67686eec378 Merged-In: I749ff325bc13ac96f512270b86d1f67686eec378
| * | | | | | Increase test coverage for VPN info sent to NetworkStatsService. am: d10299582aLorenzo Colitti2021-03-171-20/+149
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13425311 Change-Id: Ibea98977b36f0e9a71d47f0ec3fe4926516842f7
| | * | | | | Increase test coverage for VPN info sent to NetworkStatsService.Lorenzo Colitti2021-01-281-20/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug: 172870110 Test: test-only change Change-Id: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7 Merged-In: I3711b362f31cb92b759e9f5c9d244fb88d9bd5e7