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 Luongcommited 2025-03-17 21:13:47 +09:00
TetheringTest has several tests that rely on starting Wifi tethering,
but do not mock WifiManager.startTetheredHotspot. This causes the
pending Wifi request to be removed, even though the test continues
thinking that the call succeeded and continues mocking Wifi AP events.
Fix this by making sure the mock returns true in setUp(), and only set
it to false when we expect that the call should fail.
Bug: 216524590
Test: atest TetheringTest
Change-Id: Iaf076b9ae64d737a8591c7f41a5552757b47999b
Quang Anh Luongcommited 2025-03-17 15:18:29 +09:00
isTetheringWithSoftApConfig flag is finalized, replace it with a simple
SdkLevel.isAtLeastB() check. This also fixes any issues with reading the
flag during boot.
Bug: 216524590
Test: covered by existing tests
Change-Id: I6c2717a68fa4f3c664c9948ec19b246db5afdb8b
Quang Anh Luongcommited 2025-03-17 15:18:29 +09:00
stopTethering with a TetheringRequest should only stop tethering if
there is an existing request (pending or serving) that fuzzy-matches the
input and whose UID matches the caller (unless the caller is Settings,
which is allowed to remove any request).
If there is no existing fuzzy-matched request, return
TETHER_ERROR_UNKNOWN_REQUEST.
Note: This was originally merged as aosp/3527440 but was reverted due to
a dependency CL being reverted. Remerging this on top of the fix for the
dependency CL.
Reverted changes: /q/submissionid:3541662-revert-3527440-JRJJTQBUFC
Bug: 216524590
Test: atest TetheringTest RequestTrackerTest TetheringManagerTest
Change-Id: I99dd2433efbb82f3721aa708ab50d198f6fbcb10
Quang Luongauthored and Quang Anh Luongcommited 2025-03-17 15:18:29 +09:00
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 Luongauthored and Quang Anh Luongcommited 2025-03-17 15:18:29 +09:00
failureEnablingIpForwarding verifies that TetheringMetrics sends one
more error report than it should. This extra verification is caused by
any(class) being passed into the mock WifiManager.startTetheredHotspot,
which does not match null even though the actual code passes in a
null. This results in an extra failure that causes the extra error
report call.
Fix this by replacing any(class) with null, and removing the extra error
verification.
Bug: 216524590
Test: atest TetheringTest
Change-Id: I93986a999d573a186696e54793563e2be8405f39
Quang Anh Luongcommited 2025-03-15 10:42:22 +09:00
See https://b.corp.google.com/issues/402962730#comment27
for explanation how clat uid not having access to this
directory causes selinux denials, but basically the dynamic
linker tries to call realpath on /proc/self/exe, which fails
because it's post setuid/gid and thus running as clat/clat,
not as uid=root or gid=system which have access.
(note that the 'w' bits don't really matter since this is
embedded in an apex, and thus readonly filesystem anyway)
Bug: 402962730
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iaf620e33d9211c9bc0c017543bb1be2f43520a51
Maciej Żenczykowskicommited 2025-03-14 09:23:23 -07:00
There are currently two variants of checkAndNotifyCommonError that do
the exactly the same thing, except one uses IIntResultListener and
another uses ResultReceiver. Remove the lesser-used ResultReceiver
variant and just use the IIntResultListener instead (with a
IIntResultListener wrapper for the ResultReceiver).
Bug: 216524590
Test: covered by existing tests
Change-Id: I292a96b32cd975852a52c7953b03bcb35728db24
Quang Anh Luongcommited 2025-03-14 15:27:49 +09:00
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
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: I31ae861d5151c9db7e559ba19db7f07c9545d422
Priyanka Advani (xWF)authored and Gerrit Code Reviewcommited 2025-03-13 10:22:16 -07:00
stopTethering with a TetheringRequest should only stop tethering if
there is an existing request (pending or serving) that fuzzy-matches the
input and whose UID matches the caller (unless the caller is Settings,
which is allowed to remove any request).
If there is no existing fuzzy-matched request, return
TETHER_ERROR_UNKNOWN_REQUEST.
Bug: 216524590
Test: atest TetheringTest RequestTrackerTest TetheringManagerTest
Change-Id: Ia8a8eab78fbecd38321fd0d48734855cff16febb
Quang Anh Luongcommited 2025-03-13 12:49:08 +09:00
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 Luongcommited 2025-03-13 11:11:17 +09:00
The JNI libs that this target depends on are going to be shimmed on top
of ToT and Stable Cronet. This reduces the number of cross-repo dependencies, making that change simpler (see http://aosp/3507996).
Test: m
Bug: b:396593141
Change-Id: I5e8ab89ea0ebe6a82f006568f30961dcf2f0603e
Replace the explicit SDK_INT checks with the helper function
SdkLevel.isAtLeastB().
Bug: 216524590
Test: covered by existing tests
Change-Id: I32ae771d5b157d97dfbe3c37caf62e734eaa250e
Quang Anh Luongcommited 2025-03-11 17:16:56 +09:00
Currently there may be multiple identical bluetooth requests waiting for
the PAN service to connect before their listeners are notified. To
simplify future code, we should only allow one pending request/listener
pair at a time, and reject every subsequent request with
TETHER_ERROR_SERVICE_UNAVAILABLE.
This should be OK because
1) Bluetooth tethering is hardly used at all
2) Settings disallows extra startTethering calls between the first call
and the bluetooth service starting
3) Apps are expected to handle TETHER_ERROR_SERVICE_UNAVAILABLE
correctly.
Bug: 216524590
Test: atest TetheringTest
Change-Id: I8375d495575715f428e893316f7cd7e5a7ebba59
Quang Anh Luongauthored and Quang Luongcommited 2025-03-10 21:02:50 -07:00
Mockito extended tends to cause all kinds of issues due to the way it
injects itself into the bytecode of framework classes instead of
creating subclasses.
Use non-extended mockito as it is not actually necessary for current
tests.
Test: atest
Change-Id: Id2874309cce2778c4405b852df9a3ae816c4abcb
This is a no-op refactoring which inline the functionalities
to IpServer, enabling subsequent changes to move
networkAddInterface part to ConnectivityService when the
tethering is enabled.
Test: atest TetheringTests:android.net.ip.IpServerTest
atest NetdStaticLibTests:com.android.net.module.util.NetdUtilsTest
Bug: 349487600
Change-Id: I6d0e5d349691df7a15bee852d5fd1dd19f5da6f6
This is a no-op, preparatory refactoring to isolate route
modification functionality, enabling subsequent changes to move
routing control to ConnectivityService.
Test: atest TetheringTests:android.net.ip.IpServerTest
atest NetdStaticLibTests:com.android.net.module.util.NetdUtilsTest
Bug: 349487600
Change-Id: I55af07968567b173dd9f97795600390439f1b927
Pending requests should be updated via a helper class RequestTracker
and stored in a Request wrapper object. This will help out with future
changes to associate each TetheringRequest with it's own
IIntResultListener and make it easier to gate behavior changes.
Bug: 216524590
Test: atest TetheringTest RequestTrackerTest
Change-Id: Ib867e91863bdf618bb0e955eeb529cd132209d77
Quang Anh Luongcommited 2025-03-06 15:18:28 +09:00
Test: TreeHugger, manually installing tethering apex
(with and without dnsresolver apex) on pixel 6 running S
incl. 'atest bpf_existence_test'
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I63d4b84287e9c98dc0d2a517ac58d3f3ce9d7760
Maciej Żenczykowskicommited 2025-03-05 14:27:59 -08:00
This reverts commit 0e9b0e05c6.
Reason for revert: needs a .31rc specific version instead.
Will merge the required changes into the followup commit.
Change-Id: I01e9dfee4aaabc3ddab39da7519b7d9963b84124
Maciej Żenczykowskicommited 2025-03-04 21:54:09 -08:00
By itself this change is a no-op, as we don't actually *yet* start mdnsd_netbpfload.
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic7665b3dd5716bd3bbdc96450a42e9b0c26441c9
Maciej Żenczykowskicommited 2025-03-04 14:21:46 -08:00
* changes:
no-op: use stopTetheringInternal when restarting tethering on start
Use pending request when legacy tethering
no-op: Add test to verify legacyTether does not use explicit request
Quang Luongauthored and Gerrit Code Reviewcommited 2025-03-04 02:25:35 -08:00
startTethering will sometimes restart tethering if there is an existing
request of the same type but with different contents. This call is
equivalent to stopTetheringInternal, so use that instead for simplicity.
Bug: 216524590
Test: covered by existing tests
Change-Id: I224c10557c2348e2d2f971e1e3ecb11ae346d2cf
Quang Anh Luongcommited 2025-03-04 16:58:43 +09:00
Legacy tethering was changed to use it's own tethering requests
with REQUEST_TYPE_LEGACY in aosp/3465235 instead of using the pending
request as it was thought that pending requests (from startTethering)
and legacy tethering would always be mutually exclusive.
However, pre-T Bluetooth tethering actually relies on
startTethering(request) to add the pending request, and then BT service
directly calls legacyTether(iface) to start tethering. Thus we should
continue to use pending requests even for legacyTether.
Bug: 216524590
Test: atest TetheringTest
Change-Id: I0aa7b5cc6d6d54f516a07b0e89259c61e1d05f69
Quang Anh Luongcommited 2025-03-04 16:58:42 +09:00
Add a test that verifies that legacyTether will not use the
explicit pending TetheringRequest set by startTethering.
Bug: 216524590
Test: atest TetheringTest
Change-Id: I3e0638a3c60cdf3b73b1accc136ed7098e7b48f6
Quang Anh Luongcommited 2025-03-04 16:58:40 +09:00
The tether_enable_sync_sm flag has been successfully rolled out
to public stage on Pixel devices without any observed
regressions. As a result, this flag should be enabled by default
with a kill switch, allowing the feature to be deployed to all
production devices.
Test: atest TetheringTests CtsTetheringTest
Change-Id: I2f0f55c1586e1f4987b28488082c4c1f4cae0f5e
Since the feature was fully rolled out via experiment without
regression, this commit removes the flag and the corresponding
logic in PrivateAddressCoordinator. The flag is no longer
necessary and simplifies the code.
Test: atest ConnectivityCoverageTests:PrivateAddressCoordinatorTest
Fix: 312647670
Change-Id: I8781f98b7e99ed0856e9e04112056df5adca2527
Add a TetheringRequest argument to enableTetheringInternal and
sendTetherResult so we can pass the request to Wifi in a later CL.
Also pass through for TETHERING_VIRTUAL to use the request and
interface directly.
Note that removing getOrCreatePendingTetheringRequest in
setVirtualTethering is also a no-op:
- If setVirtualTethering is called from startTethering, the request
that is now passed in as a parameter is the exact same one that
was just inserted into the pending list, and which the old code
would have obtained from getOrCreatePendingTetheringRequest.
- If setVirtualTethering is called due to an IP conflict, both the
old and the new code use a placeholder request with no interface.
This codepath was already broken before this CL (and likely has
never worked).
Bug: 216524590
Test: covered by existing tests
Change-Id: I3cb9b5ed44e83bb6bbf4ed77c37cbf35e306f08b
Quang Anh Luongcommited 2025-02-13 19:09:01 +09:00
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 Luongcommited 2025-02-13 18:50:27 +09:00
Currently, WIFI_AP_STATE_CHANGED for LOHS will use any pending Wifi
TetheringRequest to start the IpServer. This is a bug, since pending
Wifi requests are always for tethered SoftAP, not LOHS. This means if
there's already a pending request for tethered SoftAP, we will
mistakenly use the tethered SoftAP request for LOHS. Then, when the
WIFI_AP_STATE_CHANGED event for the tethered SoftAP arrives, the pending
request for it will already be gone.
Fix this by always having LOHS use an implicit LOHS TetheringRequest
instead of taking the request from the pending list.
Bug: 216524590
Test: atest
Change-Id: Ic349e0b0688addf6a41b3de0528d444d716846a2
Quang Anh Luongcommited 2025-02-13 10:25:20 +09:00
If there are pending pan requests for an enable but a disable request
comes (or vice versa), remove all the pending requests and pre-emptively
fail their result listeners. This simplifies the logic and helps us
keep track of which request the future link layer event should be long
to.
Technically this is an app-visible behaviour change. In particular, if
something disables bluetooth tethering while the service is
disconnected and request(s) to enable tethering are queued, then the new
code will immediately send onTetheringFailed to all those requests,
whereas the old code would wait until the service connects, enable
tethering (and send the enabler an onTetheringStarted), and then disable
it. Given that this situation is very rare, and Bluetooth tethering is
itself so uncommon (<1% of total tethering sessions) this is an
acceptable trade-off.
Bug: 216524590
Test: atest TetheringTest
Change-Id: I061733d714894b741e7d686810dd39f054e85476
Quang Anh Luongcommited 2025-02-13 10:24:42 +09:00
Tethering will ignore interfaceStatusChanged for enabled interfaces
starting in B, instead only creating the IpServer when the link layer
event comes. Fix the assertions around interfaceStatusChanged for B.
Bug: 393978354
Test: atest TetheringTest
Change-Id: I74d0843785c5d9353e59b73d6d7b30d6d07ac0e0
Quang Anh Luongcommited 2025-02-05 10:43:59 +09:00