Commit Graph

1107 Commits

Author SHA1 Message Date
Hugo Benichi
bc4ac9775f ConnectivityManager: fix potential NPE
ConnectivityManager static sCallbackHandler is referenced and directly
used in a way that is not ensuring its proper initialization.

This patch fixes this potential NPE by using getHandler() instead.

Also this patch changes sendRequestForNetwork's signature to only accept
the subtype CallbackHandler instead of Handler: without using
CallbackHandler the NetworkCallbacks are not triggered properly and
bookkeeping of sCallbacks does not happen. sendRequestForNetwork's
signature now makes this explicit.

This step prepares the addition of overloaded versions of
registerNetworkCallback and cie that takes custom Handlers.

Test: build, flashed, manually checked connectivity
Change-Id: I52e8a2cb5075e7aef7b35e30c9845cacba927d13
2017-02-14 16:01:40 +09:00
Erik Kline
21573da57d Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe am: d313f7c9fa am: 022044ea69
am: 47500d9b1b

Change-Id: I15fe6fe4c9aec3d244b46516c2992ded33337a9f
2017-02-02 20:03:51 +00:00
Erik Kline
47500d9b1b Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe am: d313f7c9fa
am: 022044ea69

Change-Id: I2ab05143299f13012dc2a88efca52160e08c6d97
2017-02-02 07:32:09 +00:00
Erik Kline
022044ea69 Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe
am: d313f7c9fa

Change-Id: I6828bc3bb094ca8597ca2d8538045758638c374f
2017-02-02 07:27:13 +00:00
Erik Kline
ce55eb160d 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
48a2a32bdd 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
The Android Automerger
c95cbb9588 Merge commit 'f2bcda635cca9dc6f00b6efb2b9cf92892525bab' into nyc-mr1-dev-plus-aosp
* commit 'f2bcda635cca9dc6f00b6efb2b9cf92892525bab':
  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
2bb684daf5 Merge commit 'de58879efdcb7aa6d62aa4f67908ae59fa366716' into nyc-mr1-dev-plus-aosp
* commit 'de58879efdcb7aa6d62aa4f67908ae59fa366716':
  Implement metered tracking for NetworkStats summary queries.
2017-01-27 06:39:41 +00:00
The Android Automerger
d49ba144f0 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
f2bcda635c 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 454e066e27)

Change-Id: I559eb0497475daad758ba3b3395225dcd0a27a57
2017-01-26 18:53:03 +09:00
Hugo Benichi
739d7e9ce7 Fix flaky IpPrefixTest.
Test: IpPrefixTest passes
Bug: 32561414

(cherry picked from commit f5ec69155d)

Change-Id: I42928da87f7f336900b3a95ebbf28563864da8d4
2017-01-26 18:52:51 +09:00
Stephen Chen
de58879efd 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 9369e9d105)

Change-Id: I46da93ba4afa968facf98f7c3d844fd0c469095a
2017-01-26 18:52:32 +09:00
Jeremy Joslin
232e75c65b 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
2017-01-26 18:51:53 +09:00
Hugo Benichi
eba4b5b0bd 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
2017-01-26 18:51:46 +09:00
Hugo Benichi
03eeaae5f0 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
2017-01-26 18:51:43 +09:00
Jeremy Klein
d6114b0eda 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
2017-01-26 18:51:36 +09:00
Erik Kline
d99da81fae Support timeouts for requestNetwork() invocations.
(cherry-pick of 0b7a74842b)
(cherry picked from commit 155a59aa63)

Bug: 21414325
Change-Id: I1a58823a372154589f972b98c4c428eab0e0523e
2017-01-26 18:50:23 +09:00
Stephen Chen
5df334f572 DO NOT MERGE: 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 9369e9d105)

(cherry picked from commit 757658193d)

Change-Id: I79e401fc4159264a075febba82bd8c295b8e677f
2017-01-18 19:08:41 +09:00
Hugo Benichi
e4f69293e9 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)

(cherry picked from commit 8f201294fe)

Change-Id: Ic9a31809ef19e618246f9aa17f5df29bd65f8510
2017-01-18 19:08:23 +09:00
Hugo Benichi
9954fbdb65 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)

(cherry picked from commit 301b09738a)

Change-Id: If5c1e46ca6c4a09ef526cbe09654c5f55ef8d6ce
2017-01-18 19:08:21 +09:00
Hugo Benichi
5d2047de7b 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)

(cherry picked from commit 56260ed9cb)

Change-Id: I4d0b2441b6af76bc56b19218210a2a381532a3c4
2017-01-18 19:08:18 +09:00
Jeremy Klein
d707b3716b 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)

(cherry picked from commit fb63d5a4ef)

Change-Id: Ia5f328c4b25aa6624dc3c8493eb0c7bbab99904c
2017-01-18 19:08:14 +09:00
Erik Kline
ee83e11aeb DO NOT MERGE: Support timeouts for requestNetwork() invocations.
(cherry-pick of 0b7a74842b)
(cherry picked from commit 155a59aa63)

Bug: 21414325

(cherry picked from commit 5791c5f681)

Change-Id: I640c43315a071ecbf881e5ce898164915e0b787f
2017-01-18 19:07:33 +09:00
Etan Cohen
abccaf34c3 Merge "[AWARE] Unhide Wi-Fi Aware API (baseline)" am: dfe8f5dc13 am: 877ccf68fb am: 463d3c6e7c
am: 669e846a8a

Change-Id: Ib668ed15ccf1f05c5ed31f700b69e1f3ab8b4cac
2017-01-11 23:28:20 +00:00
Etan Cohen
669e846a8a Merge "[AWARE] Unhide Wi-Fi Aware API (baseline)" am: dfe8f5dc13 am: 877ccf68fb
am: 463d3c6e7c

Change-Id: If2a6b632cd03984921572b190745865953a8e808
2017-01-11 23:22:51 +00:00
Etan Cohen
463d3c6e7c Merge "[AWARE] Unhide Wi-Fi Aware API (baseline)" am: dfe8f5dc13
am: 877ccf68fb

Change-Id: I6f894d92451032657678639c3021eef07289a6a2
2017-01-11 23:17:19 +00:00
Etan Cohen
877ccf68fb Merge "[AWARE] Unhide Wi-Fi Aware API (baseline)"
am: dfe8f5dc13

Change-Id: I581b72ce62966f4c04427603a2b9686dcf46cc42
2017-01-11 23:12:16 +00:00
Etan Cohen
785ddc7f52 [AWARE] Unhide Wi-Fi Aware API (baseline)
Baseline Wi-Fi Aware API providing discovery and connectivity (data-path).

Bug: 30983968
Test: unit tests + integration (sl4a) tests passing.
Change-Id: Idd7c6a625f168717b083d5f13e291ce916571933
2017-01-11 11:13:26 -08:00
Lorenzo Colitti
84d7f0786a Remove requestRouteToHost and {start,stop}UsingNetworkFeature.
These APIs have been deprecated since L, and since M have thrown
IllegalArgumentException for apps targeting M or newer.

Test: API check passes.
Bug: 33607472
Change-Id: Ie582cac3872be21c51e1e37d16d7cfac496ed3e4
2017-01-05 17:39:21 +09:00
Hugo Benichi
22569ca49a DO NOT MERGE 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 454e066e27)

Change-Id: I559eb0497475daad758ba3b3395225dcd0a27a57
2017-01-05 12:12:50 +09:00
Hugo Benichi
79a968d619 DO NOT MERGE Fix flaky IpPrefixTest.
Test: IpPrefixTest passes
Bug: 32561414

(cherry picked from commit f5ec69155d)

Change-Id: I42928da87f7f336900b3a95ebbf28563864da8d4
2017-01-05 12:07:38 +09:00
Hugo Benichi
924e436af8 Captive portals: login activity probes like NetworkMonitor am: 454e066e27
am: 7aefeec9b3

Change-Id: I57a5a1a92385d4a3bf2fdd6bedeaf93430ecc158
2016-12-19 18:29:41 +00:00
Hugo Benichi
7aefeec9b3 Captive portals: login activity probes like NetworkMonitor
am: 454e066e27

Change-Id: Ie85df7dd734b872cc361d0820edbfffc928f9f3a
2016-12-19 02:07:41 +00:00
Hugo Benichi
454e066e27 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
Change-Id: I33cbcdab9809c712d998da6d925bdd4e3093f8ff
2016-12-19 09:19:13 +09:00
Mark Lu
8dfe9fc09c docs: changes to broadcast documentation am: 3e422ac3cc am: 276e436a24 am: ec5096b07a
am: f92e4912ea

Change-Id: I2dcb6bc7f8ebf385bc7d6a571a760c140a65e9fb
2016-12-16 05:30:20 +00:00
Mark Lu
ec5096b07a docs: changes to broadcast documentation am: 3e422ac3cc
am: 276e436a24

Change-Id: I2e8377b188ce6a10ea633e089c3a20f9ef7908fd
2016-12-16 05:06:42 +00:00
Mark Lu
9e0c74f54c docs: changes to broadcast documentation am: 3e422ac3cc
am: 276e436a24

Change-Id: I7dcb1bc57fb62f2b177c7ad15a9236da98fb749f
2016-12-16 05:06:37 +00:00
Erik Kline
c372b4ba35 Merge "Have IpManager track L2-L4 signaling traffic required for IP connectivity." am: 80ff5ecd4a
am: 4f4a914a0f

Change-Id: Ib46bdab897cef221f4c22326e562130822d42298
2016-12-15 12:28:41 +00:00
Erik Kline
a72d649673 Have IpManager track L2-L4 signaling traffic required for IP connectivity. am: 929ed666b5
am: 63c2cd962a

Change-Id: Iccd81c5d722a14409fc4f22bc34c3607bca653da
2016-12-15 10:21:08 +00:00
Erik Kline
63c2cd962a Have IpManager track L2-L4 signaling traffic required for IP connectivity.
am: 929ed666b5

Change-Id: Ie95309464d8f368f5040c74b59daba9700191e86
2016-12-15 10:13:36 +00:00
Erik Kline
867dfd1057 Have IpManager track L2-L4 signaling traffic required for IP connectivity.
Test: as follows
    - built and flashed
    - observed logcat
    - observed "dumpsys wifi ipmanager"
    - runtest BlockingSocketReaderTest passes
    - runtest ConnectivityPacketSummaryTest passes
Bug: 21859053
Bug: 26101306
Bug: 31742572
Bug: 31707128
Bug: 33531488

Change-Id: Ibecaf809dcc1813924b25749e8ba8eb2d4bdf114
2016-12-15 19:09:49 +09:00
Erik Kline
929ed666b5 Have IpManager track L2-L4 signaling traffic required for IP connectivity.
Test: as follows
    - built and flashed
    - observed logcat
    - observed "dumpsys wifi ipmanager"
    - runtest BlockingSocketReaderTest passes
    - runtest ConnectivityPacketSummaryTest passes
Bug: 21859053
Bug: 26101306
Bug: 31742572
Bug: 31707128
Bug: 33531488

Change-Id: Ibecaf809dcc1813924b25749e8ba8eb2d4bdf114
2016-12-15 17:16:48 +09:00
Mark Lu
3e422ac3cc docs: changes to broadcast documentation
- move BroadcastReceiver info to developer guide. see cl/140402421
- add usage note to CONNECTIVITY_ACTION broadcast

bug:32533262
bug:33106411

Change-Id: Ic2aa517831d29418e0c42aa6fc1e7f9aeb50f802
2016-12-13 18:28:32 -08:00
Stephen Chen
757658193d DO NOT MERGE: 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 9369e9d105)

Change-Id: I46da93ba4afa968facf98f7c3d844fd0c469095a
2016-12-09 13:59:33 +09:00
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