Commit Graph

2362 Commits

Author SHA1 Message Date
junyulai
5eb5fbfce3 [FUI27] Fix internal naming of notifyNetworkStatus
Test: TH
Bug: 174123988
Change-Id: I970ee365ca221956ee85788005d331374b5fa71a
2021-05-14 19:48:17 +08:00
junyulai
bad30368d4 [FUI26] Address comments on aosp/1560408
Test: TH
Bug: 174123988
Change-Id: I949eeb8903e903d8ede90521442b1f917d5cdfeb
2021-05-14 15:57:44 +08:00
Aaron Huang
8dd94bdcef Rename *Iface* APIs to *Interface*
Address API review feedback, other APIs have been refering to
these as "interface" instead of "iface" so migrate the APIs named
*Iface* to *Interface*.

(cherry-picked from ag/14326779)
Bug: 183972554
Test: atest android.net.UnderlyingNetworkInfoTest
Merged-In: I38b476e762fb57fa88c4a789092d0af6f5330d80
Change-Id: I38b476e762fb57fa88c4a789092d0af6f5330d80
2021-05-14 11:05:22 +08:00
Lorenzo Colitti
e61ffc1a50 Do not automatically redact TransportInfo objects.
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
2021-05-13 20:24:19 +09:00
Remi NGUYEN VAN
0d51e44e09 Move net unit tests to packages/Connectivity
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
Merged-In: I254ffd1c08ec058d594b4ea55cbae5505f8497cc

Change-Id: I254ffd1c08ec058d594b4ea55cbae5505f8497cc
2021-05-13 08:30:33 +00:00
Ken Chen
edeab9051e Merge "Add testVpnTypesEqual to verify consistency" 2021-05-13 01:22:08 +00:00
Ken Chen
a0b65e1870 Merge "Switch from networkCreate[Physical/Vpn] to networkCreate" 2021-05-13 01:20:39 +00:00
Lucas Lin
0604a2e93e Merge "Update PrivateDnsMode from StringDef to IntDef" 2021-05-12 17:09:50 +00:00
Ken Chen
4812a3ab7a Add testVpnTypesEqual to verify consistency
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
2021-05-12 17:34:34 +08:00
Chiachang Wang
536e82f56b Merge "Remove sendNetworkConditionsBroadcast" 2021-05-12 09:24:02 +00:00
Lorenzo Colitti
dacc5e5f93 Merge "Rename unwanted capabilities to forbidden capabilities." 2021-05-12 09:00:17 +00:00
Paul Hu
eda29f73aa Merge "Add MATCH_ANY_USER flag to PackageInfo queries" 2021-05-12 07:13:17 +00:00
Lorenzo Colitti
e1d928aff5 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
Ken Chen
de5e7aa2ba Switch from networkCreate[Physical/Vpn] to networkCreate
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
2021-05-11 16:06:54 +08:00
lucaslin
d6f8dbd75b Remove sendNetworkConditionsBroadcast
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
2021-05-11 09:25:54 +08:00
Benedict Wong
0a6585c58c Add internal support for IPsec forward policies
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
2021-05-07 15:09:42 -07:00
lucaslin
de1e9855ed Update PrivateDnsMode from StringDef to IntDef
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)
2021-05-05 03:19:51 +00:00
Treehugger Robot
1c9a1c1353 Merge "Add getters to NetworkStateSnapshot" 2021-04-29 09:20:34 +00:00
Treehugger Robot
3cf9eef4cc Merge "Add getters to UnderlyingNetworkInfo" 2021-04-29 07:29:08 +00:00
Treehugger Robot
416a37f7f8 Merge "Rename getAllNetworkStateSnapshot which should be pluralized" 2021-04-29 04:40:51 +00:00
Les Lee
8eb01a8a7e Merge "wifi data usage: support to get carrier merged wifi network." 2021-04-27 02:13:32 +00:00
James Mattis
4a57fe5c2b Merge "Changing per-app default request to TRACK_DEFAULT" 2021-04-26 14:39:44 +00:00
paulhu
fe2e569d4e Add MATCH_ANY_USER flag to PackageInfo queries
- 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
2021-04-26 19:03:20 +08:00
Chiachang Wang
14a74d0c62 Merge "Address API review feedback" 2021-04-26 00:22:27 +00:00
James Mattis
0abefa739d Changing per-app default request to TRACK_DEFAULT
Changing the per-app default request flows to fallback to a request of
type TRACK_DEFAULT as opposed to type REQUEST. The main benefit of this
change is that these requests will no longer be sent to the factories
which is desired.

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

Change-Id: I312e55a54f70aa82953a32ab9369d5afc02b75e5
Merged-In: I312e55a54f70aa82953a32ab9369d5afc02b75e5
2021-04-23 07:47:11 -07:00
Remi NGUYEN VAN
41869c65a9 Merge "Use connectivity resources in service-connectivity" 2021-04-23 05:42:13 +00:00
Chiachang Wang
2cd79f28d8 Address API review feedback
Address API review feedback to:
 - 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: make update-api
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I5e8c4bed8bda40d507afa894c359b5e24ee5d868
Merged-In: I5e8c4bed8bda40d507afa894c359b5e24ee5d868
2021-04-23 02:46:05 +00:00
Remi NGUYEN VAN
a4bef5d40b Use connectivity resources in service-connectivity
Migrate resource usage to the connectivity resource package.
For framework resources that have known overlays, keep a fallback until
the overlays can be migrated.

Bug: 182125649
Test: atest FrameworksNetTests
Merged-In: I778d94a5aac0c4e20e78b1ba3a002495c17a38a0
(clean cherry-pick)

Change-Id: I778d94a5aac0c4e20e78b1ba3a002495c17a38a0
2021-04-23 10:36:15 +09:00
Remi NGUYEN VAN
8acce32060 Merge "Add QUERY_ALL_PACKAGES to net integration tests" 2021-04-22 14:38:40 +00:00
Aaron Huang
e1c4b4fcb7 Add getters to UnderlyingNetworkInfo
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
2021-04-22 22:30:42 +08:00
Remi NGUYEN VAN
924c94e7cd Add QUERY_ALL_PACKAGES to net integration tests
The permission is necessary for ConnectivityService to obtain its
resource package. As the integration tests run ConnectivityService
in-process, they need the permission.

Bug: 186091860
Test: atest FrameworksNetIntegrationTests
Change-Id: I60cf9b54faddf0ea4cb02146c83c9bba58370749
2021-04-22 22:02:01 +09:00
Aaron Huang
b18cb78d6a Add getters to NetworkStateSnapshot
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
2021-04-22 18:21:00 +08:00
Aaron Huang
3227bfb2dc Rename getAllNetworkStateSnapshot which should be pluralized
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
2021-04-22 17:45:22 +08:00
Treehugger Robot
4995a0bbaa Merge "[VCN19] Rename get/setSubIds to get/setSubscriptionIds" 2021-04-22 04:43:26 +00:00
James Mattis
5ab962df61 Merge "Correctly count nri uid request counts" 2021-04-21 02:06:33 +00:00
Nazanin Bakhshi
348f5cb01e Merge "Refactoring and mocking to make sure unit test doesn't call the real service" 2021-04-20 15:44:00 +00:00
Treehugger Robot
55b86dd028 Merge "Roll forward: add a test for ParseException" 2021-04-20 10:03:56 +00:00
Remi NGUYEN VAN
060026feca Merge "Revert "Add a test for ParseException"" 2021-04-20 09:25:07 +00:00
Remi NGUYEN VAN
8cb7d32b1a Update TEST_MAPPING imports for connectivity
Connectivity CTS tests were moved from cts/tests/net to
packages/modules/Connectivity.

Bug: 185751610
Change-Id: Id4efd99c419706a52ad5d708888097bd6312d4e6
Test: treehugger is needed to test
2021-04-20 07:10:41 +00:00
Remi NGUYEN VAN
96dc675760 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
7696391a92 Revert "Add a test for ParseException"
This reverts commit 98bab00fc9.

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

Change-Id: I9f5d25c0ba81011848ab3cf7ec44aa329fbb3b0f
2021-04-20 16:04:33 +09:00
James Mattis
fff0b7ce6d Correctly count nri uid request counts
Correctly count nri uid request counts in the per-app functionality in
connectivity currently used by set profile and set oem network
preference APIs. Previously, upon creation, nris would be created prior
to removing them. This would cause the uid request counts to
artificially increase and incorrectly throw an error if the request
count limit was hit even though in actuality an apps request count was
valid.

E.g., if there was an existing request for per-app functionality and
its owning app made a change to the per-app requests, it would double
count the existing requests. If the current count was say, one under the
limit, an error would be thrown even though it was being replaced which
should have resulted in no net change to the request count limit if
working correctly.

This patch will allow for the requests to be removed prior to creation
so that request counts are tabulated correctly.

Bug: 185849563
Bug: 183785319
Test: atest FrameworksNetTests
Change-Id: I13da0c81256cc02bea6aff2fe1ef99d6f6b0e764
2021-04-19 19:28:23 -07:00
Nazanin
8d18299e28 Refactoring and mocking to make sure unit test doesn't call the real service
Bug: 180938364
Test: utest
Change-Id: Ic6a5a84c1d985fa02f8cf52c8c2ff144669b30c1
2021-04-19 17:12:05 -07:00
junyulai
3c409e8ce7 [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
lesl
f5beb8fcb0 wifi data usage: support to get carrier merged wifi network.
Carrier merged wifi network is a specific cerrier wifi network
which provides the same user experience as mobile.

To support data usage accounting for carrier merged wifi,
the change provide several APIs in NetworkTemplate:

  1. extend buildTemplateWifi so it could be used for matching
     wifi networks with subscriber Id (IMSI).
  2. add buildTemplateCarrier to let
     NetworkPolicyManagerService creates a single policy for
     a given carrier regardless of network type.

Bug: 176396812
Test: atest -c NetworkTemplateTest
Test: atest -c NetworkStatsServiceTest
Test: Manual Test with test code on mobile and wifi network.
      1. buildTemplateCarrier includes the carrier wifi and
         mobile usage
      2. buildTemplateWifi can get carrier wifi usage and support the
         filter via subscriberId

Change-Id: I667b4adf3eec0bdd3a7385109dd8c1fae8e7be32
2021-04-19 16:13:27 +08:00
Remi NGUYEN VAN
dfb51531e6 Merge "Add a test for ParseException" 2021-04-19 04:57:31 +00:00
Junyu Lai
bd7b4a4a65 Merge "[VCN20] Change requestBackgroundNetwork argument order" 2021-04-16 16:04:31 +00:00
junyulai
e576c085c3 [VCN20] Change requestBackgroundNetwork argument order
Test: atest FrameworksNetTests FrameworksVcnTests
Fix: 185215095
Merged-In: Id281678fe85ce0894b0e92e11c0283d4d1b4ecdb
Change-Id: Id281678fe85ce0894b0e92e11c0283d4d1b4ecdb
  (cherry-picked from ag/14198667)
2021-04-16 00:16:21 +08:00
lucaslin
df2a314d6c 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
98bab00fc9 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