Commit Graph

195 Commits

Author SHA1 Message Date
Hugo Benichi
45445770ab Nat464Xlat: correct racefree teardown
This patch relays the NetworkBaseObserver notifications about nat
464xlat stacked interfaces onto the ConnectivityService handler.

This allows to process interface up and down notifications in the
same thread context and eliminates several races:

  - NPE risk due to race between fixupLinkProperties called on
    ConnectivityService thread and interfaceRemoved called on
    NetworkManagementService thread.
  - stale LinkProperties pointer reads in both NetworkBaseObserver
    callbacks not called on ConnectivityService handler.
  - removes the race between stop() and interfaceRemoved().
  - removes superfluous LinkProperties notifications when stop() is
    called before the stacked interface goes up.

The teardown procedure logic common to stop() and interfaceRemoved() is
put into enterStoppedState() and enterIdleState().

This allows to distinguish and correctly handle the following teardown
scenarios:
 - an IPv4 appears -> ConnectivityService calls Nat464Xlat#stop()
                   -> Nat464Xlat calls stopClatd
                   -> clatd stops
                   -> if the stacked interface was up, it is removed
                   -> Nat464Xlat#interfaceRemoved() is triggered and
                      a LinkProperties update is sent.

 - network disconnects -> ConnectivityService calls Nat464Xlat#stop()
                       -> Nat464Xlat calls stopClatd
                       -> clatd stops
                       -> if the stacked interface was up, it is removed
                       -> Nat464Xlat#interfaceRemoved() is triggered and
                          a LinkProperties update is sent.

 - clatd crashes or exit -> Nat464Xlat#interfaceRemoved() is triggered
                         -> Nat464Xlat unregisters itself as a network
                            observer
                         -> ConnectivityService is updated about the
                            stacked interface missing, and restarts
                            Nat464Xlat if needed.

Note that the first two scenarios have two cases: stop() can be called
before the notification for the stacked interface going up (STARTED), or
after (RUNNING). In the first case, Nat464Xlat must unregister
immediately as a network observer to avoid leaks.

This patch also:
  - removes/simplifies comments related to the threading model which
    are no obsolete.
  - extract clatd management logic from ConnectivityService into
    NetworkAgentInfo
  - add new unit tests where there was none before.

Bug: 62918393
Bug: 62997041
Bug: 64571917
Bug: 65225023
Test: runtest frameworks-net
Merged-In: I27221a8a60fd9760b567ed322cc79228df877e56
Merged-In: I8f07dfbe5ea8259ff9f5793503f534945e67ad74
Merged-In: I8612db5e5050690db8cf41dd04944b4c22da340c
Merged-In: Icb2dc8229b5ea45e319233b588f2dbe39ea40d4c
Merged-In: Ibafea69224e832a6316c17dbb9b2d62a233088ac

(cherry picked from commit ef502887ec58886e9347afb841aa06cb0d13acea)

Change-Id: I9d075048873b0e1c5ed45b5674ada3fb303c2bfb
2017-09-05 22:12:01 +09:00
Jeff Sharkey
3c8f96ef4a Augment network stats based on SubscriptionPlan.
When a carrier provides an "anchor" of data usage at a specific
moment in time, augment the network statistics used by warning/limit
thresholds and Settings UI.  For example, if the OS measured 500MB
of usage, but the carrier says only 400MB has been used, we "squish"
down the OS measured usage to match that anchor.

Callers using the hidden API will have their data augmented by
default, and the public API offers a way to opt-into augmentation.

Thorough testing to verify behavior.

Test: bit FrameworksNetTests:android.net.,com.android.server.net.
Test: cts-tradefed run commandAndExit cts-dev -m CtsUsageStatsTestCases -t android.app.usage.cts.NetworkUsageStatsTest
Bug: 64534190
Change-Id: Id3d4d7625bbf04f57643e51dbf376e3fa0ea8eca
2017-08-30 10:01:10 -06:00
Lorenzo Colitti
49ab263c0b Add tether offload traffic to interface stats as well.
Currently, we only count add tethering traffic to per-UID
stats, but not to total data usage (i.e., dev and XT stats). This
is correct for software tethering, because all software forwarded
packets are already included in interface counters, but it is
incorrect for hardware offload, because such packets do not
increment interface counters.

To fix this:
1. Add an argument to ITetheringStatsProvider#getTetherStats to
   indicate whether per-UID stats are requested. For clarity,
   define integer constants STATS_PER_IFACE and STATS_PER_UID
   to represent these operations.
2. Make NetdTetheringStatsProvider return stats only if per-UID
   stats are requested. (Otherwise tethering traffic would be
   double-counted).
3. Make OffloadController's stats provider return the same
   stats regardless of whether per-UID stats were requested or
   not.
4. Make NetworkStatsService add non-per-UID tethering stats to
   the dev and XT snapshots. The per-UID snapshots were already
   correctly adding in per-UID stats.

Bug: 29337859
Bug: 32163131
Test: runtest frameworks-net
Test: runtest frameworks-telephony
Change-Id: I7a4d04ab47694d754874136179f8edad71099638
2017-08-19 00:21:56 +09:00
Charles He
d681363fd1 Opt-out for always-on VPN: rename API.
Rename the opt-out flag in AndroidManifest to
SERVICE_META_DATA_SUPPORTS_ALWAYS_ON
as directed by the API Council.

Bug: 64331776
Bug: 36650087
Test: runtest --path java/com/android/server/connectivity/VpnTest.java
Change-Id: I24326fad7a89083a2409134640bda81ee0359d08
2017-08-15 15:52:39 +01:00
Hugo Benichi
7ae02714ae Merge "NetworkNotificationManager: correctly handle existing notifications" into oc-dr1-dev
am: a03bf7acd1

Change-Id: I4ca3dcc293be5408a6f207e1ac1a7229a915723a
2017-07-28 04:39:14 +00:00
Hugo Benichi
900a3dbcc0 NetworkNotificationManager: correctly handle existing notifications
This patch corrects a regression added by commit fd35080555 that did
not take into account the case of multiple notifications shown for a
single network id. Given how network notifications are triggered, it can
happen that NO_INTERNET and SIGN_IN notifications are both triggered for
the same network when captive portal detection is slow.

Contrary to the situation before commit fd35080555, a notification
priority order is introduced so that SIGN_IN always overrides
NO_INTERNET, and NO_INTERNET is ignored if SIGN_IN is already present.

Bug: 63676954
Bug: 62503737
Test: runtest frameworks-net, added new unit tests
Merged-In: Ib8658601e8d4dc6c41b335ab7dd8caa0cccd9531
Merged-In: I4432f66067ea1ab02e1d2dfe42530bcdafa52df6
Merged-In: I74631b0bfd14daf18a1641ed7f2ec323d636ebbf
Merged-In: I73cc879e910d503946facdba498b300337f349fd
Merged-In: Ieed9e3e7755e0c5f89dc41ef66f47d4dbf4c66a9
Merged-In: I0aa590170f1bd4c37175c7e35e54d52f1fb21347

(cherry picked from commit 5fcd050e0ecd5985cf184f55ea3df4434da8f824)

Change-Id: I41675768ab59e9b23ca4275edf297b82595e5730
2017-07-28 09:17:20 +09:00
Hugo Benichi
90217e1808 Merge "ConnectivityServiceTest: fix testNetworkInfoOfTypeNone" am: 1f0d765378 am: 9efd050236 am: b1894abbc5
am: fecebf94a2

Change-Id: I7d3bfdf6d95d5db2d31439b5c3334569666864e1
2017-07-19 08:20:23 +00:00
Hugo Benichi
9efd050236 Merge "ConnectivityServiceTest: fix testNetworkInfoOfTypeNone"
am: 1f0d765378

Change-Id: I4be1d2ce67871c1e01364beca886fdd3af374321
2017-07-19 08:04:48 +00:00
Hugo Benichi
a6fe35a841 ConnectivityServiceTest: fix testNetworkInfoOfTypeNone
This patch fixes a couple of flakyness issues with
testNetworkInfoOfTypeNone. It also fixes some typos and naming issues.

Bug: 62918393, 62918393
Test: runtest frameworks-net
Change-Id: I1c56557ab113d3ef57dbc06a6e882634d03c5b09
2017-07-19 15:08:49 +09:00
Charles He
b0c5ede751 Merge "Opt-out for always-on VPN" 2017-07-18 18:47:45 +00:00
Hugo Benichi
43b7474c08 IP connectivity metrics: fix tests after proto update
Update to ipconnectivity.proto in commit
6d2f506bfd788a3685292d404dc9d82a27357cfe broke the associated unit
tests (Change-Id: I4cf5b95956df721aecd63fddfb026a7266c190b9)

Bug: 34901696
Test: runtest frameworks-net
Change-Id: I57a6bad8a9836b1c45690c4589b416786ce1dfa0
2017-07-18 14:33:12 +09:00
Charles He
9369e61e2d Opt-out for always-on VPN
Always-on VPN is a feature introduced in N. Since then, all VPN apps
targeting N+ are assumed to support the feature, and the user or the DPC
can turn on / off always-on for any such VPN app. However, a few VPN
apps are not designed to support the always-on feature. Enabling
always-on for these apps will result in undefined behavior and confusing
"Always-on VPN disconnected" notification.

This feature provides a new manifest meta-data field through which a VPN
app can opt out of the always-on feature explicitly. This will stop the
always-on feature from being enabled for the app, both by the user and
by the DPC, and will clear its existing always-on state.

A @hide API is provided to check whether an app supports always-on VPN.
Documentation is updated to reflect the behavior change.

Bug: 36650087
Test: runtest --path java/com/android/server/connectivity/VpnTest.java
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage'
Test: cts-tradefed run cts --module CtsDevicePolicyManagerTestCases --test 'com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced'

Change-Id: I477897a29175e3994d4ecf8ec546e26043c90f13
2017-07-18 00:55:38 +01:00
Hugo Benichi
93e1941b43 Merge "ConnectivityManager: allow usage of TYPE_NONE"
am: d54a27d898

Change-Id: I72dbd17db63bd7b8637e82f5cdcfec3bf1482962
2017-07-05 14:33:35 +00:00
Hugo Benichi
a64e822036 Merge "ConnectivityServiceTest: more informative assert failures"
am: cc1feacd8d

Change-Id: Iaa55014ae4c2f4927059735c349c40ada836b79b
2017-07-05 14:19:33 +00:00
Hugo Benichi
c521380789 Merge "ConnectivityServiceTest: eliminate remaining sleep()"
am: 2af7cbd8b7

Change-Id: Ib1e31c2b8999d07b20ef4cef8e70d851f93df6e5
2017-07-05 12:35:01 +00:00
Hugo Benichi
ad353f451a ConnectivityManager: allow usage of TYPE_NONE
This patch allows to use TYPE_NONE for the legacy network type variable
of NetworkInfo. This usage is "safe" with respect to legacy APIs using
network types as most of them already returns null or do nothing for
TYPE_NONE.

Of the existing APIs in ConnectivityManager that accept a network type
argument, those which were already returning null or doing nothing for
TYPE_NONE are:
  getNetworkInfo(int)
  getNetworkForType(int)
  stopUsingNetworkFeature(int, String)
  networkCapabilitiesForType(int)
  requestRouteToHostAddress(int, InetAddress)
  reportInetCondition(int, int)
  isNetworkSupported(int)
  getLinkProperties(int)

Only setProvisioningNotificationVisible needs an additional guard
against TYPE_NONE.

Bug: 30088447
Bug: 62844794
Test: runtest frameworks-net
Change-Id: I112596fcd03d3c2cd42a2a84d265adb38e3944bb
2017-07-05 21:30:52 +09:00
Hugo Benichi
99495b1a4d ConnectivityServiceTest: more informative assert failures
Bug: 62918393
Test: runtest frameworks-net
Change-Id: If87315ef7cba6380596f48b92c7e0f6eeccc8368
2017-07-05 21:30:10 +09:00
Hugo Benichi
96d0a49b19 ConnectivityServiceTest: eliminate remaining sleep()
ConnectivityServiceTest was still using sleep() in a few places although
these were unnecessary:
  - in testSatisfiedThenLostNetworkRequestDoesNotTriggerOnAvailable(),
    expectNoCallback() and expectAvailableCallback() already include
    waitForIdleHandler calls that drain the message queues and make
    sleep no-ops.
  - in testTimedoutAfterUnregisterdNetworkRequest, the sleeps were
    introduced before unregisterNetworkCallback was changed to have a
    synchronous effect for callback unregistration, therefore the sleep
    becomes simply non-sensical. To reflect this the name of the method
    is also changed.

Bug: 62918393
Test: runtest frameworks-net
Change-Id: I7b701ecf5846a5e1890e86107b8d2544b419ce44
2017-07-05 16:07:57 +09:00
Roland Levillain
8ad104e62c Merge "Revert "ConnectivityManager: allow usage of TYPE_NONE""
am: a4fcd1a2b7

Change-Id: I49221522c1a9a6e7d4ae72529c1a47b736e26a39
2017-07-04 11:31:30 +00:00
Roland Levillain
a17d7171d9 Merge "Revert "ConnectivityServiceTest: more informative assert failures""
am: 959e3f9ac9

Change-Id: Ie61051984a1b6efbb0b19754ce0fb99024ab296a
2017-07-04 11:24:25 +00:00
Roland Levillain
2e99b8e7d2 Merge "Revert "ConnectivityServiceTest: eliminate remaining sleep()""
am: 1c5d788650

Change-Id: If210f213c7840c218d5e847667c7613d53f86661
2017-07-04 11:22:32 +00:00
Roland Levillain
4bb710cb01 Revert "ConnectivityManager: allow usage of TYPE_NONE"
This CL is breaking some internal builds.

This reverts commit 0b7642a820.

Change-Id: Ie79214808d84c73f54a525f515b4c90a3fb23542
2017-07-04 11:14:03 +00:00
Roland Levillain
a12b67eacf Revert "ConnectivityServiceTest: more informative assert failures"
CL https://android-review.googlesource.com/#/c/420720/ is
breaking several internal builds, and CL
https://android-review.googlesource.com/#/c/422480/ must
be reverted beforehand.

This reverts commit a0b7f12eb7.

Change-Id: I5883409452d39e1834e183aa7b5ccdbf14291ca5
2017-07-04 11:11:35 +00:00
Roland Levillain
1c5d788650 Merge "Revert "ConnectivityServiceTest: eliminate remaining sleep()"" 2017-07-04 11:11:09 +00:00
Roland Levillain
d5810f566f Revert "ConnectivityServiceTest: eliminate remaining sleep()"
CL https://android-review.googlesource.com/#/c/420720/ is
breaking several internal builds, and CL
https://android-review.googlesource.com/#/c/422481/ must
be reverted beforehand.

This reverts commit 137a0e6d16.

Change-Id: If0b196b6860c4087a05b28770469d7850a76fd37
2017-07-04 11:10:06 +00:00
Hugo Benichi
745a3564e2 Merge "ConnectivityServiceTest: eliminate remaining sleep()"
am: a1dca50b88

Change-Id: I31a8f64b4ee37a58bc83c08251d949f44cc26fd4
2017-07-04 09:43:01 +00:00
Hugo Benichi
8a73d29f31 Merge changes I90c211dc,I4455f272
am: a5ea99e288

Change-Id: I502d978ff636a00979d2083c39381bf600d3d6da
2017-07-04 09:35:51 +00:00
Treehugger Robot
a1dca50b88 Merge "ConnectivityServiceTest: eliminate remaining sleep()" 2017-07-04 09:25:53 +00:00
Treehugger Robot
a5ea99e288 Merge changes I90c211dc,I4455f272
* changes:
  ConnectivityServiceTest: more informative assert failures
  ConnectivityManager: allow usage of TYPE_NONE
2017-07-04 09:22:07 +00:00
Hugo Benichi
137a0e6d16 ConnectivityServiceTest: eliminate remaining sleep()
ConnectivityServiceTest was still using sleep() in a few places although
these were unnecessary:
  - in testSatisfiedThenLostNetworkRequestDoesNotTriggerOnAvailable(),
    expectNoCallback() and expectAvailableCallback() already include
    waitForIdleHandler calls that drain the message queues and make
    sleep no-ops.
  - in testTimedoutAfterUnregisterdNetworkRequest, the sleeps were
    introduced before unregisterNetworkCallback was changed to have a
    synchronous effect for callback unregistration, therefore the sleep
    becomes simply non-sensical. To reflect this the name of the method
    is also changed.

Bug: 62918393
Test: runtest frameworks-net
Change-Id: I78426665670f702304212753f417b3d5a8a2c107
2017-07-04 16:23:06 +09:00
Hugo Benichi
a0b7f12eb7 ConnectivityServiceTest: more informative assert failures
Bug: 62918393
Test: runtest frameworks-net
Change-Id: I90c211dc6d6262475924ecabc2863c47aec5a0b9
2017-07-04 16:23:05 +09:00
Hugo Benichi
0b7642a820 ConnectivityManager: allow usage of TYPE_NONE
This patch allows to use TYPE_NONE for the legacy network type variable
of NetworkInfo. This usage is "safe" with respect to legacy APIs using
network types as most of them already returns null or do nothing for
TYPE_NONE.

Of the existing APIs in ConnectivityManager that accept a network type
argument, those which were already returning null or doing nothing for
TYPE_NONE are:
  getNetworkInfo(int)
  getNetworkForType(int)
  stopUsingNetworkFeature(int, String)
  networkCapabilitiesForType(int)
  requestRouteToHostAddress(int, InetAddress)
  reportInetCondition(int, int)
  isNetworkSupported(int)
  getLinkProperties(int)

Only setProvisioningNotificationVisible needs an additional guard
against TYPE_NONE.

Bug: 30088447
Bug: 62844794
Test: runtest frameworks-net
Change-Id: I4455f2726d06406047086368628c1f253d854d8d
2017-07-04 16:22:59 +09:00
Hugo Benichi
ae3dac0601 Merge "Networking unit tests: fix some flaky tests"
am: 501bae6492

Change-Id: I6815e732f334d11208ff12af4023912593d96499
2017-07-03 09:35:06 +00:00
Hugo Benichi
44ceaa602e Networking unit tests: fix some flaky tests
- less strict regex for SharedLogTest: the subsecond part of the
   timestamp can have 0, 1, 2 or 3 digits.
 - refactor NetworkStatsServiceTest and NetworkStatsObserversTest to use
   waitForIdleHandler facility of ConnectivityServiceTest.
   NetworkStatsServiceTest was using a flaky custom version of
   waitForIdleHandler.

Bug: 62918393
Bug: 32561414
Test: runtest frameworks-net
Change-Id: I634acfb5f4fe1bd5267e3f14b9f645edc32d5d12
2017-07-03 16:29:01 +09:00
Hugo Benichi
bbdcd7c4a4 Merge "ConnectivityServiceTest: more tweaks to testRequestBenchmark" am: 76efbb30f5 am: 5f046cb614
am: 7bbdfcd8eb

Change-Id: I96c39ca1899768d039a108426fb04655aaf8d55f
2017-05-31 04:10:03 +00:00
Hugo Benichi
4d7887a2fa ConnectivityServiceTest: more tweaks to testRequestBenchmark
Recent continuous testing runs indicates that commit 79614aee did not
completely fixed the issue with testRequestBenchmark.

This patch changes the name of the test to not include "test" and
removes @SmallTest annotation, which should do the job of @Ignore while
ConnectivityServiceTest still extends AndroidTestCase.

In addition timeouts are adjusted to take into account recent failures
observed.

This is the last pending action before turning on FrameworksNetTests on
presubmits.

Bug: 32561414
Test: no functional change
Change-Id: I56ef334e19e99e5a3483418330e5f0ccd6eb31bb
2017-05-31 10:23:42 +09:00
Hugo Benichi
7cabb60411 Merge changes If4deb106,Ib25d7658 am: 0388f0e47b am: 41a57af66a
am: ae278410f5

Change-Id: I4fa34b647e7b2408d4493cfb148ae7d8c24bd6e8
2017-05-26 00:58:27 +00:00
Hugo Benichi
79614aee12 @Ignore ConnectivityServiceTest#testRequestBenchmark
Ignore the last remaining test in ConnectivityServiceTest with spurious
failures. testRequestBenchmark has some intrinsic chances of failure due
to the fact it attempts to assert elapsed time durations against a
reference target.

Bug: 32561414
Test: no functional change
Change-Id: Ib25d76581b47997b2ef84df3e6a9fd9224b85d92
2017-05-26 07:18:15 +09:00
Hugo Benichi
f0fdd9a831 Merge "Move NsdServiceTest to correct directory" am: 6a5c978605 am: ca9fcb79f6
am: ecf4267889

Change-Id: Ib4e100fc8219b58ab7850407735a444dad3ec153
2017-05-24 07:15:09 +00:00
Treehugger Robot
6a5c978605 Merge "Move NsdServiceTest to correct directory" 2017-05-24 06:47:30 +00:00
Hugo Benichi
168489b45d Move NsdServiceTest to correct directory
Test: no functional change
Bug: 62044295
Change-Id: Iad3af646e8d252f84978d1a367878a78c2869982
2017-05-24 14:18:48 +09:00
Hugo Benichi
15dcccb4a1 Merge "Fix NetworkStatsObserversTest" am: bec71d8f9b am: 25282c3e38
am: 814351c843

Change-Id: Ice4bb8de4267cba7a15a60838e165fab5ebade72
2017-05-23 14:18:30 +00:00
Hugo Benichi
ce5380e12c Merge "Fix NetworkStatsAccessTest" am: d8d4bcd3bc am: cdb75d321b
am: 85afabc4ec

Change-Id: I60f9d8867655a6aa24ee192c772d4c26a96c9bcd
2017-05-23 07:02:54 +00:00
Hugo Benichi
2d2b500068 Merge "ConnectivityServiceTest: fix flakyness" am: 8222ec90c6 am: 004f36d5bc
am: eb9d0f16aa

Change-Id: Ic792060aafb5aa8b485054be18c3dba82bb15a3b
2017-05-23 04:56:41 +00:00
Hugo Benichi
a2a3380def Fix NetworkStatsObserversTest
This patch fixes several spurious unit tests in
NetworkStatsObserversTest by using the updated waitForIdleHandler of
ConnectivityServiceTest. More specifically this fixes the following
tests:
  - testUnregister_knownRequest_releasesCaller
  - testUpdateStats_deviceAccess_notifies
  - testUpdateStats_userAccess_usageSameUser_notifies
  - testUpdateStats_defaultAccess_notifiesSameUid

This patch also removes the dummy message with type -1 sent at the end
of tests in NetworkStatsObserversTest and the associated assert, because
nothing is exercised or asserted immediately after.

This patch also updates NetworkStatsObserversTest to not depend on the
deprecated junit.framework.TestCase.

Bug: 32561414
Test: runtest -x frameworks/base/tests/../NetworkStatsObserversTest.java
Change-Id: I4fc909ee9bacc964c859fa7a3db34f9dc86b89cf
2017-05-23 10:18:41 +09:00
Hugo Benichi
de08c23dc9 Fix NetworkStatsAccessTest
This patch fixes NetworkStatsAccessTest by taking into account
DEVICESUMMARY which was added in commit
3a8b343ce5220086c4f71e63f5d42f2d28434c4b.

Doing $ git revert 3a8b343ce5220086c4f71e63f5d42f2d28434c4b shows that
the existing assertions of NetworkStatsAccessTest passed before that
commit.

This patch also changes NetworkStatsAccessTest to use up-to-date testing
style and not depend on the deprecated junit.framework.TestCase.

Bug: 32561414
Test: runtest -x frameworks/base/../NetworkStatsAccessTest.java
Change-Id: Ib78f137578cf35e1c766b377b7f812a09173c49e
2017-05-23 10:18:41 +09:00
Hugo Benichi
ea4148caa3 ConnectivityServiceTest: fix flakyness
This patch attempts to fix the remaining spurious failures in
ConnectivityServiceTest, which have two causes:
 - waitForIdle() does not take into account the NetworkAgents handlers.
 - the deadlines in testRequestBenchmark are sometimes exceeded.

To fix the first issue, waitForIdle() is moved to a test level instance
method and also calls waitForIdleHandler on any non null
MockNetworkAgent. This is expected to fix spurious errors for the
following tests:
  - testMobildeDataAlwaysOn
  - testLingering
  - testPacketKeepAlive
  - testMMSonWiFi

To fix the second issue, the deadlines for testRequestBenchmark are
extended by 10ms. Also, the failure message is made more actionable by
providing the total time it took for the operation, instead of printing
the number of dispatches that were achieved before the deadline.

Bug: 32561414
Test: tests pass many times in a row (~500).
Change-Id: Id33c6ac1edfb0b89634fa7789dccb2da237e2709
2017-05-23 10:18:41 +09:00
Lorenzo Colitti
4f58f0cde4 Merge "Add test coverage for explicitlySelected networks." am: f6db1c5889 am: 3d55c5539c
am: b7535c86a0

Change-Id: I4caf9f55edeb51365293558db9d7d028b61c501c
2017-05-19 02:34:58 +00:00
Hugo Benichi
a4876e64b8 Merge "Add a method to start the captive portal login app." 2017-05-19 02:29:21 +00:00
Lorenzo Colitti
f6db1c5889 Merge "Add test coverage for explicitlySelected networks." 2017-05-19 02:05:55 +00:00