Commit Graph

249 Commits

Author SHA1 Message Date
Charles He
0aeecd42a9 Merge "Opt-out for always-on VPN: rename API." into oc-mr1-dev
am: 8b2513e439

Change-Id: Ie511c6f1034b75b4e797dbc0ca31c7c5c30f336e
2017-08-17 08:01:53 +00:00
Hugo Benichi
4842843b23 Merge "Add convenience methods to IpPrefix and LinkAddress" am: aabc00fad6 am: 3ca020fe8b am: caafb4d9f5
am: 7a2f77b3a0

Change-Id: Ied0cc53ac34c7c5f5539507b1979cbf9c215262e
2017-08-16 15:20:59 +00:00
Hugo Benichi
3ca020fe8b Merge "Add convenience methods to IpPrefix and LinkAddress"
am: aabc00fad6

Change-Id: I6d3f3c50eaec44e3a0787e849ab28e89f6f4a72d
2017-08-16 14:49:27 +00:00
Hugo Benichi
8253be9fb7 Add convenience methods to IpPrefix and LinkAddress
Also moving relevant test files into tests/net as part of runtest
framworks-net.

Also removes testHashCode in LinkAddress() because this test relies on
the assumption that hashCode() is stable across releases or jdk
versions, which is absolutely not true.

This creates maintenance work for little benefit since hashCode is
already tested as part of the equality test.

For instance this test is now broken because hashing for InetAddress
changed.

Bug: 62988545
Bug: 62918393
Test: runtest frameworks-net, added coverage in tests
Change-Id: I695bc3f0e801bf13bc4fc0706565758f12b775b4
2017-08-16 21:42:21 +09:00
Charles He
d681363fd1 Opt-out for always-on VPN: rename API.
Rename the opt-out flag in AndroidManifest to
SERVICE_META_DATA_SUPPORTS_ALWAYS_ON
as directed by the API Council.

Bug: 64331776
Bug: 36650087
Test: runtest --path java/com/android/server/connectivity/VpnTest.java
Change-Id: I24326fad7a89083a2409134640bda81ee0359d08
2017-08-15 15:52:39 +01:00
Hugo Benichi
6ecf87a88a Merge "NetworkCapabilities: fix describeImmutableDifferences" into oc-dr1-dev
am: 1b3877a965

Change-Id: I50748aa0c9332787797f91265afccf82ceabf332
2017-08-07 05:49:25 +00:00
Hugo Benichi
dec642b9b3 NetworkCapabilities: fix describeImmutableDifferences
This patch fixes the mask used in describeImmutableDifferences which did
not correctly turn NET_CAPABILITY_NOT_METERED into bit flag.

Bug: 63326103
Test: added unit tests, runtest frameworks-net
Merged-In: Ib6b390b1daef5912859302692af7dcd6cfd3e39a
Merged-In: If38efacdeec8476880835657938e435f9b598525
Merged-In: Ieccad46fcffcaf748f5644b04617e9a82527000e
Merged-In: I533ef8fe369cec19d283ff2950314fce6e28cffd
Merged-In: I12636c6699ff60487a28570208e819ea0b66fa2e
Merged-In: Ie5df14e0ea1c12e0cfabe87978ac6c9b744353b2

(cherry picked from commit 2ecb9408f4102687f20f9ca19c13071ac6098cc6)

Change-Id: I74ecf34a2c079c74152d00caea2c220e9c6d1fa5
2017-08-05 11:37:10 +09:00
Hugo Benichi
8112bf0dd4 Merge "NetworkCapabilities: fix describeImmutableDifferences" am: 7575ec2240 am: 9d951bf6f3 am: 7dac4ce465
am: 09cb221afb

Change-Id: I12636c6699ff60487a28570208e819ea0b66fa2e
2017-08-05 01:28:01 +00:00
Hugo Benichi
9d951bf6f3 Merge "NetworkCapabilities: fix describeImmutableDifferences"
am: 7575ec2240

Change-Id: If38efacdeec8476880835657938e435f9b598525
2017-08-05 00:54:43 +00:00
Hugo Benichi
99806e5606 NetworkCapabilities: fix describeImmutableDifferences
This patch fixes the mask used in describeImmutableDifferences which did
not correctly turn NET_CAPABILITY_NOT_METERED into bit flag.

Bug: 63326103
Test: added unit tests, runtest frameworks-net
Change-Id: Ib6b390b1daef5912859302692af7dcd6cfd3e39a
2017-08-04 15:17:40 +09:00
Hugo Benichi
7ae02714ae Merge "NetworkNotificationManager: correctly handle existing notifications" into oc-dr1-dev
am: a03bf7acd1

Change-Id: I4ca3dcc293be5408a6f207e1ac1a7229a915723a
2017-07-28 04:39:14 +00:00
Hugo Benichi
900a3dbcc0 NetworkNotificationManager: correctly handle existing notifications
This patch corrects a regression added by commit fd35080555 that did
not take into account the case of multiple notifications shown for a
single network id. Given how network notifications are triggered, it can
happen that NO_INTERNET and SIGN_IN notifications are both triggered for
the same network when captive portal detection is slow.

Contrary to the situation before commit fd35080555, a notification
priority order is introduced so that SIGN_IN always overrides
NO_INTERNET, and NO_INTERNET is ignored if SIGN_IN is already present.

Bug: 63676954
Bug: 62503737
Test: runtest frameworks-net, added new unit tests
Merged-In: Ib8658601e8d4dc6c41b335ab7dd8caa0cccd9531
Merged-In: I4432f66067ea1ab02e1d2dfe42530bcdafa52df6
Merged-In: I74631b0bfd14daf18a1641ed7f2ec323d636ebbf
Merged-In: I73cc879e910d503946facdba498b300337f349fd
Merged-In: Ieed9e3e7755e0c5f89dc41ef66f47d4dbf4c66a9
Merged-In: I0aa590170f1bd4c37175c7e35e54d52f1fb21347

(cherry picked from commit 5fcd050e0ecd5985cf184f55ea3df4434da8f824)

Change-Id: I41675768ab59e9b23ca4275edf297b82595e5730
2017-07-28 09:17:20 +09:00
Hugo Benichi
8419aca5fe Merge "NetworkNotificationManager: correctly handle existing notifications" am: 3451fb6156 am: 7e994d3eaa am: 5cbf7e2dc8
am: b43581504b

Change-Id: Ieed9e3e7755e0c5f89dc41ef66f47d4dbf4c66a9
2017-07-27 15:08:19 +00:00
Hugo Benichi
7e994d3eaa Merge "NetworkNotificationManager: correctly handle existing notifications"
am: 3451fb6156

Change-Id: I4432f66067ea1ab02e1d2dfe42530bcdafa52df6
2017-07-27 14:43:48 +00:00
Hugo Benichi
1fc19b9823 NetworkNotificationManager: correctly handle existing notifications
This patch corrects a regression added by commit fd35080555 that did
not take into account the case of multiple notifications shown for a
single network id. Given how network notifications are triggered, it can
happen that NO_INTERNET and SIGN_IN notifications are both triggered for
the same network when captive portal detection is slow.

Contrary to the situation before commit fd35080555, a notification
priority order is introduced so that SIGN_IN always overrides
NO_INTERNET, and NO_INTERNET is ignored if SIGN_IN is already present.

Bug: 63676954
Bug: 62503737
Test: runtest frameworks-net, added new unit tests
Change-Id: Ib8658601e8d4dc6c41b335ab7dd8caa0cccd9531
2017-07-27 21:20:20 +09:00
Di Lu
a37e02acb6 Merge "Add unit test for IpSecService" am: 58bfe539aa am: 3f5f9e1492 am: 345db82674
am: 7547060657

Change-Id: I788e4e8466a76f80d1f15330e6d3b91b73be1d32
2017-07-20 08:42:27 +00:00
Di Lu
c045847be4 Merge "Add unit test for IpSecManager" am: 64d4939d07 am: 9ca5b3e1de am: eb7bc05b32
am: e073f8ae6a

Change-Id: Iecf36183010f78920ef4112b9b0a0febf4ece82c
2017-07-20 08:38:36 +00:00
Di Lu
3f5f9e1492 Merge "Add unit test for IpSecService"
am: 58bfe539aa

Change-Id: I16fb89239e641ac39a8a7adeafd72b7fe03935ed
2017-07-20 07:36:19 +00:00
Di Lu
58bfe539aa Merge "Add unit test for IpSecService" 2017-07-20 07:27:16 +00:00
Di Lu
9ca5b3e1de Merge "Add unit test for IpSecManager"
am: 64d4939d07

Change-Id: I56c336eb8234b31154b6a7defd95ce76ea0800d8
2017-07-20 05:52:10 +00:00
ludi
b413bb0105 Add unit test for IpSecService
Test: runtest frameworks-net

Bug:38259578
Change-Id: I4a049d5fdec79e36692e3b12306bd0758c19ad75
2017-07-20 04:26:24 +00:00
ludi
50c2767142 Add unit test for IpSecManager
Test: runtest frameworks-net

Bug:38259578
Change-Id: Idb76aab899ccb7145bef2b7dce36e115c25fa6ca
2017-07-19 18:59:12 -07:00
Hugo Benichi
90217e1808 Merge "ConnectivityServiceTest: fix testNetworkInfoOfTypeNone" am: 1f0d765378 am: 9efd050236 am: b1894abbc5
am: fecebf94a2

Change-Id: I7d3bfdf6d95d5db2d31439b5c3334569666864e1
2017-07-19 08:20:23 +00:00
Hugo Benichi
9efd050236 Merge "ConnectivityServiceTest: fix testNetworkInfoOfTypeNone"
am: 1f0d765378

Change-Id: I4be1d2ce67871c1e01364beca886fdd3af374321
2017-07-19 08:04:48 +00:00
Hugo Benichi
a6fe35a841 ConnectivityServiceTest: fix testNetworkInfoOfTypeNone
This patch fixes a couple of flakyness issues with
testNetworkInfoOfTypeNone. It also fixes some typos and naming issues.

Bug: 62918393, 62918393
Test: runtest frameworks-net
Change-Id: I1c56557ab113d3ef57dbc06a6e882634d03c5b09
2017-07-19 15:08:49 +09:00
Charles He
b0c5ede751 Merge "Opt-out for always-on VPN" 2017-07-18 18:47:45 +00:00
Hugo Benichi
43b7474c08 IP connectivity metrics: fix tests after proto update
Update to ipconnectivity.proto in commit
6d2f506bfd788a3685292d404dc9d82a27357cfe broke the associated unit
tests (Change-Id: I4cf5b95956df721aecd63fddfb026a7266c190b9)

Bug: 34901696
Test: runtest frameworks-net
Change-Id: I57a6bad8a9836b1c45690c4589b416786ce1dfa0
2017-07-18 14:33:12 +09:00
Charles He
9369e61e2d Opt-out for always-on VPN
Always-on VPN is a feature introduced in N. Since then, all VPN apps
targeting N+ are assumed to support the feature, and the user or the DPC
can turn on / off always-on for any such VPN app. However, a few VPN
apps are not designed to support the always-on feature. Enabling
always-on for these apps will result in undefined behavior and confusing
"Always-on VPN disconnected" notification.

This feature provides a new manifest meta-data field through which a VPN
app can opt out of the always-on feature explicitly. This will stop the
always-on feature from being enabled for the app, both by the user and
by the DPC, and will clear its existing always-on state.

A @hide API is provided to check whether an app supports always-on VPN.
Documentation is updated to reflect the behavior change.

Bug: 36650087
Test: runtest --path java/com/android/server/connectivity/VpnTest.java
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'

Change-Id: I477897a29175e3994d4ecf8ec546e26043c90f13
2017-07-18 00:55:38 +01:00
Hugo Benichi
93e1941b43 Merge "ConnectivityManager: allow usage of TYPE_NONE"
am: d54a27d898

Change-Id: I72dbd17db63bd7b8637e82f5cdcfec3bf1482962
2017-07-05 14:33:35 +00:00
Hugo Benichi
a64e822036 Merge "ConnectivityServiceTest: more informative assert failures"
am: cc1feacd8d

Change-Id: Iaa55014ae4c2f4927059735c349c40ada836b79b
2017-07-05 14:19:33 +00:00
Hugo Benichi
c521380789 Merge "ConnectivityServiceTest: eliminate remaining sleep()"
am: 2af7cbd8b7

Change-Id: Ib1e31c2b8999d07b20ef4cef8e70d851f93df6e5
2017-07-05 12:35:01 +00:00
Hugo Benichi
ad353f451a ConnectivityManager: allow usage of TYPE_NONE
This patch allows to use TYPE_NONE for the legacy network type variable
of NetworkInfo. This usage is "safe" with respect to legacy APIs using
network types as most of them already returns null or do nothing for
TYPE_NONE.

Of the existing APIs in ConnectivityManager that accept a network type
argument, those which were already returning null or doing nothing for
TYPE_NONE are:
  getNetworkInfo(int)
  getNetworkForType(int)
  stopUsingNetworkFeature(int, String)
  networkCapabilitiesForType(int)
  requestRouteToHostAddress(int, InetAddress)
  reportInetCondition(int, int)
  isNetworkSupported(int)
  getLinkProperties(int)

Only setProvisioningNotificationVisible needs an additional guard
against TYPE_NONE.

Bug: 30088447
Bug: 62844794
Test: runtest frameworks-net
Change-Id: I112596fcd03d3c2cd42a2a84d265adb38e3944bb
2017-07-05 21:30:52 +09:00
Hugo Benichi
99495b1a4d ConnectivityServiceTest: more informative assert failures
Bug: 62918393
Test: runtest frameworks-net
Change-Id: If87315ef7cba6380596f48b92c7e0f6eeccc8368
2017-07-05 21:30:10 +09:00
Hugo Benichi
96d0a49b19 ConnectivityServiceTest: eliminate remaining sleep()
ConnectivityServiceTest was still using sleep() in a few places although
these were unnecessary:
  - in testSatisfiedThenLostNetworkRequestDoesNotTriggerOnAvailable(),
    expectNoCallback() and expectAvailableCallback() already include
    waitForIdleHandler calls that drain the message queues and make
    sleep no-ops.
  - in testTimedoutAfterUnregisterdNetworkRequest, the sleeps were
    introduced before unregisterNetworkCallback was changed to have a
    synchronous effect for callback unregistration, therefore the sleep
    becomes simply non-sensical. To reflect this the name of the method
    is also changed.

Bug: 62918393
Test: runtest frameworks-net
Change-Id: I7b701ecf5846a5e1890e86107b8d2544b419ce44
2017-07-05 16:07:57 +09:00
Roland Levillain
8ad104e62c Merge "Revert "ConnectivityManager: allow usage of TYPE_NONE""
am: a4fcd1a2b7

Change-Id: I49221522c1a9a6e7d4ae72529c1a47b736e26a39
2017-07-04 11:31:30 +00:00
Roland Levillain
a17d7171d9 Merge "Revert "ConnectivityServiceTest: more informative assert failures""
am: 959e3f9ac9

Change-Id: Ie61051984a1b6efbb0b19754ce0fb99024ab296a
2017-07-04 11:24:25 +00:00
Roland Levillain
2e99b8e7d2 Merge "Revert "ConnectivityServiceTest: eliminate remaining sleep()""
am: 1c5d788650

Change-Id: If210f213c7840c218d5e847667c7613d53f86661
2017-07-04 11:22:32 +00:00
Roland Levillain
4bb710cb01 Revert "ConnectivityManager: allow usage of TYPE_NONE"
This CL is breaking some internal builds.

This reverts commit 0b7642a820.

Change-Id: Ie79214808d84c73f54a525f515b4c90a3fb23542
2017-07-04 11:14:03 +00:00
Roland Levillain
a12b67eacf Revert "ConnectivityServiceTest: more informative assert failures"
CL https://android-review.googlesource.com/#/c/420720/ is
breaking several internal builds, and CL
https://android-review.googlesource.com/#/c/422480/ must
be reverted beforehand.

This reverts commit a0b7f12eb7.

Change-Id: I5883409452d39e1834e183aa7b5ccdbf14291ca5
2017-07-04 11:11:35 +00:00
Roland Levillain
1c5d788650 Merge "Revert "ConnectivityServiceTest: eliminate remaining sleep()"" 2017-07-04 11:11:09 +00:00
Roland Levillain
d5810f566f Revert "ConnectivityServiceTest: eliminate remaining sleep()"
CL https://android-review.googlesource.com/#/c/420720/ is
breaking several internal builds, and CL
https://android-review.googlesource.com/#/c/422481/ must
be reverted beforehand.

This reverts commit 137a0e6d16.

Change-Id: If0b196b6860c4087a05b28770469d7850a76fd37
2017-07-04 11:10:06 +00:00
Hugo Benichi
745a3564e2 Merge "ConnectivityServiceTest: eliminate remaining sleep()"
am: a1dca50b88

Change-Id: I31a8f64b4ee37a58bc83c08251d949f44cc26fd4
2017-07-04 09:43:01 +00:00
Hugo Benichi
8a73d29f31 Merge changes I90c211dc,I4455f272
am: a5ea99e288

Change-Id: I502d978ff636a00979d2083c39381bf600d3d6da
2017-07-04 09:35:51 +00:00
Treehugger Robot
a1dca50b88 Merge "ConnectivityServiceTest: eliminate remaining sleep()" 2017-07-04 09:25:53 +00:00
Treehugger Robot
a5ea99e288 Merge changes I90c211dc,I4455f272
* changes:
  ConnectivityServiceTest: more informative assert failures
  ConnectivityManager: allow usage of TYPE_NONE
2017-07-04 09:22:07 +00:00
Hugo Benichi
137a0e6d16 ConnectivityServiceTest: eliminate remaining sleep()
ConnectivityServiceTest was still using sleep() in a few places although
these were unnecessary:
  - in testSatisfiedThenLostNetworkRequestDoesNotTriggerOnAvailable(),
    expectNoCallback() and expectAvailableCallback() already include
    waitForIdleHandler calls that drain the message queues and make
    sleep no-ops.
  - in testTimedoutAfterUnregisterdNetworkRequest, the sleeps were
    introduced before unregisterNetworkCallback was changed to have a
    synchronous effect for callback unregistration, therefore the sleep
    becomes simply non-sensical. To reflect this the name of the method
    is also changed.

Bug: 62918393
Test: runtest frameworks-net
Change-Id: I78426665670f702304212753f417b3d5a8a2c107
2017-07-04 16:23:06 +09:00
Hugo Benichi
a0b7f12eb7 ConnectivityServiceTest: more informative assert failures
Bug: 62918393
Test: runtest frameworks-net
Change-Id: I90c211dc6d6262475924ecabc2863c47aec5a0b9
2017-07-04 16:23:05 +09:00
Hugo Benichi
0b7642a820 ConnectivityManager: allow usage of TYPE_NONE
This patch allows to use TYPE_NONE for the legacy network type variable
of NetworkInfo. This usage is "safe" with respect to legacy APIs using
network types as most of them already returns null or do nothing for
TYPE_NONE.

Of the existing APIs in ConnectivityManager that accept a network type
argument, those which were already returning null or doing nothing for
TYPE_NONE are:
  getNetworkInfo(int)
  getNetworkForType(int)
  stopUsingNetworkFeature(int, String)
  networkCapabilitiesForType(int)
  requestRouteToHostAddress(int, InetAddress)
  reportInetCondition(int, int)
  isNetworkSupported(int)
  getLinkProperties(int)

Only setProvisioningNotificationVisible needs an additional guard
against TYPE_NONE.

Bug: 30088447
Bug: 62844794
Test: runtest frameworks-net
Change-Id: I4455f2726d06406047086368628c1f253d854d8d
2017-07-04 16:22:59 +09:00
Hugo Benichi
ae3dac0601 Merge "Networking unit tests: fix some flaky tests"
am: 501bae6492

Change-Id: I6815e732f334d11208ff12af4023912593d96499
2017-07-03 09:35:06 +00:00
Hugo Benichi
44ceaa602e Networking unit tests: fix some flaky tests
- less strict regex for SharedLogTest: the subsecond part of the
   timestamp can have 0, 1, 2 or 3 digits.
 - refactor NetworkStatsServiceTest and NetworkStatsObserversTest to use
   waitForIdleHandler facility of ConnectivityServiceTest.
   NetworkStatsServiceTest was using a flaky custom version of
   waitForIdleHandler.

Bug: 62918393
Bug: 32561414
Test: runtest frameworks-net
Change-Id: I634acfb5f4fe1bd5267e3f14b9f645edc32d5d12
2017-07-03 16:29:01 +09:00