Commit Graph

1671 Commits

Author SHA1 Message Date
Jeff Sharkey
aa6ff6c7b0 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
2014-12-08 14:50:14 -08:00
Jeff Sharkey
fffa983fe4 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
2014-12-08 08:42:59 -08:00
Jeremy Joslin
6e39f696b7 Merge "Don't send the same PendingIntent more than once." into lmp-mr1-dev 2014-12-06 02:05:22 +00:00
Paul Jensen
26c6a232bb Merge "Reap unvalidated networks that have no chance of becoming highest scoring." into lmp-mr1-dev 2014-12-06 01:23:56 +00:00
Jeremy Joslin
1d3acf930f 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
2014-12-05 14:58:04 -08:00
Dianne Hackborn
f91526cec0 Merge "Fix issue #17323751: Additional items in aggregated battery stats" into lmp-mr1-dev 2014-12-05 22:54:08 +00:00
Dianne Hackborn
37e2d0e068 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
2014-12-05 13:54:24 -08:00
Erik Kline
c1529548aa 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
2014-12-05 18:02:56 +00:00
Paul Jensen
1f4d121b74 Merge "Remember to cancel lingering when a network again satsifies a NetworkRequest." into lmp-mr1-dev 2014-12-04 19:27:52 +00:00
Paul Jensen
5c4e5fc0b9 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
2014-12-04 11:22:39 -05:00
Erik Kline
b5ae87a8d0 Merge "Remove CONNECTIVITY_CHANGE_DELAY and friends." into lmp-mr1-dev 2014-12-04 03:14:02 +00:00
Lorenzo Colitti
79bd2e2841 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
2014-12-02 10:27:05 -08:00
Paul Jensen
d5f533917d 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
2014-12-02 09:26:17 -05:00
Erik Kline
4bcd4a7950 Merge "Revert some verbose logging from ag/489226" into lmp-mr1-dev 2014-12-02 07:22:33 +00:00
Lorenzo Colitti
425aacdce0 Merge "Only use mDefaultDns if the network claims to offer Internet" into lmp-mr1-dev 2014-12-02 06:47:52 +00:00
Lorenzo Colitti
20068c2d12 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
2014-12-02 03:40:16 +09:00
Jeremy Joslin
de802a29a1 Fix the ordering of extra values in the PI.
Bug: 18539720
Change-Id: I6bb69394b05923ca25bc1b4902bc2540a13812bd
2014-11-26 14:24:15 -08:00
Paul Jensen
1d27e7d678 Merge "Don't let NetworkMonitor state stop user-initiated transitions." into lmp-mr1-dev 2014-11-26 12:05:01 +00:00
Erik Kline
bd49990557 Revert some verbose logging from ag/489226
Bug: 18171889
Change-Id: I582a17b2272746e04717ac8da1d6984ff187ddf6
2014-11-26 09:01:16 +09:00
Jeff Davidson
30ddc724a0 Merge "Don't enforce control permission when preparing consented VPN." into lmp-mr1-dev 2014-11-24 21:19:56 +00:00
Paul Jensen
b5f79d66f0 Merge "Don't bother validating networks that don't satisfy the default request." into lmp-mr1-dev 2014-11-24 18:30:36 +00:00
Sreeram Ramachandran
04f46a029e Merge "Delete unused/non-working code." into lmp-mr1-dev 2014-11-24 17:24:26 +00:00
Sreeram Ramachandran
dadd493cee Merge "Allow VPNs to specify their underlying networks." into lmp-mr1-dev 2014-11-24 17:24:04 +00:00
Sreeram Ramachandran
e4e7baac57 Merge "Eliminate race conditions in UID-based network filtering." into lmp-mr1-dev 2014-11-24 17:21:18 +00:00
Paul Jensen
f8b75aa88a 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
2014-11-24 11:11:32 -05:00
Jeff Davidson
ca3d8edfba 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
2014-11-21 12:56:29 -08:00
Jeff Sharkey
29c8eb028b 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
2014-11-21 10:11:10 -08:00
Sreeram Ramachandran
d2b4fe2b2d 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
2014-11-21 09:26:18 -08:00
Sreeram Ramachandran
541254ae51 Delete unused/non-working code.
Change-Id: I2cba9ffdb4ed547cb922d0ac08abf81e49ffa66b
2014-11-21 08:08:19 -08:00
Sreeram Ramachandran
7c9871648e Eliminate race conditions in UID-based network filtering.
The previous code retrieved information from the legacy tracker multiple
times for each user query, leading to race conditions where the info
could've changed between the calls.

Refactors the handling of legacy data types in ConnectivityService and
unifies call paths so that APIs that deal with legacy data types
(NetworkInfo and int/networkType) and newer types (such as Network) go
through common code paths, using NetworkState to hold all the necessary
data pieces. This enables follow-on bug fixes to getActiveNetworkInfo().

The changes are limited to public "query" APIs (those that retrieve some
network information or the other). More details about the specific
changes and their rationale can be found in the code review thread.

Bug: 17460017
Change-Id: I656ee7eddf2b8cace5627036452bb5748043406c
2014-11-21 08:07:13 -08:00
Paul Jensen
638762845d Merge "Don't allow an uncreated Network to satsify requests." into lmp-mr1-dev 2014-11-21 12:42:34 +00:00
Geoffrey Borggaard
cc9b119566 am c3f5d718: Merge "Fix null handling in proxies." into lmp-dev
automerge: e34455e

* commit 'e34455e4b44a125147d025f3310630600dbdab6d':
  Fix null handling in proxies.
2014-11-21 10:17:39 +00:00
Paul Jensen
ce90ecbaf7 Don't bother validating networks that don't satisfy the default request.
The only immediate change in behavior is not validating untrusted networks.

bug:18299572
bug:18394654

Change-Id: I8d626baf37db0bd0f55ddf3af8a0abf094a12369
2014-11-20 21:00:35 -05:00
Geoffrey Borggaard
e34455e4b4 am c3f5d718: Merge "Fix null handling in proxies." into lmp-dev
* commit 'c3f5d7183a21cb081bab1a6bca3fc115523e4e78':
  Fix null handling in proxies.
2014-11-20 20:59:00 +00:00
Geoffrey Borggaard
6ff743e424 Fix null handling in proxies.
ProxyInfo.getPacFileUrl() can not be null.  It will be equal to
Uri.EMPTY.  Checking for null was causing global proxies to never be
disabled.  Or more accurately, global proxies would be disabled, but
would reappear after a reboot.

ProxyInfo.getExclusionListByString() can be null.  If no
exclusion list was specified, the proxy settings would not be
successfully saved, they would disappear after reboot.

Bug: 18453223
Change-Id: I1c27e5dca5b9664bb7468ea909bff489fa110a07
2014-11-20 19:48:20 +00:00
Erik Kline
8a82621cdb Rename EXTRA_NETWORK ConnectivityManager constants.
Per b/18414703:

    s/\<EXTRA_NETWORK_REQUEST_NETWORK\>/EXTRA_NETWORK/g
    s/\<EXTRA_NETWORK_REQUEST_NETWORK_REQUEST\>/EXTRA_NETWORK_REQUEST/g

Additionally, associated string values updated to:

    android.net.extra.NETWORK
    android.net.extra.NETWORK_REQUEST

Bug: 18414703
Change-Id: I7aeed2161829742affc666e835a97ce2c28356fe
2014-11-20 13:16:31 +09:00
Paul Jensen
262b462786 Don't allow an uncreated Network to satsify requests.
This could happen when another Network changes its capabilities and
updateCapabilities() calls rematchAllNetworksAndRequests() which
calls rematchNetworkAndRequests() on all Networks, even those that
are uncreated.
Allowing uncreated Networks to satisfy requests can lead to bugs
where ConnectivityService instructs netd to perform actions
(e.g. set default Network) on uncreated Networks which netd doesn't
know about yet.

bug:18446301
Change-Id: I857262ac66d1d3af4c264ce128f0a4bee95655de
2014-11-19 13:11:30 -05:00
Lorenzo Colitti
c52ae42e2f Merge "Populate 464xlat LinkProperties only when the interface comes up." into lmp-mr1-dev 2014-11-18 00:25:53 +00:00
xinhe
b8ede29bec Merge "air plane mode only send to the owner through the quick setting" into lmp-mr1-dev 2014-11-17 22:18:11 +00:00
Jeff Davidson
a21f7a1ac6 Expose a SystemApi method to prepare a VPN without consent.
This is NOT designed to be called normally. Most apps (even
system-privileged ones) should request user consent before launching a
VPN. However, it is needed to support flows where consent can be
obtained through other means external to the VPN flow itself.

The API requires a system-privileged permission, CONTROL_VPN.

Bug: 18327583
Change-Id: I1bcdcf0fb5707faeb861ec4535e7ccffea369ae7
2014-11-17 21:03:10 +00:00
xinhe
5598f9c908 air plane mode only send to the owner through the quick setting
It should send to all the uesers as it behaves in setting

Bug:18353278
Change-Id: Ib46a97e30bfba73dd78fab0c8139d6ccb7ad210f
2014-11-17 11:35:01 -08:00
Lorenzo Colitti
38804ae6a4 Populate 464xlat LinkProperties only when the interface comes up.
Currently Nat464Xlat reads the clat IPv4 address and updates the
clat LinkProperties when the interface is created. This causes a
race condition: because clatd only sets the IPv4 address after
creating the interface, it's possible that Nat464Xlat will read
the address before clatd has set it, causing the framework to
think that the clat IPv4 address is 0.0.0.0/32.

This seems to be happening more frequently now, perhaps because
clatd takes a bit longer to configure the IPv4 address now that
it needs to check that the address is free before using it.

Fix this by making Nat464Xlat listen for the interface coming up
instead of listening for the interface being added.

Bug: 12111730
Change-Id: Ic1c59b5b6dbb851b7431d1b06885f67803373bb9
2014-11-10 19:33:13 -08:00
Sreeram Ramachandran
2207207a7f Merge "Send broadcasts when VPNs come and go." into lmp-mr1-dev 2014-11-06 21:57:21 +00:00
Jeremy Joslin
60d379b618 Implemented requestNetwork with a PendingIntent.
ConnectivityManager.requestNetwork(NetworkRequest, PendingIntent)
was unhidden and implemented.

Added ConnectivityManager.removePendingIntentRequest(PendingIntent) as
the companion method.

Bug: 17356414
Change-Id: I656a1e149cc1292c443ebfe9e61ee3eb5a80f143
2014-11-06 11:43:27 -08:00
Robert Greenwalt
08881e11cf Merge "Fix Legacy typing of net-specific requests." into lmp-mr1-dev 2014-11-05 23:36:01 +00:00
Robert Greenwalt
08c7c9803c Fix Legacy typing of net-specific requests.
We're starting to get network requests for specific SIMs
and the Legacy Type Inference was broken because the incoming
request included a network specifier while the legacy requests
it was compared with did not.  Only compare the things we care
about.

bug:18031008
Change-Id: If107042828c152ede51a2497a3859bc1a6c83694
2014-11-05 15:06:20 -08:00
Paul Jensen
821255f29e Merge "Fix DhcpResults.setDomain() and StaticIpConfiguration.toLinkProperties()" into lmp-mr1-dev 2014-11-05 19:05:09 +00:00
Jeff Davidson
157cb03474 Merge "Update network selections on capability change." into lmp-mr1-dev 2014-11-05 17:41:36 +00:00
Paul Jensen
aadf9b78b4 Fix DhcpResults.setDomain() and StaticIpConfiguration.toLinkProperties()
setDomain() and toLinkProperties() were not setting the domains.
The setDomain() bug affected Wifi and I believe the toLinkProperties()
bug affected Ethernet and Bluetooth reverse-tethering.

bug:18252947
Change-Id: I8764cb944c293e01d99822bb52b55af7e9d77853
2014-11-05 09:35:26 -05:00
Jeff Davidson
d36242ae5d Update network selections on capability change.
Among other reasons, this is needed when a Wi-Fi connection is
upgraded from untrusted to trusted, so that the default route can be
updated to point to the Wi-Fi network instead.

Bug: 18206275
Change-Id: I53f7a6f00f66a23ae4873fa2334cd8a621f39d4f
2014-11-04 16:48:27 -08:00