Commit graph

1,692 commits

Message SHA1
Make reportInetCondition revalidate if the report differs from our state
1. If reportInetCondition says the network is not working, and
   the network is already marked not validated, don't revalidate
   it. This was superfluous and should save battery.
2. If reportInetCondition says the network is working, and the
   network is not marked as validated, revalidated. This will
   allow us to get out of a validated state quickly based on app
   input (e.g., allowing GCM's exponential backoff timer to drive
   revalidation instead of our 10-minute timer).

Bug: 19258761
Bug: 19209043
Change-Id: Iaa4bac82d117ed1f4088dab106e6f6ce46b34bc3

Lorenzo Colitti   commited 2015-02-11 11:03:50 +09:00
4e858cbafa
Make getNetworkInfo() take into account VPN underlying networks.
If a user is subject to a VPN, getActiveNetworkInfo() will return
the VPN's underlying network (e.g., TYPE_WIFI), so that apps that
call getActiveNetworkInfo to answer questions like "is the device
connected to wifi?" will continue to work. Make getNetworkInfo
do this as well: if the query is for a network type that is
underlying the current user's VPN, then return that network.

Bug: 19196545
Change-Id: Ic5a651735b927c758594a26d26a03fbd704b52e6

Lorenzo Colitti   commited 2015-02-11 10:21:01 +09:00
489eb043d7
Merge "Support connecting to networks with misconfigured subnet masks." into lmp-mr1-dev
Lorenzo Colitti   authored and   Android (Google) Code Review   commited 2015-01-23 12:50:32 +00:00
68c9c5aaff
Support connecting to networks with misconfigured subnet masks.
In K and earlier, we would connect to a network where the gateway
was not covered by the subnet mask of the IP address. This is an
invalid configuration, but it used to work, and other OSes appear
to accept it too, so support it.

Bug: 19067207
Change-Id: I822e1d754b336691b675438eefa959a3d75fd07b

Lorenzo Colitti   commited 2015-01-23 21:10:34 +09:00
64f1689c81
Merge "Log interface name and uid when filtering a blocked network." into lmp-mr1-dev
Erik Kline   authored and   Android (Google) Code Review   commited 2015-01-22 07:07:36 +00:00
3891c36428
Log interface name and uid when filtering a blocked network.
Bug: 18707263
Change-Id: Ide9a1670a97eae787b785933de0c80750c2b5601

Erik Kline   commited 2015-01-21 12:02:11 +09:00
6cb03e349b
Fix legacy request removal.
Don't say we're disconnected from a legacy type until there are no outstanding requests for it.

bug:18946574
Change-Id: I8e45c4a7558f7ced0840b71c50081989ba13c1c7

Robert Greenwalt   commited 2015-01-16 16:06:39 -08:00
e8a912443a
Merge "Don't blindly teardown unvalidated networks when releasing NetworkRequests." into lmp-mr1-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2015-01-14 12:39:01 +00:00
831fb40ae5
Don't blindly teardown unvalidated networks when releasing NetworkRequests.
These networks may be on their way to becoming validated at which point
they could satisfy the default NetworkRequest.  This change unifies the
is-this-network-needed code into a single function.

bug:18652378
Change-Id: Ia511d5c66be79b47dd7c9348ec02784ab30b960c

Paul Jensen   commited 2015-01-13 09:05:38 -05:00
9e078d2f14
Remember to cancel lingering when a network again satsifies a NetworkRequest.
When WiFi's score drops and then comes back up we would previously linger
WiFi but forget to cancel the linger timeout, so 30s later WiFi would
unexpectedly tear down.  This was not completely fixed in d5f5339.

bug:18826162
Change-Id: I7bb4b99ec969099e9815f46d4c09253be71a29be

Paul Jensen   commited 2015-01-08 10:49:34 -05:00
40e43de8d0
Clear process DNS NetID binding when expiring or releaseing legacy requests.
When requests made by ConnectivityManager.startUsingNetworkFeature() are
expired or are canceled via ConnectivityManager.stopUsingNetworkFeature(),
we must remember to clear the binding of DNS requests from the calling
process to the Network satisfying the request.

bug:18778725
Change-Id: I800c808ac6486000241b5d263aa79a1192a9fe9e

Paul Jensen   commited 2015-01-06 09:43:04 -05:00
49f74a382b
Fix timing between bcast and net setup.
A legacy network type request would generate a bcast before the network
notification was sent - the legacy startUsingNetworkFeature API requires
the notification so it can bind your dns queries to the new network.
Fast-moving clients could try to use the network before it was ready.

bug:18792871
Change-Id: I24c46ef15c249c50bfc321f62756d1f66dc3a6a9

Robert Greenwalt   commited 2014-12-19 11:54:27 -08:00
70116ce13c
Add a lastValidated bit and use it when reporting capabilities.
When we switched the way the status bar determines if a
connection is validated from using INET_CONDITION_ACTION
broadcasts to calling getDefaultNetworkCapabilitiesForUser(),
the statusbar stopped displaying ! when a network stopped having
working Internet connectivity. This is because the validated bit
is never set to false once a network is validated.

Fix this, hopefully temporarily, by introducing a new validated
bit that does go back to being false when a network no longer
has working connectivity, and use that bit in
getDefaultNetworkCapabilitiesForUser().

Bug: 18777225
Change-Id: I991c068be50252391d0e64c647fcf2e053dc82f9

Lorenzo Colitti   commited 2014-12-19 19:10:42 +09:00
5f82daecad
Rename validated to everValidated.
This is a straight rename and thus a complete no-op from a
functionality perspective.

Bug: 18777225
Change-Id: I140d7640f1460c869a311294873772819a7a7059

Lorenzo Colitti   commited 2014-12-19 19:10:42 +09:00
a8de5ca5cc
Fix race between CONNECTIVITY_ACTION and setting default network.
Now that the delay between connectivity changes and CONNECTIVITY_ACTION
has been removed (ag/599650) races between CONNECTIVITY_ACTION and
the setting of the default network become more evident.
In http://crbug.com/441818 Chrome is calling getaddrinfo()
immediately after a device goes from no connectivity to cellular
connectivity, and Chrome is erroneously getting back EAI_NODATA
because netd hasn't yet set the default network for DNS resolutions.

bug:18757162
Change-Id: Ib607dcb3697403272a8c838713a9cb602e9c6820

Paul Jensen   commited 2014-12-15 15:20:30 -05:00
0353fe5d99
Merge "Fix several HTTP proxy issues with multinetworking." into lmp-mr1-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2014-12-11 04:51:16 +00:00
7a0d9799c8
Fix several HTTP proxy issues with multinetworking.
1. Send PROXY_CHANGE_ACTION broadcast when any network's proxy changes,
   not just the default network.
2. When a process is bound to a particular Network, update the proxy
   system properties to those for the bound Network, and keep them
   updated when PROXY_CHANGE_ACTION broadcasts are received.
3. Make Network.openConnection() use the proxy for the Network.

bug:17905627
bug:17420465
bug:18144582

(cherry-pick of https://android-review.googlesource.com/#/c/115170)

Change-Id: Ia2819985e6108a8c121e74c683a5646becfd0a97

Paul Jensen   commited 2014-12-10 15:22:12 -05:00
c0618a69f1
Merge "Re-remove CONNECTIVITY_CHANGE_DELAY and supporting functions." into lmp-mr1-dev
Erik Kline   authored and   Android (Google) Code Review   commited 2014-12-10 07:29:47 +00:00
63aba09c17
Merge "Add subId as parameter for get/setDataEnabled." into lmp-mr1-dev
Wink Saville   authored and   Android (Google) Code Review   commited 2014-12-09 17:52:27 +00:00
6490d8694a
Direct notification of network interface changes.
Connectivity broadcasts recently changed and are no longer sent for
certain types of network changes.  For example, when stacked network
interfaces change for a mobile network.  To ensure that we pick up
all these details, directly wire the two services together.

Also remove some unused code for split network types.

Bug: 18666753
Change-Id: I0467bd5b330c0e0cb51af2306d821b41ad16337a

Jeff Sharkey   commited 2014-12-08 14:50:14 -08:00
aa6ff6c7b0
Offer to "merge" subscribers for data usage.
There are some cases where multiple subscriber identities (IMSI)
should be treated as "merged together" from a data usage
perspective.  This is done by extending the template used for
matching purposes to support multiple subscribers.

Then, when we query historical usage or set network policies, we
normalize the matching template to merge to any other identities
that should be included.  When normalizing, the "lowest" identity
is always used for equality and storage purposes, which allows
identities to come and go over time.

This change also fixes data usage recording for multi-SIM devices
by passing along the concrete subscriber identity for each network
interface.  Also correctly create default policies for multi-SIM
devices.  This change also drops setPolicyDataEnable() until it can
be wired up to the right underlying NetworkAgent.  (This means we
still bring up the network, and then rely on iptables rules to block
traffic when over the limit, instead of proactively disabling the
connection.)

Bug: 18012787
Change-Id: If6acf32009fdfea2b836f5aff8e2f3e5e0248b4a

Jeff Sharkey   commited 2014-12-08 08:42:59 -08:00
fffa983fe4
Re-remove CONNECTIVITY_CHANGE_DELAY and supporting functions.
Since optimistic addresses are useable upon kernel notification
there is no need for this extra connectivity delay.

---

This functionality was originally submitted in ag/572619.  Owing
to issues with bind()ing to optimistic addresses (see b/18609055)
this was reverted in ag/598673.

This reverts the revert.  :-)

Bug: 17769720
Change-Id: Ibee490b2af72050693b6bd748193f51e312ca527

Erik Kline   commited 2014-12-08 16:25:20 +09:00
b883659514
Merge "Don't send the same PendingIntent more than once." into lmp-mr1-dev
Jeremy Joslin   authored and   Android (Google) Code Review   commited 2014-12-06 02:05:22 +00:00
6e39f696b7
Merge "Reap unvalidated networks that have no chance of becoming highest scoring." into lmp-mr1-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2014-12-06 01:23:56 +00:00
26c6a232bb
Don't send the same PendingIntent more than once.
Fixing a bug where a NetworkRequest's PendingIntent can be sent more
than once when networks are rematched before the intent completes.

Added a small delay before removing the request to give the receiving
client an opportunity to put in its own request. The delay value is
configurable via Settings.Secure.

Bug: 18614074
Change-Id: Iac7c5e5a04f42f2b6794e9e22349cc631bebeab7

Jeremy Joslin   commited 2014-12-05 14:58:04 -08:00
1d3acf930f
Merge "Fix issue #17323751: Additional items in aggregated battery stats" into lmp-mr1-dev
Dianne Hackborn   authored and   Android (Google) Code Review   commited 2014-12-05 22:54:08 +00:00
f91526cec0
Fix issue #17323751: Additional items in aggregated battery stats
- Now aggregate number of times each process has crashed and ANRed.
- Now aggregate total number of connectivity changes.
- Now record connectivity changes in the history.

Crash and ANR counts are new entries at the end of "pr" in checkin.

Connectivity change counts is a new entry at the end of "m" in checkin.

Connectivity changes in the history checkin are Ecn and include the
type of connection and its state.

Change-Id: I0c01186446034cf6c3fb97d45f5e3b5c69a0438a

Dianne Hackborn   commited 2014-12-05 13:54:24 -08:00
37e2d0e068
Add subId as parameter for get/setDataEnabled.
Bug: 18279333
Change-Id: I2496a2fd92b154e5e6981cbf6b5b5939cda59122

Wink Saville   commited 2014-12-05 11:10:30 -08:00
689f70442c
Revert "Merge "Remove CONNECTIVITY_CHANGE_DELAY and friends." into lmp-mr1-dev"
This is the revert of ag/572619.

This reverts commit b5ae87a8d0, reversing
changes made to 32b61ab28f54e5b00f472b2166f9b1100375e4ff.

Bug: 18609055
Bug: 17769720
Change-Id: I122eba200f2071d4e5777ec34c1d04fb567345a8

Erik Kline   authored and   Pavel Zhamaitsiak   commited 2014-12-05 18:02:56 +00:00
c1529548aa
Merge "Remember to cancel lingering when a network again satsifies a NetworkRequest." into lmp-mr1-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2014-12-04 19:27:52 +00:00
1f4d121b74
Reap unvalidated networks that have no chance of becoming highest scoring.
These networks are unneeded and waste battery.  We won't bring up these
networks in the first place if they have no chance of becoming highest scoring.
This change handles the case where these networks are already up and
transition to a state where they have no chance of becoming highest scoring.
This happens when another network validates with a score higher than this
network can ever hope to attain.

bug:18489123
Change-Id: I77a96a72e250e25e44e0c50e7a928af8b35bb6ab

Paul Jensen   commited 2014-12-04 11:22:39 -05:00
5c4e5fc0b9
Merge "Remove CONNECTIVITY_CHANGE_DELAY and friends." into lmp-mr1-dev
Erik Kline   authored and   Android (Google) Code Review   commited 2014-12-04 03:14:02 +00:00
b5ae87a8d0
Make StatusBar display all default networks.
The basic principle is: if an app's traffic could possibly go
over a network without the app using the multinetwork APIs (hence
"by default"), then the status bar should show that network's
connectivity.

In the normal case, app traffic only goes over the system's default
network connection, so that's the only network returned.

With a VPN in force, some app traffic may go into the VPN, and thus over
whatever underlying networks the VPN specifies, while other app traffic
may go over the system default network (e.g.: a split-tunnel VPN, or an
app disallowed by the VPN), so the set of networks returned includes the
VPN's underlying networks and the system default.

Specifically:

1. Add a NETWORK_CAPABILITY_VALIDATED bit to NetworkCapabilities.
2. Add a hidden API to retrieve the NetworkCapabilities of
   all default networks for a given macro-user.
3. Modify the status bar code that used getActiveNetworkInfo to
   determine which network was active, and make it consider all
   validated networks instead.
4. Because the set of active networks depends on which VPN app
   the user is running, make the status bar re-evaluate the
   networking situation when the active user changes.

Bug: 17460017
Change-Id: Ie4965f35fb5936b088e6060ee06e362c22297ab2

Lorenzo Colitti   authored and   Jeff Davidson   commited 2014-12-02 10:27:05 -08:00
79bd2e2841
Remember to cancel lingering when a network again satsifies a NetworkRequest.
When WiFi's score drops and then comes back up we would previously linger
WiFi but forget to cancel the linger timeout, so 30s later WiFi would
unexpectedly tear down.  Also, make sure this is only done for created
Networks as "created" is the signal to initialy match Networks and requests.

bug:18169560
Change-Id: Ia69b110f6473371e556c60b950253758e023b7aa

Paul Jensen   commited 2014-12-02 09:26:17 -05:00
d5f533917d
Merge "Revert some verbose logging from ag/489226" into lmp-mr1-dev
Erik Kline   authored and   Android (Google) Code Review   commited 2014-12-02 07:22:33 +00:00
4bcd4a7950
Merge "Only use mDefaultDns if the network claims to offer Internet" into lmp-mr1-dev
Lorenzo Colitti   authored and   Android (Google) Code Review   commited 2014-12-02 06:47:52 +00:00
425aacdce0
Only use mDefaultDns if the network claims to offer Internet
Currently, if a network does not specify DNS servers, we default
it to using 8.8.8.8. This was done because the emulator did not
specify DNS servers. However, it causes queries to fail slowly,
instead of failing fast, on networks that do not have
connectivity to 8.8.8.8.

Bug: 18327075
Change-Id: I0df13ff4a17ee65e640be96695a3af31b020963a

Lorenzo Colitti   commited 2014-12-02 03:40:16 +09:00
20068c2d12
Fix the ordering of extra values in the PI.
Bug: 18539720
Change-Id: I6bb69394b05923ca25bc1b4902bc2540a13812bd

Jeremy Joslin   commited 2014-11-26 14:24:15 -08:00
de802a29a1
Merge "Don't let NetworkMonitor state stop user-initiated transitions." into lmp-mr1-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2014-11-26 12:05:01 +00:00
1d27e7d678
Revert some verbose logging from ag/489226
Bug: 18171889
Change-Id: I582a17b2272746e04717ac8da1d6984ff187ddf6

Erik Kline   commited 2014-11-26 09:01:16 +09:00
bd49990557
Merge "Don't enforce control permission when preparing consented VPN." into lmp-mr1-dev
Jeff Davidson   authored and   Android (Google) Code Review   commited 2014-11-24 21:19:56 +00:00
30ddc724a0
Merge "Don't bother validating networks that don't satisfy the default request." into lmp-mr1-dev
Paul Jensen   authored and   Android (Google) Code Review   commited 2014-11-24 18:30:36 +00:00
b5f79d66f0
Merge "Delete unused/non-working code." into lmp-mr1-dev
Sreeram Ramachandran   authored and   Android (Google) Code Review   commited 2014-11-24 17:24:26 +00:00
04f46a029e
Merge "Allow VPNs to specify their underlying networks." into lmp-mr1-dev
Sreeram Ramachandran   authored and   Android (Google) Code Review   commited 2014-11-24 17:24:04 +00:00
dadd493cee
Merge "Eliminate race conditions in UID-based network filtering." into lmp-mr1-dev
Sreeram Ramachandran   authored and   Android (Google) Code Review   commited 2014-11-24 17:21:18 +00:00
e4e7baac57
Don't let NetworkMonitor state stop user-initiated transitions.
GCM can call reportInetCondition() at any time which can cause
the NetworkMonitor to transition states to reevaluate at any time.
Previously we were only listening for users clicking the sign-in
notificaiton or completing sign-in when in the appropriate state.
With this change NetworkMonitor's state does not stop us from
listening for the user's actions.

bug:17917929
Change-Id: Ic1da31d90f7090e5fc111874cb7c37d505aaf590

Paul Jensen   commited 2014-11-24 11:11:32 -05:00
f8b75aa88a
Don't enforce control permission when preparing consented VPN.
If a VPN app requests to be prepared and has already obtained user
consent, there is no need to additionally enforce the control
permission. We only need to enforce the control permission when a VPN
is first being prepared, where such a preparation would bypass user
consent.

Also ensure that in this case, the VPN being prepared matches the
calling app. Otherwise an app could prepare another pre-consented VPN,
which is not particularly dangerous but is likely unexpected.

Finally, remove misleading comment in ConnectivityService#prepareVpn.
This method IS called from VpnService.prepare(), not only from
system-privileged apps.

Bug: 18442887
Change-Id: Ic3227c6c1c74312697f0576d3811b06692a4edff

Jeff Davidson   commited 2014-11-21 12:56:29 -08:00
ca3d8edfba
Lightweight checkin output for network stats.
Define and print a compact version of network statistics when dump
is requested with the "--checkin" flag.  Defaults to last 24 hours,
but included data can be tweaked with various flags.

Groups together detailed network identities into larger umbrella
terms like "mobile" and "wifi."

Bug: 18415963
Change-Id: I70cf9c828ea5c6e5bb6884837d3608f66fbad2e6

Jeff Sharkey   commited 2014-11-21 10:11:10 -08:00
29c8eb028b
Allow VPNs to specify their underlying networks.
These are used when responding to getActiveNetworkInfo() (and cousins)
when an app is subject to the VPN.

Bug: 17460017
Change-Id: Ief7a840c760777a41d3358aa6b8e4cdd99c29f24

Sreeram Ramachandran   commited 2014-11-21 09:26:18 -08:00
d2b4fe2b2d
Delete unused/non-working code.
Change-Id: I2cba9ffdb4ed547cb922d0ac08abf81e49ffa66b

Sreeram Ramachandran   commited 2014-11-21 08:08:19 -08:00
541254ae51