Commit Graph

70 Commits

Author SHA1 Message Date
Etan Cohen
1b6d418785 [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
Lorenzo Colitti
972b2717f5 Merge "Move some NetworkStats tests to tests/net." 2017-04-13 05:18:47 +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
Treehugger Robot
253efa0a14 Merge "Add an API hint for metered multipath traffic." 2017-04-10 05:40:10 +00:00
Hugo Benichi
98607d3f20 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
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
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
Lorenzo Colitti
3145827105 Merge "Add test coverage for NetworkSpecifiers."
am: 9ad085f55f

Change-Id: Ia328b945af4c4f55ef560b33b00fa861b8f81b0d
2017-04-03 10:45:22 +00:00
Lorenzo Colitti
8af9dc0d91 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
f2e48204b6 Merge "Move some VPN logic out of ConnectivityService"
am: a3cdab05a8

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

Change-Id: I8aa529a05fc40241ec9664775ca0ebd8960098a8
2017-03-28 12:33:28 +00:00
Lorenzo Colitti
cd447b2cdc 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
984b5b6000 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
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
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
Erik Kline
6978b2427c Merge "Also test for additional NetworkCallback calls"
am: dff6c5c30d

Change-Id: I00b3f7be06bde167872d0cdefe940cda5e138846
2017-03-01 11:03:08 +00:00
Erik Kline
4f89af67b2 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
2017-03-01 18:24:36 +09:00
Lorenzo Colitti
4f71ef3f5d ConnectivityServiceTest: remove remaining poll loops. am: aebc0598b9 am: 5f807b3b74
am: 87eab8e1c4

Change-Id: I31681e1248721704a9b792962a2ef5955e375e93
2017-02-01 03:01:52 +00:00
Lorenzo Colitti
8183372be8 Remove assertEventuallyTrue as it's unnecessary. am: 4b07a883ca am: c939693265
am: c2279a09bf

Change-Id: Ib16f54aeaa783a6e26a9d80e61388cbd9ecd9bd3
2017-02-01 03:00:41 +00:00
Lorenzo Colitti
016e4f3a23 Rename AvoidBadWifiTracker to MultinetworkPolicyTracker am: ee6c69ecc4 am: 49040a3d5a
am: 5bbbf841eb

Change-Id: I91f1338f3488cfc60eef0c2147aa7b1d61107cdd
2017-02-01 02:59:42 +00:00
Lorenzo Colitti
3c3eddc7ae Attempt to make waitForIdleHandler reliable. am: 572f1a3185 am: b18bd6bd3d
am: e160fe177d

Change-Id: I2369fbd693b467283232f47703fd471c8ff60c1f
2017-02-01 02:58:24 +00:00
Lorenzo Colitti
5f807b3b74 ConnectivityServiceTest: remove remaining poll loops.
am: aebc0598b9

Change-Id: I675096683c8ed4bc0e540491c0ff6aa828114313
2017-02-01 02:39:30 +00:00
Lorenzo Colitti
c939693265 Remove assertEventuallyTrue as it's unnecessary.
am: 4b07a883ca

Change-Id: Id574b27b40e35fbccac49910867e9735c03118d4
2017-02-01 02:38:30 +00:00
Lorenzo Colitti
49040a3d5a Rename AvoidBadWifiTracker to MultinetworkPolicyTracker
am: ee6c69ecc4

Change-Id: I7615c9128deed7011eb9ab6f2efdcfe2e237a1a5
2017-02-01 02:37:31 +00:00
Lorenzo Colitti
b18bd6bd3d Attempt to make waitForIdleHandler reliable.
am: 572f1a3185

Change-Id: Id7e23c3a2c885ff239efa577a8d366d3df6ca9a2
2017-02-01 02:36:22 +00:00
Lorenzo Colitti
aebc0598b9 ConnectivityServiceTest: remove remaining poll loops.
All the tests are now asynchronous. The only remaining uses of
Thread.sleep() are in the tests that check for NetworkRequest
timeouts.

Test: ConnectivityServiceTest passes 100 times in a row
Bug: 32561414
Change-Id: If420bd66c692a90d5031ee06a888a8cc3b4398a8
2017-01-31 15:44:23 +09:00
Lorenzo Colitti
4b07a883ca Remove assertEventuallyTrue as it's unnecessary.
The calls in testAvoidBadWifi are no longer necessary now that
waitForIdle is reliable, and the calls in testPacketKeepalives
are replaced with a wait for the NetworkAgent to disconnect.

Test: ConnectivityServiceTest passes 100 times in a row.
Bug: 32561414
Change-Id: Icbb161ca6e343bd14764a1c9ccfdd14b6cd6803f
2017-01-31 15:42:58 +09:00
Lorenzo Colitti
ee6c69ecc4 Rename AvoidBadWifiTracker to MultinetworkPolicyTracker
Rename the class and ensure that all code related to bad wifi
avoidance has names that reflect its purpose.  This will allow us
to reuse most of the the code for other purposes in future CLs.

Test: runtest frameworks-net passes
Bug: 34630278
Change-Id: Ida190e5a79e7a12f4eec07e1a3e4d9d138e83bcd
2017-01-31 15:42:57 +09:00
Lorenzo Colitti
572f1a3185 Attempt to make waitForIdleHandler reliable.
The current implementation of IdleableHandlerThread is based on
the assumption that MessageQueue#isIdle will return true iff the
message loop has finished processing its messages.

Unfortunately, this is incorrect: isIdle returns true iff are no
more messages waiting in the queue; thus, it will also return
true while it is processing the last message before going idle.

Instead of using idle handlers, take the simpler approach of
posting a runnable to the message loop and waiting for it to
be processed.

Test: see other CLs in this patch series
Bug: 31479480
Change-Id: Iae75781f067b762c8653a488a5e4d5ee0c789e01
2017-01-31 15:42:17 +09:00
Lorenzo Colitti
ad488d0158 Merge "ConnectivityServiceTest: fix flaky tests" am: ee4f8f30eb am: 96a8a237b0
am: 1adc6c2054

Change-Id: Iaa1ab50a323133cadfa4f39440fce982cde8d1fe
2017-01-27 10:00:06 +00:00
Lorenzo Colitti
822ca7bd3e Merge "ConnectivityServiceTest: remove flaky waitForIdle test." am: be80577f5b am: cdbf1e7545
am: 9d250413a0

Change-Id: I1d3707b4bc2ae00ca0fad1c3ec7e6ca859fcdd16
2017-01-27 09:55:36 +00:00
Lorenzo Colitti
96a8a237b0 Merge "ConnectivityServiceTest: fix flaky tests"
am: ee4f8f30eb

Change-Id: I0577f6b48de8a95e7d12e58a672fb0374ced9403
2017-01-27 09:51:32 +00:00
Lorenzo Colitti
cdbf1e7545 Merge "ConnectivityServiceTest: remove flaky waitForIdle test."
am: be80577f5b

Change-Id: I444746af6adc7be4a3f69243379f65aadf29ea19
2017-01-27 09:47:05 +00:00
Lorenzo Colitti
ee4f8f30eb Merge "ConnectivityServiceTest: fix flaky tests" 2017-01-27 09:40:47 +00:00
Hugo Benichi
621d836cbb frameworks-test: adding missing @SmallTest
This activates all frameworks-test tests in runs of the continuous
platform tests.

Test: $ runtest frameworks-net passes (expect Tether
Bug: 32561414
(cherry picked from commit 3664598601)

Change-Id: I7b0706a7e3368f971d508388e8ad4afc5de9d646
2017-01-26 18:52:45 +09:00
Hugo Benichi
25aed49de6 Netd events: record connect() success/errno
Test: $ runtest frameworks-net pass
Bug: 32198976

(cherry picked from commit 8b06bcdfd24100302818ae0e11ee751dd813d5cf)

Change-Id: Ib3be06d2678c3fcfe4fa9d7b77f50c6e8812db3d
2017-01-26 18:52:41 +09:00
Tony Mak
c94b3c213b Show notification for always-on app VPN
This is the same notification as the one shown during legacy lockdown
mode, sans the 'reset' button.

The notification is only shown during times when VPN has not yet
established or has failed, for example during boot or after a crash.

Bug: 29123115

(cherry picked from commit 9ca892f698)

Change-Id: I929a05c24df01e21415535a333bb14ac4b790a9d
2017-01-26 18:52:35 +09:00
Hugo Benichi
cb2a3a3bca ConnectivityServiceTest: fix testAvoidBadWifiSettings
This patch introduces an assertEventuallyThat helper function in
ConnectivityServiceTest which given a boolean function retries until the
function returns true or until a maximum retry time is reached.

This function is used to fix flakyness of testAvoidBadWifiSetting where
the Message posted by reevaluate() could reach the Handler's
MessageQueue after waitForIdle takes effect, resulting in the test to
fail.

Instead of fixing the flakyness by introdcing hard sleep times,
assertEventuallyThat is used to reduce the overall test time.

With this change the test has been observed to pass with 100% success
rate over 50000 invocations.

Test: $ runtest frameworks-net
Bug: 32561414

(cherry picked from commit b54c8cffa8)

Change-Id: If41a24989d5f65aeb439f68741f511b5eb53b18d
2017-01-26 18:52:18 +09:00
Hugo Benichi
d748276a70 Fix ConnectivityServiceTest testRequestBenchmark
This patch fixes flakyness of testRequestBenchmark by adjusting time
limit for callback registration from 100ms to 180ms, and time limits for
onAvailable and onLost triggers from 30ms to 40ms.

With these timeouts the test succeeds 100% over 5000 iterations.

When using 150ms for registration timeout, running the test 5000 times
fails 2 times.

When using 30ms for onLost timeout, running the test 5000 times fails
1 times.

In addition, this patch also cleans testRequestBenchmark and uses the
more stable SystemClock.elapsedRealtime() for duration measurements.

Test: $ runtest frameworks-net
Bug: 32561414

(cherry picked from commit 766e564647)

Change-Id: I196ab9ef7f5abe456a783eed65db09279d2ecb8c
2017-01-26 18:52:14 +09:00
Hugo Benichi
ce2cfa545d IpConnectivityMetrics reads buffer size in settings
Test: IpConnectivityMetricsTest passes. Also manually changed the new
setting and verified the buffer size is as expected after flushing the
buffer.
Bug: 32198637

(cherry picked from commit 6d8c1dfe4b)

Change-Id: Iefbeac3a688b260fb3f92dfe0bfd9db28e26749d
2017-01-26 18:51:30 +09:00
Hugo Benichi
deebea6136 IpConnectivity metrics: add version number
This patch adds a version field to ipconnectivity.proto and populates it
to 2, which is the logical version number for NYC-MR2.

Test: IpConnectivity{EventBuilder,Metrics}Test pass
Bug: 32127906

(cherry picked from commit f04b01f0a0)

Change-Id: If8f167c0dc4c1abe0e235e2adfd131168a4ddc52
2017-01-26 18:51:18 +09:00
Etan Cohen
0aa0f341ba [CS] Remove timeout event after first available
Guarantees that timeouts are only delivered if a network never
becomes available. Once a network is available the timeout is
canceled.

Bug: 31402633
Test: all timeout related unit tests pass (new one added)

(cherry picked from commit 5eba9d7061)

Change-Id: I7cd3086544c881915fc6dbf14b87a24ab0cd8748
2017-01-26 18:51:15 +09:00
Lorenzo Colitti
ebc2b946ee Move the connectivity tests to frameworks/base/tests/net.
This will give us a good place to put all the networking tests.

Fix: 31479480
Test: adb  shell am instrument -w -e notClass com.android.server.connectivity.tethering.TetherInterfaceStateMachineTest 'com.android.frameworks.tests.net/android.support.test.runner.AndroidJUnitRunner'  # PASS

(cherry picked from commit 5a7c486d70)

Change-Id: I993eeaa5dec001c39389023f355f506129b356e7
2017-01-26 18:50:59 +09:00
Hugo Benichi
bb1b93dfa8 DO NOT MERGE frameworks-test: adding missing @SmallTest
This activates all frameworks-test tests in runs of the continuous
platform tests.

Test: $ runtest frameworks-net passes (expect Tether
Bug: 32561414

(cherry picked from commit 3664598601)

Change-Id: I84f9aecfbf9ebe07c6fcfec26acb2c2cfaae2d60
2017-01-24 15:42:45 +09:00
Hugo Benichi
ef41b769e8 ConnectivityServiceTest: remove flaky waitForIdle test.
This patch removes testNotWaitingForIdleCausesRaceConditions() from
ConnectivityServiceTest because it is in nature flaky and prevents using
ConnectivityServiceTest as a patch presubmit check. Estimated failure
rate is 1/15 on Nexus 6p.

This patch also simplifies how ConnectivityServiceTest waits for
handlers to become idle by removing IdleableHandlerThread and turning it
into a signle static method.

Test: $ runtest frameworks-net
Bug: 31479480
Change-Id: I2d78709cbb61d5d01cd59cff326469417f73f1ab
2017-01-24 15:22:48 +09:00
Hugo Benichi
2ffbac43f4 ConnectivityServiceTest: fix flaky tests
This patch adjusts timeouts in ConnectivityServiceTest to fix tests
known to fail spruriously.

Test: ran the following tests 500 times without observing any failure
 - testBackgroundNetworks()
 - testMultipleLingering()
 - testPacketKeepalives()
 - testSatisfiedNetworkRequestDoesNotTriggerOnUnavailable()
 - testSatisfiedThenLostNetworkRequestDoesNotTriggerOnUnavailable()
Bug: 32561414
Change-Id: I184fe7189aac768a65b927cc42eefaf8b1b3f930
2017-01-24 15:21:18 +09:00