Commit Graph

816 Commits

Author SHA1 Message Date
Jeremy Joslin
8c7be6114c DO NOT MERGE: VPN network stat accounting changes.
Properly account for VPN apps that make heavy use of the tun
interface. Prior to this change a VPN app could be incorrectly charged
for more data than it actually used if it sent more traffic through
the tun interface than the underlying interface.

This change excludes VPN app traffic on the tun interface from the
adjustment pool and doesn't redistribute traffic to the VPN app.
Instead all of the redistributed traffic is deducted from the VPN app
which effectively represents any overhead incurred by the VPN app.

BUG: 30557871

(cherry picked from commit 13dd0e99ba)

Change-Id: I06f01aa8fe5fdc06b2d36cfb9c68feb244c2e5de
2016-12-09 13:42:29 +09:00
Hugo Benichi
8f201294fe DO NOT MERGE: ConnectivityThread: use lazy holder idiom
This patch changes the way that the ConnectivityThread is lazily
instantiated by using the "lazy initialization holder class idiom".

The first code point that tries to obtain a reference to the unique
ConnectivityThread instance will trigger the creation of the Singleton
class, which will guarantee a thread-safe initialization of the static
INSTANCE field inside Singleton according to the language specs.

This is the Item #71 of Effective Java.

The unique static instance of ConnectivityThread is not stored directly
inside ConnectivityThread class but is stored in a static nested class.
This is to avoid triggering the creation of that unique instance when
Zygote does class preloading at phone startup. Otherwise this would lead
to Zygote creating a new OS thread during preloading, which is a fatal
error.

Test: frameworks-wifi tests pass
Bug: 26749700
Bug: 28537383
Bug: 32130437

(cherry picked from commit 3ab84b087a)

Change-Id: If13b363889a8e9396273a90c3d9f9421a48aecbc
2016-12-09 13:42:26 +09:00
Hugo Benichi
301b09738a DO NOT MERGE: ConnectivityManager: use ConnectivityThread looper
This patch removes the static singleton looper used by
ConnectivityManager and instead uses the common ConnectivityThread.

This allows to removes the static atomic counter used to track
the number of registered NetworkCallback in ConnectivityManager, because
the looper is not turned off anymore when no callbacks are registered.

Also an overloaded version of sendRequestForNetwork is added taking as a
new parameter a Handler. This will allow to overload various callback
and request related API calls with user provided Handlers.

Test: ConnectivityServiceTest passes
Bug: 26749700
Bug: 28537383
Bug: 32130437

(cherry picked from commit 3b41f05d68)

Change-Id: If956addbf8e7b11b36a4b966de7fca00e8f362c1
2016-12-09 13:42:24 +09:00
Hugo Benichi
56260ed9cb DO NOT MERGE: ConnectivityManager: a simpler CallbackHandler
This patch simplifies CallbackHandler in the following way:
  - CallbackHandler directly uses the static references to
    sNetworkCallback and sCallbackRefCount. This allows to remove
    instance fields in CallbackHandler.
  - CallbackHandler does not have a reference to ConnectivityManager
    anymore
  - CallbackHandler.getObject() is now generic in a type-safe way.

Test: ConnectivityServiceTest passes
Bug: 28537383
Bug: 32130437

(cherry picked from commit 0b42baf68a)

Change-Id: I1b5fe2a361b5f623a8310ae698497c83d72f3034
2016-12-09 13:42:20 +09:00
Jeremy Klein
fb63d5a4ef DO NOT MERGE: Add a null check for the OnStartTetheringCallback.
This avoids a NullPointerException when trying to call the callback
and gives a more readable error message.

(cherry picked from commit 35e99ea8ef)

Change-Id: Ia419ff68ef10f308f9e44be47420e27099ee6070
2016-12-09 13:42:02 +09:00
Erik Kline
5791c5f681 DO NOT MERGE: Support timeouts for requestNetwork() invocations.
(cherry-pick of 0b7a74842b)
(cherry picked from commit 155a59aa63)

Bug: 21414325
Change-Id: I1a58823a372154589f972b98c4c428eab0e0523e
2016-12-08 17:13:01 +09:00
Etan Cohen
4ddc6321ef Merge "[NAN-AWARE] Rename NAN to Aware"
am: 6c75254555

Change-Id: I2e788e19a11f2709f2e542dbdc4b58433a3574bf
2016-11-06 03:13:31 +00:00
Etan Cohen
7e93db5bda [NAN-AWARE] Rename NAN to Aware
~Rename only (and any reformatting needed to pass lint) - no
functional changes!

Remove android.net.wifi.nan.STATE_CHANGED from manifest:
redundant/remnant of an older configuration.

(cherry-pick of commit a0edbf0ac8)

Bug: 32263750
Test: All unit tests and integration (sl4a) tests pass.
Merged-In: Ie4ff675fa61041e8fcf6a9bf9900ea835d0a7614
Change-Id: I4206d2fd722dc7dec9df4aee5c818101d7f9dccc
2016-11-05 09:41:38 -07:00
Lorenzo Colitti
494c218bff Restrict access to background networks to CHANGE_NETWORK_STATE. am: b8d9f52adb
am: 9410bde219

Change-Id: Ie4179344aa12e38d2e2a5fab43e028ca0c97150d
2016-09-23 04:01:07 +00:00
Lorenzo Colitti
b8d9f52adb Restrict access to background networks to CHANGE_NETWORK_STATE.
When a network goes into the background, tell netd to set the
network's permission to NETWORK. Also, close all TCP sockets on
that network, to prevent long-lived TCP connections from staying
on it and possibly continuing to use metered data.

Bug: 23113288
Change-Id: Ie89c1940b6739160e25c6e9022b8b977afb3e16e
2016-09-23 11:27:13 +09:00
Lorenzo Colitti
ec500d94b0 Support "don't ask again" in the avoid bad wifi dialog. am: c65750c8a0 am: 74cb76ff80
am: 63275aba54

Change-Id: I7d8d9f91208bcbe3ff625acf20d943b13f813d8e
2016-09-20 17:39:19 +00:00
Lorenzo Colitti
74cb76ff80 Support "don't ask again" in the avoid bad wifi dialog.
am: c65750c8a0

Change-Id: Ic6a1917a83e2d847bd673790e2c36f7316ca7acd
2016-09-20 17:14:50 +00:00
Lorenzo Colitti
c65750c8a0 Support "don't ask again" in the avoid bad wifi dialog.
This contains the following changes:

1. Make NETWORK_AVOID_BAD_WIFI a tristate: 0 means never avoid
   bad wifi, unset means prompt the user, 1 means always avoid.
2. Look at NETWORK_AVOID_BAD_WIFI only if the carrier restricts
   avoiding bad wifi (previously, we relied on the setting being
   null and defaulting to the value of the config variable).
3. Add an avoidUnvalidated bit to NetworkAgentInfo to track
   whether the user has requested switching away from this
   unvalidated network even though avoiding bad wifi is generally
   disabled. This is set to true when the user selects "switch"
   in the dialog without setting the "Don't ask again" checkbox.
4. Add a hidden setAvoidUnvalidated API to ConnectivityManager to
   set the avoidUnvalidated bit.
5. Additional unit test coverage.

Bug: 31075769
Change-Id: I1be60c3016c8095df3c4752330149ce638bd0ce1
2016-09-20 16:03:53 +09:00
Etan Cohen
c2c7d7ff8a reolve merge conflicts of 4e3d827 to nyc-mr1-dev-plus-aosp
Change-Id: Idb6cca34536fdbb94876d5cde0b2309462840da1
2016-09-16 12:40:03 -07:00
Lorenzo Colitti
f23aa46f08 Support displaying a dialog when wifi becomes unvalidated. am: 199ecfc79f am: 2b5b0e027b
am: 56e32083b5

Change-Id: Id908683dce15ffbafc042d506a38ec26d5e9a6ee
2016-09-15 16:18:42 +00:00
Lorenzo Colitti
2b5b0e027b Support displaying a dialog when wifi becomes unvalidated.
am: 199ecfc79f

Change-Id: I8b8e2b652510ca75407a9ad3c29ed111367941e0
2016-09-15 16:04:03 +00:00
Lorenzo Colitti
199ecfc79f Support displaying a dialog when wifi becomes unvalidated.
Bug: 31075769
Change-Id: I7a6e7580769365bea930f638bd44edcaa28df134
2016-09-15 23:33:34 +09:00
Lorenzo Colitti
aabaa907de Add a NET_CAPABILITY_FOREGROUND capability. am: 0f04220ffe
am: aaec66110d

Change-Id: I78d6aa21f8e4c6bbd9cefb4a36f1b77f4bbe4104
2016-09-13 16:23:10 +00:00
Lorenzo Colitti
0f04220ffe Add a NET_CAPABILITY_FOREGROUND capability.
Bug: 23113288
Change-Id: I90cb9ffb5751f0d9ec822933f37680c401e49966
2016-09-13 12:02:13 +09:00
Lorenzo Colitti
350a2fef4a Add a background NetworkRequest type for mobile data always on. am: 2666be8ae7
am: 9396da4e10

Change-Id: I4b0e05e8bb87e37bf2564fd255b8be7a2b20118a
2016-09-12 13:48:53 +00:00
Lorenzo Colitti
2666be8ae7 Add a background NetworkRequest type for mobile data always on.
Like a normal (foreground) request, a background request is only
satisfied by one network and will keep that network up. Unlike a
foreground request, when a network only has background requests,
it will linger, and after lingering is complete, it will become
a background network.

Future CLs will cause the system to treat background networks
differently, e.g., by requiring different permissions.

Bug: 23113288
Change-Id: I40f735269dad1042eb04fea15e64584fc903ccb3
2016-09-09 18:49:24 +09:00
Etan Cohen
e7395027cf [NAN] Add transport type for NAN. [DO NOT MERGE]
Add TRANSPORT_WIFI_NAN - specifies a peer-to-peer Wi-Fi NAN data
connectivity request.

While NAN uses Wi-Fi L1 PHY and part of the MAC - it is a different
protocol and constitutes a different transport.

(cherry-pick of commit 7473bc20ad)

Bug: 26564277
Change-Id: I975ebc72d8f97a592d18038b3d6465b7a40efa75
2016-09-06 15:54:10 -07:00
Lorenzo Colitti
d160a5b13a Merge \"Add an isListen method to NetworkRequests.\" into nyc-mr1-dev
am: b5239329b1

Change-Id: Ib712c3c7b44d3a623d5f5facf0c7f6844c3ebb82
2016-07-18 15:08:54 +00:00
Lorenzo Colitti
3ed97e63bb Add an isListen method to NetworkRequests.
This allows simplification of the ConnectivityService code.

Bug: 23113288
Change-Id: I124544b99c5a920124e9a3d31cda8c6d2abc21fd
2016-07-18 18:42:26 +09:00
Erik Kline
4875f44794 Add IPv6 tethering coordinator
am: 6f0405308b

Change-Id: Icf8034276d4edc7167ad03ff8860ac8e3d05c464
2016-07-13 04:57:17 +00:00
Erik Kline
6f0405308b Add IPv6 tethering coordinator
Add an IPv6TetheringCoordinator to TetheringMaster StateMachine, which
receives and processes NetworkState updates and passes the necessary IPv6
information to the revelant TetherInterfaceStateMachine.

Add an IPv6TetheringInterfaceServices to TetherInterfaceStateMachine, which
is responsible for adding local network routes and managing an IPv6
RouterAdvertisementDaemon.

Bug: 9580643
Change-Id: I3eaae460b80752e2115359d7bde873a1e9ea515a
2016-07-13 12:08:06 +09:00
Erik Kline
b2bdeca8e2 Support requesting async LinkProperties/NetworkCapabilities updates
am: 0c04b74781

Change-Id: Icc048323debbbe641941c5c0d993f4c9782c5d3e
2016-07-11 11:01:42 +00:00
Erik Kline
78bf01826a Basic IPv6 Router Advertisement daemon
am: 1a1cb0e914

Change-Id: I242eb8e932581a537a47f31e3f16c7e776da91cf
2016-07-11 10:38:49 +00:00
Erik Kline
0c04b74781 Support requesting async LinkProperties/NetworkCapabilities updates
Bug: 9580643
Change-Id: I1d7ba7645c20d7d53f6eef777dfce43727940f13
2016-07-11 19:17:41 +09:00
Erik Kline
1a1cb0e914 Basic IPv6 Router Advertisement daemon
Bug: 9580643
Change-Id: Iebd4d1f694699ffd4daf7d71e9b9d8f49e9b632f
2016-07-11 18:37:25 +09:00
Hugo Benichi
bafb27388b Merge \"ConnectivityManager: no double callback remove\" into nyc-mr1-dev
am: 0ecfb2fd34

Change-Id: Ib7b10c59c1f7c84ec78c7527fba8a6c9aa5b0c05
2016-07-07 09:38:29 +00:00
Hugo Benichi
f778e2546f ConnectivityManager: no double callback remove
This patch partially undoes ag/869831 (Change-Id:
Ia42ed7aefaebd8caf3eada8e42b6cb7a940d7647) so that ConnectivityManager
does not remove callbacks from its internal request-to-callback map at
unregistration, but instead let the singleton CallbackHandler do it when
receiving a CALLBACK_RELEASED from ConnectivityService.

ag/869831 was thought to fix b/26749700 that reported a callback leak
from sNetworkCallback, but a finer analysis of the code shows that
callbacks were correctly removed by the CallbackHandler before
ag/869831. There was therefore no callback leak.

Bug: 26749700
Bug: 28537383
Change-Id: I421d889d0e225c0e3d1eebea664f44a1cc0f3191
2016-07-07 09:44:02 +09:00
Lorenzo Colitti
5a7cd3500d Merge \"Unbreak unregisterNetworkCallback.\" into nyc-mr1-dev
am: 0271c0d4ef

Change-Id: I35ee16554e17c503b1f5628629c2c0a48d85d399
2016-07-05 02:19:18 +00:00
Lorenzo Colitti
70964d3a18 Unbreak unregisterNetworkCallback.
http://ag/1194313 broke unregisterNetworkCallback because the
system does not parcel the type of the request back to the app.
So when the app calls unregisterNetworkCallback, the
NetworkRequest that's passed in does not have a type and thus
doesn't match the request in mNetworkRequests.

Fix this by parceling over the type as well.

This was not caught by the unit test because the unit test all
runs in the same process with no parceling.

Bug: 23113288
Change-Id: I58b2ed651b9bf5cbdcca5b25c3ca24db53cffdf1
2016-07-05 01:59:49 +09:00
Lorenzo Colitti
9d1139ee06 Merge changes from topic \'networkrequest_private\' into nyc-mr1-dev
am: 0317e03dc3

Change-Id: Ia063c378bd32fdb056c0ecdc0f721d32e9fa49af
2016-07-01 15:20:21 +00:00
Lorenzo Colitti
eafe85717c Move the request type from NetworkRequestInfo to NetworkRequest.
This will allow us to simplify code that deals with
NetworkRequests outside ConnectivityService.

Bug: 23113288
Change-Id: I9b3a859d0c68cad73d7f6baa4b584d13ffd2ae36
2016-07-01 20:15:19 +09:00
Tobias Thierer
4b2e1aef96 Merge \\\"Changes for upgrade to OkHttp 2.7.5\\\" am: 5c3bebd673 am: 1f44659b2f
am: 6b473f7b67

Change-Id: I3a0dc1da2ee96d71c38cab727141efcb686627e1
2016-06-30 13:04:52 +00:00
Tobias Thierer
1f44659b2f Merge \"Changes for upgrade to OkHttp 2.7.5\"
am: 5c3bebd673

Change-Id: Id79249756929a61dca374f9f1d43d0ea9e6b1280
2016-06-30 12:49:47 +00:00
Tobias Thierer
858e39459e Changes for upgrade to OkHttp 2.7.5
- Use com.android.okhttp.Dns in place of com.android.okhttp.internal.Network
 - Specify TimeUnit.MILLISECONDS for timeouts which 2.7.5 allows and
   brings us closer to 3+

Change-Id: I95b5d72a94ebe1389f7c2e8d95903aa1aadd944b
2016-06-29 17:41:32 +01:00
fionaxu
dc9ff70da1 Merge "cold sim clean up" into nyc-mr1-dev
am: ba3428f01b

* commit 'ba3428f01b8cc112cd85d1c4ffcc1407a3b8b7c6':
  cold sim clean up

Change-Id: I5a2e24d997408badd6db7576b2fa206eb9e5c4ca
2016-06-04 05:53:44 +00:00
fionaxu
5310c30967 cold sim clean up
- add a new field: provisioningNotificationEnabled from NetworkMisc. set
  to false if we want to hide "sign in" notification and placed
  carrier-specific notification instead. it is set on connect, once set,
  it is carrier-app's responsibility to post new UI to users
- rework on the interaction between carrier app and framework
- code cleanup
- unit test support

Bug: 28567303
Change-Id: Ic84db7ffbb920d15344717f104496d3cb82e1a85
2016-06-03 11:45:12 -07:00
Jeff Sharkey
dfd98ed300 Merge "API council feedback: hide and document." into nyc-dev am: 3e0e975a38
am: 19e2f49181

* commit '19e2f49181b209d790f551b374d6d24002de7c9b':
  API council feedback: hide and document.

Change-Id: I3715fc6e824f2a55517788299afe36145db597d7
2016-05-25 20:54:18 +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
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
8ab4a8d08a Merge "DHCPv4: lease expiration is fatal, renew failures are not" into nyc-dev am: bd4b5327db
am: 8958153ac7

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

Change-Id: I314ceed6380af58fb3f6308dde11f2d29b324c66
2016-05-19 04:24:16 +00: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
7b0a58168e DHCPv4: lease expiration is fatal, renew failures are not
Bug: 24837343

Change-Id: Ib330864f8376b0907390d581b48cff5446b3392b
2016-05-18 16:17:03 +09: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
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