Commit Graph

2561 Commits

Author SHA1 Message Date
Robin Lee
624febb525 Merge "Return legacy VPN info regardless of lockdown mode" into nyc-dev
am: 4fb4490dfb

* commit '4fb4490dfbf6366813ba7f78acba705f00e21a81':
  Return legacy VPN info regardless of lockdown mode

Change-Id: I89c0784d5edae3c7ef9f8ec1c6ee4f823dbbae02
2016-05-25 21:20:43 +00:00
Robin Lee
4fb4490dfb Merge "Return legacy VPN info regardless of lockdown mode" into nyc-dev 2016-05-25 21:05:55 +00:00
Jeff Sharkey
8d5d9a0ff4 Merge "API council feedback: hide and document." into nyc-dev
am: 3e0e975a38

* commit '3e0e975a38688b4d5dbc96830788df00499fc01b':
  API council feedback: hide and document.

Change-Id: I180f504fe21f6f90179d359e8808ffff006e4538
2016-05-25 20:51:03 +00:00
TreeHugger Robot
3e0e975a38 Merge "API council feedback: hide and document." into nyc-dev 2016-05-25 20:43:56 +00:00
Hugo Benichi
477091dd52 Merge "Fix default network transition event recording" into nyc-dev
am: c6246b996d

* commit 'c6246b996d0f9c96f5f727d8f9894cb93a17a9b2':
  Fix default network transition event recording

Change-Id: Ic6ae9cd2620b1793f53667eb7d84c0b6f56d716e
2016-05-25 03:31:34 +00:00
Hugo Benichi
c6246b996d Merge "Fix default network transition event recording" into nyc-dev 2016-05-25 03:22:32 +00:00
Hugo Benichi
d3e4645858 Fix default network transition event recording
When disconnecting from a default network X and falling back on another
connected network Y as the new default, ConnectivityService was
attempting to record this event as a X -> Y "atomic" transition.

In practice the default network connectivity is actually lost and
recovering default network takes some non-zero time.

This patch changes the event recording to always record disconnection as
X -> 0 events. At the same time, if there is a fallback network that is
elected as the new default ConnectivityService will also record a 0 -> Y
event.

This patch also improves pretty-printing of DefaultNetworkEvent.

Extract from $ adb shell dumpsys connectivity_metrics_logger --events
17:51:00.086: DefaultNetworkEvent(0 -> 100:CELLULAR)
17:51:25.232: DefaultNetworkEvent(100:IPv4 -> 101:WIFI) # wifi goes on
17:51:44.064: DefaultNetworkEvent(101:DUAL -> 0)        # wifi goes off
17:51:44.187: DefaultNetworkEvent(0 -> 100:CELLULAR)

Bug: 28204408
Change-Id: I63252633235bf6ba833b9ac431a80dda75a93e67
2016-05-25 10:03:38 +09:00
Felipe Leme
bf53edcadb Merge "Fixed enforceMeteredApnPolicy when Data Saver is on." into nyc-dev
am: efd3a1749f

* commit 'efd3a1749f2737199643cc29bea6132a9786223b':
  Fixed enforceMeteredApnPolicy when Data Saver is on.

Change-Id: I87b596346c058c7ac8efbebb67b43664f1be0fed
2016-05-24 18:13:16 +00:00
Felipe Leme
5902c444d7 Fixed enforceMeteredApnPolicy when Data Saver is on.
When enforceMeteredApnPolicy() is called when Data Saver mode is on and
the caller's UID is not whitelisted, it should add a
NET_CAPABILITY_NOT_METERED to the capabilities.

Change-Id: Ieed4f4a7634ee023ec58c91859263655e0ba62d4
Fixes: 28608499 (and https://code.google.com/p/android/issues/detail?id=208478)
2016-05-23 09:43:53 -07:00
Jeff Sharkey
ca4340007e API council feedback: hide and document.
Hide isMetered() and clarify moveDatabaseFrom() docs.

Bug: 28870582, 28775585
Change-Id: Iabe63045c39ce7f662488f4224b56387c3c59519
2016-05-20 11:34:55 -06:00
Erik Kline
ef4e70afc3 Merge "DHCPv4: lease expiration is fatal, renew failures are not" into nyc-dev
am: bd4b5327db

* commit 'bd4b5327dbbe42ad997080d18c8c767c002ffde6':
  DHCPv4: lease expiration is fatal, renew failures are not

Change-Id: Ic99edb732d532da27c042824e5ca07c4b35ccfa1
2016-05-19 04:21:17 +00:00
Erik Kline
bd4b5327db Merge "DHCPv4: lease expiration is fatal, renew failures are not" into nyc-dev 2016-05-19 04:12:40 +00:00
Robin Lee
39db67ab88 Merge "Lock down networking when waiting for always-on" into nyc-dev
am: f9773c5fdd

* commit 'f9773c5fdd952e0628bc4b0e80c55258b49335ad':
  Lock down networking when waiting for always-on

Change-Id: I7be0a85597936421750d1da0fde3d55d7d4fabc5
2016-05-18 23:42:43 +00:00
Robin Lee
f9773c5fdd Merge "Lock down networking when waiting for always-on" into nyc-dev 2016-05-18 23:37:24 +00:00
Robin Lee
1bb13dc5e1 Lock down networking when waiting for always-on
Fix: 26694104
Fix: 27042309
Fix: 28335277
Change-Id: I47a4c9d2b98235195b1356af3dabf7235870e4fa
2016-05-19 00:26:53 +01:00
Erik Kline
7b0a58168e DHCPv4: lease expiration is fatal, renew failures are not
Bug: 24837343

Change-Id: Ib330864f8376b0907390d581b48cff5446b3392b
2016-05-18 16:17:03 +09:00
Felipe Leme
29052a804a Merge "Added a onRestrictBackgroundBlacklistChanged() callback." into nyc-dev
am: 8debc39f17

* commit '8debc39f1727ee4540e08cf699a6fde75268a5da':
  Added a onRestrictBackgroundBlacklistChanged() callback.

Change-Id: I4e19dd2828b8b67fc7b2d2173d77a82d67d53d19
2016-05-17 18:43:43 +00:00
TreeHugger Robot
8debc39f17 Merge "Added a onRestrictBackgroundBlacklistChanged() callback." into nyc-dev 2016-05-17 18:28:22 +00:00
Robin Lee
0ab7ea1701 Merge "Make some of the UID-based VPN code reusable" into nyc-dev
am: 89bf3e3aa2

* commit '89bf3e3aa2b3e95486445a50f4666a20b3d8e830':
  Make some of the UID-based VPN code reusable

Change-Id: I3f1b1a08059aa58cb76db6cdd070b103024b9bf3
2016-05-17 17:36:43 +00:00
TreeHugger Robot
89bf3e3aa2 Merge "Make some of the UID-based VPN code reusable" into nyc-dev 2016-05-17 17:30:01 +00:00
Robin Lee
2543ed8799 Return legacy VPN info regardless of lockdown mode
This stops Settings from telling the user detailed information, and
doesn't really protect anything secret -- privileged apps can already
tell that there's an active VPN by looking at network info.

Change-Id: I9c2a3cab6dff1b62e94a9e0735dccde226fd26a3
Fix: 28624328
2016-05-17 14:31:52 +01:00
Felipe Leme
ac719e480f Merge "Documented return value of getRestrictBackgroundStatus()." into nyc-dev
am: 522787f39a

* commit '522787f39a759cf8af8438641fa8df7470a1b959':
  Documented return value of getRestrictBackgroundStatus().

Change-Id: Ie2e7b14ecc0b574a8776121d3c79c768093ef4f7
2016-05-16 22:23:44 +00:00
Felipe Leme
3edc616bf6 Documented return value of getRestrictBackgroundStatus().
Change-Id: I2c15a6d5e23cbc3c9b59c975196c1c04c1294471
Fixes: 28775490
2016-05-16 13:57:19 -07:00
Felipe Leme
57fc863cce Added a onRestrictBackgroundBlacklistChanged() callback.
When an UID is added / removed to the Data Saver blacklist, it's
necessary to notify internal components such as the Settings UI (which
was erroneously listening to UID rules changes instead).

BUG: 28743623
BUG: 28791717

Change-Id: I11c85e141dfe074ad390fd324309d2412bfbbd45
2016-05-16 13:30:57 -07:00
Felipe Leme
0ee15c2e57 Merge "Fixed connectivity state in some power saving scenarios." into nyc-dev
am: bc26d925c6

* commit 'bc26d925c62968c0728a524a45c6e60f2b8fb781':
  Fixed connectivity state in some power saving scenarios.

Change-Id: I7ebe3864657d2147034ffae400312e94deb5ef35
2016-05-13 17:23:24 +00:00
TreeHugger Robot
bc26d925c6 Merge "Fixed connectivity state in some power saving scenarios." into nyc-dev 2016-05-13 17:14:13 +00:00
Robin Lee
722ee0bb43 Make some of the UID-based VPN code reusable
By changing some member refs into arguments and having one of the
functions create the UID range instead of adding to mVpnUsers.

This will be useful for other layers of UID filtering like having
UIDs explicitly blocked from the VPN.

Deleted one broken line of code that cleared the status intent when
a restricted profile is removed. Other than that, this commit shouldn't
change any behaviour. If it does, that's a bug.

Bug: 26694104
Change-Id: Ieb656835d3282a8ba63cc3f12a80bfae166bcf44
2016-05-13 16:03:11 +00:00
Elliott Hughes
bdd12ec7b3 resolve merge conflicts of bc90502 to nyc-dev-plus-aosp
Change-Id: Ic78042d45085718b2220107e9a84767df316440a
2016-05-13 08:57:40 -07:00
Paul Jensen
6e7084024f Merge "ApfFilter unit test" into nyc-dev
am: 906b94c00b

* commit '906b94c00bdf71cd0870416c07fcceaed67d421d':
  ApfFilter unit test

Change-Id: I97bdf703c24c8c3008113c09f5f441cd1d74bc81
2016-05-13 14:38:13 +00:00
Paul Jensen
906b94c00b Merge "ApfFilter unit test" into nyc-dev 2016-05-13 14:33:25 +00:00
Felipe Leme
16e0f1b4c4 Fixed connectivity state in some power saving scenarios.
NetworkPolicyManagerService (NPMS) manages 4 type of network restriction
when apps are running on background:

- Data Saver Mode (data usage restriction on metered-networks)
- Battery Saver Mode (power restriction on all networks)
- Doze Mode (power restriction on all networks)
- App Idle (power restriction on all networks)

These restrictions affects 2 parts of the system:

- Internal framework state on NPMS which is propagated to other internal
  classes.
- External firewall rules (managed by netd).

Although each of the power-related restrictions have their own external firewall
rules, internally apps are whitelisted to them through the same
whitelist, and the current code is only updating the internal state (and
notifying the internal listeners) when Battery Saver Mode is on.

As a consequence of this problem, there are scenarios where an app
correctly does not have internet access (because the firewall rules are
properly set), but the NetworkInfo state returns the wrong state (like
CONNECTED / CONNECTED).

This CL fixes this problem by splitting the power-related logic from
updateRulesForRestrictBackgroundLocked() into its own
method (updateRulesForPowerRestrictionsLocked()), and making sure such
method is called whenever the firewall rules are updated.

Externally to this change, the CTS tests were also improved to verify
the apps get the proper connection state; it can be verified by running:

cts-tradefed run commandAndExit cts -m CtsHostsideNetworkTests \
    -t com.android.cts.net.HostsideRestrictBackgroundNetworkTests

BUG: 28521946
Change-Id: Id5187eb7a59c549ef30e2b17627ae2d734afa789
2016-05-12 12:33:23 -07:00
Elliott Hughes
9d18567aeb Make android_net_NetUtils include what it actually uses.
Bug: http://b/28519060
Change-Id: I49dcd358d3fc8e0ba5c5e0b50a0f5dcc63281d22
2016-05-11 15:18:13 -07:00
Antonio Cansado
6fe5aa1af4 Merge "Addressing API council comments on NetworkStatsManager." into nyc-dev
am: dc5f558640

* commit 'dc5f558640da8785fabc274167ec37a0fda30cd6':
  Addressing API council comments on NetworkStatsManager.

Change-Id: I952e69e7cfbd8cebcbac7c3b19ede300e26777e8
2016-05-10 21:05:17 +00:00
Antonio Cansado
13726d128a Addressing API council comments on NetworkStatsManager.
Callbacks
 - DataUsageCallback renamed to UsageCallback
 - DataUsagePolicy removed; passing in params directly to register method
 - making it an abstract class
 - passing in (networkType, subscriberId) that reached its threshold
 - renaming onLimitReached to onThresholdReached to match existing naming
 - only monitor single network,subscriberId
 - no monitoring of specific uids; using device or user wide instead

Tags
 - only owner uid can read its tags
 - exposing only TAG_NONE to match service side

BUG: 27530098

Change-Id: I2b2664da71806868a1e937d2bf4d1f234637509b
2016-05-10 13:24:16 -07:00
Paul Jensen
a9ae8bb696 ApfFilter unit test
Bug: 26238573

Change-Id: I5171038228782bd54e91f5bcc663cc529d2c1150
2016-05-10 11:54:42 -04:00
Felipe Leme
4e40ea69d0 Merge "Fixed connectivity state in some restricted network scenarios." into nyc-dev
am: 638a6e8140

* commit '638a6e8140a22a0ddb5d5dacb02173795073bd1a':
  Fixed connectivity state in some restricted network scenarios.

Change-Id: I0fd66b16c83680940f294ea8e117443ffd8a50cd
2016-05-06 23:38:59 +00:00
Felipe Leme
06ea4b0cf1 Fixed connectivity state in some restricted network scenarios.
NetworkPolicyManagerService (NMPS) keeps an internal list of uid
rules (mUidRules) for network restrictions, and when these rules
changes it needs to notify external listeners (such as
ConnectivityService / CS).

Prior to Android N, both Data Saver mode (the feature previously known
as "Restrict Baground Data") and Battery Save mode used the same set of
firewall rules to implement their restrictions: when Battery Saver mode
NPMS would mark all networks as metered and set the proper firewall
rules externally.

Recently, these 2 modes were split in 2 distinct firewall rules and
NMPS.updateRuleForRestrictBackgroundLocked() was changed to update
the mUidRules logic based on the Data Saver firewall (since the Battery
Saver firewall changes are handled externally, on
updateRuleForRestrictPowerLocked()). As such, CS was not notified when
the power-related changes were made, which would cause apps to get a
state of CONNECTED / CONNECTED when querying its active connection.

Another scenario that is not properly handled is when a UID whitelisted
for Data Saver is brought back to foreground: although the proper
firewall rules are set, CS is not notified, and the apps state would be
DISCONNECTED / BLOCKED.

This CL introduces many changes that fix this issue:

- Fixed updateRuleForRestrictBackgroundLocked() to invoke
  onUidRulesChanged() when the Battery Saver status changed.
- Fixed updateRuleForRestrictBackgroundLocked() to invoke
  onUidRulesChanged() when an app whitelisted for Data Saver is brought
  back to the foreground.
- Added a new API (onRestrictPowerChanged() and getRestrictPower())
  to notify external services about Battery Saver mode changes.
- Fixed CS logic to properly handle the Battery Saver changes.

Externally to this change, the CTS tests were also improved to verify
the apps get the proper connection state; they can be verified running:

cts-tradefed run commandAndExit cts -m CtsHostsideNetworkTests \
    -t com.android.cts.net.HostsideRestrictBackgroundNetworkTests

BUG: 28521946

Change-Id: I8eaccd39968eb4b8c6b34f462fbc541e5daf55f1
2016-05-06 14:53:50 -07:00
Felipe Leme
65578c827a Merge "Refactored NetworkPolicyManagerService mUidRules." into nyc-dev
am: de66540fd3

* commit 'de66540fd3f73937c3cfbe1d50e575aa69acc474':
  Refactored NetworkPolicyManagerService mUidRules.

Change-Id: I25d2520eafcf8c45b80b94908a3b5bfa04315f76
2016-05-06 21:53:39 +00:00
Felipe Leme
cc2b9c36d3 Refactored NetworkPolicyManagerService mUidRules.
NetworkPolicyManagerService (NMPS) keeps an internal list of uid
rules (mUidRules) for network restrictions, and when these rules
changes it needs to notify external listeners (such as
ConnectivityService / CS).

Prior to Android N, both Data Saver mode (the feature previously known
as "Restrict Baground Data") and Battery Save mode used the same set of
firewall rules to implement their restrictions: when Battery Saver mode
NPMS would mark all networks as metered and set the proper firewall
rules externally.

Recently, these 2 modes were split in 2 distinct firewall rules and
NMPS.updateRuleForRestrictBackgroundLocked() was changed to update
the mUidRules logic based on the Data Saver firewall (since the Battery
Saver firewall changes are handled externally, on
updateRuleForRestrictPowerLocked()). As such, CS was not notified when
the power-related changes were made, which would cause apps to get a
state of CONNECTED / CONNECTED when querying its active connection.

This change refactores the mUidRules to use bitmasks, in preparation for
another change that will fix the issue.

It also fixes a minor bug that was preventing removed packages to be
removed from the whitelist.

BUG: 28521946
Change-Id: I9f0e1509a6192cad403f740c1cd76a6b7dab7d26
2016-05-06 17:58:40 +00:00
Robin Lee
e5bbf42d23 Merge "Add lockdownEnabled parameter to always-on VPN API" into nyc-dev
am: fb0faa494e

* commit 'fb0faa494efd998145d4f20b12f31c10b47cb0f1':
  Add lockdownEnabled parameter to always-on VPN API

Change-Id: Ibc69bb988ba0d1e641ee48fb5a844dc414f58e07
2016-05-04 18:55:54 +00:00
Robin Lee
f2796025ed Merge changes I31d5260d,Ied92f558 into nyc-dev
am: c58c9ae0a9

* commit 'c58c9ae0a931b6c71d7924cfd4e900e8919a6fcc':
  Start VPN as early as possible during startup
  Split network agent created state from connected state

Change-Id: I55167ad8f3cde11407a2d35b0f859c263c0fbbec
2016-05-04 18:55:11 +00:00
Robin Lee
fb0faa494e Merge "Add lockdownEnabled parameter to always-on VPN API" into nyc-dev 2016-05-04 18:38:30 +00:00
Robin Lee
c58c9ae0a9 Merge changes I31d5260d,Ied92f558 into nyc-dev
* changes:
  Start VPN as early as possible during startup
  Split network agent created state from connected state
2016-05-04 18:35:19 +00:00
Robin Lee
c4980d88aa Start VPN as early as possible during startup
- Switch from USER_STARTING to USER_STARTED which is the foreground
  version of the broadcast

- Set the new VPN network as CONNECTING initially to avoid spamming
  apps with useless notifications ahead of the network being fully
  available

Bug: 26694104
Fix: 28335277
Change-Id: I31d5260dda62ff440c31c44eb0aa5c891e2717e5
2016-05-04 17:46:10 +01:00
Robin Lee
a8c0b6ef7e Split network agent created state from connected state
Network creation setup sometimes involves extra steps after actually
calling into netd to create the underlying network, rules & routes &
to begin allowing sockets bound to it.

For example, VPN networks can set a UID whitelist or blacklist. This
should happen:

  - AFTER there is a netID & network created in netd as
    network-specific rules will need to be tied to / point at it. Those
    rules are tied to the lifecycle of netd's network which is tracked
    by `NetworkAgentInfo.created` on the frameworks side.

  - BEFORE the CONNECTED broadcast and network callbacks have been sent
    out so that we don't create a race condition between clients that
    want to use the network and the server actually having the network
    ready

The race condition existed prior to this change and required any client
making use of network callbacks to sleep for a short amount of time after
receiving to actually be able to use the network.

Among other things, that race condition is now fixed.

Bug: 26694104
Change-Id: Ied92f5588a98c3e97f456bc98b676bf201ab5472
2016-05-04 16:24:46 +00:00
Robin Lee
94e69beca3 Add lockdownEnabled parameter to always-on VPN API
Allows callers to opt-out of blockading network traffic during boot and
on VPN app failure.

Bug: 26694104
Change-Id: Ibfbd43ad09a25f2e38053fcd6306df3711f8bde2
2016-05-03 13:24:42 +01:00
Pierre Imai
ddb5e9164d Merge changes I86257bc8,I5c2221c5 into nyc-dev
am: 20f253eb7d

* commit '20f253eb7d82f980d1c6cbab2b06315a027ed62c':
  Use Netd's binder interface to set resolver configuration.
  Add Gservices settings for resolver configuration.

Change-Id: I80fdc381bd3ff33a8efa6624d7115c346789ca17
2016-05-02 13:00:13 +00:00
Lorenzo Colitti
20f253eb7d Merge changes I86257bc8,I5c2221c5 into nyc-dev
* changes:
  Use Netd's binder interface to set resolver configuration.
  Add Gservices settings for resolver configuration.
2016-05-02 12:49:19 +00:00
Pierre Imai
2166469c85 Use Netd's binder interface to set resolver configuration.
BUG: 25731675
Change-Id: I86257bc84371832466161e5357ae173c305a7d18
2016-05-02 08:29:21 +00:00
Jeff Sharkey
4b6d6eb09f Merge "Flag to mark foreground jobs, fix data saver." into nyc-dev
am: 9a977b7d45

* commit '9a977b7d45df0d3d59c5eec7f9534c3bd5fcd91d':
  Flag to mark foreground jobs, fix data saver.

Change-Id: I908d725a84e9590d0da38a586b066a63473d4f28
2016-04-29 22:59:31 +00:00