Commit Graph

1107 Commits

Author SHA1 Message Date
Robert Greenwalt
7316f068a7 Mark Restricted APN connections as restricted.
If anything unrestricted is bundled in the whole thing has to be
unrestricted (we can't restrict based on destination or intent)
but the NOT_METERED flag wasn't taken into account.

This wasn't a problem before because telephony set that statically
and late, but a change caused it to be marked NOT_METERED earlier
which exposed this bug.

bug: 37208956
Test: new NetworkCapabilitiesTest.  Fails without fix, works with.
Change-Id: I7b7a1c38621ce0ecde8cf041e82b1ebb7a9c6f15
2017-04-18 11:29:20 -07:00
Hugo Benichi
82ed0de810 Merge "ConnectivityManager: release all requests mapping to a callback." am: 1a8f04b1b2 am: 4d80366762
am: e505b37ec5

Change-Id: I99267e14ab04ce62c5c2385f24f5865e791a24a0
2017-04-14 15:36:10 +00:00
Hugo Benichi
2aa65af966 ConnectivityManager: release all requests mapping to a callback.
This patch changes how callback unregistration works in order to be
consistent with undocumented use cases currently de-facto supported
by the API (although in a buggy way):
  - callback recycling: releasing then reregistering a callback again.
  - multiple request registrations with the same callback.

The second use case is not desirable but needs to be taken into account
for now for the purpose of correctly releasing NetworkRequests
registered in ConnectivityService.

In order to support request release in both use cases with minimal
amount of complexity for the time being the following changes are done:
  - request to callback unmapping is done synchronously at callback
    release time.
  - all requests associated to a callback are unmapped at callback
    release time.

This fixes the following issues:
  - a callback stops being triggered as soon as it is released.
    Otherwise when recycling the callback immediately, it is possible
    the previous request associated with it triggers it, confusing the
    app.
  - when a callback is registered multiple times, the requests are not
    leaked.
  - when a callback is registered multiple times and then released, the
    N-1 first registrations do not trigger the callback anymore.

In the future it would be desirable to enforce the intended 1:1 mapping
between callbacks and requests at registration time.

Bug: 35921499, 35955593, 20701525
Test: - added new tests in ConnectivityManagerTest to test releasing,
      recycling, and a disabled test for no multiple regristration.
      - new tests catch regression causing b/35921499, b/35955593.
Change-Id: Ia0917ac322fc049f76adb4743bc745989fed6d26
2017-04-14 22:17:21 +09:00
Etan Cohen
fedaf00fa3 [CM] Unhide the NetworkSpecifier as object API
API visibility change: unhide allowing NetworkSpecifier
to be an arbitrary object.

Bug: 27533960
Bug: 36053921
Bug: 36275276
Test: builds and runs
Change-Id: I1d1705cca7ece077ef8d7c674c62d5369fedbb03
Merged-In: I7535495681da8f168c46d6d95e13925cffecc99b
Merged-In: I6500639ae839ee9ad5af34d1292d1539c943e2ad
2017-04-14 18:23:45 +09:00
Etan Cohen
6c2ab24a4c Make the NetworkSpecifier a class instead of a string.
Bug: 27533960
Bug: 36053921
Bug: 36275276
Test: connectivity, wifi, telephony unit tests
Change-Id: Idd9b10a8418c53c8cf386d9ff8252226b076bbf9
Merged-In: I7535495681da8f168c46d6d95e13925cffecc99b
Merged-In: I6500639ae839ee9ad5af34d1292d1539c943e2ad
2017-04-14 18:22:10 +09:00
Lorenzo Colitti
dfa91739a6 resolve merge conflicts of 4db137b0599a to oc-dev-plus-aosp
Test: builds
Change-Id: I786ece9b82e47691855c8549e174345080964b91
2017-04-14 11:37:12 +09:00
Hugo Benichi
45670bb37d Connectivity metrics: add transports pretty printing
This patch also
  - partially reverts commit 7f818778a8
    that exposed a getTransports method on NetworkCapabilities.
  - moves enumerateBits to BitUtils (as unpackBits), and adds the
    reverse packBit method.

Bug: 34901696
Test: manually looked at $ adb shell dumpsys connmetrics list
Change-Id: I1650daf8fc9c1b6e0d986d2285f81e888be8847f
Merged-In: Id04f9080e7f75608deeb49306aec34941e71794c

(cherry picked from commit df456e13a1127e3c8594b1d22ea4a9b3dca67a4b)
2017-04-13 22:17:50 +00:00
Lorenzo Colitti
211d434588 Merge "Move some NetworkStats tests to tests/net." am: 972b2717f5 am: 67401e25c2
am: 997e6b085a

Change-Id: I37c1d362d891ec3b09b00df44aaf233adf355077
2017-04-13 05:48:37 +00:00
Lorenzo Colitti
972b2717f5 Merge "Move some NetworkStats tests to tests/net." 2017-04-13 05:18:47 +00:00
Lorenzo Colitti
05a404cea0 Merge changes from topic 'network_specifier' am: 78e38f292d am: 362bef45d1
am: cfd729093f

Change-Id: I7535495681da8f168c46d6d95e13925cffecc99b
2017-04-12 22:58:42 +00:00
Lorenzo Colitti
78e38f292d Merge changes from topic 'network_specifier'
* changes:
  [CM] Unhide the NetworkSpecifier as object API
  Make the NetworkSpecifier a class instead of a string.
2017-04-12 22:27:37 +00:00
Lorenzo Colitti
4ff3a778ab Move some NetworkStats tests to tests/net.
This groups them together with the rest of the networking unit
tests. It also speeds up compile/test cycles ("runtest -x" of one
file goes from 1m15s to 30s).

Test: runtest frameworks-net passes on internal tree
Change-Id: I53cb0c51355fe4b4b30e451fa09fbbf58da39efd
2017-04-13 02:38:11 +09:00
Lorenzo Colitti
e454b43d3f 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.

(cherry picked from commit 48a2a32bdd)

Test: builds, boots, runtest frameworks-net passes.
Bug: 34630278
Change-Id: Ic7fd0b9e1cd879fdfaf84009d7125391895e9087
2017-04-06 16:50:06 +09:00
Etan Cohen
1dee8d4d74 [CM] Unhide the NetworkSpecifier as object API
API visibility change: unhide allowing NetworkSpecifier
to be an arbitrary object.

Bug: 27533960
Bug: 36053921
Bug: 36275276
Test: builds and runs
Change-Id: I1d1705cca7ece077ef8d7c674c62d5369fedbb03
2017-04-05 21:16:18 -07:00
Etan Cohen
8913454e36 Make the NetworkSpecifier a class instead of a string.
Bug: 27533960
Bug: 36053921
Bug: 36275276
Test: connectivity, wifi, telephony unit tests
Change-Id: Idd9b10a8418c53c8cf386d9ff8252226b076bbf9
2017-04-05 14:18:20 -07:00
Hugo Benichi
7f818778a8 Connectivity metrics: add transports to validation probes
This patch adds transports info to ValidationProbeEvent and migrates
netId logging for this event to the topt-level netId field in
ConnectivityMetricsEvent.

Test: modified unit tests. $ runtest frameworks-net passes
Bug: 3490169
Change-Id: Ibf51049ba8901ae5ca4ea86e2f500944a4738b5c
2017-03-21 11:43:18 +09:00
Hugo Benichi
45f6ef836d Connectivity metrics: serialize networkId, transports, ifname
This patch adds translation from ConnectivityMetricsEvent to
IpConnectivityEvent of recently added fields:
 - top-level network id
 - top-level ifname
 - transports

Also adds inference of link layer from transports or ifname.

At the moment these new fields are not populated in
ConnectivityMetricsEvent. Follow-up patches will fill this gap for
the events of the android.net.metrics package.

Test: new unit tests, $ runtest frameworks-net passes
Bug: 34901696
Change-Id: I563a6a3183470bdfaabb7c781a1beaf6b1058bf0
2017-03-21 10:18:11 +09:00
Hugo Benichi
4e4731baee Merge "ConnectivityManager: unhide methods with Handler argument" am: 0ba4ca681b am: b4db58d5c8
am: 1673f71afb

Change-Id: Ic575f187803548ce15965d6fde942a5322d9e35e
2017-03-13 07:18:54 +00:00
Hugo Benichi
b4db58d5c8 Merge "ConnectivityManager: unhide methods with Handler argument"
am: 0ba4ca681b

Change-Id: I470d68a25e62b9493ac7cfb5887e8345968f1097
2017-03-13 07:09:49 +00:00
Hugo Benichi
51a5826b2e ConnectivityManager: unhide methods with Handler argument
Test: no functionality change
Bug: 32130437
Change-Id: I2a57175142683f991a215b584282db143a76ed9d
2017-03-09 15:25:26 +09:00
Etan Cohen
61d46aad9e Merge "[CM] Allow timeout in request network" am: 43d964ac8f am: 24c862dad6
am: ac879cbcaf

Change-Id: If42250966d619073d45d608aab454589213b1756
2017-03-07 17:02:05 +00:00
Etan Cohen
24c862dad6 Merge "[CM] Allow timeout in request network"
am: 43d964ac8f

Change-Id: Ic7a3da0a5292be5e13abca9c98c422bc2f50f3a0
2017-03-07 16:49:53 +00:00
Etan Cohen
43d964ac8f Merge "[CM] Allow timeout in request network" 2017-03-07 16:40:27 +00:00
Erik Kline
2b1df53310 Merge "request{LinkProperties,NetworkCapabilities} no longer needed" am: 67a9265809 am: 57c8c6b5f4
am: bb54baba04

Change-Id: Id2aa8aeff6d299edb85955c12ab0a04023458597
2017-03-07 13:42:11 +00:00
Erik Kline
57c8c6b5f4 Merge "request{LinkProperties,NetworkCapabilities} no longer needed"
am: 67a9265809

Change-Id: I79b9323be242ed5d2bf83962f78c613a465a20b8
2017-03-07 13:33:29 +00:00
Erik Kline
26af1d81b3 request{LinkProperties,NetworkCapabilities} no longer needed
Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
    - manual USB tethering toggling between WiFi and mobile
Bug: 32163131
Change-Id: I57edf5114b6361f320577c7870e40f8b3cdf74ce
2017-03-07 17:18:06 +09:00
Erik Kline
0fd4b155a5 Merge "Always send all available state when calling onAvailable()." am: 8fdbb6d6e2 am: b90963fe4d
am: 3765538bab

Change-Id: Ic82e3cb92841ea99972faad6ae004d77c725831b
2017-03-07 06:08:40 +00:00
Erik Kline
b90963fe4d Merge "Always send all available state when calling onAvailable()."
am: 8fdbb6d6e2

Change-Id: I81e70fecf060a4103b51084a60a32c78f6219f6b
2017-03-07 06:00:09 +00:00
Erik Kline
99f301bdfd Always send all available state when calling onAvailable().
The state that needs to be transferred includes:
    - NetworkCapabilities
    - LinkProperties
    - whether the network is currently suspended

Additionally:
    - Rename notifyNetworkCallback() to notifyNetworkAvailable()
      in order to clarify its real function.
    - fix previous copy/paste error in unittest

Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
    - USB tethering with mobile and Wi-Fi upstream toggling
Bug: 32163131
Change-Id: Ib4460bcd5d08863a9feac9e8ab41a238897bb3ea
2017-03-07 12:57:26 +09:00
Hugo Benichi
ca809f4260 Merge "Revert "ConnectivityManager: no double NetworkCallback registration" because oit caused regressions http://b/35955593, http://b/35921499." am: 704520c392 am: e8a3a43193
am: 22d4258a75

Change-Id: I8e66e223003a38735b707d21d7bedb19170b1937
2017-03-06 12:45:10 +00:00
Hugo Benichi
e8a3a43193 Merge "Revert "ConnectivityManager: no double NetworkCallback registration" because oit caused regressions http://b/35955593, http://b/35921499."
am: 704520c392

Change-Id: Ia0ae78f8406b81377491407cf5ef8ca339952def
2017-03-06 12:30:05 +00:00
Hugo Benichi
1d6742c945 Revert "ConnectivityManager: no double NetworkCallback registration" because oit caused regressions http://b/35955593, http://b/35921499.
This reverts commit ca4bf6edc3.

Change-Id: I86c07c113f24753be7c977e6d7f570b99391e1b5
2017-03-06 06:16:51 +00:00
Etan Cohen
f67bde923c [CM] Allow timeout in request network
Add (unhide) a public API which provides network requests with a
timeout. When timed-out the (newly unhidden) onUnavailable() callback
is triggered.

Note: this CL does not add a handler to the API to be consistent
with the existing APIs. There is a separate effort (b/32130437)
to update these APIs with Handlers.

Bug: 31399536
Test: unit tests and CTS (new)
Change-Id: I45ce9ada63372cb56937bb620bfbb7729e5e25d2
2017-03-02 08:06:27 -08:00
Hugo Benichi
a5dd9aba90 Merge "ConnectivityManager: no double NetworkCallback registration" am: 06a192fa49 am: e71290cc46
am: 974e83cc0b

Change-Id: I73569fd084c14a78067e09565418f296994cd424
2017-03-02 08:12:09 +00:00
Hugo Benichi
e71290cc46 Merge "ConnectivityManager: no double NetworkCallback registration"
am: 06a192fa49

Change-Id: I250fa7d3c5e37a66caa41cc898a44bcb18c9a0c4
2017-03-02 08:04:03 +00:00
Hugo Benichi
ca4bf6edc3 ConnectivityManager: no double NetworkCallback registration
Test: new test in ConnectivityManagerTest
Bug: 20701525
Change-Id: I205333d31d43e6e6c7fe704ce63b458065f345ce
2017-03-02 15:19:37 +09:00
Erik Kline
2762541780 Merge "Update UpstreamNetworkMonitor to use custom Handlers" am: 35c89886c2 am: baaa19d65a
am: c239511cdb

Change-Id: I9a210b4896810e7365b2403495716395b3866650
2017-02-24 08:24:51 +00:00
Erik Kline
baaa19d65a Merge "Update UpstreamNetworkMonitor to use custom Handlers"
am: 35c89886c2

Change-Id: I76433822a9b7c124e4b7cfcf2a20cb0e43a60199
2017-02-24 08:15:19 +00:00
Erik Kline
7807ff12af Update UpstreamNetworkMonitor to use custom Handlers
Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
Bug: 32130437
Bug: 32163131

Change-Id: I2bc3f87cdf7fa6392b4750eb8adb4ea33c6a3f43
2017-02-24 13:06:51 +09:00
Hugo Benichi
8f5e49bbe3 Merge "ConnectivityManager: allow custom Handlers" am: ef69246260 am: 585855decf
am: 0f99e5367b

Change-Id: I9f7fc64c2d3d6f88344c9547b8e1ac17cf3d1104
2017-02-22 05:59:44 +00:00
Hugo Benichi
585855decf Merge "ConnectivityManager: allow custom Handlers"
am: ef69246260

Change-Id: I8da5540f6561cdef4adc91bbeeb9c21a91c08d49
2017-02-22 03:48:10 +00:00
Hugo Benichi
fd44e91bcb ConnectivityManager: allow custom Handlers
This patch adds overloaded version of registerDefaultNetworkCallback
registerNetworkCallback, and requestNetwork with an additional Handler
argument that is used for running the caller provided NetworkCallback.

It also clarifies the documentation of the existing methods that
implicitly uses the internal singleton ConnectivityThread about which
internal Handler is used for running NetworkCallbacks.

Test: build, flashed, booted device
Bug: 32130437
Change-Id: Iae15f81e47e2dc0355baf2f2c1679b77e56af299
2017-02-22 09:24:01 +09:00
Etan Cohen
e4d934db90 Merge changes from topic 'cm_request_to' am: d6877b2576 am: 0a8122afa9 am: 6e3ea85738
am: a8bb0c7fdd

Change-Id: I2cef23ff183428041273007cf9bb1b655f92372a
2017-02-16 14:46:52 +00:00
Etan Cohen
a8bb0c7fdd Merge changes from topic 'cm_request_to' am: d6877b2576 am: 0a8122afa9
am: 6e3ea85738

Change-Id: Ief32189b0f6f2c70d7e4097f70dbdf8195bd8713
2017-02-16 14:38:28 +00:00
Etan Cohen
6e3ea85738 Merge changes from topic 'cm_request_to' am: d6877b2576
am: 0a8122afa9

Change-Id: I2720e64e4af88df9d3a7b6209e9fcef4a0340986
2017-02-16 14:29:29 +00:00
Etan Cohen
d6877b2576 Merge changes from topic 'cm_request_to'
* changes:
  [CM] Remove maximum timeout value for request network
  [CM] Remove non-functional timeout from request network
2017-02-16 14:15:44 +00:00
Etan Cohen
8500016ea4 [CM] Remove maximum timeout value for request network
The request network with timeout was originally created with a
check of max timeout against a constant of 100 minutes. However,
the API was not public and did not implement a timeout. Any users
were internal and never got any onUnavailable() callback (since
timeout never triggered).

There is no reason to have a max timeout so the constant is
remove.

Bug: 31399536
Test: unit tests and CTS of ConnectivityManager
Change-Id: Icbedfb4299d75b6a7e3e43720111531f1faafd06
2017-02-16 14:15:16 +00:00
Hugo Benichi
6987c7d743 Merge "ConnectivityManager: fix potential NPE" am: b688dd18ab am: 95d22b0c92 am: 3b0915b6f5
am: 47be55d3ec

Change-Id: I628fdf36a5a80a2d93ff4c4785253cb16a9e4ad2
2017-02-15 01:29:31 +00:00
Hugo Benichi
47be55d3ec Merge "ConnectivityManager: fix potential NPE" am: b688dd18ab am: 95d22b0c92
am: 3b0915b6f5

Change-Id: I6f487ce9da656610c939ddc78e834ac8ef5f8135
2017-02-15 01:24:29 +00:00
Hugo Benichi
3b0915b6f5 Merge "ConnectivityManager: fix potential NPE" am: b688dd18ab
am: 95d22b0c92

Change-Id: I72e114037ce6a0ec53863749b8ffa34513c9fdce
2017-02-15 01:09:58 +00:00