Commit Graph

3199 Commits

Author SHA1 Message Date
Treehugger Robot
8fdbb6d6e2 Merge "Always send all available state when calling onAvailable()." 2017-03-07 05:51:41 +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
Hugo Benichi
e8a3a43193 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
1d6742c945 Revert "ConnectivityManager: no double NetworkCallback registration" because oit caused regressions http://b/35955593, http://b/35921499.
This reverts commit ca4bf6edc3.

Change-Id: I86c07c113f24753be7c977e6d7f570b99391e1b5
2017-03-06 06:16:51 +00:00
Etan Cohen
f67bde923c [CM] Allow timeout in request network
Add (unhide) a public API which provides network requests with a
timeout. When timed-out the (newly unhidden) onUnavailable() callback
is triggered.

Note: this CL does not add a handler to the API to be consistent
with the existing APIs. There is a separate effort (b/32130437)
to update these APIs with Handlers.

Bug: 31399536
Test: unit tests and CTS (new)
Change-Id: I45ce9ada63372cb56937bb620bfbb7729e5e25d2
2017-03-02 08:06:27 -08:00
Hugo Benichi
e71290cc46 Merge "ConnectivityManager: no double NetworkCallback registration"
am: 06a192fa49

Change-Id: I250fa7d3c5e37a66caa41cc898a44bcb18c9a0c4
2017-03-02 08:04:03 +00:00
Hugo Benichi
ca4bf6edc3 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
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
Erik Kline
baaa19d65a Merge "Update UpstreamNetworkMonitor to use custom Handlers"
am: 35c89886c2

Change-Id: I76433822a9b7c124e4b7cfcf2a20cb0e43a60199
2017-02-24 08:15:19 +00:00
Erik Kline
7807ff12af Update UpstreamNetworkMonitor to use custom Handlers
Test: as follows
    - built (bullhead)
    - flashed
    - booted
    - runtest frameworks-net passes
Bug: 32130437
Bug: 32163131

Change-Id: I2bc3f87cdf7fa6392b4750eb8adb4ea33c6a3f43
2017-02-24 13:06:51 +09:00
Hugo Benichi
585855decf Merge "ConnectivityManager: allow custom Handlers"
am: ef69246260

Change-Id: I8da5540f6561cdef4adc91bbeeb9c21a91c08d49
2017-02-22 03:48:10 +00:00
Hugo Benichi
fd44e91bcb ConnectivityManager: allow custom Handlers
This patch adds overloaded version of registerDefaultNetworkCallback
registerNetworkCallback, and requestNetwork with an additional Handler
argument that is used for running the caller provided NetworkCallback.

It also clarifies the documentation of the existing methods that
implicitly uses the internal singleton ConnectivityThread about which
internal Handler is used for running NetworkCallbacks.

Test: build, flashed, booted device
Bug: 32130437
Change-Id: Iae15f81e47e2dc0355baf2f2c1679b77e56af299
2017-02-22 09:24:01 +09:00
Robin Lee
02f7e1039b Merge "Reinstate USER_PRESENT for ConnectivityService"
am: ba7503a1eb

Change-Id: If8b7239cdabdd79d9ea24baf99e95c6ec1a9acf3
2017-02-21 17:55:07 +00:00
Treehugger Robot
ba7503a1eb Merge "Reinstate USER_PRESENT for ConnectivityService" 2017-02-21 13:23:41 +00:00
sj.cha
9b75c75197 Merge "Infinite reboot when OS upgrade from M to N with set Always-on VPN" am: 63ca8979e4 am: b4b83c82cd
am: 65373db594

Change-Id: I5e0faee7a0b1c6bdfafe77560a91e999f40edc4a
2017-02-17 13:27:04 +00:00
sj.cha
65373db594 Merge "Infinite reboot when OS upgrade from M to N with set Always-on VPN" am: 63ca8979e4
am: b4b83c82cd

Change-Id: I82c297e654af6690c6a3be216a0da08a3aff5b9d
2017-02-17 13:21:34 +00:00
sj.cha
b4b83c82cd Merge "Infinite reboot when OS upgrade from M to N with set Always-on VPN"
am: 63ca8979e4

Change-Id: I21a69eb02b13b20f66996836d54b8aadadfa80ec
2017-02-17 13:17:00 +00:00
Treehugger Robot
63ca8979e4 Merge "Infinite reboot when OS upgrade from M to N with set Always-on VPN" 2017-02-17 13:07:21 +00:00
Etan Cohen
a8bb0c7fdd Merge changes from topic 'cm_request_to' am: d6877b2576 am: 0a8122afa9
am: 6e3ea85738

Change-Id: Ief32189b0f6f2c70d7e4097f70dbdf8195bd8713
2017-02-16 14:38:28 +00:00
Etan Cohen
6e3ea85738 Merge changes from topic 'cm_request_to' am: d6877b2576
am: 0a8122afa9

Change-Id: I2720e64e4af88df9d3a7b6209e9fcef4a0340986
2017-02-16 14:29:29 +00:00
Etan Cohen
0a8122afa9 Merge changes from topic 'cm_request_to'
am: d6877b2576

Change-Id: I9ca18c0570be831ab37cdf200c28b0778117198d
2017-02-16 14:23:18 +00:00
Etan Cohen
d6877b2576 Merge changes from topic 'cm_request_to'
* changes:
  [CM] Remove maximum timeout value for request network
  [CM] Remove non-functional timeout from request network
2017-02-16 14:15:44 +00:00
Etan Cohen
8500016ea4 [CM] Remove maximum timeout value for request network
The request network with timeout was originally created with a
check of max timeout against a constant of 100 minutes. However,
the API was not public and did not implement a timeout. Any users
were internal and never got any onUnavailable() callback (since
timeout never triggered).

There is no reason to have a max timeout so the constant is
remove.

Bug: 31399536
Test: unit tests and CTS of ConnectivityManager
Change-Id: Icbedfb4299d75b6a7e3e43720111531f1faafd06
2017-02-16 14:15:16 +00:00
Hugo Benichi
47be55d3ec Merge "ConnectivityManager: fix potential NPE" am: b688dd18ab am: 95d22b0c92
am: 3b0915b6f5

Change-Id: I6f487ce9da656610c939ddc78e834ac8ef5f8135
2017-02-15 01:24:29 +00:00
Hugo Benichi
3b0915b6f5 Merge "ConnectivityManager: fix potential NPE" am: b688dd18ab
am: 95d22b0c92

Change-Id: I72e114037ce6a0ec53863749b8ffa34513c9fdce
2017-02-15 01:09:58 +00:00
Hugo Benichi
95d22b0c92 Merge "ConnectivityManager: fix potential NPE"
am: b688dd18ab

Change-Id: If562fc6a921569ad9d3141cac72b6f395a30da9e
2017-02-15 01:05:24 +00:00
Hugo Benichi
bc4ac9775f ConnectivityManager: fix potential NPE
ConnectivityManager static sCallbackHandler is referenced and directly
used in a way that is not ensuring its proper initialization.

This patch fixes this potential NPE by using getHandler() instead.

Also this patch changes sendRequestForNetwork's signature to only accept
the subtype CallbackHandler instead of Handler: without using
CallbackHandler the NetworkCallbacks are not triggered properly and
bookkeeping of sCallbacks does not happen. sendRequestForNetwork's
signature now makes this explicit.

This step prepares the addition of overloaded versions of
registerNetworkCallback and cie that takes custom Handlers.

Test: build, flashed, manually checked connectivity
Change-Id: I52e8a2cb5075e7aef7b35e30c9845cacba927d13
2017-02-14 16:01:40 +09:00
Erik Kline
47500d9b1b Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe am: d313f7c9fa
am: 022044ea69

Change-Id: I2ab05143299f13012dc2a88efca52160e08c6d97
2017-02-02 07:32:09 +00:00
Erik Kline
022044ea69 Merge "Add ConnectivityManager.networkCapabilitiesForType()" am: c313123afe
am: d313f7c9fa

Change-Id: I6828bc3bb094ca8597ca2d8538045758638c374f
2017-02-02 07:27:13 +00:00
Erik Kline
d313f7c9fa Merge "Add ConnectivityManager.networkCapabilitiesForType()"
am: c313123afe

Change-Id: I0ad50fbf38f11b383fd889dc598cfddd47051477
2017-02-02 07:22:05 +00:00
Erik Kline
ce55eb160d 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
2017-02-02 11:07:59 +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
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
ad488d0158 Merge "ConnectivityServiceTest: fix flaky tests" am: ee4f8f30eb am: 96a8a237b0
am: 1adc6c2054

Change-Id: Iaa1ab50a323133cadfa4f39440fce982cde8d1fe
2017-01-27 10:00:06 +00:00