Commit Graph

4402 Commits

Author SHA1 Message Date
Charles He
65e8bd2e04 Merge changes from topic "always-on-vpn"
* changes:
  Opt-out for always-on VPN: rename API.
  Opt-out for always-on VPN
2017-09-19 07:50:13 +00:00
Hugo Benichi
b166a64b20 Merge "Wakeup packet events: addressing a few comments" am: efd7e6d7a9 am: ca88876b58 am: 19625788a1
am: 17d5101e99

Change-Id: I7d57c0f2377f44bcf75e18c80c0306bbfccb9591
2017-09-19 07:42:18 +00:00
Hugo Benichi
17d5101e99 Merge "Wakeup packet events: addressing a few comments" am: efd7e6d7a9 am: ca88876b58
am: 19625788a1

Change-Id: I8ca2a01a95acaaca2599563efd6a21e4372d1f95
2017-09-19 07:36:12 +00:00
Hugo Benichi
ca88876b58 Merge "Wakeup packet events: addressing a few comments"
am: efd7e6d7a9

Change-Id: I67b2e54d45a39005e2091a46e8b90d8cc75fe079
2017-09-19 07:21:12 +00:00
Hugo Benichi
6c35b8082c Wakeup packet events: addressing a few comments
This patch addresses a few post-submit comment for
commits f562ac34a51dc and 60c9f63b66921.

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net
Merged-In: I4abec57e0c6bc869dc57b5eb54582dd977b64c30

(cherry picked from commit 175b574e27daa0d8832b8cc9615a15fce998309a)

Change-Id: Ied9d0cec98685e5a91ed2ca2c81ad88d7ae8d751
2017-09-19 16:14:19 +09:00
Hugo Benichi
efd7e6d7a9 Merge "Wakeup packet events: addressing a few comments" 2017-09-19 07:12:03 +00:00
Rubin Xu
42325fa3e9 Merge "Fix LinkPropertiesTest.testCompareResult" am: 430d8472b2 am: 1c7c93e084 am: 3db86833e6
am: f49156fd33

Change-Id: Ie928474dc005c713063885d156786106ca2c281c
2017-09-19 06:57:14 +00:00
Rubin Xu
f49156fd33 Merge "Fix LinkPropertiesTest.testCompareResult" am: 430d8472b2 am: 1c7c93e084
am: 3db86833e6

Change-Id: I72b0ca1b9b50dacb7067eb6ca12ca48a072b5d26
2017-09-19 06:51:07 +00:00
Rubin Xu
1c7c93e084 Merge "Fix LinkPropertiesTest.testCompareResult"
am: 430d8472b2

Change-Id: If87f8c43371ee1f5e2e893232c9e340a1a7339f4
2017-09-19 06:37:40 +00:00
Hugo Benichi
d4a29081c1 Wakeup packet events: addressing a few comments
This patch addresses a few post-submit comment for
commits f562ac34a51dc and 60c9f63b66921.

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net
Change-Id: I4abec57e0c6bc869dc57b5eb54582dd977b64c30
2017-09-19 14:07:47 +09:00
Rubin Xu
830124470a Fix LinkPropertiesTest.testCompareResult
Test: runtest frameworks-core -c android.net.LinkPropertiesTest
Change-Id: Ie97b7a7a1557b14296d7c33e98991cdede8463b0
2017-09-15 11:55:28 +01:00
Hugo Benichi
aba2884647 Merge "Merge changes I4719b4dc,I0308cdf4,I38db1bb7 am: e5090f2547 am: 1cbdfb6460 am: b025492a6b" into oc-mr1-dev-plus-aosp
am: add643c337

Change-Id: I235a6e894157f0a2b6bbcb26a35dd758da6aefc3
2017-09-15 06:54:11 +00:00
Hugo Benichi
47834c4698 Merge "Merge changes Ie2676b20,Ie8db6f85 am: f33207512a am: 3b0c20458d am: 7d16886c7e" into oc-mr1-dev-plus-aosp
am: 24d8238137

Change-Id: I05671ad4513645fff420cbc9fc4f8355bdeaa1f1
2017-09-15 06:51:45 +00:00
Hugo Benichi
611f62c6b9 Connectivity metrics: add WakeupStats events
This patch defines a new WakeupStats event in ipconnectivity.proto and
populates these events from the NFLOG wakeup events stored in
NetdEventListenerService.

There is one WakeupStats object per known interface on which ingress
packets arrive and may wake the system up.

Example from $ adb shell dumpsys connmetrics list:

...
WakeupStats(wlan0, total: 58, root: 0, system: 3, apps: 38, non-apps: 0, unrouted: 17, 6111s)
WakeupEvent(13:36:31.686, iface wlan0, uid -1)
WakeupEvent(13:38:50.846, iface wlan0, uid -1)
WakeupEvent(13:39:16.676, iface wlan0, uid 10065)
WakeupEvent(13:40:32.144, iface wlan0, uid 1000)
WakeupEvent(13:40:35.827, iface wlan0, uid 1000)
WakeupEvent(13:40:47.913, iface wlan0, uid 10004)
WakeupEvent(13:40:52.622, iface wlan0, uid 10014)
WakeupEvent(13:41:06.036, iface wlan0, uid 10004)
...

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net
Merged-In: Ie2676b20bfb411a1902f4942643df0c20e268d99

(cherry pick from commit 60c9f63b66926745603978e1bd6372b3a44561d1)

Change-Id: I3087f446fc998fc1ca895d975b80c4a1dd029bf3
2017-09-15 10:36:24 +09:00
Hugo Benichi
8b3f87160b Connectivity metrics: collect NFLOG wakeup events
This patch stores NFLOG packet wakeup events sent by Netd to the system
server into a ring buffer inside NetdEventListenerService. The content
of this buffer is accessible by $ dumpsys connmetrics or $ dumpsys
connmetrics list, and is added to bug reports.

The wakeup event buffer stores currently uid and timestamps.

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net, new unit tests

Merged-In: Ie8db6f8572b1a929a20398d8dc03e189bc488382

(cherry picked from commit f562ac34a51da55e4d15e34f0cd1cb597e7d926c)

Change-Id: Ibe706872a80dfd06abd9779a2116ca7e4bc0fb77
2017-09-15 10:35:17 +09:00
Rubin Xu
da51a11429 Merge "Refactor CompareResult<> class and its call sites" am: 414e97272f am: 027607ce4d am: c345562746
am: 3c737b4acc

Change-Id: Ib6c61ffe9718ef29c122609a9b343d4e01290568
2017-09-14 22:53:59 +00:00
Hugo Benichi
46510068bc Merge changes I4719b4dc,I0308cdf4,I38db1bb7 am: e5090f2547 am: 1cbdfb6460
am: b025492a6b

Change-Id: I5385a3747e039a42e86034f7632edd0f855b2eb1
2017-09-14 18:11:06 +00:00
Hugo Benichi
b5141eb1d4 Merge changes Ie2676b20,Ie8db6f85 am: f33207512a am: 3b0c20458d
am: 7d16886c7e

Change-Id: Ifd0ace409909d258db3738e58126bbf1c48af5dc
2017-09-14 18:02:14 +00:00
Hugo Benichi
1cbdfb6460 Merge changes I4719b4dc,I0308cdf4,I38db1bb7
am: e5090f2547

Change-Id: I3b222afc77b121769cc18d52e5c3d8bcec9db886
2017-09-14 12:08:26 +00:00
Hugo Benichi
3b0c20458d Merge changes Ie2676b20,Ie8db6f85
am: f33207512a

Change-Id: Ib4fab32418da8274bd6b5cb9fef85e0db79d866a
2017-09-14 12:01:19 +00:00
Hugo Benichi
e5090f2547 Merge changes I4719b4dc,I0308cdf4,I38db1bb7
* changes:
  IpManagerTest: fix flaky test
  Fix flaky NsdManagerTest
  Boostrap test for NetworkMonitor
2017-09-14 11:59:58 +00:00
Hugo Benichi
f33207512a Merge changes Ie2676b20,Ie8db6f85
* changes:
  Connectivity metrics: add WakeupStats events
  Connectivity metrics: collect NFLOG wakeup events
2017-09-14 11:53:02 +00:00
Rubin Xu
3c737b4acc Merge "Refactor CompareResult<> class and its call sites" am: 414e97272f am: 027607ce4d
am: c345562746

Change-Id: I850f2ceab5949c2fceba5d25eda639a319efa7b3
2017-09-14 10:13:40 +00:00
Hugo Benichi
3c15d11b94 Connectivity metrics: add WakeupStats events
This patch defines a new WakeupStats event in ipconnectivity.proto and
populates these events from the NFLOG wakeup events stored in
NetdEventListenerService.

There is one WakeupStats object per known interface on which ingress
packets arrive and may wake the system up.

Example from $ adb shell dumpsys connmetrics list:

UPDATEME
...
WakeupStats(wlan0, total: 58, root: 0, system: 3, apps: 38, non-apps: 0, unrouted: 17, 6111s)
WakeupEvent(13:36:31.686, iface wlan0, uid -1)
WakeupEvent(13:38:50.846, iface wlan0, uid -1)
WakeupEvent(13:39:16.676, iface wlan0, uid 10065)
WakeupEvent(13:40:32.144, iface wlan0, uid 1000)
WakeupEvent(13:40:35.827, iface wlan0, uid 1000)
WakeupEvent(13:40:47.913, iface wlan0, uid 10004)
WakeupEvent(13:40:52.622, iface wlan0, uid 10014)
WakeupEvent(13:41:06.036, iface wlan0, uid 10004)
...

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net
Change-Id: Ie2676b20bfb411a1902f4942643df0c20e268d99
2017-09-14 13:29:56 +09:00
Rubin Xu
027607ce4d Merge "Refactor CompareResult<> class and its call sites"
am: 414e97272f

Change-Id: I3d463e29d8ba806d69596bee64234a28d0c6f34d
2017-09-13 21:59:11 +00:00
Rubin Xu
7297def9a4 Merge "Patch incoming LinkProperties before it's visible to the outside" into oc-mr1-dev am: f531f886fb
am: d8f6972b8c

Change-Id: I4ab30e194dca28decc9e621c45d25af3d4c8b2c8
2017-09-13 20:19:54 +00:00
Rubin Xu
d8f6972b8c Merge "Patch incoming LinkProperties before it's visible to the outside" into oc-mr1-dev
am: f531f886fb

Change-Id: Id2afe1701b1c09e7a8d8070a2514e22d2213c61d
2017-09-13 19:33:25 +00:00
Hugo Benichi
ce2d1859b2 Fix flaky NsdManagerTest
Bad synchronization between the mock handler and the test assertions
were causing testDiscoverService() to sometime fails (1/50 ~ 1/100 repro
rate).

Bug: 32561414
Bug: 62918393
Test: runtest frameworks-net, NsdManager#testDiscoverService now passes
      1000 times without errors.
Change-Id: I0308cdf48fc6bdc2fc9b4e8f7d5241a1cf2ea443
2017-09-13 18:38:53 +09:00
Rubin Xu
414e97272f Merge "Refactor CompareResult<> class and its call sites" 2017-09-13 09:35:04 +00:00
Hugo Benichi
454d55d822 Boostrap test for NetworkMonitor
This will finally allow to write captive portal detection unit tests.

Bug: 32561414
Bug: 62918393
Test: runtest frameworks-net
Change-Id: I38db1bb79ae80a82b4199dc9cb1b56257e0cf222
2017-09-13 16:21:50 +09:00
Rubin Xu
599db833bb Patch incoming LinkProperties before it's visible to the outside
Otherwise we risk a race condition when we are fixing the LinkProperties
routes, other parts of ConnectivityService is reading the field at the
same time.

Test: runtest frameworks-net -c com.android.server.ConnectivityServiceTest
Test: runtest frameworks-core -c android.net.LinkPropertiesTest
Bug: 65529483
Bug: 35995111

(cherry picked from commit 6c1f6fd78927514df73ddace81edac4899c4cda4)

Change-Id: I539578703570a901e0a5dff0155422ca78c52401
2017-09-12 13:39:09 +01:00
Rubin Xu
5a3c019ad2 Merge "Patch incoming LinkProperties before it's visible to the outside" am: 7b625191e2 am: 2f36b7afbb am: 2cf8f74180
am: 74af26095c

Change-Id: Ibd5c615b9cb38664742e96327163bd970a38d848
2017-09-12 11:40:31 +00:00
Rubin Xu
74af26095c Merge "Patch incoming LinkProperties before it's visible to the outside" am: 7b625191e2 am: 2f36b7afbb
am: 2cf8f74180

Change-Id: Ic82526773116db3b80449cb0241a1f80934b3d55
2017-09-12 11:34:55 +00:00
Rubin Xu
2f36b7afbb Merge "Patch incoming LinkProperties before it's visible to the outside"
am: 7b625191e2

Change-Id: I032ba648ec0476ab8a02a710e2ae485ab4a590b8
2017-09-12 11:23:20 +00:00
Rubin Xu
efc3c4a547 Patch incoming LinkProperties before it's visible to the outside
Otherwise we risk a race condition when we are fixing the LinkProperties
routes, other parts of ConnectivityService is reading the field at the
same time.

Test: runtest frameworks-net -c com.android.server.ConnectivityServiceTest
Test: runtest frameworks-core -c android.net.LinkPropertiesTest
Bug: 65529483
Bug: 35995111
Change-Id: I539578703570a901e0a5dff0155422ca78c52401
2017-09-12 10:18:58 +01:00
Hugo Benichi
802e27811c Connectivity metrics: collect NFLOG wakeup events
This patch stores NFLOG packet wakeup events sent by Netd to the system
server into a ring buffer inside NetdEventListenerService. The content
of this buffer is accessible by $ dumpsys connmetrics or $ dumpsys
connmetrics list, and is added to bug reports.

The wakeup event buffer stores currently uid and timestamps.

Bug: 34901696
Bug: 62179647
Test: runtest frameworks-net, new unit tests
Change-Id: Ie8db6f8572b1a929a20398d8dc03e189bc488382
2017-09-12 10:02:13 +09:00
Rubin Xu
2fa7d9e5cc Refactor CompareResult<> class and its call sites
Move all corner case logic from call sites to CompareResult's implementation,
add a constructor to directly do the comparison.

Test: runtest frameworks-core -c android.net.LinkPropertiesTest
Change-Id: I95bba82ec38d295b18c49c025dffab5f17271cbd
2017-09-08 13:27:58 +01:00
Charles He
a05761a80b 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
Merged-In: I24326fad7a89083a2409134640bda81ee0359d08
(cherry picked from commit d681363fd1)
2017-09-08 10:47:34 +01:00
Charles He
738a0a48ab 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
Merged-In: I477897a29175e3994d4ecf8ec546e26043c90f13
(cherry picked from commit 9369e61e2d)
2017-09-08 10:18:36 +01:00
Hugo Benichi
ddc2ecc155 Merge changes Ic92b6d5c,I98b23b22,I0fb40d7b am: 9c57accc45 am: 6b2ccf4ad7 am: 500f63b54a -s ours
am: 4d602d21ed  -s ours

Change-Id: I6cc1c6fbaf6c0d85f9fea4fe51ee60cabcc7b256
2017-09-08 02:16:11 +00:00
Hugo Benichi
4d602d21ed Merge changes Ic92b6d5c,I98b23b22,I0fb40d7b am: 9c57accc45 am: 6b2ccf4ad7
am: 500f63b54a  -s ours

Change-Id: I7aae41297a1c4041631876b4f871c2df66c05f94
2017-09-08 02:02:50 +00:00
Hugo Benichi
6b2ccf4ad7 Merge changes Ic92b6d5c,I98b23b22,I0fb40d7b
am: 9c57accc45

Change-Id: Id1a9f8232ef3e08cf708d2406403fce3c59be9e5
2017-09-08 01:42:28 +00:00
Rubin Xu
0a3d075a3f Merge "Always add local subnet routes to the interface's routing table" into oc-mr1-dev am: 5e0e5974c5
am: 86315d57a9

Change-Id: I820a21561404b05df7d662192b9590c5fd84b0c3
2017-09-07 22:24:39 +00:00
Rubin Xu
86315d57a9 Merge "Always add local subnet routes to the interface's routing table" into oc-mr1-dev
am: 5e0e5974c5

Change-Id: I04ee4b9123a4b43ea435f771e85f713f4ecbc8fe
2017-09-07 18:06:47 +00:00
Rubin Xu
70b9208871 Always add local subnet routes to the interface's routing table
For some networks such as mobile data connections, its LinkProperties
does not contain routes for the local subnet so no such route is added
to the interface's routing table. This can be problematic especially
if the device is in VPN lockdown mode where there exists high-priority
PROHIBIT routing rule which in turn blocks the network's default gateway
route from being added (next hop address hitting the prohibit rule).

We fix this by patching LinkProperties to always include direct connected routes
when they are received by ConnectivityService. This has the added advantage that
when apps get LinkProperties, they see the directly connected routes as well.

Bug: 63662962
Test: runtest frameworks-core -c android.net.LinkPropertiesTest
Test: runtest frameworks-services -c com.android.server.ConnectivityServiceTest
Test: Start with device with mobile data, set up ics-OpenVPN in always-on
      lockdown mode. Turn off mobile data then turn it back on, observe
      mobile data connectivity is restored and VPN successfully reconnects.

(cherry picked from commit 1bb5c0818f0c4fb426e13b65a3ba3db7f36c3d88)

Change-Id: Ia14f88bcf49d37286519c26dff6b7180303e2cbe
2017-09-07 14:17:57 +01:00
Hugo Benichi
71449be2a7 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
Bug: 65439160
Test: runtest frameworks-net
Merged-In: I57a6bad8a9836b1c45690c4589b416786ce1dfa0

(cherry picked from commit 43b7474c08)

Change-Id: I98b23b2208bbd7d12237fcb000f3cf10c53d9e55
2017-09-07 22:17:18 +09:00
Rubin Xu
581059b2e6 Merge "Always add local subnet routes to the interface's routing table" am: 609dd56140 am: 4bb100dcd0 am: e3469a426e
am: af3207c188

Change-Id: I704f9895ddd4c4fc2ab50a927939aee67a916fae
2017-09-07 13:04:28 +00:00
Rubin Xu
af3207c188 Merge "Always add local subnet routes to the interface's routing table" am: 609dd56140 am: 4bb100dcd0
am: e3469a426e

Change-Id: I21f4231c968b37cdcf1565279eedfb990dbc583b
2017-09-07 12:55:58 +00:00
Rubin Xu
4bb100dcd0 Merge "Always add local subnet routes to the interface's routing table"
am: 609dd56140

Change-Id: I0b1728fae18c891d91fafdfbb1905c05e0fea47f
2017-09-07 12:25:05 +00:00
Rubin Xu
609dd56140 Merge "Always add local subnet routes to the interface's routing table" 2017-09-07 12:12:09 +00:00