Commit Graph

2819 Commits

Author SHA1 Message Date
Felipe Leme
22b4cc077c Merge "Fixed connectivity state in some power saving scenarios." into nyc-dev am: bc26d925c6 am: 0ee15c2e57
am: be24cac6d6

* commit 'be24cac6d6c4e09f508e81dc8dd545a188a035cf':

Change-Id: I2ff4fafa45f2f41a6d34e1c2b602f1152e3645e7
2016-05-13 17:35:42 +00:00
Felipe Leme
5ef19be783 Merge "Fixed connectivity state in some power saving scenarios." into nyc-dev am: bc26d925c6 am: 0ee15c2e57
am: be24cac6d6

* commit 'be24cac6d6c4e09f508e81dc8dd545a188a035cf':

Change-Id: If85188ccc995b4f50070ca85de199280b03290f2
2016-05-13 17:32:27 +00:00
Felipe Leme
651b527311 Merge "Fixed connectivity state in some power saving scenarios." into nyc-dev am: bc26d925c6 am: cc02a95cbd
am: 492e99b2be

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

Change-Id: Idd27e581b208a0d80d8fa6a4d7cf75eac82a32fd
2016-05-13 17:31:58 +00:00
Felipe Leme
be24cac6d6 Merge "Fixed connectivity state in some power saving scenarios." into nyc-dev am: bc26d925c6
am: 0ee15c2e57

* commit '0ee15c2e57d33665eafea69d7ec6ce86cfbfef87':

Change-Id: Ic63dadce968a17a4df8b39f8904f5818d48e95ac
2016-05-13 17:29:07 +00:00
Felipe Leme
492e99b2be Merge "Fixed connectivity state in some power saving scenarios." into nyc-dev am: bc26d925c6
am: cc02a95cbd

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

Change-Id: I9ce60e8520c041e1345960a51394f8477c4ac49e
2016-05-13 17:26:29 +00: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
Elliott Hughes
cade402444 resolve merge conflicts of bc90502 to nyc-dev-plus-aosp am: bdd12ec7b3
am: daabe978d4

* commit 'daabe978d40dce3feefb770558738cc1750d7fc3':
  Make android_net_NetUtils include what it actually uses.

Change-Id: I775c03ba7fd3895c6525d3986b564b228d34063b
2016-05-13 16:08:58 +00:00
Elliott Hughes
daabe978d4 resolve merge conflicts of bc90502 to nyc-dev-plus-aosp
am: bdd12ec7b3

* commit 'bdd12ec7b3cb77dc29854cb8b6c2357aa4efb6ea':
  Make android_net_NetUtils include what it actually uses.

Change-Id: I84a143e1922c7180a0a1926d2cfd87b59bca137d
2016-05-13 16:06:35 +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
271cf91dc9 Merge "Merge "ApfFilter unit test" into nyc-dev am: 906b94c00b am: 771d9fe0b6" into nyc-mr1-dev-plus-aosp
am: 2e5feeef6c

* commit '2e5feeef6c607ff24598ee7b47ac58d754df472b':

Change-Id: Ibef62387f6c05632432408c5e011377dd8498d6a
2016-05-13 14:47:57 +00:00
Paul Jensen
2fb47c132e Merge "ApfFilter unit test" into nyc-dev am: 906b94c00b am: 6e7084024f
am: 2a7cb091a3

* commit '2a7cb091a35bcd126ba4ca53b337b88ad65e3161':
  ApfFilter unit test

Change-Id: Ide959b34cd6bd97620b2c14812bd362d203fd85f
2016-05-13 14:43:06 +00:00
Android Build Merger (Role)
2e5feeef6c Merge "Merge "ApfFilter unit test" into nyc-dev am: 906b94c00b am: 771d9fe0b6" into nyc-mr1-dev-plus-aosp 2016-05-13 14:41:03 +00:00
Paul Jensen
2f1c97e468 Merge "ApfFilter unit test" into nyc-dev am: 906b94c00b
am: 771d9fe0b6

* commit '771d9fe0b607a953f2efbb64745c1e68f4fced01':
  ApfFilter unit test

Change-Id: I00a8b46efdd8e52d2756723f2e11b48e3231eff6
2016-05-13 14:40:42 +00:00
Paul Jensen
2a7cb091a3 Merge "ApfFilter unit test" into nyc-dev am: 906b94c00b
am: 6e7084024f

* commit '6e7084024fbbc93b301345ecb581f128b23bec08':
  ApfFilter unit test

Change-Id: I17ddf9d4823588dd2cad0d5662ec434ae2d027f6
2016-05-13 14:40:39 +00: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
01206517e6 Merge "Merge "Addressing API council comments on NetworkStatsManager." into nyc-dev am: dc5f558640 am: de224ba451" into nyc-mr1-dev-plus-aosp
am: d7021ad5d5

* commit 'd7021ad5d54422949067db1165a8c8ff95c8c93e':

Change-Id: I7a1644a097b8edbaa0da0b80c0e2b6f374f99cf1
2016-05-10 21:14:17 +00:00
Antonio Cansado
c864144517 Merge "Addressing API council comments on NetworkStatsManager." into nyc-dev am: dc5f558640 am: 6fe5aa1af4
am: 4247c46428

* commit '4247c464282bf8c9c458090f0e6b491cf9bc8c63':
  Addressing API council comments on NetworkStatsManager.

Change-Id: Ie6455799758f0bdb67440f72c266effaf412e22f
2016-05-10 21:14:09 +00:00
Android Build Merger (Role)
d7021ad5d5 Merge "Merge "Addressing API council comments on NetworkStatsManager." into nyc-dev am: dc5f558640 am: de224ba451" into nyc-mr1-dev-plus-aosp 2016-05-10 21:08:59 +00:00
Antonio Cansado
1d7c800c19 Merge "Addressing API council comments on NetworkStatsManager." into nyc-dev am: dc5f558640
am: de224ba451

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

Change-Id: I1383b3c11653daaa3a0ca34600dbc7e28af24641
2016-05-10 21:08:28 +00:00
Antonio Cansado
4247c46428 Merge "Addressing API council comments on NetworkStatsManager." into nyc-dev am: dc5f558640
am: 6fe5aa1af4

* commit '6fe5aa1af45379cc93ec8456b2b947b3a0cfed4a':
  Addressing API council comments on NetworkStatsManager.

Change-Id: Ia886e1ce98520c1618ba501097a2c979a628bbb4
2016-05-10 21:08:25 +00: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
7c38c68128 Merge "Merge "Fixed connectivity state in some restricted network scenarios." into nyc-dev am: 638a6e8140 am: 4e40ea69d0" into nyc-mr1-dev-plus-aosp
am: f7d3b5fbd4

* commit 'f7d3b5fbd411a76a8fa5b550da699ed497c315af':

Change-Id: I84bb94fff82e9a7965147b0bb1736ab5529b6c8d
2016-05-06 23:48:57 +00:00
Felipe Leme
89d7d6d5c7 Merge "Merge "Fixed connectivity state in some restricted network scenarios." into nyc-dev am: 638a6e8140 am: 4e40ea69d0" into nyc-mr1-dev-plus-aosp
am: 725e9d0ad8

* commit '725e9d0ad8a1ba44117d0ed14c424dfb976e967e':

Change-Id: I681d58e763bec7b22b2962c98661576f534d6669
2016-05-06 23:48:54 +00:00
Felipe Leme
04ba6ab37a Merge "Fixed connectivity state in some restricted network scenarios." into nyc-dev am: 638a6e8140 am: 87d20317bf
am: ffeacedc35

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

Change-Id: I1bc51c4a06dad9245ce0ed884707855b2c04edf1
2016-05-06 23:48:47 +00:00
Android Build Merger (Role)
f7d3b5fbd4 Merge "Merge "Fixed connectivity state in some restricted network scenarios." into nyc-dev am: 638a6e8140 am: 4e40ea69d0" into nyc-mr1-dev-plus-aosp 2016-05-06 23:47:02 +00:00
Felipe Leme
8ba1a4ad8b Merge "Fixed connectivity state in some restricted network scenarios." into nyc-dev am: 638a6e8140
am: 4e40ea69d0

* commit '4e40ea69d0e4cdba9f0215509eadd54d7706eb34':

Change-Id: Ic58995d889136c62d397bb8323ed8b66be90e3cf
2016-05-06 23:46:37 +00:00
Android Build Merger (Role)
725e9d0ad8 Merge "Merge "Fixed connectivity state in some restricted network scenarios." into nyc-dev am: 638a6e8140 am: 4e40ea69d0" into nyc-mr1-dev-plus-aosp 2016-05-06 23:44:23 +00:00
Felipe Leme
ffeacedc35 Merge "Fixed connectivity state in some restricted network scenarios." into nyc-dev am: 638a6e8140
am: 87d20317bf

* commit '87d20317bf26e87ef58798d3c5aafb81aa163788':
  Fixed connectivity state in some restricted network scenarios.

Change-Id: Ifeb332fbf00c554b78d0ad724b34e3a8ebfc9894
2016-05-06 23:43:55 +00:00
Felipe Leme
b6b2eaeb7c Merge "Fixed connectivity state in some restricted network scenarios." into nyc-dev am: 638a6e8140
am: 4e40ea69d0

* commit '4e40ea69d0e4cdba9f0215509eadd54d7706eb34':
  Fixed connectivity state in some restricted network scenarios.

Change-Id: I76e419d0d010652699b9081418f5f654763887d1
2016-05-06 23:43:52 +00: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
ba4184084f Merge "Merge "Refactored NetworkPolicyManagerService mUidRules." into nyc-dev am: de66540fd3 am: 0da215640f" into nyc-mr1-dev-plus-aosp
am: 7938df3cfc

* commit '7938df3cfcab9dac33cde9b219f8e3614836ea2b':

Change-Id: I4f87fca12c9b4d8c3e54a5fbb3cf8b991e0d2007
2016-05-06 22:03:23 +00:00
Felipe Leme
623bfd96f1 Merge "Refactored NetworkPolicyManagerService mUidRules." into nyc-dev am: de66540fd3 am: 65578c827a
am: 1dd2392e2e

* commit '1dd2392e2e11cd5d1442e697470509d64fd456c6':
  Refactored NetworkPolicyManagerService mUidRules.

Change-Id: I0b348dc47666d563d368d82aa9633dcfe56992a0
2016-05-06 22:03:18 +00:00
Android Build Merger (Role)
7938df3cfc Merge "Merge "Refactored NetworkPolicyManagerService mUidRules." into nyc-dev am: de66540fd3 am: 0da215640f" into nyc-mr1-dev-plus-aosp 2016-05-06 21:58:55 +00:00
Felipe Leme
ec7b062a3e Merge "Refactored NetworkPolicyManagerService mUidRules." into nyc-dev am: de66540fd3
am: 0da215640f

* commit '0da215640fa1aa90e7f3063cfa23df629f268ff2':
  Refactored NetworkPolicyManagerService mUidRules.

Change-Id: I58c29071b21ffdd9285b33964bfc2c5b254dd298
2016-05-06 21:58:26 +00:00
Felipe Leme
1dd2392e2e Merge "Refactored NetworkPolicyManagerService mUidRules." into nyc-dev am: de66540fd3
am: 65578c827a

* commit '65578c827a30fb7bcedbc960e8623afd6a75b8e5':
  Refactored NetworkPolicyManagerService mUidRules.

Change-Id: Ie81707e54ebf15e5b01a533bda433551d0a3b73e
2016-05-06 21:58:18 +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
64d5c5e8a1 Merge "Merge "Add lockdownEnabled parameter to always-on VPN API" into nyc-dev am: fb0faa494e am: e5bbf42d23" into nyc-mr1-dev-plus-aosp
am: 06864ec342

* commit '06864ec34283ef08024b4e7ebecfaa68c00cbd42':

Change-Id: I18549dd882c1dd6f2a8e39a170c1defccfc59890
2016-05-04 22:10:41 +00:00
Robin Lee
67372ea20d Merge "Merge changes I31d5260d,Ied92f558 into nyc-dev am: c58c9ae0a9 am: f2796025ed" into nyc-mr1-dev-plus-aosp
am: 9eeec0d910

* commit '9eeec0d91099c6881445c229d88458d7f4d0c635':

Change-Id: If71bb13a2871cb577a9b39cf0db9eca0c880d79c
2016-05-04 22:10:33 +00:00
Robin Lee
4385168b4b Merge "Merge "Add lockdownEnabled parameter to always-on VPN API" into nyc-dev am: fb0faa494e am: 78d0888e8c" into nyc-mr1-dev-plus-aosp
am: 062a28b6a4

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

Change-Id: I9ebd6221451ee10649a1f340031d62c6483832f1
2016-05-04 22:04:40 +00:00
Robin Lee
78442b3022 Merge "Merge changes I31d5260d,Ied92f558 into nyc-dev am: c58c9ae0a9 am: 31b3676cce" into nyc-mr1-dev-plus-aosp
am: fbde3272fd

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

Change-Id: I6e1d6a1977db342f45a1a9114a56c181540e12bf
2016-05-04 22:03:54 +00:00
Android Build Merger (Role)
06864ec342 Merge "Merge "Add lockdownEnabled parameter to always-on VPN API" into nyc-dev am: fb0faa494e am: e5bbf42d23" into nyc-mr1-dev-plus-aosp 2016-05-04 21:48:26 +00:00