Commit Graph

2559 Commits

Author SHA1 Message Date
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
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
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
Android Build Merger (Role)
9eeec0d910 Merge "Merge changes I31d5260d,Ied92f558 into nyc-dev am: c58c9ae0a9 am: f2796025ed" into nyc-mr1-dev-plus-aosp 2016-05-04 21:48:10 +00:00
Robin Lee
61f7678c55 Merge "Add lockdownEnabled parameter to always-on VPN API" into nyc-dev am: fb0faa494e
am: e5bbf42d23

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

Change-Id: I79cc73d918ff368534d7e269291cb6d24e6774ac
2016-05-04 21:42:55 +00:00
Robin Lee
939c283b12 Merge changes I31d5260d,Ied92f558 into nyc-dev am: c58c9ae0a9
am: f2796025ed

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

Change-Id: Ibb02f2731536ebafaa4c24ef5cd2113f7cd43632
2016-05-04 21:42:47 +00:00
Robin Lee
88228712ee Merge "Add lockdownEnabled parameter to always-on VPN API" into nyc-dev am: fb0faa494e
am: 78d0888e8c

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

Change-Id: I7ec39775980ec839aa814cf284ea352789aa788f
2016-05-04 21:41:23 +00:00
Robin Lee
26847f53fd Merge changes I31d5260d,Ied92f558 into nyc-dev am: c58c9ae0a9
am: 31b3676cce

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

Change-Id: I6bb605a83b96a3efab36ab6a7bdb5859e1eafea8
2016-05-04 21:40:46 +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
Android Build Merger (Role)
db023f0663 Merge "Merge changes I86257bc8,I5c2221c5 into nyc-dev am: 20f253eb7d am: 3ac235673c" into nyc-mr1-dev-plus-aosp 2016-05-02 13:05:01 +00:00
Lorenzo Colitti
b832193f48 Merge changes I86257bc8,I5c2221c5 into nyc-dev am: 20f253eb7d
am: 3ac235673c

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

Change-Id: I69f888bb27b3bd632f63ec95558db14d59605c71
2016-05-02 13:04:25 +00:00
Lorenzo Colitti
e5243a3a5a Merge changes I86257bc8,I5c2221c5 into nyc-dev am: 20f253eb7d
am: ddb5e9164d

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

Change-Id: I36c07f09ac62620fd4119eff1f9da5a278d08144
2016-05-02 13:04:22 +00: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
Android Build Merger (Role)
e041484836 Merge "Merge "Flag to mark foreground jobs, fix data saver." into nyc-dev am: 9a977b7d45 am: 0c5c67f743" into nyc-mr1-dev-plus-aosp 2016-04-29 23:02:13 +00:00
Jeff Sharkey
c4c37fc1c3 Merge "Flag to mark foreground jobs, fix data saver." into nyc-dev am: 9a977b7d45
am: 0c5c67f743

* commit '0c5c67f743abeba5c30112634ce82fd63ae2d1a1':
  Flag to mark foreground jobs, fix data saver.

Change-Id: Idbf3bdfc76cadfbcb6bbf17ac1aa99df72a7a0a1
2016-04-29 23:01:49 +00:00
Jeff Sharkey
25bbae6e74 Merge "Flag to mark foreground jobs, fix data saver." into nyc-dev am: 9a977b7d45
am: 4b6d6eb09f

* commit '4b6d6eb09fe922be19fac9fa1b289584e84d1bb0':
  Flag to mark foreground jobs, fix data saver.

Change-Id: I30b87193a1d5d45f4ffeb919276a70ae709a1cdc
2016-04-29 23:01:47 +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
Jeff Sharkey
7dbf83df03 Flag to mark foreground jobs, fix data saver.
When a job will eventually run in the foreground, the internal
scheduling needs to ignore any background network restrictions when
satisfying constraints.  This also means the job should ignore the
current device doze state, since the requesting app could get the
same behavior by starting their own foreground service.

Always dispatch network policy changes to ConnectivityService first
to ensure that it has up-to-date information.  Fix bugs around data
saver that were causing networks to not be marked as BLOCKED for
background apps; before this fix apps would have been spinning in
internal connectivity loops, thinking that the network was actually
connected when the kernel was actually blocking their traffic.

Offer new ConnectivityService method overloads to ignore the blocked
state for a specific UID.

Print unsatisfied job constraints to aid debugging.

Bug: 26571724
Change-Id: Iaaa17933e6dc1bf6d3dff26d0bfc12222e51e241
2016-04-29 13:44:07 -06:00
Android Build Merger (Role)
594e5455d3 Merge "Merge "Stop user faster and clear stale broadcasts" into nyc-dev am: ec6faca007 am: 9dee0bccd8" into nyc-mr1-dev-plus-aosp 2016-04-29 00:59:33 +00:00
Amith Yamasani
cb0a78fd39 Merge "Stop user faster and clear stale broadcasts" into nyc-dev am: ec6faca007
am: 9dee0bccd8

* commit '9dee0bccd8e692d1ca86bcf7180170f153dc99c7':
  Stop user faster and clear stale broadcasts

Change-Id: I16c4c1dfcff9f4d63da0444923a29fda0bea5ee8
2016-04-29 00:59:02 +00:00
Amith Yamasani
49392af782 Merge "Stop user faster and clear stale broadcasts" into nyc-dev am: ec6faca007
am: 2bb6008a4c

* commit '2bb6008a4cd20654b268e13276c6a56ecc0eab2b':
  Stop user faster and clear stale broadcasts

Change-Id: I423d1f8448f8ba5b54f90a2fa192f231f38b761c
2016-04-29 00:58:58 +00:00
Amith Yamasani
2bb6008a4c Merge "Stop user faster and clear stale broadcasts" into nyc-dev
am: ec6faca007

* commit 'ec6faca0078263dfbf2b41d11cdb14586e40fd75':
  Stop user faster and clear stale broadcasts

Change-Id: I36eeb177791730a26077542606559e3e4428b87e
2016-04-29 00:56:43 +00:00
Amith Yamasani
e095d2f708 Stop user faster and clear stale broadcasts
Moved several USER_STOPPING registered receivers to listen
to USER_STOPPED, since they don't need to be blocking the
shutdown of the user.

Clear all stale broadcasts when stopping a user, so that we
don't unnecessarily start up processes and deliver stale
broadcasts. This was causing code to run when the user was
already stopped and resulted in crashes when other providers
and services couldn't be started anymore. Hopefully this fixes
many of those races.

Bug: 28371487
Change-Id: Ic35a7a23fa8fe009a53f8bf7545d4dad5fa34134
2016-04-28 10:02:44 -07:00
TreeHugger Robot
33ec77265a Merge "Tethering and Data Saver: There Can Be Only One!" into nyc-dev am: 5af619f
am: 7f026f8

* commit '7f026f8927c30180817f46ee38ee292ad05997ff':
  Tethering and Data Saver: There Can Be Only One!

Change-Id: Idb0ab16443ca061f97ed2f12e0ee01d9fa61b187
2016-04-27 23:40:42 +00:00
Felipe Leme
7f026f8927 Merge "Tethering and Data Saver: There Can Be Only One!" into nyc-dev
am: 5af619f

* commit '5af619f1cdd78fa1cd799ea05f1b59b75b589a0d':
  Tethering and Data Saver: There Can Be Only One!

Change-Id: I876c9a30e9451b1c346296c233068bdfb579f584
2016-04-27 23:31:49 +00:00
TreeHugger Robot
5af619f1cd Merge "Tethering and Data Saver: There Can Be Only One!" into nyc-dev 2016-04-27 22:41:13 +00:00
Android Build Merger (Role)
ca295bc1e0 Merge "Merge changes I8de95add,Ia6f4ccfd into nyc-dev am: 6333d09 am: d00f83f" into nyc-mr1-dev-plus-aosp 2016-04-27 02:02:03 +00:00
TreeHugger Robot
deb90020d9 Merge changes I8de95add,Ia6f4ccfd into nyc-dev am: 6333d09
am: d00f83f

* commit 'd00f83f56024ddcce1d42a03c6a27f317ccab7f3':
  Remove unused event tags of IpConnectivityEvent
  Better ConnectivityMetricsEvent printing

Change-Id: I7b9588ab0533963ed918ec8aee7ba7c4ec1dea0a
2016-04-27 02:01:14 +00:00
TreeHugger Robot
e0f0a9cbde Merge changes I8de95add,Ia6f4ccfd into nyc-dev am: 6333d09
am: bd858ec

* commit 'bd858ec5d9ab3a95ab0282296b1c36737dde3e3a':
  Remove unused event tags of IpConnectivityEvent
  Better ConnectivityMetricsEvent printing

Change-Id: I07a76836e84a71844332b387fef64511c01bf6bf
2016-04-27 02:01:11 +00:00
Hugo Benichi
bd858ec5d9 Merge changes I8de95add,Ia6f4ccfd into nyc-dev
am: 6333d09

* commit '6333d09474b46971da33af9be8abe0ede5725410':
  Remove unused event tags of IpConnectivityEvent
  Better ConnectivityMetricsEvent printing

Change-Id: I57ce8977a481d3c9a441ea4dab407ec367e3adca
2016-04-27 01:57:13 +00:00
TreeHugger Robot
6333d09474 Merge changes I8de95add,Ia6f4ccfd into nyc-dev
* changes:
  Remove unused event tags of IpConnectivityEvent
  Better ConnectivityMetricsEvent printing
2016-04-27 01:49:53 +00:00
Hugo Benichi
e51bf9e2a4 Better ConnectivityMetricsEvent printing
This patch adds more information printing for IpConnectivity event
classes in android.net.metrics.

example:

ConnectivityMetricsEvent(14:36:35.799, 0, 1026): DhcpClientEvent(wlan0, DhcpRequestingState)
ConnectivityMetricsEvent(14:36:35.805, 0, 1026): DhcpClientEvent(wlan0, DhcpHaveAddressState)
ConnectivityMetricsEvent(14:36:35.809, 0, 4096): IpManagerEvent(wlan0, PROVISIONING_OK, 155ms)
ConnectivityMetricsEvent(14:36:35.810, 0, 1026): DhcpClientEvent(wlan0, DhcpBoundState)
ConnectivityMetricsEvent(14:36:35.871, 0, 2048): NetworkEvent(101, NETWORK_CONNECTED, 0ms)
ConnectivityMetricsEvent(14:36:35.874, 0, 2051): ValidationProbeEvent(101, PROBE_HTTP:599, 3ms)
ConnectivityMetricsEvent(14:36:35.874, 0, 2048): NetworkEvent(101, NETWORK_VALIDATION_FAILED, 0ms)
ConnectivityMetricsEvent(14:36:35.928, 0, 3072): DefaultNetworkEvent(0 -> 101, [WIFI], IPv4: false, IPv6: false)
ConnectivityMetricsEvent(14:36:37.008, 0, 2051): ValidationProbeEvent(101, PROBE_HTTP:204, 134ms)
ConnectivityMetricsEvent(14:36:37.008, 0, 2050): NetworkEvent(101, NETWORK_VALIDATED, 1137ms)

Also fixes a couple of event logging issues:
  - do no record spurious receive DhcpErrorEvent when a network goes down.
  - add an eventType field to IpManagerEvent instead of using the
    loggger component tag.

Bug: 28204408
Change-Id: Ia6f4ccfd7a0c63a5ccec18825f226c0b5781217b
2016-04-27 09:11:29 +09:00
TreeHugger Robot
566531cd9c Merge "Frameworks/base: Make debug helper lazy in ConnectivityManager" into nyc-dev am: 2082480
am: 6915561

* commit '69155619b9783df3609b3f43b625760b5957dbe4':

Change-Id: Ie39d3e645eeb4b792cede5e24248a9b5c6afe980
2016-04-26 15:37:28 +00:00
TreeHugger Robot
9739a467db Merge "Frameworks/base: Make debug helper lazy in ConnectivityManager" into nyc-dev am: 2082480
am: 12aea50

* commit '12aea502c103777317d6105f59365384034ced8a':
  Frameworks/base: Make debug helper lazy in ConnectivityManager

Change-Id: Ifc6094201f1c92b92465010ab6f965d7946ec0e7
2016-04-26 15:34:26 +00:00
Andreas Gampe
69155619b9 Merge "Frameworks/base: Make debug helper lazy in ConnectivityManager" into nyc-dev
am: 2082480

* commit '20824800388aa8aea5c8a21a4a5d3fbf8ff16125':
  Frameworks/base: Make debug helper lazy in ConnectivityManager

Change-Id: I38789a6165023d77c0a730591cd7fa1c45588dc5
2016-04-26 15:31:11 +00:00
TreeHugger Robot
2082480038 Merge "Frameworks/base: Make debug helper lazy in ConnectivityManager" into nyc-dev 2016-04-26 15:25:44 +00:00
Felipe Leme
9842878b75 Tethering and Data Saver: There Can Be Only One!
If tethering is on when Data Saver mode is turned on, tethering should
be disabled, and vice-versa.

BUG: 28313291
Change-Id: I7f3dadbd97ea1492ab76b41043dea7487c1db02d
2016-04-25 15:36:25 -07:00
Jeff Sharkey
6557b6af48 resolve merge conflicts of afd09db to nyc-mr1-dev-plus-aosp
Change-Id: Ie8417362964aa2fb17941d870ffcb060d3e47ea1
2016-04-25 16:19:44 -06:00
Jeff Sharkey
16580a6028 resolve merge conflicts of c79a568 to nyc-dev-plus-aosp
Change-Id: I3ee02bc596f285fa41ffcafa882ae5997ef67d22
2016-04-25 15:53:50 -06:00
Jeff Sharkey
c0ffd5162f resolve merge conflicts of 59ad404 to nyc-mr1-dev-plus-aosp
Change-Id: I65f892594034c6de4ac17459c01e146fe4c4e377
2016-04-25 15:52:11 -06:00
Andreas Gampe
b704658951 Frameworks/base: Make debug helper lazy in ConnectivityManager
Place helper map for callback field names into a holder. This avoids
the reflective calls in static initialization of ConnectivityManager
in the common (non-debug) case, which means the class can be
compile-time initialized. Also saves the storage necessary (both
the storage array as well as the reflection metadata).

Follow-up to b027e6e92b.

Bug: 27265238
Change-Id: Ib4bfaf27acd234a035a5d198458340099a156a4c
2016-04-25 10:30:53 -07:00
Jeff Sharkey
40d1fb87a4 API changes for DownloadManager and JobScheduler.
To support moving DownloadManager, add new JobScheduler network type
constraint that matches "any network except roaming."  Also add an
API to get a specific JobInfo by ID.

Since the default network can be different on a per-app basis, and
individual apps may be blocked due to app standby, evaluate job
connectivity constraints on a per-UID basis.  To implement this
cleanly, add NetworkInfo.isMetered() to match the isRoaming() API.

Add new DownloadManager APIs to support charging and device idle
constraints, which are plumbed through to JobScheduler under the
hood when scheduled.

Add filtering to JobScheduler dumpsys to omit noisy details for
packages the caller isn't interested in.

Bug: 28098882, 26571724, 19821935
Change-Id: I09ca7184ef7ce6adba399f579d415a5fb2ea6110
2016-04-24 14:39:34 -06:00