Guard NetworkCapabilities capability 38 via SDK 37 or U Extension 21

Calling addCapability(38) (NET_CAPABILITY_PRIORITIZE_UNIFIED_COMMUNICATIONS)
on Android builds without the Mainline backport emits an error-level
"addCapability is called with invalid capability: 38" log on API 35/36
and throws IllegalArgumentException on API <= 34. However, gating
strictly on Build.VERSION.SDK_INT >= 37 disables Unified Communications
slicing on Android 14-16 devices that support capability 38 via Mainline
(U Extensions >= 21).

Add isUnifiedCommunicationsSupported() returning true on SDK >= 37 or
SDK >= UPSIDE_DOWN_CAKE with
SdkExtensions.getExtensionVersion(UPSIDE_DOWN_CAKE) >= 21, make
createUnifiedCommunicationsNetworkRequest() @Nullable (returning null
instead of a wildcard new NetworkRequest.Builder().build() that
registers a duplicate callback), skip registerNetworkCallback() when
null, and keep getNetworkSlice() unguarded by SDK version with an
explicit null check on capabilities.

Bug: webrtc:466507512
Change-Id: I8098913647515b5921c77b917cd8e1120ae3aca2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/520841
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Reviewed-by: Sameer Vijaykar <samvi@google.com>
Reviewed-by: Denise Tell <dct@google.com>
Commit-Queue: William Miranda <willmiranda@google.com>
Cr-Commit-Position: refs/heads/main@{#49510}
2 files changed
tree: 2bbf3010ac569082f2b79f0b6ef79c2451d547ce
  1. .agents/
  2. agents/
  3. api/
  4. audio/
  5. build_overrides/
  6. call/
  7. common_audio/
  8. common_video/
  9. data/
  10. docs/
  11. examples/
  12. experiments/
  13. g3doc/
  14. infra/
  15. knowledge_base/
  16. logging/
  17. media/
  18. modules/
  19. net/
  20. p2p/
  21. pc/
  22. resources/
  23. rtc_base/
  24. rtc_tools/
  25. rust/
  26. sdk/
  27. stats/
  28. system_wrappers/
  29. test/
  30. tools_webrtc/
  31. video/
  32. .clang-format
  33. .clang-tidy
  34. .git-blame-ignore-revs
  35. .gitignore
  36. .gn
  37. .mailmap
  38. .rustfmt.toml
  39. .style.mdformat
  40. .style.yapf
  41. .yapfignore
  42. AUTHORS
  43. BUILD.gn
  44. CODE_OF_CONDUCT.md
  45. codereview.settings
  46. DEPS
  47. DIR_METADATA
  48. ENG_REVIEW_OWNERS
  49. GEMINI.md
  50. LICENSE
  51. license_template.txt
  52. native-api.md
  53. OWNERS
  54. OWNERS_INFRA
  55. PATENTS
  56. PRESUBMIT.py
  57. presubmit_test.py
  58. presubmit_test_mocks.py
  59. pylintrc
  60. pylintrc_old_style
  61. README.chromium
  62. README.md
  63. unsafe_buffers_paths.txt
  64. vpython.toml
  65. vpython.toml.uv.lock
  66. WATCHLISTS
  67. webrtc.gni
  68. webrtc_lib_link_test.cc
  69. whitespace.txt
README.md

WebRTC is a free, open software project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs. The WebRTC components have been optimized to best serve this purpose.

Our mission: To enable rich, high-quality RTC applications to be developed for the browser, mobile platforms, and IoT devices, and allow them all to communicate via a common set of protocols.

The WebRTC initiative is a project supported by Google, Mozilla and Opera, amongst others.

Development

See here for instructions on how to get started developing with the native code.

Authoritative list of directories that contain the native API header files.

More info