Commit Graph

1048 Commits

Author SHA1 Message Date
Hugo Benichi
3ab84b087a 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

Change-Id: I4d5672a3195d3af9a0a2c85f871695257abe782b
2016-10-20 09:30:13 +09:00
Hugo Benichi
0b42baf68a 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
Change-Id: I5004da5b91498e6ff7f8b05057a9e24b975bb56e
2016-10-20 09:09:02 +09:00
Lorenzo Colitti
50d8cd9119 Restrict access to background networks to CHANGE_NETWORK_STATE. am: b8d9f52adb am: 9410bde219
am: 494c218bff

Change-Id: I49bc23dcb5f36654c61a7aa76c41cebda81349f5
2016-09-25 20:11:52 +00: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
e414d2ef36 Support "don't ask again" in the avoid bad wifi dialog. am: c65750c8a0 am: 74cb76ff80 am: 63275aba54
am: ec500d94b0

Change-Id: I60ebe27ec892658c5a051457b13506e59ba33824
2016-09-21 06:04:15 +00: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
1f80a59004 resolve merge conflicts of b62007a to master
Change-Id: Ib09134090aa135d88bb807034b262a23c8b40e5f
2016-09-16 01:45:15 +09: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
242b00f7ed Add a NET_CAPABILITY_FOREGROUND capability. am: 0f04220ffe am: aaec66110d
am: aabaa907de

Change-Id: I08ca73666668ddc6c9bfe002844a9d2e0ecb28e4
2016-09-14 19:22:54 +00:00
Lorenzo Colitti
f2b4b3e4e7 Add a background NetworkRequest type for mobile data always on. am: 2666be8ae7 am: 9396da4e10
am: 350a2fef4a

Change-Id: I9e11b75fe0af8a116593394b151c7fb4d1e167f8
2016-09-14 05:02:12 +00: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
Etan Cohen
5716482c36 Merge "Support timeouts for requestNetwork() invocations." 2016-08-17 17:15:46 +00:00
Jeremy Joslin
13dd0e99ba 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
Change-Id: I62a75a0c0c0111e052b7903baa9f5d6d94ef57fd
2016-08-16 15:53:57 -07:00
Erik Kline
155a59aa63 Support timeouts for requestNetwork() invocations.
(cherry-pick of 06c3ef1367e850746eef0a5462bdce8674d74c30)

Bug: 21414325
Change-Id: I08118be8e8cf92fc406d431e99a6c9191a863ff3
2016-08-15 10:19:45 -07:00
Lorenzo Colitti
2f1d7cabed Merge \"Merge \\"Add an isListen method to NetworkRequests.\\" into nyc-mr1-dev am: b5239329b1\" into nyc-mr1-dev-plus-aosp
am: 17450e41b3

Change-Id: Ic71a5722ee877de73e7ffd340a5ffb84a2d4910d
2016-07-18 15:15:33 +00: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
693b398a32 Add IPv6 tethering coordinator am: 6f0405308b
am: 4875f44794

Change-Id: I9a5bd7d72ec6a4b63922fc5704d15cb5eafc1e8d
2016-07-13 05:02:13 +00: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
Etan Cohen
2b5f37913d resolve merge conflicts of 7473bc2 to master
Change-Id: Ib300a32277a4bb21ed9f5a024118370d361aa1c1
2016-07-12 10:09:16 -07:00
Erik Kline
3e5de27d07 Support requesting async LinkProperties/NetworkCapabilities updates am: 0c04b74781
am: b2bdeca8e2

Change-Id: If177966a19c830a106ce689c7e07a7835bb2c1a1
2016-07-12 01:46:09 +00:00
Erik Kline
78b05827f9 Basic IPv6 Router Advertisement daemon am: 1a1cb0e914
am: 78bf01826a

Change-Id: I30627432d5736a17248aa90b225d08244a4dee5d
2016-07-12 01:46:01 +00: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
652986d462 Merge \\"ConnectivityManager: no double callback remove\\" into nyc-mr1-dev am: 0ecfb2fd34
am: bafb27388b

Change-Id: I8fb5bac2bb6b7665192c8c788d7818d637500935
2016-07-07 09:45:36 +00: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
53c4eb01d2 Merge \\"Unbreak unregisterNetworkCallback.\\" into nyc-mr1-dev am: 0271c0d4ef
am: 5a7cd3500d

Change-Id: I7861e8ff7b8528d8468f8217e13398f78be50de5
2016-07-05 02:28:07 +00: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
41acc1ca8c Merge changes from topic \\'networkrequest_private\\' into nyc-mr1-dev am: 0317e03dc3
am: 9d1139ee06

Change-Id: I09231f4f4f3bd13f6b51fe8117eff7d002cf10dd
2016-07-01 15:27:07 +00: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
46a334019c Merge \\\\"Changes for upgrade to OkHttp 2.7.5\\\\" am: 5c3bebd673 am: 1f44659b2f am: 6b473f7b67
am: 4b2e1aef96

Change-Id: I02fe28e773df3b328be8c7ea26b0df065014188a
2016-06-30 13:12:46 +00: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