Commit Graph

2332 Commits

Author SHA1 Message Date
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
Remi NGUYEN VAN
41869c65a9 Merge "Use connectivity resources in service-connectivity" 2021-04-23 05:42:13 +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
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
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
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
Chiachang Wang
4bc8b1386f Merge "Make getUid a method on UserHandle itself instead of static" 2021-04-13 08:15:47 +00:00
Chiachang Wang
d2bce7b6e3 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
3d1e89d298 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
James Mattis
6e4405f926 Adding log history for setOemNetworkPreference()
Adding historical logging for the setOemNetworkPreference() calls. This
will last across reboots.

Bug: 177257940
Bug: 176494815
Test: atest FrameworksNetTests
Change-Id: I4fc35fd58ff741830aa292adc1c559b4279ad8f9
2021-04-08 17:40:06 -07:00
Chiachang Wang
97565cfdb3 Make getUid a method on UserHandle itself instead of static
This commit addresses the API review feedback that getUid()
will be better to make it be a method on UserHandle itself
rather than a static method.

Update as it is and update the corresponding usages.

Fix: 184735865
Test: make update-api
Test: atest FrameworksNetTests
Test: atest CtsNetTestCasesLatestSdk
Change-Id: I33844309224d84764704255d251fadc8940202ca
2021-04-09 08:33:07 +08:00
Remi NGUYEN VAN
029a0cff8a 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
Chiachang Wang
d125112aa2 Merge "Assign the bit calculation as long to prevent overflow" 2021-04-07 04:24:46 +00:00
Chiachang Wang
7dd2a3d7db Assign the bit calculation as long to prevent overflow
The value should be assigned as a long to do the bit calculation
as the mNetworkCapabilities is intended to be a long. Otherwise,
the value will be temporary assigned into an integer then
assigned to the target long. When the bit shift calculation
is out of the integer scope, the calculation will overflow and
result in unexpected bebavior.

Without assigning to a long, ConnectivityServiceTest will get
Out-Of-Memory in StringBuilder while generating toString() in
NetworkCapabilities after updating tests to verify
NET_CAPABILITY_VSIM and NET_CAPABILITY_BIP.

Bug: 130869457
Test: atest FrameworksNetTests
Change-Id: I4d34c1215c7efb6dc352c314107792e3fa512ad7
2021-04-07 02:06:33 +00:00
Treehugger Robot
7fe967c611 Merge "ConnectivityManager: Address review comments from aosp/1595396" 2021-04-07 00:36:27 +00:00
Roshan Pius
f75ffaaded ConnectivityManager: Address review comments from aosp/1595396
Bug: 156867433
Test: atest android.net
Test: atest com.android.server
Change-Id: I7f5d043732ae22edd14bf581b7dc676c9236b545
2021-04-06 16:42:51 +00:00
Frank Li
133733bdd2 Merge "Add session ID to VpnTransportInfo" 2021-04-06 06:50:48 +00:00
James Mattis
bd275dcf3d Adding per-app support for app add/remove
Adding support for per-app network functionality to react to application
installs, removals and updates. Also, opportunistic cleanup of a couple
annotations.

Bug: 177092163
Bug: 176494815
Test: atest FrameworksNetTests
atest NetworkStackTests
atest FrameworksNetIntegrationTests
atest NetworkStackIntegrationTests
atest CtsNetTestCasesLatestSdk

Change-Id: I45acbd0d2ef50d575f14a944ce82b185ed69f219
2021-04-05 09:55:44 -07:00
Chalard Jean
167cc4a044 Merge "Fix a bug where the wrong profile is queried" 2021-04-05 05:48:17 +00:00
Chalard Jean
0a04bdb730 Fix a bug where the wrong profile is queried
UserManager#isManagedProfile() is not aware of the user
handle of the context the UM instance is created on.
Instead, call isManagedProfile(int).

Bug: 183625645
Test: ConnectivityServiceTest
Change-Id: I1fef22d67d75df25a8c2d0694f857c3e1c1a1306
2021-04-02 19:24:44 +09:00
Benedict Wong
4310e45eff Downgrade list of subIds in NetworkCapabilities to @SystemApi
This change downgrades API visibility for the list-of-subIds in the
NetworkCapabilities to SystemApi

Bug: 175662146
Test: atest NetworkCapabilitiesTest#testSubIds
Test: atest FrameworksNetTests
Change-Id: I372fa9eaa7585aefd1710948ca007456feedd578
2021-04-02 01:18:11 -07:00
Aaron Huang
e36b232c4a Merge "Move deduceRestrictedCapability to libs/net and rename it" 2021-04-01 11:37:51 +00:00
Chalard Jean
58b8d1eb22 Merge "Fix testLegacyLockdownVpn flaky" 2021-04-01 08:19:53 +00:00
lifr
375d1f5904 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
Test: atest ConnectivityServiceTest
      atest VpnTransportInfoTest
      atest android.net.cts.NetworkAgentTest
Change-Id: I8d09e25b83f7ee8be21ec9c9bd3c72a251f1370d
Merged-In: I8d09e25b83f7ee8be21ec9c9bd3c72a251f1370d
           (cherry-picked from ag/14011912)
2021-04-01 15:46:31 +08:00
Chalard Jean
face022980 Fix testLegacyLockdownVpn flaky
When WiFi disconnects, the VPN disconnects immediately. The
broadcast can therefore be sent before the broadcast receiver is
registered, which causes the receiver to not see the broadcast.

The puzzling part is that CONNECTIVITY_ACTION is a sticky
broadcast, so one would expect the broadcast to still be
received, even if the registration is done after the broadcast
is sent. The reason this doesn't happen is that the context used
by the test is a BroadcastInterceptingContext, which does not
treat sticky broadcasts as sticky.

Bug: 184115648
Test: atest --iterations 1000 'ConnectivityServiceTest#testLegacyLockdownVpn'
Change-Id: Ib44c92839d25951cc7d2db0f923e1b104690e1e0
2021-04-01 06:27:46 +00:00
Suprabh Shukla
2adfd3ccb5 Add required permission to FrameworksNetIntegrationTests
Test: atest FrameworksNetIntegrationTests

Fixes: 184166194
Change-Id: I7ad920ba5962f9c71c3c3db86809e7cb6b934425
2021-03-31 18:52:04 -07:00
Lorenzo Colitti
cbc6a315c5 Merge changes I24580ea4,Id48b8eab
* changes:
  Allow the system to register 250 NetworkCallbacks.
  Add more test coverage for limiting the number of callbacks.
2021-03-30 16:01:58 +00:00
Lorenzo Colitti
b4f8d8e130 Allow the system to register 250 NetworkCallbacks.
Give anyone with PERMISSION_MAINLINE_NETWORK_STACK (i.e.,
either the system or the networkstack process) a separate limit
of 250 callbacks per UID.

Bug: 183921387
Test: new unit tests
Change-Id: I24580ea48e3ad502ef584efc5fde0b5d22e392b4
2021-03-30 22:54:01 +09:00
Lorenzo Colitti
64ef4d3785 Add more test coverage for limiting the number of callbacks.
Bug: 183921387
Test: test-only change
Change-Id: Id48b8eab507fb616cb0adfeba52e00858d44b8a6
2021-03-30 20:28:36 +09:00
Treehugger Robot
364ad64fa7 Merge changes I3826b9ef,I91d68ca3
* changes:
  Add static for constant
  Get NetworkCapabilities from NetworkCallback
2021-03-30 08:22:41 +00:00
Lorenzo Colitti
2206e976c1 Merge changes If539cf5d,I9765f1c9,I6d3007a1
* changes:
  Add test coverage for NetworkAgent callbacks.
  Add a setTeardownDelayMs API to NetworkAgent.
  Address comments on onBlockedStatusChanged(Network, int) CL.
2021-03-30 00:38:47 +00:00
Sudheer Shanka
90358f5154 Remove NetworkPolicyManager.isUidBlocked() API.
It isn't used by ConnectivityService any more and even if
it needs such utility method in the future, we could create
one which is part of connectivity module and doesn't need
to be exposed as part of NetworkPolicyManager API surface.

Bug: 183696103
Test: atest ./tests/net/java/com/android/server/ConnectivityServiceTest.java
Change-Id: Ie3c681f88e4b2b9bb92d2224c5ea96b074f155d5
2021-03-29 12:39:12 +00:00
Lorenzo Colitti
1bc9ad0375 Add test coverage for NetworkAgent callbacks.
Tests the onNetworkCreated, onNetworkUnwanted and
onNetworkDisconnected callbacks, and the teardown delay timer.

Bug: 181941583
Test: atest --rerun-until-failure 500 ConnectivityServiceTest#testNetworkAgentCallbacks
Change-Id: If539cf5d01ba23193afab2433ed0ac4e7f0550ec
2021-03-29 21:33:11 +09:00
Frank Li
8539ed6fd2 Merge changes from topic "NetworkAgent02"
* changes:
  Fix cannot success verify count of the networkAgent Config items on R device
  [TL02]Remove hidden API usage of NetworkAgent
2021-03-29 11:08:24 +00:00
lifr
f459c60984 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