Commit Graph

2525 Commits

Author SHA1 Message Date
Sudheer Shanka
27e6931583 Ensure network connectivity on app start.
Bug: 27803922
Test: cts-tradefed run singleCommand cts-dev --module CtsHostsideNetworkTests
Change-Id: Ifd7a52924cd6bbc809c9a3f92d52fe2df09b7fe2
2017-02-13 17:17:41 -08:00
Jeremy Joslin
4ad7ca056f Adding a little more verbose logging.
Log statements to help track the request call path.

Test: manual
Change-Id: I68cfdf68cf8adcece45de2a60bec94e6f06be761
2017-02-13 11:35:03 -08:00
Jeremy Joslin
f95c865411 Adding a new internal method to get all valid scorers.
New NetworkScoreManager method to get all valid scorers from the
NetworkScoreService. The implementation is stubbed out for the time
being.

Test: make
Bug: 35095406
Change-Id: Iece2cc10a0a9377f2d82385d172b06660bb9b130
2017-02-09 15:32:04 -08:00
TreeHugger Robot
5a0d21156d Merge "Check for null inputs in the ctor." 2017-02-09 00:25:28 +00:00
Jeremy Joslin
e925aeacab Check for null inputs in the ctor.
Test: gts-tradefed run gts -m GtsGmscoreHostTestCases -t com.google.android.gts.wifi.WifiHostTest
Bug: 35152108
Change-Id: I321b52b0feb62aced20bca7f47e962f5c7d78343
2017-02-08 14:50:34 -08:00
TreeHugger Robot
a327386e90 Merge "Fix typo in ScoredNetwork javadoc." 2017-02-08 21:56:18 +00:00
Jeremy Joslin
a5172f69ca New internal interface method to get the active scorer metadata.
Returns the cached NetworkScorerAppData from the connected service.

Test: runtest frameworks-services -c com.android.server.NetworkScoreServiceTest
Bug: 34773276
Change-Id: Ia8986e770c4ede0c0f7e2ad4f5bc0a0117a9ae2b
2017-02-07 16:12:22 +00:00
Sundeep Ghuman
c3cd62f848 Fix typo in ScoredNetwork javadoc.
Bug: 34824590
Test: NA
Change-Id: I1dcb9a2ca7de1e42f28ecf5b916700ffb184da72
2017-02-06 14:54:09 -08:00
Jeremy Joslin
bdd9ac2324 Default the lastSelectetNetworkId to -1
Test: adb shell am instrument -e class android.net.RecommendationRequestTest  -w com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Bug: 35045563
Change-Id: I04d71f2072d8a5a706f05905b580dd7af77d13d8
2017-02-06 12:55:43 -08:00
Jeremy Joslin
37e877becc Cache NetworkScorerAppData in the ScoringServiceConnection.
Store the entire NetworkScorerAppData instance in the
ScoringServiceConnection instead of just most of its fields.

Test: runtest frameworks-services -c com.android.server.NetworkScoreServiceTest
Bug: 34773276
Change-Id: Id2ed7c431dee9895e85e1966903ac919f1704eba
2017-02-03 16:29:38 +00:00
Erik Kline
e8bc75bfcc Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe am: 6f32aa0259 am: 7196e935a8
am: c700509ade

Change-Id: I15fe6fe4c9aec3d244b46516c2992ded33337a9f
2017-02-02 20:03:51 +00:00
Erik Kline
c700509ade Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe am: 6f32aa0259
am: 7196e935a8

Change-Id: I2ab05143299f13012dc2a88efca52160e08c6d97
2017-02-02 07:32:09 +00:00
Erik Kline
7196e935a8 Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe
am: 6f32aa0259

Change-Id: I6828bc3bb094ca8597ca2d8538045758638c374f
2017-02-02 07:27:13 +00:00
Erik Kline
6f32aa0259 Merge "Add ConnectivityManager.networkCapabilitiesForType()"
am: c313123afe

Change-Id: I0ad50fbf38f11b383fd889dc598cfddd47051477
2017-02-02 07:22:05 +00:00
Erik Kline
35bf06c968 Add ConnectivityManager.networkCapabilitiesForType()
This static method returns a NetworkCapabilities instance with
transports and capabilities set according to the given legacy type.

Also:
    - add NetworkRequest.Builder.setCapabilities(), to be able to use
      the NetworkCapabilities instances returned from the above
    - update UpstreamNetworkMonitor to make immediate use of this

Test: as follows
    - build (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
    - WiFi to DUN upstream tethering works
Bug: 32163131

Change-Id: Idfe1ddd2815c355cbf27cf29eb0e3de177de84e9
2017-02-02 11:07:59 +09:00
Lorenzo Colitti
2de4925f5c Add an API hint for metered multipath traffic.
This allows an application that knows how to provide seamless
network connectivity (e.g., using QUIC multipath) to find out if
doing so is desired.

Test: builds, boots, runtest frameworks-net passes.
Bug: 34630278
Change-Id: Ic7fd0b9e1cd879fdfaf84009d7125391895e9087
2017-02-01 17:02:29 +09:00
Jeremy Joslin
94ea572773 Merge "Post runnables instead of sending messages." am: 71317f4a6c am: 71a4792147 am: 31669e8924
am: 28f9de475f

Change-Id: I6f2774e0efd7cfcabb49db25614bac99bfdb1b30
2017-02-01 01:53:28 +00:00
Jeremy Joslin
28f9de475f Merge "Post runnables instead of sending messages." am: 71317f4a6c am: 71a4792147
am: 31669e8924

Change-Id: Ia7937ea6d29924e1b717430e8330d81e3f7ee9e3
2017-02-01 01:48:05 +00:00
Jeremy Joslin
31669e8924 Merge "Post runnables instead of sending messages." am: 71317f4a6c
am: 71a4792147

Change-Id: Idff8f071f316942e8b520c913e96d3eb8b44227d
2017-02-01 01:40:58 +00:00
Jeremy Joslin
71a4792147 Merge "Post runnables instead of sending messages."
am: 71317f4a6c

Change-Id: I13cb1fd38262f869b99245678c89f45b834210c8
2017-02-01 01:34:16 +00:00
Jeremy Joslin
c695a17421 Post runnables instead of sending messages.
Gaining access to a Handler's Looper can be problematic in custom
Handler implementations. Instead of creating a new internal Handler
to dispatch the method calls on we simply post Runnables to the
given Handler.

Test: adb shell am instrument -e class android.net.NetworkRecommendationProviderTest -w com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Bug: 34845471
Change-Id: I6fe380a92aebd630781abe5853f94737bcfeaa5f
2017-01-31 11:51:25 -08:00
Robert Quattlebaum
9cd7af310c Minor updates to reflect libbinder changes.
* Parcel: Update comment to reflect new file path
* IpPrefix: Update AIDL file to indicate appropriate C++ header

Change-Id: Ia9edccca5e8ef1f36a709b593a768003e1234dfa
2017-01-30 15:05:53 -08:00
John Reck
6e4f930457 Merge "Fix a bunch of repeated reads of a ro.* property" am: 4265991701 am: e4c2e8f303
am: 3c2837e77e

Change-Id: Idbcb9dfeac57036d3621474ee65ba967cc7bc499
2017-01-27 23:05:52 +00:00
John Reck
3c2837e77e Merge "Fix a bunch of repeated reads of a ro.* property" am: 4265991701
am: e4c2e8f303

Change-Id: Id6af451556fde8eefac8076735e625911f8bf272
2017-01-27 23:02:41 +00:00
John Reck
e4c2e8f303 Merge "Fix a bunch of repeated reads of a ro.* property"
am: 4265991701

Change-Id: I996fbd1002ef788a768b575ab6d2177dc9ab5af1
2017-01-27 22:57:29 +00:00
John Reck
ed065024a5 Fix a bunch of repeated reads of a ro.* property
SystemProperties.get() is not particularly fast,
especially if a string is returned. Since ro.* values
are unable to be changed, there's no need to
continously re-query them. Cache the value at
static init time to trivially fix this.

Test: refactoring CL.
Change-Id: Iccb021d3cb2ba3a4a1d0048ddec6811bb7409eec
(cherry picked from commit aa67f684ff)
2017-01-27 11:04:39 -08:00
The Android Automerger
6a688ca1ad Merge commit '88932754ffdcbffb3cb43e03991e5eb598c10458' into nyc-mr1-dev-plus-aosp
* commit '88932754ffdcbffb3cb43e03991e5eb598c10458':
  Captive portals: login activity probes like NetworkMonitor
  Logging improvements in CaptivePortalLoginActivity
  Captive portal systel log improvements
  Fix flaky IpPrefixTest.
  Removing bogus file added by mistake
  frameworks-test: adding missing @SmallTest
  Netd events: record connect() success/errno
  Add missing dependency.
  Show notification for always-on app VPN
2017-01-27 06:39:52 +00:00
The Android Automerger
7bc2aebd53 Merge commit '48a1136c8b3000c651e8bcd86325acd1dce6e4ec' into nyc-mr1-dev-plus-aosp
* commit '48a1136c8b3000c651e8bcd86325acd1dce6e4ec':
  Implement metered tracking for NetworkStats summary queries.
2017-01-27 06:39:41 +00:00
The Android Automerger
53095bb5bd Merge commit 'a19056c35d16ddb5a6c1d3343729701b8939f1e1' into nyc-mr1-dev-plus-aosp
* commit 'a19056c35d16ddb5a6c1d3343729701b8939f1e1': (35 commits)
  NetworkMonitor: send one DNS probe per web probe
  NetworkMonitor metrics: add first validation information
  APF: also drop any ICMPv6 RSs
  ConnectivityServiceTest: fix testAvoidBadWifiSettings
  Fix ConnectivityServiceTest testRequestBenchmark
  Switch over to new "time.android.com" NTP pool.
  Define API for metering network stats buckets.
  Refactored NetworkStatsServiceTest to use Mockito instead of EasyMock.
  Use @Ignore to explicitly disable a @Test method.
  Fixed NetworkStatsServiceTest and converted it to JUnit4.
  VPN network stat accounting changes.
  ConnectivityThread: use lazy holder idiom
  ConnectivityManager: use ConnectivityThread looper
  ConnectivityManager: a simpler CallbackHandler
  Indicate the NsdServiceInfo attributes are only filled in for a resolved service.
  Add a null check for the OnStartTetheringCallback.
  TokenBucket for rate-limiting and throttling
  IpConnectivityMetrics reads buffer size in settings
  CaptivePortalLogin: set mixed content policy to compatibility.
  Add IP conn metrics to dumpsys and bug reports
  ...
2017-01-27 06:39:05 +00:00
Hugo Benichi
88932754ff Captive portals: login activity probes like NetworkMonitor
This patch changes CaptivePortalLoginActivity captive portal test to be
consistent with NetworkMonitor by:
 - using Network.java to open the http connection.
 - adding a UserAgent property to the request header.

Test: manually tested.
Bug: 32369183

(cherry picked from commit cdf3ba48cc)

Change-Id: I559eb0497475daad758ba3b3395225dcd0a27a57
2017-01-26 18:53:03 +09:00
Stephen Chen
48a1136c8b Implement metered tracking for NetworkStats summary queries.
Dependent on ag/1550196 where API is defined.

Bug: 31015360
Bug: 26545374
Test: runtest --path
frameworks/base/core/tests/coretests/src/android/net/NetworkStatsTest.java,
other test classes.

(cherry picked from commit 2514787897)

Change-Id: I46da93ba4afa968facf98f7c3d844fd0c469095a
2017-01-26 18:52:32 +09:00
Hugo Benichi
c328248cdc NetworkMonitor metrics: add first validation information
This patch adds first validation information to:
  - ValidationProbeEvent, by extending the probe_type int field of to
    also include a bit indicating if the probe was part of a first
    validation attempt or not.
  - NetworkMonitorEvent, by defining new contants for the event_type
    field.

Test: $ runtest frameworks-net
      + manually generating events and inspecting the
        output of $ adb shell dumpsys connmetrics list
Bug: b/32198726

(cherry picked from commit 147aa6d53b)

Change-Id: Ie7a62c4f62a13ce52806d3adaa9e627cb246073c
2017-01-26 18:52:25 +09:00
Jeff Sharkey
06124cc892 Switch over to new "time.android.com" NTP pool.
Also add logging to measure success/failure details.

Test: builds, boots, and NTP fix obtained
Bug: 32969463

(cherry picked from commit d3f689bf14)

Change-Id: I7da416099ae903fd92beb516251ef4e51673eecf
2017-01-26 18:52:11 +09:00
Jeremy Joslin
fe1ce2f90c 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 8b436d865c)

Change-Id: I06f01aa8fe5fdc06b2d36cfb9c68feb244c2e5de
2017-01-26 18:51:53 +09:00
Hugo Benichi
d28766c74d 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 c4fe5d373c)

Change-Id: If13b363889a8e9396273a90c3d9f9421a48aecbc
2017-01-26 18:51:49 +09:00
Hugo Benichi
1e19aefa6f 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 7724cdd8b9)

Change-Id: If956addbf8e7b11b36a4b966de7fca00e8f362c1
2017-01-26 18:51:46 +09:00
Hugo Benichi
9c58a11f98 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 d42650faaa)

Change-Id: I1b5fe2a361b5f623a8310ae698497c83d72f3034
2017-01-26 18:51:43 +09:00
Philip P. Moltmann
092feb5b1c Indicate the NsdServiceInfo attributes are only filled in for a resolved service.
Fixes: 28530428

(cherry picked from commit 7d5da4b044)

Change-Id: If2bfc06589adb361f11b89cd5923cb5c255cb680
2017-01-26 18:51:39 +09:00
Jeremy Klein
a17dabedde 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 5f277e1667)

Change-Id: Ia419ff68ef10f308f9e44be47420e27099ee6070
2017-01-26 18:51:36 +09:00
Erik Kline
95be623a27 Support timeouts for requestNetwork() invocations.
(cherry-pick of 06c3ef1367)
(cherry picked from commit 57faba9ec7)

Bug: 21414325
Change-Id: I1a58823a372154589f972b98c4c428eab0e0523e
2017-01-26 18:50:23 +09:00
Elliot Waite
0ce4b0e4c3 Fix @links in reference docs. am: 54de77470d am: ab978c035e am: 28ba4722a9
am: 9b21265b2c

Change-Id: If246ebdb36cf2832d5a6c42cbe752e290b6fb6e8
2017-01-26 04:49:33 +00:00
Elliot Waite
9b21265b2c Fix @links in reference docs. am: 54de77470d am: ab978c035e
am: 28ba4722a9

Change-Id: I98177a8cf0a20677e140406bb7371474ca259e5b
2017-01-26 04:44:54 +00:00
Elliot Waite
28ba4722a9 Fix @links in reference docs. am: 54de77470d
am: ab978c035e

Change-Id: If0d0613362e0ea95cf48eaf9a16d3eea48b589ea
2017-01-26 04:39:57 +00:00
Elliot Waite
54de77470d Fix @links in reference docs.
Change-Id: I40cea46efd80c448640ff69753698fe8404da40b
2017-01-25 17:00:55 -08:00
TreeHugger Robot
dc4ffdabc6 Merge "Create an API for retrieving a badged wifi icon." 2017-01-26 00:59:20 +00:00
Jeremy Joslin
ba24273401 Implemented network score cache filtering.
NetworkScoreCaches registered with a filter type will now only
receive updates that match their filter criteria.

Test: runtest frameworks-services -c com.android.server.NetworkScoreServiceTest
Bug: 34127291
Change-Id: I3d5e6e57b6682707b0734259a2530658ad75dbb7
2017-01-24 17:33:47 -08:00
Amin Shaikh
15902eef8b Create an API for retrieving a badged wifi icon.
Bug: 34202067
Test: ./gts-tradefed run gts -m GtsNetTestCases -t com.google.android.net.gts.wifi.NetworkBadgingTest
Change-Id: Ia3bf9c0a489ae08de8d635aa620cbccca22af1b2
2017-01-24 14:34:19 -08:00
Jeremy Joslin
5c5747e541 Merge "Mark the INetworkScoreCache as oneway." am: edadb3efc3 am: 4fcc44dc9a am: ea65f9d392
am: 577aac1385

Change-Id: I9044cfa8445014d08bc416e46811c57e5972d653
2017-01-24 18:41:47 +00:00
Jeremy Joslin
577aac1385 Merge "Mark the INetworkScoreCache as oneway." am: edadb3efc3 am: 4fcc44dc9a
am: ea65f9d392

Change-Id: I54af428743c036da20a0adbaa38d00ca348364fc
2017-01-23 21:42:00 +00:00
Jeremy Joslin
ea65f9d392 Merge "Mark the INetworkScoreCache as oneway." am: edadb3efc3
am: 4fcc44dc9a

Change-Id: I4d2dc6446f347643f654799094ac7f6fb7529438
2017-01-23 21:35:27 +00:00