Commit graph android_packages_modules_Co.../tests/net/java
Message SHA1
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

Hugo Benichi   commited 2017-05-02 13:31:24 +09:00
f04537fd28
NsdManager: unit tests for argument validation
Test: new tests pass.
Bug: 37013369, 33298084
Change-Id: Ia514d2bbd967d46fed54e379f319b572ade22c62

Hugo Benichi   commited 2017-04-27 16:35:48 +09:00
bad1bfedcd
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

Hugo Benichi   commited 2017-04-27 16:35:30 +09:00
59ade871f8
Merge "NsdService: bootstrap unit tests"
Hugo Benichi   authored and   Gerrit Code Review   commited 2017-04-27 05:22:54 +00:00
0f0ab71fb1
Merge "[AWARE] Add UID checking to WifiAwareNetworkSpecifier"
Etan Cohen   authored and   Gerrit Code Review   commited 2017-04-25 13:21:36 +00:00
7b6ba2b3ea
NsdService: bootstrap unit tests
Test: new tests part of $ runtest frameworks-net
Bug: 37013369, 33298084
Change-Id: Ief45f838268380b4b2a128390fbf34d55a3b922b

Hugo Benichi   commited 2017-04-25 10:42:58 +09:00
91c45e4dbb
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

Hugo Benichi   commited 2017-04-22 10:07:03 +09:00
330ae0ac78
Merge "NsdManager: add unit tests"
Hugo Benichi   authored and   Gerrit Code Review   commited 2017-04-22 00:31:28 +00:00
dc1684ab07
Merge "Mark Restricted APN connections as restricted."
Treehugger Robot   authored and   Gerrit Code Review   commited 2017-04-21 23:12:52 +00:00
a6a4f5589c
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

Robert Greenwalt   commited 2017-04-21 22:00:17 +00:00
1f4578fa86
Merge "Use Vpn rules (not firewall) for always-on VPN"
Treehugger Robot   authored and   Gerrit Code Review   commited 2017-04-21 21:53:15 +00:00
dcb162176e
[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

Etan Cohen   commited 2017-04-21 18:47:35 +00:00
1b6d418785
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

Hugo Benichi   commited 2017-04-21 05:16:37 +00:00
7f792c577a
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

Hugo Benichi   commited 2017-04-14 22:17:21 +09:00
2aa65af966
Merge "Move some NetworkStats tests to tests/net."
Lorenzo Colitti   authored and   Gerrit Code Review   commited 2017-04-13 05:18:47 +00:00
972b2717f5
Merge changes from topic 'network_specifier'
* changes:
  [CM] Unhide the NetworkSpecifier as object API
  Make the NetworkSpecifier a class instead of a string.

Lorenzo Colitti   authored and   Gerrit Code Review   commited 2017-04-12 22:27:37 +00:00
78e38f292d
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

Lorenzo Colitti   commited 2017-04-13 02:38:11 +09:00
4ff3a778ab
Merge "Add an API hint for metered multipath traffic."
Treehugger Robot   authored and   Gerrit Code Review   commited 2017-04-10 05:40:10 +00:00
253efa0a14
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

Hugo Benichi   commited 2017-04-10 13:19:23 +09:00
98607d3f20
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

Lorenzo Colitti   commited 2017-04-06 16:50:06 +09:00
e454b43d3f
Make the NetworkSpecifier a class instead of a string.
Bug: 27533960
Bug: 36053921
Bug: 36275276
Test: connectivity, wifi, telephony unit tests
Change-Id: Idd9b10a8418c53c8cf386d9ff8252226b076bbf9

Etan Cohen   commited 2017-04-05 14:18:20 -07:00
8913454e36
Merge "Add test coverage for NetworkSpecifiers."
am: 9ad085f55f

Change-Id: Ia328b945af4c4f55ef560b33b00fa861b8f81b0d

Lorenzo Colitti   authored and   android-build-merger   commited 2017-04-03 10:45:22 +00:00
3145827105
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

Lorenzo Colitti   commited 2017-04-03 17:46:35 +09:00
8af9dc0d91
Merge "Move some VPN logic out of ConnectivityService"
am: a3cdab05a8

Change-Id: I212c2d6de1676ab65e6bbf34148d66e183d60c62

Robin Lee   authored and   android-build-merger   commited 2017-03-30 16:08:50 +00:00
f2e48204b6
Merge "Move some VPN logic out of ConnectivityService"
Robin Lee   authored and   Gerrit Code Review   commited 2017-03-30 16:00:41 +00:00
a3cdab05a8
Merge changes If94102c7,I8d51e8e0
am: 22b829c049

Change-Id: I8aa529a05fc40241ec9664775ca0ebd8960098a8

Lorenzo Colitti   authored and   android-build-merger   commited 2017-03-28 12:33:28 +00:00
fdad5b79a2
Make ConnectivityServiceTest pass on wifi-only devices.
Test: ConnectivityServiceTest passes on ryu on internal master
Test: ConnectivityServiceTest passes on bullhead
Change-Id: If94102c7df0257ea9e69e72b07a685ae3c2c4022

Lorenzo Colitti   commited 2017-03-28 12:53:06 +09:00
cd447b2cdc
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

Robin Lee   commited 2017-03-27 13:40:51 +01:00
5ac0cc547c
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

Robin Lee   commited 2017-03-27 13:40:51 +01:00
984b5b6000
Merge "request{LinkProperties,NetworkCapabilities} no longer needed"
am: 67a9265809

Change-Id: I79b9323be242ed5d2bf83962f78c613a465a20b8

Erik Kline   authored and   android-build-merger   commited 2017-03-07 13:33:29 +00:00
57c8c6b5f4
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

Erik Kline   commited 2017-03-07 17:18:06 +09:00
26af1d81b3
Merge "Always send all available state when calling onAvailable()."
am: 8fdbb6d6e2

Change-Id: I81e70fecf060a4103b51084a60a32c78f6219f6b

Erik Kline   authored and   android-build-merger   commited 2017-03-07 06:00:09 +00:00
b90963fe4d
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

Erik Kline   commited 2017-03-07 12:57:26 +09:00
99f301bdfd
Merge "Revert "ConnectivityManager: no double NetworkCallback registration" because oit caused regressions http://b/35955593, http://b/35921499."
am: 704520c392

Change-Id: Ia0ae78f8406b81377491407cf5ef8ca339952def

Hugo Benichi   authored and   android-build-merger   commited 2017-03-06 12:30:05 +00:00
e8a3a43193
Revert "ConnectivityManager: no double NetworkCallback registration" because oit caused regressions http://b/35955593, http://b/35921499.
This reverts commit ca4bf6edc3.

Change-Id: I86c07c113f24753be7c977e6d7f570b99391e1b5

Hugo Benichi   commited 2017-03-06 06:16:51 +00:00
1d6742c945
Merge "ConnectivityManager: no double NetworkCallback registration"
am: 06a192fa49

Change-Id: I250fa7d3c5e37a66caa41cc898a44bcb18c9a0c4

Hugo Benichi   authored and   android-build-merger   commited 2017-03-02 08:04:03 +00:00
e71290cc46
ConnectivityManager: no double NetworkCallback registration
Test: new test in ConnectivityManagerTest
Bug: 20701525
Change-Id: I205333d31d43e6e6c7fe704ce63b458065f345ce

Hugo Benichi   commited 2017-03-02 15:19:37 +09:00
ca4bf6edc3
Merge "Also test for additional NetworkCallback calls"
am: dff6c5c30d

Change-Id: I00b3f7be06bde167872d0cdefe940cda5e138846

Erik Kline   authored and   android-build-merger   commited 2017-03-01 11:03:08 +00:00
6978b2427c
Also test for additional NetworkCallback calls
Specifcally:
    - onCapabilitiesChanged
    - onLinkPropertiesChanged
    - onNetworkSuspended

Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
Bug: 32163131

Change-Id: Ie0f7c8ac21313b11980bb335c89ecde6fd8e311c

Erik Kline   commited 2017-03-01 18:24:36 +09:00
4f89af67b2
Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe am: d313f7c9fa
am: 022044ea69

Change-Id: I2ab05143299f13012dc2a88efca52160e08c6d97

Erik Kline   authored and   android-build-merger   commited 2017-02-02 07:32:09 +00:00
47500d9b1b
Merge "Add ConnectivityManager.networkCapabilitiesForType()"
am: c313123afe

Change-Id: I0ad50fbf38f11b383fd889dc598cfddd47051477

Erik Kline   authored and   android-build-merger   commited 2017-02-02 07:22:05 +00:00
d313f7c9fa
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

Erik Kline   commited 2017-02-02 11:07:59 +09:00
ce55eb160d
ConnectivityServiceTest: remove remaining poll loops. am: aebc0598b9 am: 5f807b3b74
am: 87eab8e1c4

Change-Id: I31681e1248721704a9b792962a2ef5955e375e93

Lorenzo Colitti   authored and   android-build-merger   commited 2017-02-01 03:01:52 +00:00
4f71ef3f5d
Remove assertEventuallyTrue as it's unnecessary. am: 4b07a883ca am: c939693265
am: c2279a09bf

Change-Id: Ib16f54aeaa783a6e26a9d80e61388cbd9ecd9bd3

Lorenzo Colitti   authored and   android-build-merger   commited 2017-02-01 03:00:41 +00:00
8183372be8
Rename AvoidBadWifiTracker to MultinetworkPolicyTracker am: ee6c69ecc4 am: 49040a3d5a
am: 5bbbf841eb

Change-Id: I91f1338f3488cfc60eef0c2147aa7b1d61107cdd

Lorenzo Colitti   authored and   android-build-merger   commited 2017-02-01 02:59:42 +00:00
016e4f3a23
Attempt to make waitForIdleHandler reliable. am: 572f1a3185 am: b18bd6bd3d
am: e160fe177d

Change-Id: I2369fbd693b467283232f47703fd471c8ff60c1f

Lorenzo Colitti   authored and   android-build-merger   commited 2017-02-01 02:58:24 +00:00
3c3eddc7ae
ConnectivityServiceTest: remove remaining poll loops.
am: aebc0598b9

Change-Id: I675096683c8ed4bc0e540491c0ff6aa828114313

Lorenzo Colitti   authored and   android-build-merger   commited 2017-02-01 02:39:30 +00:00
5f807b3b74
Remove assertEventuallyTrue as it's unnecessary.
am: 4b07a883ca

Change-Id: Id574b27b40e35fbccac49910867e9735c03118d4

Lorenzo Colitti   authored and   android-build-merger   commited 2017-02-01 02:38:30 +00:00
c939693265
Rename AvoidBadWifiTracker to MultinetworkPolicyTracker
am: ee6c69ecc4

Change-Id: I7615c9128deed7011eb9ab6f2efdcfe2e237a1a5

Lorenzo Colitti   authored and   android-build-merger   commited 2017-02-01 02:37:31 +00:00
49040a3d5a
Attempt to make waitForIdleHandler reliable.
am: 572f1a3185

Change-Id: Id7e23c3a2c885ff239efa577a8d366d3df6ca9a2

Lorenzo Colitti   authored and   android-build-merger   commited 2017-02-01 02:36:22 +00:00
b18bd6bd3d