Commit Graph

36927 Commits

Author SHA1 Message Date
paulhu
29797ebfae Update network preference priority value for VPN am: da7129d862
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1762867

Change-Id: I8aaea58aa38921cd354d326e074285f06d724f2b
2021-07-12 15:00:06 +00:00
paulhu
da7129d862 Update network preference priority value for VPN
Currently netd supports only the default value for VPN but CS
send priorty value 1 to netd. It will break the default routing
for VPN. Thus, update network preference priority value to 0 for
VPN.

Bug: 193245476
Test: atest CtsHostsideNetworkTests:HostsideVpnTests
Change-Id: I197cb358e8e30355fbf675e4c623abebe7abdb7f
2021-07-12 18:15:46 +08:00
Remi NGUYEN VAN
19122edbc5 Merge "Remove catch clause on compat shim" am: 5b37955322
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760688

Change-Id: I9b3dea9ce41f0afb1093c9c0affb185e870c4cd3
2021-07-12 04:05:37 +00:00
Remi NGUYEN VAN
5b37955322 Merge "Remove catch clause on compat shim" 2021-07-12 03:52:54 +00:00
Remi NGUYEN VAN
3c5a0f7de9 Merge "Remove hidden ArrayUtils usage in test" am: 946da61e70
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1760689

Change-Id: If2a051f415f46544955e6646ed7d74c52d4e2d22
2021-07-12 02:31:43 +00:00
Remi NGUYEN VAN
946da61e70 Merge "Remove hidden ArrayUtils usage in test" 2021-07-12 02:21:12 +00:00
Remi NGUYEN VAN
bd514f4993 Merge "Rename shared utils to connectivity-module-utils" am: c5ba57ec15
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1757315

Change-Id: Ib72d1cf70e1d1842ba7563fb106fde3d30e9c4f6
2021-07-09 09:53:36 +00:00
Remi NGUYEN VAN
61cc1ac9bd Remove hidden ArrayUtils usage in test
Internal utils are generally jarjared by connectivity jarjar rules, but
ArrayUtils is not actually statically linked into the tests, so this
makes the ConnectivityCoverageTests fail. FrameworksNetTests has been
fine because it does not use jarjar, but does not exercise updated code
because of that.

Remove usage of the hidden utility, as there are reasonable alternatives
with non-hidden APIs that avoid other breakages long-term.

Bug: 187935317
Test: atest ConnectivityCoverageTests:ConnectivityServiceTest
Change-Id: I8ed85b941c3d1028771a5ac33196b1509a95789d
2021-07-09 18:52:51 +09:00
Remi NGUYEN VAN
c5ba57ec15 Merge "Rename shared utils to connectivity-module-utils" 2021-07-09 09:41:22 +00:00
Remi NGUYEN VAN
c432565460 Merge "Add new network capabilities to support automotive head unit via USB" am: 8890ead0e0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1757322

Change-Id: If50a92d2cfbce8f91a179d73b5716b87758df8b2
2021-07-09 04:57:20 +00:00
Remi NGUYEN VAN
58cd24586c Rename shared utils to connectivity-module-utils
Rename net-module-utils-srcs to connectivity-module-utils-srcs.

This is done as the module utils are made specific to
service-connectivity to contain only classes used by
service-connectivity.

Bug: 192998401
Test: Tests prepared in next change
Change-Id: I354f4b84aa90cc12579c4db5479cf2de1dc9cf5d
2021-07-09 13:42:31 +09:00
Remi NGUYEN VAN
8890ead0e0 Merge "Add new network capabilities to support automotive head unit via USB" 2021-07-09 04:38:10 +00:00
Remi NGUYEN VAN
ca5530ed1d Remove catch clause on compat shim
registerSystemDefaultNetworkCallback no longer throws
UnsupportedApiLevelException as it has compatibility behavior down to Q,
so remove the catch clause for the checked exception.

The exception would previously not be thrown since the Tethering module
is only running on R+.

Bug: 182961265
Test: atest TetheringTests
Change-Id: I3c58235f3a59294995e5f32502fec6ccd17a3cf0
2021-07-09 10:24:44 +09:00
James Mattis
48f3878591 Merge "Only pass the NRI for removal in NRI#binderDied" am: 24fa1d7a8f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1741953

Change-Id: Iac74fa029c1736ae5a094d80766acbb838a6e212
2021-07-09 00:05:48 +00:00
James Mattis
24fa1d7a8f Merge "Only pass the NRI for removal in NRI#binderDied" 2021-07-08 23:54:46 +00:00
Chalard Jean
b819ff4142 Merge "Remove exclusivity restriction of multiple preferences" am: 278b92f6a0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1719390

Change-Id: Ib41c5050c389ac115221005f565ff4f59a799502
2021-07-08 04:05:45 +00:00
Chalard Jean
278b92f6a0 Merge "Remove exclusivity restriction of multiple preferences" 2021-07-08 03:50:34 +00:00
Remi NGUYEN VAN
577f3e158d Merge "Ensure wifi reconnects before waiting for metered" am: 14f0d14c14
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1757311

Change-Id: Icdf3557348e3a4f58c7e988057609cbbbd9e5e33
2021-07-08 00:54:52 +00:00
lucaslin
6f77442d76 Add new network capabilities to support automotive head unit via USB
- Add a new transport type for USB and a new network capability
to support automotive head unit.
- In order to pass DnsManagerTest#testTransportTypesEqual, Android.bp
needs to link to dnsresolver_aidl_interface-V8-java. That test checks
whether the TRANSPORT types defined in NetworkCapabilities are the
same as IDnsResolver.aidl.

(clean cherry-pick of change in downstream branch history, original
change ID before project move:
Iec2df09a776d779108f95098e01b7ffdf6f8867a)

Bug: 181742019
Test: atest FrameworksNetTests

Merged-In: I3c2563d4ae4e3715d0c6270344ba8f7ef067872f
Change-Id: Ie438ec68577ebdaaf990795fa27f1169b0105411
2021-07-08 09:44:39 +09:00
Remi NGUYEN VAN
14f0d14c14 Merge "Ensure wifi reconnects before waiting for metered" 2021-07-08 00:40:37 +00:00
James Mattis
8f03680fdb Only pass the NRI for removal in NRI#binderDied
When NetworkRequestInfo#binderDied is called in ConnectivityService,
only pass the NRI to handleRemoveNetworkRequest. This is to prevent a
potential crash when unlinkDeathRecipient is called twice for the same
NRI.

Also, as a cleanup, don't iterate mRequests in the log message on binderDied.

As per the bug, the chain of events leading to a potential crash are:

- `Connectivity.NetworkRequestInfo#binderDied()` is called for an NRI
tracking multiple `NetworkRequest` items. This can happen for a TRACK_DEFAULT
request filed by a UID on a different preference than the default, which
copies the request list.
- This in turn triggers multiple `EVENT_RELEASE_NETWORK_REQUEST` events
for the same NRI, one for reach `NetworkRequest` tracked.
- When handling `EVENT_RELEASE_NETWORK_REQUEST`, each `NetworkRequest`
that is passed in will then be used to look up the parent NRI that originally
sent it to be released.
- Therefore if an NRI was tracking three requests, it would trigger three
release network events, then each request would be used to look up the
same NRI again when handling said release event.
- Finally, `ConnectivityService.NetworkRequestInfo#unlinkDeathRecipient` is
called for the NRI in question. Using the scenario above, that means we could
call `unlinkDeathRecipient` multiple times for the same NRI if it was tracking
multiple network requests causing the associated crash.
- If `unlinkDeathRecipient` is called more than once for the same NRI, it will
cause the crash listed in this bug.
- The fix is to only call handleRemoveNetworkRequest for the NRI once. This
works since when removing the NRI, we iterate over all of its requests to
remove them. By only calling handleRemoveNetworkRequest once, it's ensured
`unlinkDeathRecipient` for this NRI as part of
`Connectivity.NetworkRequestInfo#binderDied()` is only called  once and not
potentially multiple times.

Bug: 185541983
Test: atest FrameworksNetTests
Change-Id: I2a2ad4ec6d415423182a1856a898779203658f8b
2021-07-07 17:16:59 -07:00
paulhu
aa0743d7c4 Remove exclusivity restriction of multiple preferences
- Each network preference has been assigned a priority value so
  that netd can know which uid range rule has higher priority. So
  remove the restriction that all network preferences are
  exclusive.
- Add priority check when getting request for uid.

Bug: 171872461
Test: atest FrameworksNetTests
(cherry-pick from ag/14731887)
Merged-In: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b

Change-Id: I6912db753c8b4a194aa7af92b01ca6dcfec10d8b
2021-07-07 23:06:43 +08:00
Treehugger Robot
5c7e4c179b Merge "Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported" am: 1d2ad89424
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755630

Change-Id: I4539d7b5d254c09d629e4d0bdb8b5db4a9d9db96
2021-07-07 04:11:26 +00:00
Treehugger Robot
b9b4ee6d0e Merge "Fix flake in testMobileDataAlwaysOn" am: 02ea3f55c1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755251

Change-Id: Ide762b07177c861a7308690a8e39040de2414506
2021-07-07 04:11:20 +00:00
Treehugger Robot
1d2ad89424 Merge "Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported" 2021-07-07 03:53:17 +00:00
Treehugger Robot
02ea3f55c1 Merge "Fix flake in testMobileDataAlwaysOn" 2021-07-07 03:52:38 +00:00
Remi NGUYEN VAN
3499d73016 Merge changes I99ce72bd,I5a11a802 am: 527ffb6f0c
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1756971

Change-Id: Icb435dbe7be5eb125b88336263fd3519139501db
2021-07-07 03:21:57 +00:00
Paul Hu
cef78638b5 Merge "Use Netd new added/removed uid range methods" am: 51bfbbfb1b
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755053

Change-Id: I1ab928e64501c47adbb1416555640084098cf72f
2021-07-07 03:21:51 +00:00
Remi NGUYEN VAN
527ffb6f0c Merge changes I99ce72bd,I5a11a802
* changes:
  Add retries for WifiManager#connect
  Use WifiManager.connect to reconnect wifi
2021-07-07 03:07:21 +00:00
Paul Hu
51bfbbfb1b Merge "Use Netd new added/removed uid range methods" 2021-07-07 03:07:10 +00:00
paulhu
0e79d95332 Use Netd new added/removed uid range methods
Replace network[Add|Remove]UidRanges to
network[Add|Remove]UidRangesParcel. The new methods are passing
NativeUidRangeConfig which contains priority value for each uid
range rules.

Bug: 171872461
Test: atest FrameworksNetTests
Test: atest HostsideVpnTests
(cherry-pick from ag/14911836)
Merged-In: I08bbdbcb8450b08e6208fa730137348550f9e3d2

Change-Id: I08bbdbcb8450b08e6208fa730137348550f9e3d2
2021-07-07 03:06:32 +00:00
Maciej Żenczykowski
4f8727b8a7 remove obsolete/no-op NativeQtaguidTest am: 2aabf4138e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1757412

Change-Id: I43c6fa74b4fbd45cd047b6169316e656debae855
2021-07-07 02:07:54 +00:00
Remi NGUYEN VAN
c6be26e0ef Ensure wifi reconnects before waiting for metered
testGetMultipathPreference assumes that wifi will auto-reconnect after
changing its metered status, but this is not necessarily the case if the
BSSID has been blocklisted after it failed validating too many times.

Call ensureWifiConnected to force wifi to reconnect before waiting for
it to become metered.

Bug: 190913510
Test: atest ConnectivityManagerTest
Change-Id: Iafe9837b97e4d654bb0f3962d48a94c1f31bbebc
2021-07-07 10:55:39 +09:00
Maciej Żenczykowski
2aabf4138e remove obsolete/no-op NativeQtaguidTest
qtaguid is long dead - test is thus a no-op

New test logs:
  Running Tests...

  x86 CtsNativeNetTestCases
  -------------------------
  CtsNativeNetTestCases (1 Test)
  [1/1] BpfTest#bpfStructSizeTest: PASSED (0ms)

  Summary
  -------
  x86 CtsNativeNetTestCases: Passed: 1, Failed: 0, Ignored: 0, Assumption Failed: 0,

  All tests passed!

Test: atest CtsNativeNetTestCases, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9ff784dbfda0ce981904d53eacb7bc831cbe81da
2021-07-06 22:15:44 +00:00
Treehugger Robot
b2817e8e31 Merge "add test for /system/etc/bpf/{netd,clatd}.o using correct struct sizes" am: 464d0b2bdd
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1756440

Change-Id: I8414a4ab963e8754978c781635a66de52be39813
2021-07-06 20:58:42 +00:00
Treehugger Robot
464d0b2bdd Merge "add test for /system/etc/bpf/{netd,clatd}.o using correct struct sizes" 2021-07-06 20:44:57 +00:00
Maciej Żenczykowski
bbc4ea32bc add test for /system/etc/bpf/{netd,clatd}.o using correct struct sizes
This test is required to ensure that the system is compatible
with future updates of the tethering mainline module, which
updates BPF .o files on device.

This test must already be passing on OEM devices because otherwise
the offload.o program in the Tethering mainline module would bootloop
the device.

Bug: 190519702
Test: atest CtsNativeNetTestCases, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibaedb8fcb28591ffba1506514f2305d55712a26b
2021-07-06 02:50:47 -07:00
Remi NGUYEN VAN
00407b0c1b Add retries for WifiManager#connect
Connect can error with BUSY if the framework is busy when connect is
called. Add retries so that if this happens, the connection can succeed
after the framework stops being busy.

Also log the level of scan results when several configurations are
available, and clarify the legacy broadcast assert.

Bug: 188077861
Test: atest CtsNetTestCases
Change-Id: I99ce72bd2604489cb419ea9984643b6985728461
2021-07-06 17:53:48 +09:00
Remi NGUYEN VAN
e687d5844e Fix flake in testMobileDataAlwaysOn
The internal structure backing getAllNetworks is updated after
invoking lost callbacks, so the test needs to wait for the handler
to be idle before calling getAllNetworks.

Also avoid assertions in finally clauses, as it causes confusing
error messages.

Bug: 185081944
Change-Id: I8ad5ab45a3e65b0031672e6f594b1a6d6ad5abcb
Test: atest ConnectivityServiceTest
2021-07-06 06:09:17 +00:00
Remi NGUYEN VAN
1f210f792a Fix flake in testConnectivityDiagnosticsCallbackOnConnectivityReported
The test relied on waitForIdle to ensure diagnostics callbacks were called,
but as this may require several iterations in the handler queue, this makes
the test unreliable.

Use mockito timeouts on the verify() calls instead.

Bug: 192651465
Change-Id: Iae1704af7ae3649eae301c6aee223ac753629d55
Test: atest ConnectivityServiceTest
2021-07-06 06:05:38 +00:00
Lorenzo Colitti
51f5f61742 Merge "Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true" am: 844ca1290e
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1755176

Change-Id: I5c7cb78792108b89b366da9528ffae424331aba9
2021-07-06 03:51:26 +00:00
Lorenzo Colitti
736df2cb2f Merge "Enable and disable usb IpServer according to ACTION_USB_STATE" am: d479e694f0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1731453

Change-Id: Ic250214e5e731aa2505620703e53dfa2083bffa6
2021-07-06 03:51:19 +00:00
Lorenzo Colitti
844ca1290e Merge "Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true" 2021-07-06 03:39:31 +00:00
Lorenzo Colitti
d479e694f0 Merge "Enable and disable usb IpServer according to ACTION_USB_STATE" 2021-07-06 03:39:15 +00:00
Remi NGUYEN VAN
3676ffb9af Use WifiManager.connect to reconnect wifi
Address a TODO to use WifiManager#connect to reconnect wifi, instead of
WifiManager#reconnect. #connect also clears the BSSID denylist; that
list has caused flakyness due to tests that cause the network not to
validate such as captive portal or invalid private DNS behavior tests,
causing wifi to ignore the access point in reconnect attempts.

Bug: 188077861
Test: atest CtsNetTestCasesLatestSdk

Change-Id: I5a11a802db8a4881c161e6038c1c183d2ac23a05
2021-07-06 11:30:51 +09:00
markchien
b28740ec89 Load ncm regexs config to tetherableUsbRegexs if isUsingNcm=true
If config_tether_ncm_regexs is configured, load it to
tetherableUsbRegexs if ncm is used for TETHERING_USB. Load it to
tetherableNcmRegexs if ncm is used for TETHERING_NCM.

Bug: 185649441
Test: atest TetheringTests
Change-Id: I0c542560bd04e8c0a6a78d632da5a00a34d9a3fa
2021-07-05 23:11:50 +08:00
markchien
b41a00e778 Enable and disable usb IpServer according to ACTION_USB_STATE
Before this change, usb IpServer would be created if corresponding
interface is available even there is no enable tethering attempt. And
usb IpServer only be disabled when interface is removed. Usb tethering
could not be stopped if interface is always avaialbe.
After this change, usb IpServer would be enabled and disabled according
to ACTION_USB_STATE.

Bug: 185649441
Test: atest TetheringCoverageTests
      atest MtsTetheringTestLatestSdk
      atest CtsTetheringTest
Change-Id: I8375e3f998d677dc658370b2553facaec0d5ff7c
2021-07-05 22:53:07 +08:00
Junyu Lai
ce077a3ad0 Merge "Consider NetworkOffer is unneeded if it cannot satisfy the request" am: b028fc7cf1
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1731452

Change-Id: I9c7bb2e88ad6b6929bf7db3b7433b772c4f5d15a
2021-07-05 09:09:01 +00:00
Junyu Lai
b028fc7cf1 Merge "Consider NetworkOffer is unneeded if it cannot satisfy the request" 2021-07-05 08:57:07 +00:00
Remi NGUYEN VAN
b65aea1772 Merge "Move BitUtils, RingBuffer test to coretests" am: 6be4ebcb0a
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1754897

Change-Id: Ib30b1f12b17241d66a80130f772d2948e3cee358
2021-07-05 05:18:21 +00:00