Commit Graph

1678 Commits

Author SHA1 Message Date
Lorenzo Colitti
cef8aecacf Only stop/start clatd if necessary.
Previously we would restart clatd on every LinkProperties
change, which now happens every time we switch radio technology
(e.g., LTE to HSPA). We also would not stop it if the link got
an IPv4 address.

Bug: 15024258
Bug: 17186694
Bug: 17569702
Change-Id: I65cfcd5e7acec8ea1a12392a59dabd668c58490f
2014-09-24 00:03:23 +09:00
Paul Jensen
f9e3dcf9e0 am 1c637c5f: Merge "Remove needless locking of mRulesLock that caused deadlocks." into lmp-dev
* commit '1c637c5fef678a82fd1f2c380d41ed6ebcb5bf2e':
  Remove needless locking of mRulesLock that caused deadlocks.
2014-09-23 12:08:22 +00:00
Paul Jensen
4a8196d434 Merge "Remove needless locking of mRulesLock that caused deadlocks." into lmp-dev 2014-09-23 12:00:35 +00:00
Lorenzo Colitti
885024dd7d am bb17a717: Merge changes I3ebf0cec,I8635472c into lmp-dev
* commit 'bb17a717750c558ece69344ecd93d96d4fbc4aca':
  Add a throw route to the VPN endpoint.
  Support non-unicast route types: unreachable and throw.
2014-09-23 03:21:21 +00:00
Lorenzo Colitti
83d12dbbb7 Block address families with routes, not NetworkAgent side channel
Now that we support unreachable routes, use those to block
address families on VPNs. This is a much more elegant solution.
Also update LinkProperties when IP addresses are added and
removed, fixing a TODO.

Bug: 17462989
Change-Id: Ib749d84710dca70d672350b9f129bb91419ec77e
2014-09-23 10:48:28 +09:00
Wink Saville
b0f0792383 Cleanup NetworkCapabilities.
Remove unused imports and variables.
Fix misspellings.
Added @Overrides.

Change-Id: I81f4adb0504e92d01c5465a0e14bc46d5ec3987e
2014-09-22 21:51:47 +00:00
Lorenzo Colitti
2129034e25 Support non-unicast route types: unreachable and throw.
Bug: 17462989
Change-Id: I8635472ca3e96ec2866af2de48e6260ab2da13fb
2014-09-22 13:10:15 +09:00
Paul Jensen
42aba3e38a Remove needless locking of mRulesLock that caused deadlocks.
The locks were added in c006f1 when underlying functions weren't performing
locking.  In 21062e7 the underlying functions were changed to perform locking
but the higher level locking wasn't removed.  The higher level locking can
now cause deadlocks with the new NetworkAgentInfo locking.  This change
removes the needless higher level locking.  Now all mRulesLock locking
only guards simple accesses to the appropriate two data strucures so there is
no chance of a deadlock.  I verified that all accesses to the appropriate
two data structures are guarded by mRulesLock locking.

bug:17569997
Change-Id: Id9f4e3d19d6895876925ae32f12460db30359368
2014-09-19 11:14:12 -04:00
Robert Greenwalt
61b67c71c5 Merge "Use unified Tethering Permission Check" into lmp-dev 2014-09-18 00:02:16 +00:00
Robert Greenwalt
3c5dee0a26 Use unified Tethering Permission Check
The BT and Wifi mechanisms for enabling Tethering did their own
permission checks.  This set of changes unifies the check into
a ConnectivityManager function so they can be kept in sync.

bug:17435527
Change-Id: I8c157a5acf56ffbddd349cb6a45160ae7be8541b
2014-09-17 16:18:12 -07:00
Jeff Sharkey
d44d6c7e8c Merge "NetworkStats always needs arrays." into lmp-dev 2014-09-17 19:01:13 +00:00
Jeff Sharkey
7b51ae7abc NetworkStats always needs arrays.
Internal logic relies on Arrays.copyOf(), so always give ourselves
valid arrays, using shared empty objects to save overhead.

Bug: 17502649
Change-Id: I5dbb00545bdfe45bbd48144ab505ea08cc92cbcd
2014-09-17 09:26:31 -07:00
Robert Greenwalt
e06ea4b12f Add NetworkAgent event for ExplicitlySelected
Lets Wifi tell us when the user selected this AP vs auto-connected.

bug:17396168
Change-Id: I6e067ab62ed49040629aa31fe07ff880d3d542f0
2014-09-16 17:03:59 -07:00
Robert Greenwalt
a652f2a6c5 Merge "Report Network status to NetworkAgent." into lmp-dev 2014-09-16 22:59:33 +00:00
Ang Li
9d294201bf Fix a typo in comment.
Change-Id: I23224b1adf946ebec0ec7a39686913189c9b8287
2014-09-15 15:09:16 -07:00
Robert Greenwalt
2dce6d63dc Report Network status to NetworkAgent.
Currently just valid/invalid based on NetworkMonitor findings.

Changed NetworkMonitor to start out in default state since starting in Offline causes
a spurious invalid report at creation time.

Added some logging.

bug:17395269
Change-Id: I9ae650b561834d8f8979033744d97df852e76df9
2014-09-14 07:43:10 -07:00
Paul Jensen
39fc7d5e8e Update Inet state when NetworkMonitor re-evaluates a network.
Previously the Inet state (the little exclamation mark beside the WiFi
and Cellular bars) only transitioned from bad to good once.  With this
change it can transition back to bad (and later to good again) if a network
re-evaluation is triggered, say by ConnectivityManager.reportBadNetwork.
Also, avoid triggering re-evaluation in two unwanted cases.

bug:16214361
Change-Id: I7856724249ffcbb0945276dcf45019876231fdaf
2014-09-12 23:02:28 +00:00
Paul Jensen
05e85ee7a6 Better handling of unvalidated networks.
Give unvalidated networks penalized scores and allow them to satisfy
requests.

Previously unvalidated networks were never allowed to satisfy
NetworkRequests and so never caused CONNECTIVITY_ACTION broadcasts.
Previously if there were no other networks present an unvalidated
network would still be made the default.  This change formalizes
this behavior using our existing network score logic by assigning
unvalidated networks a highly penalized score.

bug:16358003
bug:17364306
Change-Id: I28fcd6f5ac4b52a4d1c234c472cfa8ba998bcc6f
2014-09-12 13:32:00 -04:00
Paul Jensen
4fb6fe5260 Merge "Flush HTTP socket pools and DNS cache when binding process to a Network." into lmp-dev 2014-09-11 13:15:22 +00:00
Paul Jensen
7c60bc2a70 Make Network.openConnection() share HttpHandlers not OkHttpClients.
HttpHandler and HttpsHandler classes have a lot of bug fixes baked into
them that the Network.openConnection() API should be using, for example
disabling SPDY support.

bug:17420465
Change-Id: I9f1472753a542d1dd6bffde3a60c37a9145098aa
2014-09-11 00:25:50 +00:00
Robert Greenwalt
2ea88e8ece Merge "Don't accept score below 0." into lmp-dev 2014-09-10 19:30:22 +00:00
Paul Jensen
3e2917cd71 Flush HTTP socket pools and DNS cache when binding process to a Network.
Future HTTP requests could use an old socket that's bound to a different Network
causing unexpected results.  DNS results could also not be appropriate.

bug:17283566
bug:17432215
Change-Id: I88b40b723c7b442000cafe8ce8b9d989d8995991
2014-09-10 18:26:25 +00:00
Robert Greenwalt
31475db1a4 Don't accept score below 0.
Network Factories are allowed to go below, but networks need to be
constrained.  Allowing the network to go below 0 meant that -1 could
sometimes leak through and foul the logic.

The core of 17361330 will be fixed when we stop sending scores for
listens to NetworkFactories, but it exposed this issue too.  Summary:

1 - add a network listener.  This isn't  a request so it's not sent
to networks.
2 - alter your score (ethernet sets score to -1 when the link goes
down) (16:07:39.782)
3 - a bug in ConnectivityService causes score changes to get sent for
all network requests and network listeners causing NetworkFactories
to no see 2 entities.  This bug will be fixed by a pending change
(https://googleplex-android-review.googlesource.com/#/c/540840/).
This causes the ethernet NetworkFactory to see two entities, both
served by networks of score -1.  (16:07:39.989)
4 - disconnect Ethernet - this only sends 0 scores for known
requests, not network listeners.  Had it been sent for both entities
they both would have evaluated that the networkfactory score (-1)
was lower than the request score (0) and both released their
refcount. (16:08:03.147)
5 - this means the listener is tracked by the EthernetNetworkFactory
with a score of -1 while the factory itself has a score of -1 so the
network release isn't called.

bug:17361330
Change-Id: Ife34ca0f9c233dd3c3df80f6fea580af43afcdeb
2014-09-10 10:39:37 -07:00
Paul Jensen
1470f9bc83 Merge "Stop logging false error when lingering completes." into lmp-dev 2014-09-09 10:59:42 +00:00
Paul Jensen
a7b03c56aa Merge "Don't send listening NetworkRequests to NetworkFactories." into lmp-dev 2014-09-09 10:59:20 +00:00
Paul Jensen
3d08d3c061 Merge "Implement ConnectivityManager.reportBadNetwork() to trigger network validation." into lmp-dev 2014-09-09 10:58:59 +00:00
Paul Jensen
f2d8b983b5 Stop logging false error when lingering completes.
When lingering completes ConnectivityService would log an error message
saying the Network still had NetworkRequests.  Fixed by ignoring
listening NetworkRequests which aren't a problem.

Change-Id: Ie78a1f91c47b012eae28a377dd77bee2cfcbde3b
2014-09-07 13:16:03 -04:00
Paul Jensen
c92d3ebde4 Don't send listening NetworkRequests to NetworkFactories.
We were doing this when a NetworkAgent updated its score.

bug:17393458
Change-Id: Id19ffc36b942b7112da70dfadd6abd57fcd128bd
2014-09-07 13:10:07 -04:00
Sreeram Ramachandran
9171989a9c Reserve NetIds 1..50 for OEM use.
Also reserve 51..100 for our use.

Bug: 17303534
Change-Id: Id082368b493dc3c5b5c479e51d273458d80ec6aa
2014-09-05 16:24:51 -07:00
Robert Greenwalt
ad35b13305 Fix networking API per scripting checks.
bug:17389242
Change-Id: I6017f559788ee16a1721b387796e5bda5e07280d
2014-09-04 16:50:29 -07:00
Robert Greenwalt
949b25423e Merge "Catch creation of NetworkRequest without NetCap" into lmp-dev 2014-09-04 21:08:11 +00:00
Jason Monk
f098cfcbbe Proxy fixes from API review feedback
Bug: 17389383
Change-Id: Ib5e40f55d02687ee917ba30773123cf3e4c2a97d
2014-09-04 15:39:56 -04:00
Paul Jensen
83f5d57e0c Implement ConnectivityManager.reportBadNetwork() to trigger network validation.
Network traffic used to perform the network validation is billed to the UID of
the caller of reportBadNetwork.  This change does not change the actions taken
upon validation failing or succeeding:  NetworkMonitor will show the sign-in
notification if a captive portal is found.  NetworkMonitor will inform
ConnectivityService if a network tests functional.  NetworkMonitor will not
take action if a network lacks any connectivity.
Also, remove an unused Thread that was confusing bandwidth billing.

bug:17326268
Change-Id: I7fea23480af54211004a0a1c535a71c2793f21bb
2014-09-04 12:02:52 -04:00
Robert Greenwalt
ea266c65ee Catch creation of NetworkRequest without NetCap
Using reflection you could do this and it would crash the system.
Thanks, ServiceFuzzer!

bug:17379629
Change-Id: I8b470bda78a69761ccd92496746f5d295b5d07f2
2014-09-03 20:57:41 -07:00
Lorenzo Colitti
939112e006 Kill the NetworkInfo(int type) constructor. IT'S A TRAP!
This constructor does nothing, including doing nothing with its
only argument. This causes it to return a NetworkInfo for
TYPE_MOBILE no matter what was passed in.

Bug: 16610051
Change-Id: I4ccd5ec050f7824fb06496c00fcd7901defeb7bd
2014-08-29 18:34:49 -07:00
Lorenzo Colitti
d092cb50d3 Use per-Network connection pools for openConnection.
If we don't do this, per-network HTTP requests will go over the
wrong network if any previous HTTP request was made by the same
app on another network.

Bug: 17300006
Change-Id: I1854c16dee6adb9e81fb12b097577439d69a644e
2014-08-29 18:13:19 -07:00
Lorenzo Colitti
860a7aa21a Pass the socket mark for DNS queries to dnsmasq.
This makes tethered clients use the correct DNS servers when
tethering to non-default networks like the DUN APN.

Bug: 16357676
Change-Id: I8933b6de198a92c2aaf0291931ace8966ddba275
2014-08-29 10:21:58 -07:00
Diego Pontoriero
31a5939353 Change TelephonyManager method name to accurately reflect functionality.
Bug: 17163860
Change-Id: I4390d79c49831454146a42b89520a16984c5f260
2014-08-28 13:50:36 -07:00
Robert Greenwalt
ab8e02d0c1 Merge "Clean up Connectivity Logging." into lmp-dev 2014-08-28 16:29:55 +00:00
Robert Greenwalt
419e1b4362 Clean up Connectivity Logging.
bug:17285109
Change-Id: I61b98aa636996f8d4915fd954d49a22c20cfe9ab
2014-08-27 14:49:14 -07:00
Paul Jensen
660ce150ee Merge "Fix to allow removing sign-in notification when network removed." into lmp-dev 2014-08-26 23:58:40 +00:00
Paul Jensen
7844b81ae8 Fix to allow removing sign-in notification when network removed.
When the NetworkMonitor is told a network disconnected and a sign-in
notification has been shown to the user, the NetworkMonitor requests
the notification be removed.  This request goes to the
ConnectivityService who may have already removed the NetworkAgentInfo
from mNetworkForNetId so we cannot look up the NetID in there.
There is no harm in allowing notification hiding for networks that
are disconnected as the notification logic does not effect the
Network state (like the validation message that caused the addition
of the Network liveness check).

bug:17261757
Change-Id: Id0a299e230ae37e641ac2faeebc45550e27c1fa4
2014-08-25 22:45:39 -04:00
Robert Greenwalt
03653b12d4 Merge "Remove listen requests properly." into lmp-dev 2014-08-25 23:12:46 +00:00
Robert Greenwalt
8c5842cfaf Remove listen requests properly.
https://googleplex-android-review.googlesource.com/#/c/527772/
correctly stopped adding listen requests to the mNetworkForRequestId
sparse array, but when we remove requests, if it's not getting
serviced by a network, we don't remove it from the network.  That
means that when we go to send a notification for that network we have
a request affiliated with the network, but don't have data for the
request and hit this NPE.

If it's not a request, don't do the optimization and remove it only
from the network servicing the request, but instead scan all networks
and remove it from each, if found.

bug:17239054
Change-Id: I49165ed08c224ef20f703469f9ce39df5f21b163
2014-08-25 15:42:10 -07:00
Robert Greenwalt
8830c19455 Merge "Update the http proxy on LinkProperty change." into lmp-dev 2014-08-25 19:05:00 +00:00
Paul Jensen
becb073b12 Merge "Remove captive portal sign-in actions." into lmp-dev 2014-08-25 18:52:32 +00:00
Robert Greenwalt
1f358c86ef Update the http proxy on LinkProperty change.
bug:16308315
Change-Id: Ie44634a9223f289903c09653f77a998d3a344654
2014-08-23 09:51:35 -07:00
Jeff Davidson
e1dbb17d41 Merge "Allow NetworkRequest release from the system process." into lmp-dev 2014-08-22 16:52:33 +00:00
Paul Jensen
af9351f884 Remove captive portal sign-in actions.
This reverts commit e0101cd and removes the related NetworkMonitor code.
The thinking is the broadcasts are not robust enough as they rely on apps
working together and are not sufficiently tested.

bug:17115050
Change-Id: I433032867cc4fea7191a1b13842b16825dc74df4
2014-08-22 09:42:56 -04:00
Lorenzo Colitti
e1d81d158a Merge "Rework the per-network URL API." into lmp-dev 2014-08-22 03:07:28 +00:00