Commit Graph

169 Commits

Author SHA1 Message Date
Lorenzo Colitti
1291166c38 Rename unwanted capabilities to forbidden capabilities.
Addresses API council feedback.

Bug: 184890428
Test: atest FrameworksNetTests CtsNetTestCases
Test: atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest on R device
Change-Id: Id7c68fbf56ee08fcad8e8e3aacf037fa1885936b
2021-05-11 17:46:13 +09:00
Treehugger Robot
935946812a Merge "[VCN19] Rename get/setSubIds to get/setSubscriptionIds" 2021-04-22 04:43:26 +00:00
Remi NGUYEN VAN
ddca748431 Roll forward: add a test for ParseException
The test simply creates an exception and verifies that it has the
required fields.

The constructor tests are only run on S+ as they are not part of the
API before that.

Change-Id: Ic30a34d3203c1b40923ba783a34f0cfed53a07ae
Test: atest FrameworksNetTests
2021-04-20 16:04:33 +09:00
Remi NGUYEN VAN
9f81edadc4 Revert "Add a test for ParseException"
This reverts commit 9bab179f2f.

Reason for revert: Test broken on R: b/185751610

Change-Id: I9f5d25c0ba81011848ab3cf7ec44aa329fbb3b0f
2021-04-20 16:04:33 +09:00
junyulai
2217becf8d [VCN19] Rename get/setSubIds to get/setSubscriptionIds
Test: atest FrameworksNetTests FrameworksVcnTests
Fix: 185215036
Merged-In: I9d90df5fc13b36d2cdc4920b456dcc87fcd2b3a7
Change-Id: I9d90df5fc13b36d2cdc4920b456dcc87fcd2b3a7
  (cherry-picked from ag/14198665)
2021-04-19 17:41:01 +08:00
Remi NGUYEN VAN
24ff1cea47 Merge "Add a test for ParseException" 2021-04-19 04:57:31 +00:00
lucaslin
1c8ddf038d Add test for [set|is]BypassableVpn
Bug: 182963397
Test: 1. atest CtsNetTestCases:NetworkAgentConfigTest
      2. atest CtsNetTestCasesLatestSdk:NetworkAgentConfigTest
Change-Id: I0250a0313d3a7561ab8efa851fbc06f5bce11185
2021-04-15 15:44:01 +08:00
Remi NGUYEN VAN
9bab179f2f Add a test for ParseException
The test simply creates an exception and verifies that it has the
required fields.

Test: atest FrameworksNetTests
Change-Id: I76ded2ac3f93ff3910bba3f1e4f1c17092e35372
2021-04-14 09:37:30 +00:00
Chiachang Wang
fba3c60305 Add SDK version check to skip S added API test
NetworkAgentConfigTest is a part of CtsNetTestCasesLatestSdk.
It will be used in mainline test with a R build. Test will
fail with method not found error. Add a version check to skip
the S added API tests.

Test: atest NetworkAgentConfigTest in R and S device
Fix: 185151127
Change-Id: Ib372e68afa99af455eb2713c8f6f1c8ef1d4cfdf
2021-04-13 10:18:36 +08:00
Chiachang Wang
ef8132e88d Rename APIs in NetworkAgentConfig.Builder
As API review feedback, rename disableProvisioningNotification()
to setEnabledProvisioningNotification and disableNat64Detection()
to setEnabledNat64Detection. Also, update code in caller side
accordingly.

Bug: 184735772
Test: make update-api ; atest FrameworksNetTests
Change-Id: If7305634863d1503c967e5593ebd0c8af2174bea
2021-04-12 17:27:47 +08:00
Remi NGUYEN VAN
c86653cf56 Replace fields with getters in keepalive API
General guidance is to have getters in the API instead of fields.

Fixes: 181014882
Test: m
Change-Id: Id4bfc447701e8d0380163047779fbba043f17b6f
2021-04-08 14:06:53 +09:00
Aaron Huang
9489cff024 Merge "Move deduceRestrictedCapability to libs/net and rename it" 2021-04-01 11:37:51 +00:00
lifr
09ad57ff79 Fix cannot success verify count of the networkAgent Config items on R
device

Test: atest CtsNetTestCasesLatestSdk:android.net.NetworkAgentConfigTest
Fix: 183474500
Change-Id: Ie0fd5ba816c390bfb7bc6512d896a88482c217ec
Merged-In: Ie0fd5ba816c390bfb7bc6512d896a88482c217ec
2021-03-29 15:36:32 +08:00
lifr
75764c8666 [TL02]Remove hidden API usage of NetworkAgent
The connection service will become the mainline module.
Remove the hidden API usage of NetworkAgent.

Bug: 170598012
CTS-Coverage-Bug: 170598012
Test: atest FrameworksNetTests FrameworksTelephonyTests
      atest FrameworksWifiTests
Change-Id: I4e4040ae7f94bdf479c7df9ec2ffabafbe06331c
Merged-In: I4e4040ae7f94bdf479c7df9ec2ffabafbe06331c
2021-03-29 15:33:44 +08:00
Aaron Huang
522918f4ba Move deduceRestrictedCapability to libs/net and rename it
NetworkCapabilities is included in framework-connectivity, so external
module cannot have dependencies on its hidden API. Move the method to
libs/net so that external modules can use it by including the library.

Bug: 178777253
Test: FrameworksNetTests
(cherry-picked from ag/13921626)
Merged-In: I77970b3a5e5e0e9d263639694b1f06519169bf64
Change-Id: I77970b3a5e5e0e9d263639694b1f06519169bf64
2021-03-26 14:13:51 +08:00
Junyu Lai
651b002c6c Merge "Fix cannot find removeUnwantedCapability on R device" 2021-03-23 12:16:18 +00:00
Chiachang Wang
f6bd19640b Merge "Correct the logic in NetworkCapabilitiesTest" 2021-03-23 11:46:31 +00:00
junyulai
4018b15909 Fix cannot find removeUnwantedCapability on R device
Test: atest CtsNetTestCasesLatestSdk:android.net.NetworkCapabilitiesTest
Fix: 183473863
Merged-In: Icf2cda325795acee22a6c634e8d978f64c5ac3cb
Change-Id: Icf2cda325795acee22a6c634e8d978f64c5ac3cb
  (cherry-picked from ag/13966708)
2021-03-23 17:40:55 +08:00
Chiachang Wang
dd29da510a Correct the logic in NetworkCapabilitiesTest
setOwnerUid() and setAdministratorUids() should run in R+.
Previous logic will skip them in S+. Correct the logic to
what it should be.

Bug: 172183305
Test: atest android.net.NetworkCapabilitiesTest
Change-Id: Ic983aa00f930fb26350469ef093bcba2990433a4
2021-03-23 15:16:39 +08:00
Junyu Lai
c58d82ef84 Merge "[VCN15] expose addUnwantedCapability and related APIs" 2021-03-23 05:02:22 +00:00
junyulai
24efbfdfbe [VCN15] expose addUnwantedCapability and related APIs
Test: m -j doc-comment-check-docs
Bug: 175662146
Merged-In: I3f2e6a99e015f09cc4405f6804eac4ae33e3dcc7
Change-Id: I3f2e6a99e015f09cc4405f6804eac4ae33e3dcc7
  (cherry-picked from ag/13929102)
2021-03-22 16:51:50 +08:00
Chiachang Wang
2ae123ec47 Merge "Revert "Correct the logic in NetworkCapabilitiesTest"" 2021-03-22 06:26:33 +00:00
Chiachang Wang
a5572f4656 Revert "Correct the logic in NetworkCapabilitiesTest"
This reverts commit 8e5d524f75.

Reason for revert: <Merge abnormal in automerger>

Change-Id: I0cdb401f4962050bf24dc9d9871d4ef15cf52629
2021-03-22 06:15:02 +00:00
Treehugger Robot
e05e71e820 Merge "Correct the logic in NetworkCapabilitiesTest" 2021-03-22 02:20:19 +00:00
Roshan Pius
98f59ecb99 TransportInfo: Add a generic redaction mechanism
This replaces the existing mechanism for redacting location sensitive
fields with a more extensible mechanism. Currently supported redactions
are for the following permissions:
i. ACCESS_FINE_LOCATION
ii. LOCAL_MAC_ADDRESS
iii. NETWORK_SETTINGS

Also, removed WifiInfo from ConnectivityServiceTest to reduce cross
dependencies on wifi code.

Bug: 156867433
Bug: 162602799
Test: atest android.net
Test: atest com.android.server
Change-Id: I2bb980c624667a55c1383f13ab71b9b97ed6eeab
2021-03-19 20:15:21 +00:00
Chiachang Wang
8156c4ea31 Revert^2 "Replace the usage of UidRange"
1b5c01b06f

UidRange is used in a shared way between ConnectivityService
and VPN through the use of NetworkCapabilities. UidRange will
be part of the ConnectivityService mainline but Vpn.java will
stay in the framework. We need a way to replace the APIs using
UidRange, or to make UidRange system API. The only really
relevant surface here is NetworkCapabilities#{setUids, getUids}.
The need for UidRange could be replaced by an integer Range, so
replace the usage of UidRange by a integer Range in
NetworkCapabilities#{setUids, getUids} and update the relevant
callers.

Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk

Change-Id: I0f679fb5fb8f4fe26461ca4912ca1fdfe7f43c9e
Merged-In: I4e5aec6ef1ea02e038fcd7ed117a3b67b69c5cb9
2021-03-19 02:11:07 +00:00
Anthony Stange
1b5c01b06f Revert "Replace the usage of UidRange"
Revert "Add shims for NetworkRequest"

Revert submission 1626206-replaceUidRange

Reason for revert: Breaking build - b/183106405
Reverted Changes:
I0b79c73e8:Add shims for NetworkRequest
I4bc0daf5a:Replace the usage of UidRange
I4e5aec6ef:Replace the usage of UidRange
I107c329d4:Expose uids related APIs in NetworkRequest and Net...

Change-Id: I6290429db1c8e787f8138b55b98fd92a74ac6402
2021-03-18 16:30:59 +00:00
Chiachang Wang
8e5d524f75 Correct the logic in NetworkCapabilitiesTest
setOwnerUid() and setAdministratorUids() should run in R+.
Previous logic will skip them in S+. Correct the logic to
what it should be.

Bug: 172183305
Test: atest android.net.NetworkCapabilitiesTest
Change-Id: I46f7dab5eb50cbdcd58aa4c58f43829d10b6c3d8
2021-03-18 13:37:31 +00:00
Chiachang Wang
0843e480ca Replace the usage of UidRange
UidRange is used in a shared way between ConnectivityService
and VPN through the use of NetworkCapabilities. UidRange will
be part of the ConnectivityService mainline but Vpn.java will
stay in the framework. We need a way to replace the APIs using
UidRange, or to make UidRange system API. The only really
relevant surface here is NetworkCapabilities#{setUids, getUids}.
The need for UidRange could be replaced by an integer Range, so
replace the usage of UidRange by a integer Range in
NetworkCapabilities#{setUids, getUids} and update the relevant
callers.

Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Change-Id: I4e5aec6ef1ea02e038fcd7ed117a3b67b69c5cb9
2021-03-17 23:02:22 +08:00
Paul Hu
05c16014dc Merge "Replace InetAddress#parseNumericAddress" 2021-03-15 07:03:46 +00:00
paulhu
1013c81acb Replace InetAddress#parseNumericAddress
-Connectivity is becoming a mainline module in S but mainline
modules are not allowed to use non-formal APIs. Thus, replace
non-formal API InetAddress#parseNumericAddress to
InetAddresses#parseNumericAddress.
- Add deprecated method legacyParseIpAndMask() for IpPrefix and
LinkAddress. Because InetAddresses#parseNumericAddress has
a little different behavior in some case, but these two classes
should keep working as before. So these two classes will use
the new deprecated method.

Bug: 181756157
Test: FrameworksNetTests
Change-Id: I1c96b75f0b8d5e93304a39b4a8c8849964e5e810
2021-03-12 19:57:40 +08:00
junyulai
e587a4c39e [VCN04] Add Subscription Id set into NetworkCapabilities
This is a generic way to request networks that has different
subId but belongs to the same carrier. For example, cellular
networks with different SIM card, or carrier Wifi that
provided by the operator.

Test: atest NetworkCapabilitiesTest#testSubIds
Test: m doc-comment-check-docs -j
Test: atest CtsNetTestCases
Bug: 175662146

Change-Id: Ifca766f5acc73c285948d6251ec31506d9bb0bcb
2021-03-11 23:03:05 +08:00
Remi NGUYEN VAN
90ca2615a4 Fix common tests on Q and R
The common tests cannot reference EthernetNetworkSpecifier,
as it did not exist in Q and R yet.

Bug: 179329291
Merged-In: Iec8ef874a3ca6dcc65944bbbaa3575a5ae0f4989
Change-Id: Iec8ef874a3ca6dcc65944bbbaa3575a5ae0f4989
Test: atest CtsNetTestCasesLatestSdk
2021-03-11 23:02:02 +08:00
Remi NGUYEN VAN
57c9cc2614 Add Ethernet, TestNetworkSpecifier API
Rename StringNetworkSpecifier to EthernetNetworkSpecifier (its only
production user), and make it module-lib API.
The original StringNetworkSpecifier file is actually kept to satisfy
some invalid dependencies; it will be removed separately.

This allows specifying an Ethernet interface with a non-deprecated API:
until this change the only way to do so would be to use
NetworkRequest#setSpecifier(String), which is deprecated.

Similarly, add the TestNetworkSpecifier API for TestNetworkManager, to
replace previous usage of StringNetworkSpecifier. TestNetworkManager is
module API, so TestNetworkSpecifier should be module API too. This
allows tests to request the test interface specifically, without using
the deprecated NetworkRequest#setSpecifier(String).

Bug: 179329291
Test: m
Merged-In: Iee569f5c8bbdc4bc979610e1191308281f3d4620

Change-Id: Iee569f5c8bbdc4bc979610e1191308281f3d4620
2021-03-11 23:02:02 +08:00
Remi NGUYEN VAN
db59856886 Fix CaptivePortalTest before R
The last change broke the test on Q and R. Fix it to check
Q and R behavior properly, so the test can be run in presubmit
on such devices too.

Bug: 181844595
Change-Id: I99847ea30d49d690d9011d4763a7345126807119
Test: atest CtsNetTestCasesLatestSdk
2021-03-04 10:45:02 +00:00
lifr
a9f5551cf5 [CS05]Remove the hidden API usage of MetricsLogger
Legacy metrics are unused and deprecated, so they are being removed.
Therefore, delete the usage of the hidden MetricsLogger API.

Bug: 157966864
Test: atest CtsNetTestCases
      atest CaptivePortalTest
      atest ConnectivityServiceTest
Change-Id: I51241f5d50ec580015882c84dd917b015c700c7c
2021-03-03 10:17:52 +00:00
junyulai
14133c117d [FUI09] Expose NetworkStateSnapshot as system API
This is needed by NetworkStatsService and
NetworkPolicyManagerService to utilize the snapshots of
information of networks that grabbed from ConnectivityService.

Test: atest FrameworksNetTests NetworkPolicyManagerServiceTest
Bug: 174123988
Change-Id: I7e974ef7b23ba9ba6ee775eed9899b0c0e2eca55
2021-03-02 23:09:16 +08:00
Lucas Lin
125200718e Merge changes I06ab0f2d,I8b146aa1
* changes:
  Use UserHandle#getIdentifier to get the userid
  Add test for getStartUser(), getEndUser() and createForUser()
2021-03-02 04:13:32 +00:00
Junyu Lai
f641e8c44c Merge "[FUI08] Create NeworkStateSnapshot" 2021-02-26 10:53:36 +00:00
junyulai
74dcf1a32d [FUI08] Create NeworkStateSnapshot
Since NetworkState has UnsupportedAppUsage APIs that cannot
be changed, create another class for follow-up patches
to expose as system API.

Test: NetworkStateSnapshotTest
Bug: 174123988
Change-Id: I54ef872847f34166aa34a79f6178c90ac12b6c72
2021-02-26 11:57:06 +08:00
lucaslin
aad3854ad9 Add test for getStartUser(), getEndUser() and createForUser()
- Follow-up commit will modify getStartUser() and getEndUser(),
to make sure the result is consistent, add test before changing
getStartUser() and getEndUser().
- Add a test for createForUser() to ensure the last uid of
the previous user is smaller than the first uid of the next user.
- Move this test file to tests/net/common, so that it can be run
in CTS.

Bug: 170598012
Test: atest FrameworksNetTests:UidRangeTest
      CtsNetTestCasesLatestSdk:UidRangeTest
      Also run above tests on Q and R devices.
Change-Id: I8b146aa14b50911e50a39f266e8d8dc17df853b2
2021-02-25 18:32:40 +08:00
Remi NGUYEN VAN
7ad622c832 Fix CaptivePortalDataTest on R
The test can only use setUserPortalUrl(Uri, int) and
setVenueInfoUrl(Uri, int) on S+.

Bug: 180870236
Change-Id: I1cfa765ad12a228e09eb146d1e6e5ba2e3aa3979
Test: atest FrameworksNetTestCases
2021-02-24 02:08:42 +00:00
James Mattis
da32cfeebf Marking setOemNetworkPreference as @SystemApi
Marking setOemNetworkPreference in ConnectivityManager as @SystemApi.

Bug: 176496438
Bug: 176494815
Test: atest FrameworksNetTests
atest FrameworksNetIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I4681c88dc3a83f71c387b29610c33594e57cb43f
2021-02-11 20:38:21 -08:00
James Mattis
45d81845a4 Implementation of setOemNetworkPreference
Main implementation of ConnectivityService.setOemNetworkPreference. This
covers the main requirements of this method including listener
functionality.

Bug: 176495594
Bug: 177101287
Bug: 176494815
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I8d318ab07785e52dd84d6261fdea8f318dce9bc5
2021-02-11 20:38:18 -08:00
Hai Shalom
ead8991fbb Merge "Support for Terms & Conditions notification" 2021-02-10 15:36:58 +00:00
Hai Shalom
7c6ab4004a Support for Terms & Conditions notification
- Added API to add T&C URL in the CaptivePortalData class, and to
indicate if the source is from Passpoint.
- Added source indication for the Venue URL API.
- Allow the connectivity service to send a new T&C acceptance
notification.
- Updated the merge method to prefer the Capport data over the
network agent data, if the source is not authenticated (not from
Passpoint).
- Propagate the Venue Friendly name to the captive portal activity
to be used instead of SSID, when available.

Bug: 162785447
Test: End-to-end test
Test: atest ConnectivityServiceTest
Test: atest CtsNetTestCasesLatestSdk:CaptivePortalDataTest
Test: atest NetworkNotificationManagerTest
Change-Id: I4e77c3b6c01941b03c46ad32da70c77e0fecac64
2021-02-08 12:05:20 -08:00
James Mattis
e74935d4e6 Update OemNetworkPreferences to use 1:1 Map
Updated OemNetworkPreferences to use a Map instead of an Array of Arrays
(SparseArray<List<String>>). This is for two reasons: to make the API
simpler and also prevent issues with duplicate entries for packages
mapped to more than one preference which is not supported.

Bug: 176597181
Bug: 176494815
Test: atest FrameworksNetTests
Change-Id: I85363e28b46b89ae60a85219313c2a45bd5e7dd5
2021-02-04 20:12:40 -08:00
junyulai
2050bed66e [FUI04] Refactor VpnInfo
As a preparation of exposing system API. This patch does some
harmless refactoring, which includes:
  1. Change raw arrays into lists according to API guidelines.
  2. Write test.
  3. Rename class to UnderlyingNetworkInfo.
  4. Rename vpnIface to iface.
  5. Make underlyingIfaces @NonNull in order to adapt new
     unparceling code.
  6. implement equals and hashCode for testing.

Test: atest android.net.UnderlyingNetworkInfoTest
Bug: 174123988

Change-Id: I405c21e57c4af8a12a9dd0a1749b9e6690f87045
2021-01-29 17:44:32 +08:00
Remi NGUYEN VAN
a162ff05e0 Fix CaptivePortalDataTest#testParcelUnparcel on R
CaptivePortalData only has 7 fields on R, not 8.

Bug: 177290955
Change-Id: I156738d07821fee43420d8af14c4bce36dd0e4a4
Test: atest CtsNetTestCasesLatestSdk:CaptivePortalDataTest on R
2021-01-19 02:33:09 +00:00
Treehugger Robot
6516373759 Merge "Fix CaptivePortalDataTest on R-" 2021-01-15 05:26:34 +00:00