Commit Graph

14477 Commits

Author SHA1 Message Date
Lorenzo Colitti
0d942e81c7 Merge "Rename unwanted capabilities to forbidden capabilities." 2021-05-12 09:00:17 +00:00
Lorenzo Colitti
2422319cb7 Remove dead code.
Remove a few legacy methods that have no callers.

Test: m
Change-Id: I499e940dc98453194fc528d65a89696471ad8bdd
2021-05-12 17:35:49 +09:00
Lorenzo Colitti
94311aa902 Remove mPublicSync.
This is no longer necessary as all the methods that take it are
running on on the handler thread, either in Tethering itself or
on the state machine thread in IpServer, which runs on the same
thread as Tethering.

Specifically:
- interfaceStatusChanged, interfaceAdded, interfaceRemoved,
  interfaceLinkStateChanged: run from mNetdCallback, which always
  posts them to mHandler.
- setWifiTethering: only called by enableTetheringInternal, which
  is called by the following:
  - startTethering, stopTethering: via lambda posted to mHandler
  - IpServerCallback#requestEnableTethering: called by IpServer
    while processing a command.
- setEthernetTethering: only called by enableTetheringInternal.
- EthernetCallback: runs on mExecutor, which posts to mHandler.
- getLastTetherError: only used by the test. Renamed to
  getLastErrorForTest to ensure no other callers.
- sendTetherStateChangedBroadcast: called only by
  notifyInterfaceStateChange, which is called only by
  - IpServerCallback#updateInterfaceState, which is called only
    by sendInterfaceState, which is called by various IpServer
    state enter methods.
- notifyLinkPropertiesChanged: called only by
  IpServerCallback#updateLinkProperties, which is only called by
  IpServer#sendLinkProperties, which is only called by:
  - Code that processes CMD_IPV6_TETHER_UPDATE
  - IpServer#handleNewPrefixRequest: only called when processing
    CMD_NEW_PREFIX_REQUEST.
  - IpServer#sendInterfaceState (see above)
- handleWifiApAction, handleWifiP2pAction: only called by
  mStateReceiver, which runs on the handler thread
- tether(String, int): called by:
  - tether(String, IIntResultListener): posted to mHandler
  - changeInterfaceState: called by:
    - EthernetCallback (see above)
    - enableWifiIpServingLocked: called by handleWifiApAction and
      handleWifiP2pAction (see above)
    - tetherMatchingInterfaces: only called by handleUsbAction,
      which is run from mStateReceiver on the handler thread.
- untether(String): called by:
  - untether(String, IIntResultListener): posted to mHandler
  - changeInterfaceState (see above)
- setUsbTethering: called by:
  - setUsbTethering(boolean, IIntResultListener): posted to mHandler
  - enableTetheringInternal (see above)
- setNcmTethering: called by enableTetheringInternal (see above)
- getTetheredIfaces: called only by TetheringTest. Renamed to
  getTetheredIfacesForTest to ensure no other callers.
- getErroredIfaces: unused, deleted in this CL
- getTetheredIfaces: called by:
  - isTetheringActive: called by onUserRestrictionsChanged, which
    is only called by mStateReceiver
  - TetheringTest
- dump(): changed to run on handler thread
- upstreamWanted: called by
  - TetherModeAliveState#enter
  - TetherModeAliveState#updateUpstreamWanted, which is called
    only by TetherModeAliveState#processMessage.

Test: atest TetheringCoverageTests
Test: enabled/disabled hotspot, USB tethering
Change-Id: Id49d33f027b8df4c97fda480ff239c0ba90bb96a
2021-05-12 17:35:49 +09:00
Lorenzo Colitti
5f729e14a3 Make Tethering#dump asynchronous.
This is in preparation for removing mPublicSync.

Test: m
Test: adb shell dumpsys tethering
Test: atest TetheringTests TetheringIntegrationTests
Change-Id: Ib2c9d0bff23614f76c8e075d32cb03412d3d21f7
2021-05-12 17:35:49 +09:00
Lorenzo Colitti
b54bdabe5a Skip presubmit for IPsec transport mode IPv6 TCP tests.
These tests are currently broken due to what appears to be an
upstream regression affecting 5.10 kernels, and are causing
all networking CLs to fail presubmit.

Skip them in presubmit until the regression is fixed. The tests
will still fail when run manually or in postsubmit.

Bug: 186608065
Test: atest CtsNetTestCases:android.net.cts.IpSecManagerTest
Change-Id: Ib78e13ace62a0addddff0a2d17b7f393a4cc4f87
2021-05-12 17:35:49 +09:00
David Su
b8e4a7b1e7 Merge "Emphasize possibility of multiple networks with same transport" am: cf514f511d am: ee28d79784 am: 32cee1bf1b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1620459

Change-Id: I8417a8af1202c01803c61ff54363b45960af6965
2021-05-11 17:04:48 +00:00
David Su
32cee1bf1b Merge "Emphasize possibility of multiple networks with same transport" am: cf514f511d am: ee28d79784
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1620459

Change-Id: If641ab6d8ab300048c5666eea399e3ab8404d826
2021-05-11 16:48:03 +00:00
David Su
ee28d79784 Merge "Emphasize possibility of multiple networks with same transport" am: cf514f511d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1620459

Change-Id: I5ce97c2040817b68c6b70640db22d5d04bb304f3
2021-05-11 16:10:55 +00:00
David Su
cf514f511d Merge "Emphasize possibility of multiple networks with same transport" 2021-05-11 15:51:28 +00:00
Orion Hodson
276e973b32 Merge "Move to renamed NDK symbol AFileDescriptor_getFd" into sc-dev 2021-05-11 14:31:42 +00:00
Remi NGUYEN VAN
62c5136e00 Use jniThrowErrnoException from JNIHelp
Use the jniThrowErrnoException that is available in JNIHelp, instead of
reimplementing in NetworkUtils.

Bug: 179229316
Test: device boots and has connectivity
Merged-In: I257a9d55ce1f5a7c588e209b4a89d3e7a3e09994

Change-Id: I257a9d55ce1f5a7c588e209b4a89d3e7a3e09994
2021-05-11 14:18:27 +00:00
Lorenzo Colitti
5026b3ea93 Do not automatically redact TransportInfo objects.
Currently, NetworkCapabilities always redacts the TransportInfo
objects it contains whenever a defensive copy is made. This makes
it impossible to make a defensive copy on a TransportInfo
parcelled from another process without redacting it.

Stop redacting by default; instead rely on ConnectivityService
explicitly calling NetworkCapabilities' redacting constructor
when it returns a NetworkCapabilities object to an app via a
callback or synchronous call. This is currently done by
- createWithLocationInfoSanitizedIfNecessaryWhenParceled, which
  is called from callCallbackForRequest, getNetworkCapabilities,
  and getDefaultNetworkCapabilitiesForUser.
- getNetworkCapabilitiesWithoutUids, which is used when sending
  ConnectivityDiagnosticsManager callbacks. In this method,
  unconditionally redact all information, which is what the code
  did previously due to the default redaction setting for empty
  NetworkCapabilities objects being REDACT_ALL.

Bug: 183938194
Test: atest NetworkCapabilitiesTest
Test: atest FrameworksNetTests CtsNetTestCases HostsideVpnTests
Change-Id: I3108ee94cb0930958e071ba678c3554525b0db82
2021-05-11 22:47:03 +09:00
Remi NGUYEN VAN
1fd558efee Move NetworkUtils JNI out of core/jni
Keep the utilities included via a library, but move them out of
core/jni, and prepare a library to package them together with
framework-connectivity.

Also remove unnecessary dependencies in framework-connectivity.

Bug: 171540887
Test: device boots and has connectivity

Merged-In: I0b55dfe92f3cb6e848d79ac7953756f39aaa2597

Change-Id: I0b55dfe92f3cb6e848d79ac7953756f39aaa2597
2021-05-11 13:02:39 +00:00
Remi NGUYEN VAN
e4d51c9710 Build framework-connectivity using module_current
framework-connectivity needs to build only against stable APIs.

Bug: 171540887
Test: m framework-connectivity.impl
Merged-In: I2d51d37d067bf6fe86e4dedf05855a2dd67ed57c

Change-Id: I2d51d37d067bf6fe86e4dedf05855a2dd67ed57c
2021-05-11 13:00:42 +00:00
Lorenzo Colitti
395fafb54f Rename unwanted capabilities to forbidden capabilities.
Addresses API council feedback.

Bug: 184890428
Test: atest FrameworksNetTests CtsNetTestCases
Test: atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest on R device
Change-Id: Id7c68fbf56ee08fcad8e8e3aacf037fa1885936b
2021-05-11 17:46:13 +09:00
Chalard Jean
778c86525b Allow any transport with TEST if the network is restricted
This will allow CTS to add the WIFI transport and others,
letting them test a number of essential features of the
ranking algorithm.
It's relatively safe because restricted networks can never
become the default, and NOT_RESTRICTED is a default
capability so very few apps would be affected by the shell
creating such a network.

Bug: 184037351
Test: NetworkScoreTest (which is under review)
Change-Id: I21055dc613fead6130adc2122f2cdd0af9b49adf
2021-05-11 15:42:10 +09:00
Lorenzo Colitti
1df16c6f8f Rename unwanted capabilities to forbidden capabilities.
Addresses API council feedback.

Bug: 184890428
Test: atest FrameworksNetTests CtsNetTestCases
Test: atest CtsNetTestCasesLatestSdk:NetworkCapabilitiesTest on R device
Change-Id: Id7c68fbf56ee08fcad8e8e3aacf037fa1885936b
2021-05-08 01:48:01 +09:00
Hungming Chen
8a480eebef Fix attaching program failure on kernel 5.10 am: 3c94994650 am: dc0ec70f3f am: 29f06c4478
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1697147

Change-Id: Ia770d7b85ff9650743d2825cbdff12f5c634630f
2021-05-06 08:17:26 +00:00
Hungming Chen
8097f6c9b2 Fix attaching program failure on kernel 5.10 am: 3c94994650 am: dc0ec70f3f am: fdd9f07e20
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1697147

Change-Id: I737e0b73011cae23417fe458473dca7d7b21277e
2021-05-06 08:10:38 +00:00
Hungming Chen
fdd9f07e20 Fix attaching program failure on kernel 5.10 am: 3c94994650 am: dc0ec70f3f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1697147

Change-Id: Ia8e6302907d0115f92cd1186ea626dd1115a131e
2021-05-06 07:30:44 +00:00
Hungming Chen
29f06c4478 Fix attaching program failure on kernel 5.10 am: 3c94994650 am: dc0ec70f3f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1697147

Change-Id: I639f84c8b4c92b3167b30f0e467a96d6e4500808
2021-05-06 07:28:46 +00:00
Hungming Chen
dc0ec70f3f Fix attaching program failure on kernel 5.10 am: 3c94994650
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1697147

Change-Id: I67cee508cb60f424b01c84fc729b892693905e95
2021-05-06 07:14:29 +00:00
Hungming Chen
3c94994650 Fix attaching program failure on kernel 5.10
Attach BPF program may be failed with the netlink error message
"Invalid argument". Per debug kernel trace, it is failed in
comparing the kind name in tc_new_tfilter.

Log:
05-05 19:44:42.329  1073  2332  2332 W tc_new_tfilter:
Specified filter kind does not match existing one

Test: enable usb tethering and check the follows

$ adb shell tc filter show dev <upstream, downstream> ingress
filter protocol ipv6 pref 1 bpf chain 0
filter protocol ipv6 pref 1 bpf chain 0 handle 0x1
prog_offload_schedcls_tether_upstream6_ether:[*fsobj]
direct-action not_in_hw id 3 tag 94ca9b12972fdea8
filter protocol ip pref 2 bpf chain 0
filter protocol ip pref 2 bpf chain 0 handle 0x1
prog_offload_schedcls_tether_upstream4_ether:[*fsobj]
direct-action not_in_hw id 9 tag 992aa9bfd0503457
filter protocol ipv6 pref 1 bpf chain 0
filter protocol ipv6 pref 1 bpf chain 0 handle 0x1
prog_offload_schedcls_tether_downstream6_rawip:[*fsobj]
direct-action not_in_hw id 4 tag 7fb60e556b8f3be7
filter protocol ip pref 2 bpf chain 0
filter protocol ip pref 2 bpf chain 0 handle 0x1
prog_offload_schedcls_tether_downstream4_rawip:[*fsobj]
direct-action not_in_hw id 6 tag e41426095404fb64

Change-Id: I471a2e34c626a3737cbd2754e4d1b3000bcf6ba6
2021-05-06 02:52:07 +00:00
lucaslin
57f9ba8b40 Update PrivateDnsMode from StringDef to IntDef
Update PrivateDnsMode from StringDef to IntDef because IntDef is
the normal way of representing multiple choices in public API.
Also update other related files.

Bug: 185311744
Test: 1. make update-api
      2. atest FrameworksNetTests CtsNetTestCases CtsNetTestCasesLatestSdk
      3. atest FrameworksServicesTests:DevicePolicyManagerTest
Change-Id: I23e7ec140066979726d769cabc5f7057bb2167e6
Merged-In: I23e7ec140066979726d769cabc5f7057bb2167e6
    (Cherry-picked from ag/14227609)
2021-05-05 03:19:51 +00:00
lucaslin
09f1245d4a Define PRIVATE_DNS_MODE_OPPORTUNISTIC locally
The type of ConnectivityManager#PRIVATE_DNS_MODE_OPPORTUNISTIC
has changed from String to int, but the String definition is still
needed to update to Settings.Global.PRIVATE_DNS_MODE, so the
simplest way is to define one locally.

Bug: 185311744
Test: atest CtsNetTestCases
Change-Id: Iafcd861714d8aca44cede658ed630f9d5afd5e59
Merged-In: Iafcd861714d8aca44cede658ed630f9d5afd5e59
    (Cherry-picked from ag/14232792)
2021-05-05 02:36:44 +00:00
junyulai
f3496591f9 Don't run testRequestBackgroundNetwork in instant app mode
Per documentation at the sdk website, the instant app mode
does not have the permission that is needed to get test network.
Thus, ignore test in instant app mode.

Test: atest CtsNetTestCases:android.net.cts.ConnectivityManagerTest#testRequestBackgroundNetwork \
      --instant
Bug: 185927087
Change-Id: Ic7bf230349c2a17ac485a72416b294dba81dac06
2021-05-04 18:33:29 +08:00
Junyu Lai
2e3d79675b Merge "Add doc to getNetworkCapabilities" am: 59d89299c9 am: 622e129d00 am: efca123280
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1690668

Change-Id: I0c41878350ffe4015fe9e6034651f50366503dfe
2021-05-03 04:06:34 +00:00
Junyu Lai
efca123280 Merge "Add doc to getNetworkCapabilities" am: 59d89299c9 am: 622e129d00
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1690668

Change-Id: Iab7908bbeb3fd58599d7702e44450a4224a78f5b
2021-05-03 03:50:18 +00:00
Junyu Lai
622e129d00 Merge "Add doc to getNetworkCapabilities" am: 59d89299c9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1690668

Change-Id: I81c764ca04e3a300272ba18faa35d9fb0ecb54b1
2021-05-03 03:34:22 +00:00
Junyu Lai
59d89299c9 Merge "Add doc to getNetworkCapabilities" 2021-05-03 03:16:24 +00:00
Orion Hodson
a1a2ccb8d7 Move to renamed NDK symbol AFileDescriptor_getFd
Bug: 185256332
Test: TH
Change-Id: Ic13f1d9832d5ae5b6ae4b96323025d9b695fdaf9
2021-04-30 17:48:03 +01:00
Chalard Jean
070bdd4b77 Add doc to getNetworkCapabilities
Test: doc-only change
Fixes: 158092418
Change-Id: Ic20fb55e1bdd4e836468794d1f86d3e9d0bc5965
2021-04-30 11:24:00 +00:00
Aaron Huang
a546d85a03 Add required permission to Tethering
The permission of Tethering is moved to a separate xml file,
add the xml module to the required field of tethering app.

Bug: 151213404
Test: TetheringTests
Ignore-AOSP-First: merge conflict resolutions
Change-Id: I40b45a0f1b44fba0b68e94811d14725a59ed4e59
2021-04-29 15:19:50 +00:00
Bill Yi
fb03ac13e0 Import translations. DO NOT MERGE ANYWHERE
Auto-generated-cl: translation import
Change-Id: I7f1f328ec7a68bc9219f11fffc32b650de1a3bf3
2021-04-29 13:56:51 +00:00
junyulai
ba4b6d1bd4 [SP32.3] No-op refactoring of OffloadControllerTest
This is necessary change for minimize the code size when
repeatedly restarting OffloadController in subsequent
patches.

Test: atest TetheringTests
Bug: 149467454
Merged-In: I0b02d01cd8749d81c9d020dee7fdb4f80e18ae98
Change-Id: I0b02d01cd8749d81c9d020dee7fdb4f80e18ae98
  (cherry-picked from ag/14234078)
2021-04-29 18:19:55 +08:00
Treehugger Robot
07ac16932e [automerger skipped] Merge "Rename getAllNetworkStateSnapshot which should be pluralized" am: 984e51670e am: b481b9cef3 am: 7d4cea5005 -s ours
am skip reason: Merged-In Ic18d17d05984fa2466c962c7843c0ef7183ce77c with SHA-1 ab615e5c03 is already in history

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1684034

Change-Id: Ica9ed0e1d93f46da1d012e2e5a6c9ade0863a9fc
2021-04-29 05:45:59 +00:00
Treehugger Robot
7d4cea5005 Merge "Rename getAllNetworkStateSnapshot which should be pluralized" am: 984e51670e am: b481b9cef3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1684034

Change-Id: I0fa34d7cddaede25898d262196804bdd327caf8e
2021-04-29 05:28:28 +00:00
Treehugger Robot
b481b9cef3 Merge "Rename getAllNetworkStateSnapshot which should be pluralized" am: 984e51670e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1684034

Change-Id: Ie83813d57b678de4f60fe8e70aa1aa42d74a0bc8
2021-04-29 05:07:31 +00:00
Treehugger Robot
984e51670e Merge "Rename getAllNetworkStateSnapshot which should be pluralized" 2021-04-29 04:40:51 +00:00
Chiachang Wang
38b7a40643 Add test for ConnectivityManager.setGlobalProxy()
ConnectivityManager.setGlobalProxy() requires NETWORK_STACK
permission. Add test to verify exception thrown if caller has
no permission.

Bug: 186061922
Test: atest CtsNetTestCases CtsNetTestCasesLatestSdk
Change-Id: I87e2e6a878bd538b2e8c6f72f44335746151a9a7
2021-04-28 09:27:49 +00:00
Paul Hu
3040e81c8f Merge "Fix testSocketKeepaliveLimitTelephony on R" into sc-dev 2021-04-28 02:19:09 +00:00
Treehugger Robot
a5286902fd Merge "Add native coverage listener to tethering coverage test" am: e6bafe29b0 am: 1c4103c150 am: 9662233c70
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1687651

Change-Id: I570739b3b7f58aabb7856896b0f3f2e0c9f1967c
2021-04-27 19:51:49 +00:00
Treehugger Robot
b22fb6c09e Merge "Add native coverage listener to tethering coverage test" am: e6bafe29b0 am: 1c4103c150 am: 659bbf4f24
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1687651

Change-Id: Ifd9f54157ecc1d0f1a109dde05a12b2ef75e07e8
2021-04-27 19:50:31 +00:00
Treehugger Robot
659bbf4f24 Merge "Add native coverage listener to tethering coverage test" am: e6bafe29b0 am: 1c4103c150
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1687651

Change-Id: I2c5465f222c89f65de9fe42272f9ee4cfc971df5
2021-04-27 19:32:38 +00:00
Treehugger Robot
9662233c70 Merge "Add native coverage listener to tethering coverage test" am: e6bafe29b0 am: 1c4103c150
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1687651

Change-Id: Ib128e298c8b695438a562e5cbb092fd04c4746c2
2021-04-27 19:32:29 +00:00
Treehugger Robot
1c4103c150 Merge "Add native coverage listener to tethering coverage test" am: e6bafe29b0
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1687651

Change-Id: I895dd9b7c2a9fdf1f9e9dae18e54a5fe635d954f
2021-04-27 19:08:11 +00:00
Sarah Chin
5ea0c2bd8d Merge "Add tests for NetCapability#getCapabilityCarrierName" am: 45fa6bd811 am: 4d9f226837 am: db1cde3f50
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1683350

Change-Id: I7575a22f8c0e96148263c51b4bccf22a363a9131
2021-04-27 19:01:32 +00:00
Sarah Chin
3fb5810dda Merge "Add tests for NetCapability#getCapabilityCarrierName" am: 45fa6bd811 am: 4d9f226837 am: 2200bcd2db
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1683350

Change-Id: Iabb48367287651d3a4ec6cac558587504883ff17
2021-04-27 18:55:32 +00:00
Sarah Chin
2200bcd2db Merge "Add tests for NetCapability#getCapabilityCarrierName" am: 45fa6bd811 am: 4d9f226837
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1683350

Change-Id: I7d74dc77ea69c68138c282af74f19dd67c38253f
2021-04-27 18:36:09 +00:00
Sarah Chin
db1cde3f50 Merge "Add tests for NetCapability#getCapabilityCarrierName" am: 45fa6bd811 am: 4d9f226837
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1683350

Change-Id: I306e0ba0bb52de4a408e21a26a81a327905c7d59
2021-04-27 18:35:59 +00:00