Commit graph android_packages_modules_Co.../Tethering/common/TetheringLib
Message SHA1
Prepare to move VCN: Add visibilities for tests
Before moving VCN code, add the new code locations to the
"visibility" fields of Connectivity dependencies.

Bug: 379938062
Flag: EXEMPT; visibility changes
Test: presubmit
Change-Id: I51becaacb93d5e43b8b8234b80cb9b272181ad01

Yan Yan   commited 2025-07-10 20:47:00 +00:00
e82942e7c5
Start tethered hotspot with TetheringRequest
Use WifiManager.startTetheredHotspot(TetheringRequest, Executor,
SoftApCallback) to start softap. This allows for passing in the
requested SoftApConfiguration via TetheringRequest.

Bug: 216524590
Test: atest TetheringTest TetheringManagerTest
Change-Id: Ie4fb851e8b2243d233f9a8b3e18e2fa335cec307

Quang Anh Luong   commited 2025-03-17 21:13:47 +09:00
f7b6434a65
[Revert^2] Reject TetheringRequests that fuzzy-match existing ones
Legacy behavior will return success results to multiple startTethering
calls of the same type, even though the link layer can only support one
of those requests at a time (other than tethered AP + LOHS).

For B+, clean up this behavior by only allowing the amount of requests
that the link layer can concurrently support. To do this, we'll
introduce the concept of "fuzzy-matching" such that if a new request
fuzzy-matches an existing request (either pending or serving), this
indicates that the link layer cannot support the new request
concurrently, and we'll fail the new request with
TETHER_ERROR_DUPLICATE_REQUEST.

To keep track of serving requests, we'll store the request and it's
IpServer in RequestTracker when we call IpServer.enable(), and we'll
remove it (indexed by IpServer) when
1) Calling IpServer.onStop()
2) Calling IpServer.unwanted()
3) We detect an IpServer transition to AvailableState with error code

Note: This was originally merged as aosp/3529632 but was reverted due to
a crash when reading aconfig flags at boot. That issue has been fixed
here.

Reverted changes: /q/submissionid:3541662-revert-3527440-JRJJTQBUFC

Bug: 216524590
Test: atest TetheringTest RequestTrackerTest TetheringManagerTest

Change-Id: I87a1ed31927cda27d3b7fdd7c823b8f828f8d777

Quang Luong   authored and   Quang Anh Luong   commited 2025-03-17 15:18:29 +09:00
8b29d287f5
Revert "Reject TetheringRequests that fuzzy-match existing ones"
Revert submission 3527440

Reason for revert: Droidmonitor created revert due to b/403261952. Will be verifying through ABTD before submission.

Reverted changes: /q/submissionid:3527440

Change-Id: Ife596c639899528778f53fef797749fa88596dd6

Priyanka Advani (xWF)   commited 2025-03-13 10:22:16 -07:00
01b6b070ad
Reject TetheringRequests that fuzzy-match existing ones
Legacy behavior will return success results to multiple startTethering
calls of the same type, even though the link layer can only support one
of those requests at a time (other than tethered AP + LOHS).

For B+, clean up this behavior by only allowing the amount of requests
that the link layer can concurrently support. To do this, we'll
introduce the concept of "fuzzy-matching" such that if a new request
fuzzy-matches an existing request (either pending or serving), this
indicates that the link layer cannot support the new request
concurrently, and we'll fail the new request with
TETHER_ERROR_DUPLICATE_REQUEST.

To keep track of serving requests, we'll store the request and it's
IpServer in RequestTracker when we call IpServer.enable(), and we'll
remove it (indexed by IpServer) when
1) Calling IpServer.onStop()
2) Calling IpServer.unwanted()
3) We detect an IpServer transition to AvailableState with error code

Bug: 216524590
Test: atest TetheringTest RequestTrackerTest TetheringManagerTest
Change-Id: I1e193f3595a48f806fb70fd08630a12ce2631a59

Quang Anh Luong   commited 2025-03-13 11:11:17 +09:00
2add9260ef
Use SdkLevel.isAtLeastB() instead of SDK_INT
Replace the explicit SDK_INT checks with the helper function
SdkLevel.isAtLeastB().

Bug: 216524590
Test: covered by existing tests
Change-Id: I32ae771d5b157d97dfbe3c37caf62e734eaa250e

Quang Anh Luong   commited 2025-03-11 17:16:56 +09:00
96f8e1b787
no-op: Refactor bluetooth tethering listener
enableTetheringInternal immediately sends the tether result for all
types except for TETHERING_BLUETOOTH, which relies on
setBluetoothTethering to sends the result immediately if the Pan
service is connected, or defer the result until after the Pan service
connects.

To keep better track of the active listeners and simplify the logic for
further listener behavior changes (i.e. notifying the listener after the
link layer event), refactor the bluetooth listener to be called
immediately within enableTetheringInternal if the Pan service is
connected like the other tethering types.

Bug: 216524590
Test: covered by existing tests
Change-Id: I91196e430b44ef2391de662ff0ed6e051b453d98

Quang Anh Luong   commited 2025-02-13 18:50:27 +09:00
48fbdf4a36
Add basic implementation of stopTetheringRequest
Add a basic implementation of stopTetheringRequest that simply stops
tethering for that specific type if it is active, or fail with
TETHER_ERROR_UNKNOWN_REQUEST if not. In the future, we will do fuzzy
matching to ensure the correct request is removed.

Bug: 216524590
Test: atest TetheringManagerTest#testStopTetheringRequest
Change-Id: Ib4a660aacdb83e645e39ceb61b7cda45bb24d89d

Quang Anh Luong   commited 2025-01-31 16:23:04 +09:00
696c164c2d
Add methods to distinguish TetheringRequest types
Add TetheringRequest#RequestType to distinguish the type of
TetheringRequest (i.e. from startTethering, from implicit broadcasts, or
from the legacy tether API) as well as helper methods to create these
requests. These will be used in a future CL.

Bug: 216524590
Test: build

Change-Id: Ibfda48f59e80d423c9b6ee0d244cbdab14be1bd2

Quang Anh Luong   commited 2025-01-21 17:48:38 +09:00
01b9e966d8
Disallow legacy tether() API starting in B
As part of the major tethering refactor to associate every IpServer with
a TetheringRequest, tether()/untether() APIs should be completely
removed in B and all tethering should go through startTethering() (with
the exception of Wifi LOHS and Wifi P2P, which will move to
startTethering() in a future CL).

Bug: 216524590
Test: atest CtsTetheringTests TetheringTests

Change-Id: If7981f1ee7d80ff0a1cc0069ba7a4ebf79144160

Quang Anh Luong   commited 2025-01-15 08:59:42 +09:00
30d8a25db3
Merge "Remove WRITE_SETTINGS permission from Tethering APIs" into main
Quang Luong   authored and   Gerrit Code Review   commited 2024-12-18 18:42:49 -08:00
915d138309
Merge "Fix legacy tether behavior for duplicate requests" into main
Quang Luong   authored and   Gerrit Code Review   commited 2024-12-18 00:37:54 -08:00
7f911faf5e
Remove WRITE_SETTINGS permission from Tethering APIs
As TetheringManager moves to a Public API, remove the weak
WRITE_SETTINGS permission and use TETHER_PRIVILEGED instead. System
callers can still aquire TETHER_PRIVILEGED, and public callers must be
Device Owner or Carrier App to bypass (to be done in a future CL)

Bug: 374400379
Test: atest TetheringTest TetheringServiceTest CtsTetheringTests
Change-Id: Ia192021ac48f9eb3f27cc8c412f17629ad16a587

Quang Anh Luong   commited 2024-12-18 13:53:04 +09:00
2782b3bddf
Fix legacy tether behavior for duplicate requests
Legacy duplicate tethering requests would restart tethering if a pending
request existed that was different (via equals()) from the new request.

However, this behavior existed before uid/package name was added to
TetheringRequest#equals(), so we should use new method to check
equality while ignoring uid/package name.

Bug: 216524590
Test: atest TetheringTest TetheringManagerTest
Change-Id: I962c7b4d8efc7f631077d6fa0f87f52ee779192e

Quang Anh Luong   commited 2024-12-18 13:53:04 +09:00
2d260e9e35
Merge "Ensure TetheringService binder is alive after system_server crash" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-12-17 10:23:17 -08:00
0c01b26eca
Ensure TetheringService binder is alive after system_server crash
servicemanager does not restart on a system_server crash, so
mConnectorSupplier might temporarily return a stale version of
TetheringService. Any operation on the stale binder causes a
DeadObjectException.

This change adds a check to ensure the binder is alive before use
and falls back to polling servicemanager.

Bug: 353920381
Bug: 271276384
Change-Id: I549d5a07966ebaed7e4a4ebe96e831dcac3b05bd
Signed-off-by: charid <dhoddeti.brahmachari@oppo.com>

charid   authored and   Patrick Rohr   commited 2024-12-17 09:13:37 -08:00
d236106983
Make Tethering public API for DO/Carrier apps
Make a limited subset of Tethering APIs public for DO/Carrier apps
to start Wifi tethering with a custom SoftApConfiguration.

The following APIs are needed to be moved to public
- TetheringManager
    - startTethering
    - stopTethering
    - registerTetheringEventCallback
    - unregisterTetheringEventCallback
- TetheringManager.TetheringRequest
    - getSoftApConfiguration
- TetheringManager.TetheringRequest.Builder
    - setSoftApConfiguration
- TetheringInterface
- TetheringEventCallback
    - onTetheredInterfacesChanged

Checks for DO/Carrier apps will be added in a later CL.

API-Coverage-Bug: 374400379

Bug: 216524590
Test: atest TetheringTest TetheringManagerTest
Change-Id: I9fb420ec6cebea17d8f3bc40a0ae8735074d9eb0

Quang Anh Luong   commited 2024-12-05 11:49:39 +09:00
2f37e81851
Add stopTethering(TetheringRequest) stubs
Add a new API TetheringManager.stopTethering(TetheringRequest) to allow
apps to stop tethering for a specific request.

This CL only provides the API stubs. Implementation will be added in a
future CL.

Bug: 216524590
Test: atest TetheringManagerTest

Change-Id: If00a7dc5d328dac620fb69c384378c36e99e1856

Quang Anh Luong   commited 2024-12-05 08:32:10 +09:00
5475f2dd74
Introduce interfaceName field into TetheringRequestParcel
Bug: 340376953
API-Coverage-Bug: 365678805
Test: Presubmit
Test: atest EthernetTetheringTest
Test: atest TetheringTest
Test: atest NsdManagerDownstreamTetheringTest -b
Test: atest TetheringManagerTest -b

Change-Id: I8025cc2e238b8f9516bf18d8ea0253f1c58a05e6

Seungjae Yoo   authored and   Quang Anh Luong   commited 2024-12-05 08:14:10 +09:00
eab1de47f4
Expose Connectivity libraries to VCN and tests
This patch exposes Connectivity libraries to allow migrating VCN to
its own non-updatable framework and service libraries. It also
creates a utility library for VCN.

Bug: 369703242
Test: atest FrameworksVcnTests && atest CtsVcnTestCases
Flag: EXEMPT no functional change
Change-Id: I1981f1cc824dcf426a76a0af8e4e3460fccb754e

Yan Yan   commited 2024-11-23 23:07:44 -08:00
587f996eb4
Clean up TetheringRequest#toString()
Clean up TetheringRequest#toString() by printing the TetheringType and
ConnectivityScope in a human-readable form and only printing the values
of fields that have been set.

Bug: 216524590
Test: atest TetheringManagerTest
Change-Id: Ie2c35190a09605e3018b9d2d1f1d00cdc7bbb977

Quang Anh Luong   commited 2024-11-19 21:24:47 +09:00
676ad858e2
Include SoftAP config in TetheringEventCallback
Include SoftApConfiguration in TetheringEventCallback via
TetheringInterface, to allow apps to know which interfaces are created
with their SoftApConfigurations.

API-Coverage-Bug: 371133403

Bug: 216524590
Test: atest TetheringTest CtsTetheringTest
Change-Id: I1b4868ba8327bee3b03c0f21e5b4f0845f2f24a8

Quang Anh Luong   commited 2024-11-18 13:37:39 +09:00
a66b78ab87
Add new flag for Tethering w/ SoftApConfig
Old flag gantry flow was disabled due to being out of sync
(b/362407371). This change adds a new version of the same flag to
kickstart a new gantry flow.

Flag: com.android.net.flags.tethering_with_soft_ap_config

Bug: 216524590
Test: build
Change-Id: I50701582852c2077e7807ab2685e390f112fd029

Lorenzo Colitti   commited 2024-11-13 17:19:11 +00:00
172fe79552
Revert^2 "Add UID and package name to TetheringRequest"
This reverts commit c8df03ffd7.

Reason for revert: Will fix issue with CL aosp/3326396

Change-Id: I220025f7c8f8145a232ac2ae7f44e16088c122d7

Oscar Shu   commited 2024-11-05 22:52:36 +00:00
46722ad4c4
Revert "Add UID and package name to TetheringRequest"
This reverts commit 462703c850.

Reason for revert: b/375535923

Change-Id: I7f77959490e8243bb95985bd28b67efcf0f3eb00

Patrick Rohr   authored and   Gerrit Code Review   commited 2024-10-30 16:29:15 +00:00
c8df03ffd7
Add UID and package name to TetheringRequest
Add a uid and package name to TetheringRequest to keep track of which
app the request belongs to, and also convey this information to Wifi
for later use with resource conflicts.

Bug: 216524590
Test: atest TetheringManagerTest TetheringServiceTest
Change-Id: If963694cb1bbd831ba379a76043825c94ef9d67a

Quang Anh Luong   commited 2024-10-23 15:52:03 +09:00
462703c850
Merge "Change TetheringManager#RequestDispatcher as static" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-10-04 23:13:14 +00:00
edddb5b6f7
Change TetheringManager#RequestDispatcher as static
If the system GC does not recycle the RequestDispatcher
objects in time, they will hold more contexts, which may
lead to OutOfMemoryError.

So change TetheringManager#RequestDispatcher as static.

Bug:369730368

Change-Id: Ia67d8547bd2d239b5f939bd870761f2946afd43b
Signed-off-by: dingfeisong <dingfeisong@xiaomi.corp-partner.google.com>

dingfeisong   authored and   Feisong Ding   commited 2024-09-26 06:03:18 +00:00
8675fc0c5d
Merge "Make java_sdk_library dependencies explicit" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-09-10 19:12:45 +00:00
430a8ad33c
Make java_sdk_library dependencies explicit
modules should specify the submodule of java_sdk_library that the module
actually depends on

Test: CI
Bug: 358613520
Change-Id: I0367068c901df98483f6cf95160d3e7801881b0a

Jihoon Kang   commited 2024-09-10 00:01:31 +00:00
8401b6a9f0
Add NetworkStack to framework-connetivity and framework-tethering impl lib visibility
As NetworkStackApi*Shims modules defined in
packages/modules/NetworkStack depends on the impl libs of
framework-connectivity and framework-tethering

Test: m nothing
Bug: 358613520
Change-Id: I5c90d4ae6eeb51f42f1ae1c88dd726bfdcd093e8

Jihoon Kang   commited 2024-09-09 22:55:01 +00:00
e7cae17b3a
Add SoftApConfiguration to TetheringRequest
Allow apps to specify the SoftApConfiguration to use for Tethering via
TetheringRequest.

API-Coverage-Bug: 361242098

Bug: 216524590
Test: atest TetheringManagerTest
Change-Id: I956a2f9dc989e7b2d404b84957d859035e4cd6e8

Quang Anh Luong   authored and   Quang Luong   commited 2024-08-21 07:28:26 +00:00
a940e426c1
Use java_aconfig_library for android_core_networking flags
Connectivity repo now can use java_aconfig_library since this target is
available on all downstream branches.

This CL removes framework-connectivity-t-mdns-standalone-build-sources.
Files in this target use flags which won't be available in the
out-of-tree build but the next out-of-tree library import will not use
the classes in that filegroup anymore.
So the standalone build rule will still match the out-of-tree build.

Bug: 345121279
Test: TH
Change-Id: I2a9aa02bd0c9aa00d460f98cd51d5dec4098fb89

Motomu Utsumi   commited 2024-08-16 16:57:29 +09:00
2fc115491a
More documentation about TETHERING_VIRTUAL
Bug: 353392669
Test: N/A
Change-Id: Idaff2c67eccfa3000964c185feba9eaf61260c05

Seungjae Yoo   commited 2024-07-16 13:39:49 +09:00
50e486668c
Merge "Add more consistent null checks" into main
Treehugger Robot   authored and   Gerrit Code Review   commited 2024-07-09 21:37:51 +00:00
2a3d34413c
Revert^2 "Baseline one more Lint FlaggedApi violation"
This reverts commit d6fa127ec0.

Reason for revert: updating lint-baseline.xml does not cause build brekage; keep holding back the separate CL that turns FlaggedApi violations into errors

Change-Id: Ie5d048bde1c0b717cb0d589d33550e6b68154be8

Mårten Kongstad   authored and   Gerrit Code Review   commited 2024-07-04 06:31:15 +00:00
3eb23a9d5e
Revert "Baseline one more Lint FlaggedApi violation"
Revert submission 3156916-flagged-api-lint-baseline

Reason for revert: Droidmonitor created revert due to build breakages in b/350976857.

Reverted changes: /q/submissionid:3156916-flagged-api-lint-baseline

Change-Id: I52ca486a00d47f478c61ce0ae39b9d9b584af87e

Priyanka Advani   authored and   Gerrit Code Review   commited 2024-07-03 19:53:58 +00:00
d6fa127ec0
Add more consistent null checks
This change moves the null check into the service implementation. Since
exceptions on oneway binder interfaces are ignored (across process), the
code was changed to just return early instead.

This also adds a couple of Objects.requireNonNull() assertions in
TetheringManager to assert the existing @NonNull annotation.

Test: TH
Bug: 337167681
Change-Id: I5301ed084bb26c2f910041e9b25314f8181718d1

Patrick Rohr   commited 2024-07-02 11:53:17 -07:00
0692aff5c5
Baseline one more Lint FlaggedApi violation
The Lint FlaggedApi checks are currently configured as warnings. Add
existing violations to baselines files to prepare for turning the
FlaggedApi checks into errors.

Bug: 303434307
Test: treehugger
Flag: EXEMPT not possible to flag baseline changes
Merged-In: I5cbff0293af79e68057fd42ecfa8d2c8af31ae6a
Change-Id: I5cbff0293af79e68057fd42ecfa8d2c8af31ae6a

Mårten Kongstad   commited 2024-07-02 13:27:38 +02:00
dddac40259
Replace TetheringRequestParcel with TetheringRequest
Replace TetheringRequestParcel with TetheringRequest in the service
code. This makes future changes easier since TetheringRequest is a
proper class and not an AIDL object.

Bug: 216524590
Test: atest TetheringTest TetheringManagerTest
Change-Id: I0cdee597d393e53feb9fe9aff4d6c67330c88599

Quang Anh Luong   commited 2024-06-26 16:25:13 +09:00
3e65131ba3
Baseline Lint FlaggedApi violations
The Lint FlaggedApi checks are currently configured as warnings. Add
existing violations to baselines files to prepare for turning the
FlaggedApi checks into errors.

Bug: 303434307
Test: treehugger
Flag: EXEMPT not possible to flag baseline changes
Merged-In: I990ce57cd5cdac44ee8b93565b45aa15790ad697
Change-Id: I990ce57cd5cdac44ee8b93565b45aa15790ad697

Mårten Kongstad   commited 2024-06-20 09:05:51 +02:00
4ece737f4f
Introduce TETHERING_VIRTUAL type
Bug: 340376953
Test: Presubmit
Change-Id: I0714b62ebfc63fc966d7873ebdd68ae72c015bc4

Seungjae Yoo   commited 2024-06-19 16:18:51 +09:00
07b8fe1f92
Remove unused library visibility
This commit removes the unused library visibility.

The "frameworks/base/packages/Connectivity" folder is the
temporary folder for modulizing the connectivity codes. There is
no such need now.

Test: m
Change-Id: Ia2890fe64c1bc369fcb90be645263bc56c98a7b2

Chiachang Wang   commited 2024-03-01 00:57:52 +00:00
52d329642a
Move VpnManagerServiceTest and VpnTest to frameworks
These unit tests are closely tied to the source code in
frameworks/base and were incorrectly placed in the connectivity
module. Also update the libraries visibility that are used by
the tests.

Test: atest FrameworksNetTests
Change-Id: I196c33a8bd5b5cdb9d42aea381e900681ff6d25e

Chiachang Wang   commited 2024-02-29 07:48:02 +00:00
a5d9875823
Update flags.aconfig to follow the current APIs
This CL also specifies aconfig_declaration module in java_sdk_library
register_nsd_offload_engine will be moved to the platform flags.aconfig
in the followup CL.

Test: TH
Change-Id: I430a5f0b1e1ef2e3394cf6aa8efebbd46da41765

Motomu Utsumi   commited 2024-02-19 06:58:35 +00:00
52f294cbc4
Make TetheringRequest parcelable
Make TetheringRequest parcelable so we can pass it via Wifi APIs and map
Soft AP state changes to the correct request.

Bug: 216524590
Test: build
Change-Id: I63a45b14e9abc288b353159dfdcbe96fde485cb7

Quang Anh Luong   commited 2024-02-15 10:15:05 +09:00
1252f7f428
[DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5

Aditya Choudhary   commited 2024-01-31 12:34:50 +00:00
01b5ede2b2
implement Thread Border Router e2e integration test
This implements a basic border routing test case (ping) and demonstrates a
valid test environment for Thread Border Router test cases.

Later we can add more packet verifications and more test cases.

Bug: 295843010
Test: atest android.net.ThreadBorderRouterTest

Change-Id: Ifb9b6d45539143a227c2bc0ed69b5c3167ef9acd

Handa Wang   commited 2023-12-26 15:24:54 +08:00
806f5a1bec
Remove workaround to remove FlaggedAPI in ump
Test: TH
Change-Id: Icd3c87a7da9b45e5341a1a2ead68f0a9809591bb

Motomu Utsumi   commited 2023-12-04 08:59:43 +00:00
88410c6fd6
Baseline issues that were previously suppressed
java_sdk_library has previously internally disabled a few legitimate
issues. As this is being un-done for modules, add baselines for the
pre-existing issues.

Bug: 306806877
Test: m checkapi
Merged-In: Ie764d33196675e1482f30ecfd3d6d22b7fa25c27
Change-Id: Ie764d33196675e1482f30ecfd3d6d22b7fa25c27

Anton Hansson   commited 2023-11-07 08:40:36 +00:00
d8e40b3204