Commit Graph

11783 Commits

Author SHA1 Message Date
Lorenzo Colitti
45ed4e60d0 Expose upstream requirements to UpstreamNetworkMonitor. am: 0e7e32ab2c am: 9dcd8587ed am: ce664ec1cf
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1556198

Change-Id: I2008fa03e5be4d692c5aca09f3ceeb3a822c0bea
2021-04-01 10:07:48 +00:00
Lorenzo Colitti
daab695c62 Rename members in TestConnectivityManager. am: 9bbdac6275 am: a6d9d23180 am: cece10d4e0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1659938

Change-Id: I3aefc96deeb0cbed9bc608c3435e18cda174b391
2021-04-01 09:26:23 +00:00
Lorenzo Colitti
7ba849ee98 Add the ability to affect ordering in the tethering unit tests. am: 3e09f80e8a am: bdb012f733 am: a116b7f370
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1635021

Change-Id: I1ebce83cee60c2b5adc2102a7bda23b9c06460e2
2021-04-01 09:26:22 +00:00
Lorenzo Colitti
cfe964feac Make Tethering file NetworkRequests only if needed. am: 2bcde0fd97 am: cce64f0dd7 am: bd868cd5d0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1556199

Change-Id: I5e1059993a86ec1fdd5bb9a7001683af5dcd6b57
2021-04-01 09:26:21 +00:00
Lorenzo Colitti
a403fd6c1a Expose upstream requirements to UpstreamNetworkMonitor. am: 0e7e32ab2c am: 9dcd8587ed am: 9902d8c14f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1556198

Change-Id: Ie3d1ea858e3582ff84a409efb4403bac0b609993
2021-04-01 09:26:19 +00:00
Lorenzo Colitti
cece10d4e0 Rename members in TestConnectivityManager. am: 9bbdac6275 am: a6d9d23180
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1659938

Change-Id: If02ce4eed9804d705a575fe7171459dafba216c9
2021-04-01 08:39:16 +00:00
Lorenzo Colitti
ce664ec1cf Expose upstream requirements to UpstreamNetworkMonitor. am: 0e7e32ab2c am: 9dcd8587ed
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1556198

Change-Id: I285334ac1096dcbd3102961f4d9bd7f44f2dcded
2021-04-01 08:39:15 +00:00
Lorenzo Colitti
a116b7f370 Add the ability to affect ordering in the tethering unit tests. am: 3e09f80e8a am: bdb012f733
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1635021

Change-Id: Iee27da6e7f6972564ee062e789905197e8994aa9
2021-04-01 08:39:15 +00:00
Lorenzo Colitti
bd868cd5d0 Make Tethering file NetworkRequests only if needed. am: 2bcde0fd97 am: cce64f0dd7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1556199

Change-Id: I66b565a18a850c020f1289566c646bdda1b6bd94
2021-04-01 08:39:15 +00:00
Lorenzo Colitti
9902d8c14f Expose upstream requirements to UpstreamNetworkMonitor. am: 0e7e32ab2c am: 9dcd8587ed
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1556198

Change-Id: I47a5bdced72c17ecc5182f57623de1ae21f29036
2021-04-01 08:39:14 +00:00
Lorenzo Colitti
a6d9d23180 Rename members in TestConnectivityManager. am: 9bbdac6275
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1659938

Change-Id: I406e1acb5615bff8eae2690af4972ec5040bc77a
2021-04-01 08:04:34 +00:00
Lorenzo Colitti
bdb012f733 Add the ability to affect ordering in the tethering unit tests. am: 3e09f80e8a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1635021

Change-Id: Iddf2d125678538248f7070899baffebfbc7529d3
2021-04-01 08:04:33 +00:00
Lorenzo Colitti
cce64f0dd7 Make Tethering file NetworkRequests only if needed. am: 2bcde0fd97
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1556199

Change-Id: Ieaedc7d8d7bea358b42dc4e8e5b4533c69c7c8e4
2021-04-01 08:04:32 +00:00
Lorenzo Colitti
9dcd8587ed Expose upstream requirements to UpstreamNetworkMonitor. am: 0e7e32ab2c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1556198

Change-Id: I862c58cbf368567e88b6ed89c1f92f96c95f7243
2021-04-01 08:04:31 +00:00
Lorenzo Colitti
9bbdac6275 Rename members in TestConnectivityManager.
These members are public mutable and their names are confusing.
Make them package-private and final.

Bug: 173068192
Test: test-only change
Change-Id: I87131c48f67b6614c25aa99e1cbc53196f49aa7c
2021-03-31 20:23:20 +09:00
Lorenzo Colitti
3e09f80e8a Add the ability to affect ordering in the tethering unit tests.
Currently, TestConnectivityManager immediately sends all
callbacks and broadcasts to the Tethering code as soon as the
test code makes any change.

This makes it impossible to affect the order in which those
events are delivered to the Tethering code, so it is not possible
to test for races.

Fix some of this as follows:
1. Make TestConnectivityManager post all its callbacks to the
   handlers that Tethering registered them with.
2. In TetheringTest, use the existing TestLooper object to
   advance time manually. Also use setUseRegisteredHandlers to
   ensure that the broadcasts are sent in order. This requires
   calling dispatchAll() after sending the broadcast to preserve
   the existing synchronous behaviour. Take advantage of that to
   remove lots of existing dispatchAll calls.
3. Add a TestLooper to UpstreamNetworkMonitorTest and use it.
   Keep the test passing by adding lots of mLooper.dispatchAll(),
   which is a bit ugly but probably acceptable given the
   additional coverage it provides.

This exposes an existing bug in the code where if upstream
selection is in automatic mode, and all CONNECTIVITY_ACTION
broadcasts are received before all NetworkCallbacks, the code
does not switch upstream.

In order to make the tests pass, re-order the CONNECTIVITY_ACTION
broadcasts with the NetworkCallbacks in TestConnectivityManager
so as not to trigger the bug. A future CL will make the order
configurable.

While I'm at it, switch TestConnectivityManager from HashMap to
ArrayMap, which is generally preferred for maps that do not
contain too many elements.

Bug: 173068192
Test: test-only change
Change-Id: I964f365c691fbc396ab0a87f292bd32b123011fe
2021-03-31 20:17:11 +09:00
Lorenzo Colitti
2bcde0fd97 Make Tethering file NetworkRequests only if needed.
Currently, Tethering files NetworkRequests even when
config_tether_upstream_automatic is enabled. This is incorrect:
when the automatic upstream selection is enabled, the tethering
upstream should always follow the default network and there is
no need to file any requests.

These requests are harmful when tethering is not using cellular
as its upstream, because:

- If the device does not use mobile data always on, the request
  causes the cellular network to be brought up, causing power
  draw.
- Even if the device does use mobile data always on, the request
  causes the cellular network to come to the foreground, which
  allows all apps to access it, causing potential data usage.

Amend the existing testGetCurrentPreferredUpstream to cover these
changes, by making that test case always set automatic upstream
mode. This does not result in any loss of meaningful test
coverage, because getCurrentPreferredUpstream is only ever called
when chooseUpstreamAutomatically is enabled.

Bug: 173068192
Test: atest TetheringTests
Change-Id: I068a5338699a3ed04f24f97f785ea89ff5890e50
2021-03-31 19:27:17 +09:00
Lorenzo Colitti
0e7e32ab2c Expose upstream requirements to UpstreamNetworkMonitor.
UpstreamNetworkMonitor is the part of tethering that files
NetworkRequests for upstream netwoks, but it currently does not
know all the requirements for upstream selection. For example, it
does not know whether automatic upstream selection is in use.
This forces the upstream selection code to be split between
UpstreamNetworkMonitor and Tethering. This makes it difficult to
follow.

This CL ensures that all information about upstream requirements
(DUN required, automatic upstream selection, tryCell) is passed
to UpstreamNetworkMonitor so it can be aware of it.

This CL also removes the ability for UpstreamNetworkMonitor's
callers to call registerMobileNetworkRequest or
releaseMobileNetworkRequest. In a future CL, this will be
automatically done by UpstreamNetworkMonitor depending on the
upstream requirements.

This CL is a no-op refactoring with no behaviour changes.

Bug: 173068192
Test: atest TetheringTests
Change-Id: I174f765c616e0dbe2aa493c12613e6131cff0666
2021-03-31 19:27:17 +09:00
Sudheer Shanka
c38f2b7d1b [automerger skipped] Check and skip certain operations if they are unsupported. am: b0f50c579b am: 7695f293a7 am: 19d07566b9 -s ours
am skip reason: skip tag Change-Id Ie68e17063454e7feeffc93b20b1b8fbb276e837f with SHA-1 f0ba6291b1 is already in history

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1658759

Change-Id: I1077c60354b1c8498989272077ed0825a13d9b9b
2021-03-31 00:40:13 +00:00
Sudheer Shanka
90cc78a3c3 [automerger skipped] Check and skip certain operations if they are unsupported. am: b0f50c579b am: 7695f293a7 am: 83b66e64c7 -s ours
am skip reason: skip tag Change-Id Ie68e17063454e7feeffc93b20b1b8fbb276e837f with SHA-1 f0ba6291b1 is already in history

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1658759

Change-Id: I4c0f3bdcd71fe484dca53810bfa3444bef00495e
2021-03-31 00:39:06 +00:00
Sudheer Shanka
19d07566b9 Check and skip certain operations if they are unsupported. am: b0f50c579b am: 7695f293a7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1658759

Change-Id: I29d4c5a2b332f6eff426393212583fae6a8c0e11
2021-03-30 23:48:30 +00:00
Sudheer Shanka
83b66e64c7 Check and skip certain operations if they are unsupported. am: b0f50c579b am: 7695f293a7
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1658759

Change-Id: I4ececd442b6fab3ad4e6aefd0937226831a7b87b
2021-03-30 23:48:22 +00:00
Sudheer Shanka
7695f293a7 Check and skip certain operations if they are unsupported. am: b0f50c579b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1658759

Change-Id: I8068e4beebfe928977a97e5c0241b19e5d719d06
2021-03-30 23:12:32 +00:00
Sudheer Shanka
fd8bfb3f97 Merge "Revert NPMS threshold to BFGS." into sc-dev 2021-03-30 17:51:52 +00:00
Sudheer Shanka
b0f50c579b Check and skip certain operations if they are unsupported.
Fixes: 178334463
Test: com.android.cts.net.HostsideRestrictBackgroundNetworkTests#testMeteredNetworkAccess_expeditedJob
Change-Id: Ie68e17063454e7feeffc93b20b1b8fbb276e837f
Merged-In: Ie68e17063454e7feeffc93b20b1b8fbb276e837f
2021-03-30 16:22:43 +00:00
lifr
ac6614fa05 Add session ID to VpnTransportInfo
- This will be visible only to apps with the NETWORK_SETTINGS
  permissions (signature), and will be redacted for all other callers.
- This string is expected to be the same as set by
  VpnService#setSession, and in general, VpnConfig.session. But it
  will be a general API that Vpn.java can call when setting the
  VpnTransportInfo.
- This string cannot be updated once the VPN NetworkAgent is connected.

Bug: 171872481
Ignore-AOSP-First: needed to prevent automerger race breaking build
Test: atest ConnectivityServiceTest
      atest VpnTransportInfoTest
      atest NetworkAgentTest
Change-Id: I883035262465238c35c5a931d89707f3e84feef8
2021-03-29 14:51:25 +00:00
Sudheer Shanka
384fb5cb42 Revert NPMS threshold to BFGS.
Earlier, we changed the threshold to IMP_FG to allow
HPJs to bypass power saving network restrictions but
later we made a change to instead use network capability
for HPJs, so reverting the threshold to BGFS.

Bug: 177641226
Test: atest ./tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
Ignore-AOSP-First: This depends on an earlier cl which is not in AOSP
Change-Id: I6364ca04254bdbcc3d2081a70babfbd927e0084e
2021-03-26 13:25:58 -07:00
Remi NGUYEN VAN
bee627b39c Merge "Add framework-connectivity to the Tethering APEX" into sc-dev 2021-03-25 14:51:56 +00:00
Remi NGUYEN VAN
4baffbe8e3 Merge "Reference framework-connectivity stubs explicitly" into sc-dev 2021-03-25 02:05:07 +00:00
Remi NGUYEN VAN
6d575cace8 Add framework-connectivity to the Tethering APEX
Add framework-connectivity and its jni library dependency to the APEX.

Bug: 171540887
Test: device boots, has connectivity
Ignore-AOSP-First: Merge conflicts, will cherry-pick

Change-Id: I72fc7fee7bfcd909cbc79b4c34e8b3f29055d378
2021-03-24 23:05:29 +09:00
Remi NGUYEN VAN
02b94faf80 Reference framework-connectivity stubs explicitly
To merge the framework-connectivity and framework-connectivity.impl
targets, framework-connectivity stubs need to be referenced explicitly
in java_sdk_libraries, otherwise the build system will currently see
dependency cycles.

Bug: 183600168
Test: m
Ignore-AOSP-First: Needs manual cherry-picks
Change-Id: I556747f9ba934f8b44b6ea9a518adbccc84ac2a9
2021-03-24 23:05:13 +09:00
Chiachang Wang
f03ce99d71 [automerger skipped] Replace the usage of UidRange am: b439ce8bda -s ours
am skip reason: skip tag Change-Id I4bc0daf5ad9e4b4043f4a897ddab16aec8f8a536 with SHA-1 41918d6cd1 is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/13973150

Change-Id: I467054b8b492f3672f643a8ff2a286cc5d2578cf
2021-03-24 06:08:17 +00:00
Chiachang Wang
b439ce8bda Replace the usage of UidRange
The parameter of NetworkCapabilities.setUids() and
NetworkRequest.Builder.setUids() are updated to take a set of
integer Range instead of a set of UidRange because of refactor
work for the incoming connectivity mainline module.

The parameter change stops NetworkRequestTest to work in the
different API levels. Replace the usage with shims to work in
both current and stable APIs.

Ignore-AOSP-First: Prevent race in automerger
Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk

(cherry picked from commit 41918d6cd1)

Change-Id: I3ff97b9bbda8839d271151165b8d99a04ae9e1f1
Merged-In: I4bc0daf5ad9e4b4043f4a897ddab16aec8f8a536
2021-03-24 03:53:29 +00:00
Chiachang Wang
592d72bf4c [automerger skipped] Replace the usage of UidRange am: 2257ecc830 -s ours am: 5e8d1596b6 -s ours
am skip reason: skip tag Change-Id I4bc0daf5ad9e4b4043f4a897ddab16aec8f8a536 with SHA-1 41918d6cd1 is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/13958466

Change-Id: I056312ed3ec9c22854a09fa2f75cacca19c07e03
2021-03-23 05:12:05 +00:00
Chiachang Wang
c86cecc0cb [automerger skipped] Replace the usage of UidRange am: 2257ecc830 -s ours am: 20df1dc6cc -s ours
am skip reason: skip tag Change-Id I4bc0daf5ad9e4b4043f4a897ddab16aec8f8a536 with SHA-1 41918d6cd1 is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/13958466

Change-Id: I27f39c91f81a25cc03dbcc99b4b22569128b5eb9
2021-03-23 04:51:48 +00:00
Chiachang Wang
20df1dc6cc [automerger skipped] Replace the usage of UidRange am: 2257ecc830 -s ours
am skip reason: skip tag Change-Id I2550cb3ddd9c72c12de0dbf9baf32eec6fa3b151 with SHA-1 00950274cb is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/13958466

Change-Id: I9e89c1a6e81b97e37254a23a4c4e28356836b77a
2021-03-23 04:09:57 +00:00
Chiachang Wang
5e8d1596b6 [automerger skipped] Replace the usage of UidRange am: 2257ecc830 -s ours
am skip reason: skip tag Change-Id I4bc0daf5ad9e4b4043f4a897ddab16aec8f8a536 with SHA-1 c1f14634a4 is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/13958466

Change-Id: I01b4b6925c5976899584d663963b354b193e096e
2021-03-23 04:09:51 +00:00
Chiachang Wang
44582f2549 [automerger skipped] Replace the usage of UidRange am: 00950274cb -s ours
am skip reason: skip tag Change-Id I4bc0daf5ad9e4b4043f4a897ddab16aec8f8a536 with SHA-1 41918d6cd1 is already in history

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/13958465

Change-Id: I9e82ec7ffc167bb5a48b3d5c1f7ff350be61479c
2021-03-23 03:34:31 +00:00
Chiachang Wang
2257ecc830 Replace the usage of UidRange
The parameter of NetworkCapabilities.setUids() and
NetworkRequest.Builder.setUids() are updated to take a set of
integer Range instead of a set of UidRange because of refactor
work for the incoming connectivity mainline module.

The parameter change stops NetworkRequestTest to work in the
different API levels. Replace the usage with shims to work in
both current and stable APIs.

Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Merged-In: I4bc0daf5ad9e4b4043f4a897ddab16aec8f8a536
Merged-In: I2550cb3ddd9c72c12de0dbf9baf32eec6fa3b151
Change-Id: I90b3384d2a78275df9f8717dba9d654eb82036bd
2021-03-23 08:51:40 +09:00
Chiachang Wang
00950274cb Replace the usage of UidRange
The parameter of NetworkCapabilities.setUids() and
NetworkRequest.Builder.setUids() are updated to take a set of
integer Range instead of a set of UidRange because of refactor
work for the incoming connectivity mainline module.

The parameter change stops NetworkRequestTest to work in the
different API levels. Replace the usage with shims to work in
both current and stable APIs.

Bug: 172183305
Test: atest FrameworksNetTests CtsNetTestCasesLatestSdk
Merged-In: I4bc0daf5ad9e4b4043f4a897ddab16aec8f8a536
Change-Id: I2550cb3ddd9c72c12de0dbf9baf32eec6fa3b151
2021-03-23 08:48:41 +09:00
Treehugger Robot
009ce5040f [automerger skipped] Merge "Shorten the name for the dump file." am: a7542972b1 am: 3935ac08fd am: 9d3174e4cb -s ours
am skip reason: skip tag Change-Id Ic0f87b97bb58e115fe81e2d688ce0e633397da42 with SHA-1 2b5735165a is already in history

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1648668

Change-Id: I6c7b77dfd766e7c8deec293a437d49e059fd85f3
2021-03-22 23:01:18 +00:00
Treehugger Robot
b412119253 [automerger skipped] Merge "Shorten the name for the dump file." am: a7542972b1 am: 3935ac08fd am: d802f4898f -s ours
am skip reason: skip tag Change-Id Ic0f87b97bb58e115fe81e2d688ce0e633397da42 with SHA-1 2b5735165a is already in history

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1648668

Change-Id: Ie3c654e53d42ac4de12aed66aa7ec74373e2c929
2021-03-22 23:00:06 +00:00
Treehugger Robot
d802f4898f Merge "Shorten the name for the dump file." am: a7542972b1 am: 3935ac08fd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1648668

Change-Id: Ia73a8459e6bba6f24fc1f40cdb8cfb3177d9f9bb
2021-03-22 22:20:28 +00:00
Treehugger Robot
9d3174e4cb Merge "Shorten the name for the dump file." am: a7542972b1 am: 3935ac08fd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1648668

Change-Id: Ifb3ab6932f7c562456379f960c18a57ce03e11eb
2021-03-22 22:20:24 +00:00
Sudheer Shanka
15308ca45b [automerger skipped] Try reconnecting to wifi if it doesn't automatically connect. am: 8bb9eb1912 am: bc0ca639a2 am: 81330c83ce -s ours
am skip reason: skip tag Change-Id I31fb127ef333d39fe4697043876c7cef15d525e3 with SHA-1 aae0d619ae is already in history

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1648670

Change-Id: Ib7e2365f676ef63f46b88a5d3e64c6aa29a17e37
2021-03-22 21:59:24 +00:00
Treehugger Robot
3935ac08fd Merge "Shorten the name for the dump file." am: a7542972b1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1648668

Change-Id: I11f5ca67a111e7d923310b68d90f66ef383d015a
2021-03-22 21:55:45 +00:00
Sudheer Shanka
a0e282b018 [automerger skipped] Try reconnecting to wifi if it doesn't automatically connect. am: 8bb9eb1912 am: bc0ca639a2 am: e2a709360c -s ours
am skip reason: skip tag Change-Id I31fb127ef333d39fe4697043876c7cef15d525e3 with SHA-1 aae0d619ae is already in history

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1648670

Change-Id: I989eba23f64e3587f539e318ee70b0b491fe5ee5
2021-03-22 21:40:46 +00:00
Treehugger Robot
a7542972b1 Merge "Shorten the name for the dump file." 2021-03-22 21:34:02 +00:00
Sudheer Shanka
e2a709360c Try reconnecting to wifi if it doesn't automatically connect. am: 8bb9eb1912 am: bc0ca639a2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1648670

Change-Id: Ibcd508be488d90fa147587dbc45de9a7066c8b8b
2021-03-22 21:15:58 +00:00
Sudheer Shanka
81330c83ce Try reconnecting to wifi if it doesn't automatically connect. am: 8bb9eb1912 am: bc0ca639a2
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1648670

Change-Id: Ief4defadb6e4f5b45a7ef3d3022953244eca4788
2021-03-22 21:14:50 +00:00