157 Commits

Author SHA1 Message Date
Hugo Benichi
93f4591684 NsdManager: add test coverage for discoverServices()
Test: added new tests
Bug: 37013369, 33298084
Change-Id: If6c1113ee1bd4690db90abd5a61c3e229c827aec
2017-05-02 15:26:33 +09:00
Hugo Benichi
8c5eeb0afc NsdManager: unit test coverage for servive registration
This patch adds test coverage for NsdManager#registerService() and
NsdManager#unregisterService(). This test shows a potential defect in
the api: if unregisterService() fails, the associated listener is always
unregistered from NsdManager. If the service initially registered is
still registered, this potentially make it impossible to unregister.

Test: added new unit test
Bug: 37013369, 33298084
Change-Id: Ia089b6d2f2a349907a8b29d9a3acd7f59e177887
2017-05-02 13:31:24 +09:00
Hugo Benichi
52d9e733ae NsdManager: unit tests for argument validation
Test: new tests pass.
Bug: 37013369, 33298084
Change-Id: Ia514d2bbd967d46fed54e379f319b572ade22c62
2017-04-27 16:35:48 +09:00
Hugo Benichi
1fac3191c7 NsdService: disentangle NativeDaemonConnector from ctor
This patch disentangles the creation of NativeDaemonConnector from the
creation of NsdService by introducing a wrapper type DaemonConnection.

This allows to mock this dependency in unit tests.

Test: enhanced previously introduced new tests.
Bug: 37013369, 33298084
Change-Id: I894b7cddfc509f86d0134d214c88c063b81b5e0a
2017-04-27 16:35:30 +09:00
Hugo Benichi
7ca060aa95 Merge "NsdService: bootstrap unit tests" 2017-04-27 05:22:54 +00:00
Etan Cohen
2fd19ffa06 Merge "[AWARE] Add UID checking to WifiAwareNetworkSpecifier" 2017-04-25 13:21:36 +00:00
Hugo Benichi
cbb13672bc NsdService: bootstrap unit tests
Test: new tests part of $ runtest frameworks-net
Bug: 37013369, 33298084
Change-Id: Ief45f838268380b4b2a128390fbf34d55a3b922b
2017-04-25 10:42:58 +09:00
Hugo Benichi
495a17b332 Move byte logics from ApfFilter into BitsUtil
This patch extracts into BitUtils byte manipulation helper methods
and unsigned type manipulation helper methods from ApfFilter into
an independent and reusable structure.

Test: $ runtest frameworks-net
Change-Id: I0f33af10457a63dbde5983f14353a79b8cd877d9
2017-04-22 10:07:03 +09:00
Hugo Benichi
dc54ad7fc3 Merge "NsdManager: add unit tests" 2017-04-22 00:31:28 +00:00
Treehugger Robot
b90b2015d3 Merge "Mark Restricted APN connections as restricted." 2017-04-21 23:12:52 +00:00
Robert Greenwalt
a7e148a874 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
Merged-In: I7b7a1c38621ce0ecde8cf041e82b1ebb7a9c6f15
Test: new NetworkCapabilitiesTest.  Fails without fix, works with.
Change-Id: I86c1b2854413a94662aa53e697d32380695ab9ac
2017-04-21 22:00:17 +00:00
Treehugger Robot
e4f56a7e44 Merge "Use Vpn rules (not firewall) for always-on VPN" 2017-04-21 21:53:15 +00:00
Etan Cohen
859748f08c [AWARE] Add UID checking to WifiAwareNetworkSpecifier
Wifi Aware networks are per app - i.e. a requestor gets
a dedicated network. Change verifies that the only the
original requestor matches the created network (using UID).

Bug: 36053921
Test: Integration (sl4a) tests
Change-Id: I4ff3994731dd7ccb88e2bea333d1e6905b136f02
2017-04-21 18:47:35 +00:00
Hugo Benichi
db8adb7983 NsdManager: add unit tests
This prepares some refactoring and the addition of a timeout to
resolveService.

Test: new tests pass
Bug: 37013369, 33298084
Change-Id: Ie8277bd5983278507bfa70495b4ce7d13895b24b
2017-04-21 05:16:37 +00:00
Erik Kline
ca41be796a Clarify IControlsTethering LOCAL_ONLY state name
Test: as follows
    - build
    - flashed
    - booted
    - "runtest frameworks-net" passes
    - manually starting tethering shows Settings and icon updates
Bug: 31466854
Bug: 32163131

Change-Id: I1f45511f00aca37480f894be4a9a004f1a3b35d7
2017-04-21 11:12:24 +09:00
Treehugger Robot
275edcb940 Merge "Switch to WifiManager.{start,stop}SoftAp()" 2017-04-20 15:37:31 +00:00
Erik Kline
8351faa900 Add local-only hotspot info into tether state change broadcast
Test: as follows
    - build
    - flashed
    - booted
    - "runtest frameworks-net" passes
    - manually starting tethering shows Settings and icon updates
Bug: 31466854
Bug: 32163131

Change-Id: I938074587dfeec221c5cdb43a392802ad3fc3589
2017-04-20 19:44:01 +09:00
Erik Kline
ceb54c63dc Switch to WifiManager.{start,stop}SoftAp()
Test: as follows
    - built
    - flashed
    - booted
    - "runtest frameworks-net" passes
Bug: 31466854

Change-Id: I730d029128a14b936c111ae159b9708d935f4656
2017-04-18 15:22:49 +09:00
Hugo Benichi
dafed3d008 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
Treehugger Robot
0ef8df6d52 Merge "Extract SimChangeListener to its own file" 2017-04-13 08:19:07 +00:00
Lorenzo Colitti
ab3901dc8b Merge "Move some NetworkStats tests to tests/net." 2017-04-13 05:18:47 +00:00
Lorenzo Colitti
d0f476bdae 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
c86013be93 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
Erik Kline
227648f336 Extract SimChangeListener to its own file
Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
    - runtest -x full/path/to/SimChangeListenerTest.java passes
Bug: 32163131
Change-Id: If90539fe9a5dc07c7c24ed0b70b920d94065a623
2017-04-12 15:57:49 +09:00
Erik Kline
ea9cc488eb Tethering: support Local-only Hotspot mode for downstreams
Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - "runtest frameworks-net" passes
Bug: 31466854

Change-Id: Ia50e28c8ce0af8cdd7ac63217d921aff213668e7
2017-04-10 19:11:08 +09:00
Treehugger Robot
7a12f7efc7 Merge "Add an API hint for metered multipath traffic." 2017-04-10 05:40:10 +00:00
Hugo Benichi
fa0dadc540 DO NOT MERGE IP connectivity metrics: fix tests.
This patch fixes mismatch between current proto compiler and what is
expected in several IP connectivity metrics unit tests.

Test: built, flashed, $ runtest frameworks-net
Bug: 37126521
Change-Id: I1476c923d61f748ecac1146423127f54ba117502
2017-04-10 13:19:23 +09:00
Lorenzo Colitti
46aa9c022e 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 2de4925f5cc64aeb92e02a8f740d3ff20f36dddd)

Test: builds, boots, runtest frameworks-net passes.
Bug: 34630278
Change-Id: Ic7fd0b9e1cd879fdfaf84009d7125391895e9087
2017-04-06 16:50:06 +09:00
Etan Cohen
a743427896 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
Lorenzo Colitti
0e068f6360 Merge "Add test coverage for NetworkSpecifiers."
am: 9a029b5262

Change-Id: Ia328b945af4c4f55ef560b33b00fa861b8f81b0d
2017-04-03 10:45:22 +00:00
Lorenzo Colitti
6556a220d7 Add test coverage for NetworkSpecifiers.
Tests various combinations of empty / non-empty NetworkSpecifiers
and changing specifiers on the fly.

Test: ConnectivityServiceTest passes
Bug: 27533960
Change-Id: Ibd6b4efc861dc51689e46f3882ba859223411bf0
2017-04-03 17:46:35 +09:00
Robin Lee
e61a30f635 Merge "Move some VPN logic out of ConnectivityService"
am: ec86462033

Change-Id: I212c2d6de1676ab65e6bbf34148d66e183d60c62
2017-03-30 16:08:50 +00:00
Robin Lee
ec86462033 Merge "Move some VPN logic out of ConnectivityService" 2017-03-30 16:00:41 +00:00
Lorenzo Colitti
0a34afb48d Merge changes If94102c7,I8d51e8e0
am: 22b829c049

Change-Id: I8aa529a05fc40241ec9664775ca0ebd8960098a8
2017-03-28 12:33:28 +00:00
Lorenzo Colitti
42cdf57703 Make ConnectivityServiceTest pass on wifi-only devices.
Test: ConnectivityServiceTest passes on ryu on internal master
Test: ConnectivityServiceTest passes on bullhead
Change-Id: If94102c7df0257ea9e69e72b07a685ae3c2c4022
2017-03-28 12:53:06 +09:00
Robin Lee
c3736bc10d Use Vpn rules (not firewall) for always-on VPN
Firewall rules don't work on 464xlat because they were created under
an assumption that there's only one address for the server and it's
ipv4, which doesn't go so well when we're on an ipv6-only network.

Bug: 33159037
Test: runtest -x net/java/com/android/server/connectivity/VpnTest.java
Change-Id: Id331526367fe13838874961da194b07bd50d4c97
2017-03-27 13:40:51 +01:00
Robin Lee
b8c2a2b850 Move some VPN logic out of ConnectivityService
This cleanup helps declutter ConnectivityService, and encapsulates the
always-on setting inside of Vpn instead of spreading it across two
classes.

In particular having the save code in one file and the load code in
another file was weird and I apologise for that.

Added a SystemServices wrapper for Settings.Secure and PendingIntent
calls to decouple some of the global state nastiness and make it
testable without forcing ConnectivityService to drive the load/save.

Test: runtest -x tests/net/java/com/android/server/ConnectivityServiceTest.java
Test: runtest -x tests/net/java/com/android/server/connectivity/VpnTest.java
Bug: 33159037
Change-Id: Ie2adb1c377adfcef0a5900dc866e6118f451b265
2017-03-27 13:40:51 +01:00
Erik Kline
dea2371e71 Merge "Address some comments on IpManagerTest"
am: b2afa1ede5

Change-Id: Ic986c23c693757b8311e0de0c0a94281db67f62d
2017-03-14 06:08:34 +00:00
Erik Kline
246bc1f795 Address some comments on IpManagerTest
Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
Bug: 26991160
Change-Id: Ib543874188537e31422206d67d1760762a7c85cd
2017-03-14 13:02:49 +09:00
Erik Kline
cf07e0d541 Merge "Skeleton of an IpManagerTest"
am: db4333a2c2

Change-Id: I5817c2458c222afb85389deaf22b43d245577b2a
2017-03-14 03:11:15 +00:00
Erik Kline
aa95ae57ec Skeleton of an IpManagerTest
Test: as follows
    - biult (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
Bug: 26991160
Change-Id: Idddddf0c1a7a8d0a8acff8a5526b02a533d5f3ec
2017-03-14 10:19:52 +09:00
Erik Kline
0f901af920 Merge "request{LinkProperties,NetworkCapabilities} no longer needed"
am: 75dfc5bd91

Change-Id: I79b9323be242ed5d2bf83962f78c613a465a20b8
2017-03-07 13:33:29 +00:00
Erik Kline
465c46d555 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
e0a62a4398 Merge "Always send all available state when calling onAvailable()."
am: affbb8b6a9

Change-Id: I81e70fecf060a4103b51084a60a32c78f6219f6b
2017-03-07 06:00:09 +00:00
Erik Kline
c75d4fad22 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
4cf199383f 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
649e32484e Revert "ConnectivityManager: no double NetworkCallback registration" because oit caused regressions http://b/35955593, http://b/35921499.
This reverts commit faa70976b490116323107166f90fdd944c5bdc77.

Change-Id: I86c07c113f24753be7c977e6d7f570b99391e1b5
2017-03-06 06:16:51 +00:00
Hugo Benichi
5983a772cb Merge "ConnectivityManager: no double NetworkCallback registration"
am: 06a192fa49

Change-Id: I250fa7d3c5e37a66caa41cc898a44bcb18c9a0c4
2017-03-02 08:04:03 +00:00
Hugo Benichi
faa70976b4 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
47d8385184 Merge "Also test for additional NetworkCallback calls"
am: dff6c5c30d

Change-Id: I00b3f7be06bde167872d0cdefe940cda5e138846
2017-03-01 11:03:08 +00:00