Commit Graph

3757 Commits

Author SHA1 Message Date
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
87eab8e1c4 ConnectivityServiceTest: remove remaining poll loops. am: aebc0598b9
am: 5f807b3b74

Change-Id: I06815166fe9ab4b7d6ab580a9eda5304067f9f91
2017-02-01 02:49:23 +00:00
Lorenzo Colitti
c2279a09bf Remove assertEventuallyTrue as it's unnecessary. am: 4b07a883ca
am: c939693265

Change-Id: I7f6d543a3d05b0b165adc7a7c3938c7081c3f778
2017-02-01 02:48:10 +00:00
Lorenzo Colitti
5bbbf841eb Rename AvoidBadWifiTracker to MultinetworkPolicyTracker am: ee6c69ecc4
am: 49040a3d5a

Change-Id: I0ff0169ebc5e53cc9f57f224225fb0c93dc241ed
2017-02-01 02:47:16 +00:00
Lorenzo Colitti
e160fe177d Attempt to make waitForIdleHandler reliable. am: 572f1a3185
am: b18bd6bd3d

Change-Id: I72c03d3686858631aefdf96e13e8033f27788f8c
2017-02-01 02:45:55 +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
Robin Lee
5dec1ff337 Reinstate USER_PRESENT for ConnectivityService
Reverts half of commit 829f7c72e5
Reverts parts of commit 9b747914f3

Lockdown VPN still needs this to start properly on devices without FBE,
such as phones upgraded from M. Without listening to USER_PRESENT the
first unlock of keystore may get missed, since USER_UNLOCKED is sent too
soon to be useful.

Bug: 34587043
Change-Id: If7a2f5a3173b0f6856244a5f7904bf00c9a5b5e7
2017-01-30 09:19:46 +00:00
Lorenzo Colitti
76b0452e73 Merge "ConnectivityServiceTest: fix flaky tests" am: ee4f8f30eb am: 96a8a237b0 am: 1adc6c2054
am: ad488d0158

Change-Id: I3a16ff459b8f702249f14e9becbb2630ce7471fd
2017-01-27 10:04:15 +00:00
Lorenzo Colitti
495016e658 Merge "ConnectivityServiceTest: remove flaky waitForIdle test." am: be80577f5b am: cdbf1e7545 am: 9d250413a0
am: 822ca7bd3e

Change-Id: Iebafbf438ee4efcd53b3e6d5c71b34c0ca4e2c6b
2017-01-27 10:00:14 +00: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
1adc6c2054 Merge "ConnectivityServiceTest: fix flaky tests" am: ee4f8f30eb
am: 96a8a237b0

Change-Id: I66f2c2174c2895224724245c1b3d815da1678955
2017-01-27 09:55:39 +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
9d250413a0 Merge "ConnectivityServiceTest: remove flaky waitForIdle test." am: be80577f5b
am: cdbf1e7545

Change-Id: I7fbf2cb2c9778f5c961335c5b9fd5a138ec140db
2017-01-27 09:51:39 +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
16a1f7aed4 Merge commit 'f2bcda635cca9dc6f00b6efb2b9cf92892525bab' into nyc-mr1-dev-plus-aosp am: c95cbb9588 -s ours
am: 92c1e2502a

Change-Id: Iaaba0c8dd7181a5560158c47e817d31c25d8dbf6
2017-01-27 07:43:06 +00:00
Stephen Chen
45150fcbcb Merge commit 'de58879efdcb7aa6d62aa4f67908ae59fa366716' into nyc-mr1-dev-plus-aosp am: 2bb684daf5
am: 04f8e0edfc

Change-Id: I318efe59e1967150338a7bd8001c27d9ebe3cf75
2017-01-27 07:42:07 +00:00
Hugo Benichi
ac6a39cf7e Merge commit 'a19056c35d16ddb5a6c1d3343729701b8939f1e1' into nyc-mr1-dev-plus-aosp am: d49ba144f0 -s ours
am: a72a13498e

Change-Id: I7028ef23f597e6e82ecdb6c11a6c8dcdb1d1f77b
2017-01-27 07:40:56 +00:00
Hugo Benichi
92c1e2502a Merge commit 'f2bcda635cca9dc6f00b6efb2b9cf92892525bab' into nyc-mr1-dev-plus-aosp
am: c95cbb9588  -s ours

Change-Id: Icf4cf5e8e95b9de4b313f826a40c1df81c02aa8a
2017-01-27 07:29:59 +00:00
Stephen Chen
04f8e0edfc Merge commit 'de58879efdcb7aa6d62aa4f67908ae59fa366716' into nyc-mr1-dev-plus-aosp
am: 2bb684daf5

Change-Id: I3de8f91b1c9d0160ec58be8347502769580e0159
2017-01-27 07:29:07 +00:00
Hugo Benichi
a72a13498e Merge commit 'a19056c35d16ddb5a6c1d3343729701b8939f1e1' into nyc-mr1-dev-plus-aosp
am: d49ba144f0  -s ours

Change-Id: Ie2f8c1e18acf57238fe4816812562ecd1644cf51
2017-01-27 07:28:06 +00:00
The Android Automerger
c95cbb9588 Merge commit 'f2bcda635cca9dc6f00b6efb2b9cf92892525bab' into nyc-mr1-dev-plus-aosp
* commit 'f2bcda635cca9dc6f00b6efb2b9cf92892525bab':
  Captive portals: login activity probes like NetworkMonitor
  Logging improvements in CaptivePortalLoginActivity
  Captive portal systel log improvements
  Fix flaky IpPrefixTest.
  Removing bogus file added by mistake
  frameworks-test: adding missing @SmallTest
  Netd events: record connect() success/errno
  Add missing dependency.
  Show notification for always-on app VPN
2017-01-27 06:39:52 +00:00
The Android Automerger
2bb684daf5 Merge commit 'de58879efdcb7aa6d62aa4f67908ae59fa366716' into nyc-mr1-dev-plus-aosp
* commit 'de58879efdcb7aa6d62aa4f67908ae59fa366716':
  Implement metered tracking for NetworkStats summary queries.
2017-01-27 06:39:41 +00:00
The Android Automerger
d49ba144f0 Merge commit 'a19056c35d16ddb5a6c1d3343729701b8939f1e1' into nyc-mr1-dev-plus-aosp
* commit 'a19056c35d16ddb5a6c1d3343729701b8939f1e1': (35 commits)
  NetworkMonitor: send one DNS probe per web probe
  NetworkMonitor metrics: add first validation information
  APF: also drop any ICMPv6 RSs
  ConnectivityServiceTest: fix testAvoidBadWifiSettings
  Fix ConnectivityServiceTest testRequestBenchmark
  Switch over to new "time.android.com" NTP pool.
  Define API for metering network stats buckets.
  Refactored NetworkStatsServiceTest to use Mockito instead of EasyMock.
  Use @Ignore to explicitly disable a @Test method.
  Fixed NetworkStatsServiceTest and converted it to JUnit4.
  VPN network stat accounting changes.
  ConnectivityThread: use lazy holder idiom
  ConnectivityManager: use ConnectivityThread looper
  ConnectivityManager: a simpler CallbackHandler
  Indicate the NsdServiceInfo attributes are only filled in for a resolved service.
  Add a null check for the OnStartTetheringCallback.
  TokenBucket for rate-limiting and throttling
  IpConnectivityMetrics reads buffer size in settings
  CaptivePortalLogin: set mixed content policy to compatibility.
  Add IP conn metrics to dumpsys and bug reports
  ...
2017-01-27 06:39:05 +00:00
Hugo Benichi
f2bcda635c Captive portals: login activity probes like NetworkMonitor
This patch changes CaptivePortalLoginActivity captive portal test to be
consistent with NetworkMonitor by:
 - using Network.java to open the http connection.
 - adding a UserAgent property to the request header.

Test: manually tested.
Bug: 32369183

(cherry picked from commit 454e066e27)

Change-Id: I559eb0497475daad758ba3b3395225dcd0a27a57
2017-01-26 18:53:03 +09:00
Hugo Benichi
7488fe4159 Captive portal systel log improvements
This patch improves system logging around captive portal detection to
make inspection of bug reports sligthly easier:

- NetworkMonitor now logs by default CMD_CAPTIVE_PORTAL_RECHECK and
  CMD_CAPTIVE_PORTAL_APP_FINISHED. Other system logs are kept off with
  a new VDBG boolean contant,
- NetworkNotificationManager now prints the notification id at
  notification time. This allows to easily correlate show and clear.
- errors in NetworkNotificationManager are logged as Throwable instead
  of through their implicit toString() method.

Test: $ runtest frameworks-net
Bug: 32198726

(cherry picked from commit 2a3998dd05)

Change-Id: I1eaab5ea702063dde3e23324d3a1b3dc172c5ac5
2017-01-26 18:52:55 +09:00
Hugo Benichi
739d7e9ce7 Fix flaky IpPrefixTest.
Test: IpPrefixTest passes
Bug: 32561414

(cherry picked from commit f5ec69155d)

Change-Id: I42928da87f7f336900b3a95ebbf28563864da8d4
2017-01-26 18:52:51 +09: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
Stephen Chen
de58879efd Implement metered tracking for NetworkStats summary queries.
Dependent on ag/1550196 where API is defined.

Bug: 31015360
Bug: 26545374
Test: runtest --path
frameworks/base/core/tests/coretests/src/android/net/NetworkStatsTest.java,
other test classes.

(cherry picked from commit 9369e9d105)

Change-Id: I46da93ba4afa968facf98f7c3d844fd0c469095a
2017-01-26 18:52:32 +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
Felipe Leme
d67fae88b6 Refactored NetworkStatsServiceTest to use Mockito instead of EasyMock.
Test: m -j32 FrameworksServicesTests && adb install -r -g ${ANDROID_PRODUCT_OUT}/data/app/FrameworksServicesTests/FrameworksServicesTests.apk && adb shell am instrument -e class "com.android.server.net.NetworkStatsServiceTest" -w "com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner"

BUG: 30943463

(cherry picked from commit de2a6f1b1d)

Change-Id: Ia9929295ab2396a7ebb133e65d157f98414e4dfa
2017-01-26 18:52:04 +09:00
Felipe Leme
ab6ab9bd36 Use @Ignore to explicitly disable a @Test method.
BUG: 30839080
BUG: 31007021

(cherry picked from commit a4dc2a7129)

Change-Id: I35942e60493adebb22871541a34240368c691ee7
2017-01-26 18:52:01 +09:00
Felipe Leme
ed1e28dfad Fixed NetworkStatsServiceTest and converted it to JUnit4.
Most tests were failing because due to a null NetworkCapabilities.
Example:

1) testNetworkStatsWifi(com.android.server.net.NetworkStatsServiceTest)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.net.NetworkCapabilities.hasCapability(int)' on a null object reference
	at
	com.android.server.net.NetworkStatsService.updateIfacesLocked(NetworkStatsService.java:983)

BUG: 30839080

(cherry picked from commit f96df4b298)

Change-Id: Ie09b2f43cf6ec745e404d5ec98bd0b072d211ea3
2017-01-26 18:51:58 +09:00
Jeremy Joslin
232e75c65b VPN network stat accounting changes.
Properly account for VPN apps that make heavy use of the tun
interface. Prior to this change a VPN app could be incorrectly charged
for more data than it actually used if it sent more traffic through
the tun interface than the underlying interface.

This change excludes VPN app traffic on the tun interface from the
adjustment pool and doesn't redistribute traffic to the VPN app.
Instead all of the redistributed traffic is deducted from the VPN app
which effectively represents any overhead incurred by the VPN app.

BUG: 30557871

(cherry picked from commit 13dd0e99ba)

Change-Id: I06f01aa8fe5fdc06b2d36cfb9c68feb244c2e5de
2017-01-26 18:51:53 +09:00
Hugo Benichi
eba4b5b0bd ConnectivityManager: use ConnectivityThread looper
This patch removes the static singleton looper used by
ConnectivityManager and instead uses the common ConnectivityThread.

This allows to removes the static atomic counter used to track
the number of registered NetworkCallback in ConnectivityManager, because
the looper is not turned off anymore when no callbacks are registered.

Also an overloaded version of sendRequestForNetwork is added taking as a
new parameter a Handler. This will allow to overload various callback
and request related API calls with user provided Handlers.

Test: ConnectivityServiceTest passes
Bug: 26749700
Bug: 28537383
Bug: 32130437

(cherry picked from commit 3b41f05d68)

Change-Id: If956addbf8e7b11b36a4b966de7fca00e8f362c1
2017-01-26 18:51:46 +09:00
Hugo Benichi
03eeaae5f0 ConnectivityManager: a simpler CallbackHandler
This patch simplifies CallbackHandler in the following way:
  - CallbackHandler directly uses the static references to
    sNetworkCallback and sCallbackRefCount. This allows to remove
    instance fields in CallbackHandler.
  - CallbackHandler does not have a reference to ConnectivityManager
    anymore
  - CallbackHandler.getObject() is now generic in a type-safe way.

Test: ConnectivityServiceTest passes
Bug: 28537383
Bug: 32130437

(cherry picked from commit 0b42baf68a)

Change-Id: I1b5fe2a361b5f623a8310ae698497c83d72f3034
2017-01-26 18:51:43 +09:00
Jeremy Klein
d6114b0eda Add a null check for the OnStartTetheringCallback.
This avoids a NullPointerException when trying to call the callback
and gives a more readable error message.

(cherry picked from commit 35e99ea8ef)

Change-Id: Ia419ff68ef10f308f9e44be47420e27099ee6070
2017-01-26 18:51:36 +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