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 Luongcommited 2025-01-21 17:48:38 +09:00
The intention of this test case is to check that the cached hotspot prefix doesn't get assigned to ethernet, even if released, so that it can be offered to the hotspot if requested again.
Therefore we should call `requestStickyDownstreamAddress` instead of `requestDownstreamAddress` when requesting the prefix for hotspot.
Bug: 375858174
Test: atest TetheringTests:com.android.networkstack.tethering.PrivateAddressCoordinatorTest#testReservedPrefix --iteration 200
Change-Id: I5d897aa958a9549f3d773bd59920906a815edb5e
In the current design, the upstream monitor collects prefixes
of all upstream networks to prevent prefix conflicts,
which are coordinated by the PrivateAddressCoordinator.
However, the upstream monitor does not exclude the newly
added NET_CAP_LOCAL_NETWORK capability, which could be
held by a downstream network. This could lead to a prefix
conflict detection loop:
1. In UpstreamNetworkMonitor, a prefix is collected from
a local network and sent to the PrivateAddressCoordinator.
2. PrivateAddressCoordinator detects a prefix conflict with
an existing downstream prefix.
3. The conflict notification is sent to the local
network provider, triggering a recovery.
Test: atest TetheringTests:com.android.networkstack.tethering.UpstreamNetworkMonitorTest
Bug: 349487600
Bug: 382397803
Change-Id: I743d569394e190c8620b283689d853cd2f5e3f28
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 Luongcommited 2024-12-18 13:53:04 +09:00
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 Luongcommited 2024-12-18 13:53:04 +09:00
The hotspotPrefix was previously released on line 192, so when a new
prefix was allocated on line 206, it was allowed to "conflict" with the
now-released hotspotPrefix.
This change moves the call to releaseDownstream() to the end, so the
test can properly check for conflicts.
Test: TH
Bug: 375858174
Change-Id: Iac786237340fc14098701d86fa80946a7fb8e0b6
This commit updates the logic for launching the entitlement UI
for tethering when there are multiple users. It disables the
check for whether the current user can change tethering settings
for secondary users due to a potential issue with calling
createContextAsUser. This reverts the behavior change introduced
in aosp/3289821.
One expected outcome is this change will break tethering with
entilement check enabled for HSUM-enabled devices. Since there
is no currently HSUM-enabled projects, disable this check is
safe.
Test: Manual
1. Mock requires entitlement
2. adb shell cmd user set-system-user-mode-emulation headless
3. enable hotspot
Test: atest TetheringTests:EntitlementManagerTest
Bug: 382624069
Change-Id: Ife3b721d1374602a8fa760954b372429cda1bf71
This commit ensures that EntitlementManager sends the appropriate
error code to the receiver when the current user is not allowed
to perform entitlement check. This error code also listened by
the tethering module, where it would stop tethering when receiving
such error code.
Test: atest TetheringTests:EntitlementManagerTest
Bug: 376792293
Change-Id: I2dd18f9df9ad7cab542f8877b9fc86600c248144
This is a test only refactoring which updates the unit tests to use a
TestableResultReceiver to have better readability, and asserting
no entitlement result received.
Test: atest TetheringTests:EntitlementManagerTest
Bug: 376792293
Change-Id: I5cc02c8ab85ae614e714055c7f8f4c076341f48f
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 Luongcommited 2024-11-18 13:37:39 +09:00
Change the permission check for tethering to checkPackage. This avoids
having to create context as another user which is not supported when
running the networkstack from secondary user.
Bug: 375535923
Bug: 216524590
Test: atest TetheringManagerTest TetheringServiceTest
Change-Id: Ibc3abe9ec2eab5ec976c6a9cbc08e1552203ee5d
Oscar Shuauthored and Quang Luongcommited 2024-11-08 02:31:46 +00:00
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 Luongcommited 2024-10-23 15:52:03 +09:00
This is a no-op refactoring which only introduce
dependencies object injection to replace the wrapper class.
Test: atest TetheringTests:EntitlementManagerTest
Fix: 363972541
Change-Id: I24b0bf5f8951c453af1e9ae9278285d1a7b86849
This change addresses the launch of entitlement UI activities
in Headless System User Mode (HSUM) on multi-user devices.
HSUM is a configuration where the system user (user 0) does
not represent a human user and primarily runs system services.
In this mode, the first user set up on the device is not user 0.
Modified the EntitlementManager logic to handle the
launch of the entitlement UI in multi-user environments,
specifically addressing scenarios where HSUM is enabled, which
includes:
1. Always launch the UI to the foreground current user.
2. Check whether the current user is allowed to show the UI.
This ensures the UI is presented to the appropriate user.
Test: Manual
1. Mock requires entitlement
2. adb shell cmd user set-system-user-mode-emulation headless
3. enable hotspot
Test: atest TetheringTests:EntitlementManagerTest
Fix: 363972541
Change-Id: I950d678741a3f1714f347206fa161bcd7538b402
This CL splits requestDownstreamAddress into two methods: requestStickyDownstreamAddress and requestDownstreamAddress.
- The requestStickyDownstreamAddress is equivalent to the former requestDownstreamAddress when useLastAddress=true.
- The new requestDownstreamAddress method allows allocating an address without providing the interface type and scope, which is Thread NAT64's use case.
Bug: 369282577
Change-Id: Ib839d121c7b46c492f2c4c1c61b52b5d017fa055
* changes:
Update unit tests to reflect the changes to RoutingCoordinator and PrivateAddressCoordinator
Move PrivateAddressCoordinator from Tethering to staticlibs
Refator IpServer to allocate IPv4 address via RoutingCoordinatorManager API
Introduce PrivateAddressCoordinator methods at RoutingCoordinatorManager
Treehugger Robotauthored and Gerrit Code Reviewcommited 2024-10-17 01:28:02 +00:00
This CL moves PrivateAddressCoordinator from Tethering to staticlibs
so that RoutingCooridnatorService can create an instance of
PrivateAddressCoordinator.
Bug: 350699020
Change-Id: I13ccd515972243719465c1c9ab844f802bc8884b
* Renamed TapPacketReader to PollPacketReader to better reflect its
functionality beyond TAP interface interaction.
* The class includes general logic for polling and sending packets to
file descriptors, making it suitable for wider use cases.
Test: TH
Change-Id: Icdf9a9d7ef6f49b589ed9cdbd05159ab95e7e5d9
* changes:
Remove unused method TetheringConfiguration#isRandomPrefixBaseEnabled()
PrivateAddressCoordinator: introduce Dependencies class
PrivateAddressCoordinator: move the special handling of WiFi P2P dedicated IP to IpServer
Treehugger Robotauthored and Gerrit Code Reviewcommited 2024-10-08 17:07:29 +00:00
This CL introduces the Dependencies class for PrivateAddressCoordinator
to allow changing the TetheringConfiguration in tests. Although in
production code TetheringConfiguration won't change after passed to
PrivateAddressCoordinator, there are unit test cases relying on changing
the configuration at runtime.
Bug: 369282577
Change-Id: I5e42005f85e784c0ce3ac9192248c9e4ed4e6147
dedicated IP to IpServer
The source of
TetheringConfiguration#shouldEnableWifiP2pDedicatedIp is in the
Tethering's resources. As refactoring the code, we noticed that it will
be simpler to handle this at IpServer (constructed using
TetheringConfiguration) instead of at PrivateAddressCoordinator
(will require reflection to read the Tethering's resources).
Bug: 369282577
Change-Id: I7b766ef6a769043c2a4ca11741db5c16c5c57071
TetheringMetrics creates a thread to process all metrics work on
a handler. This thread should remain active alongside the
Tethering service but should be closed in test class. Therefore,
add MonitorThreadLeak to ensure the thread is closed correctly.
Test: atest TetheringMetricsTest
Change-Id: Ic57beb3324945ddbb45fec9697056889044e680c
The previous implementation for tracking tethering active sessions
was overly complex. This commit simplifies the logic by:
- Moving the counting to the BpfCoordinatorShimImpl (31 impl)
where rule addition and deletion are centralized.
- Eliminating the unnecessary Android version check (S+) as
the 31 shim only runs on S+.
- Relocating the tracking counters from
ConntrackEventConsumer to the shim class, improving code
locality and encapsulation.
This change addresses the feedback from the networking mainline
release council and resolves a release blocker.
Test: atest TetheringTests:com.android.networkstack.tethering.BpfCoordinatorTest
Fix: 370652384
Change-Id: I70ca58fc45694c738745d7a872272641a62551fd
Need to refresh the usage data. If the network switches back to
Wi-Fi after using cellular data (Wi-Fi -> Cellular -> Wi-Fi), the
old baseline might be inaccurate, leading to incorrect delta
calculations.
Also address some leftover comments.
Fix: 369306449
Fix: 370652336
Test: atest TetheringTests
Change-Id: I1c14aac533cee1d989b7ab354111f071da018058
This removes all the complex downstream prefix / address selection
logic and reduces it to generating a random address within the selected
prefix and checking whether it satisfies a set of conditions. If the
conditions are not met, the process is retried (for a total of 10 times)
before eventually moving on to the next prefix.
The conditions that must be satisfied are:
- Address within prefix does not end in .0, .1, .255
- Address is not contained within a range of commonly used prefixes.
- Prefix does not overlap with another prefix on the system.
Test: TH
Change-Id: I4c53bcaa29c11cde4df99d5bcb834fde94961da4
The dependency of PrivateAddressCoordinator on Context is too generic.
Actually it just needs the ConnectivityManager#getAllNetworks.
This CL clarifies the dependency and this provides flexibility of
instantiation of the class.
Bug: 369282577
Change-Id: I49043f7f557d83856d54cefc201208b7d9b9dd7f
TetheringConfiguration
We're removing the dependency on TetheringConfiguration because
TetheringConfiguration is not parcelable so it cannot be used in AIDL
API. Eventually we'll make PrivateAddressCoordinator expose its
functionalities via AIDL API at RoutingCoordinator.
Bug: 369282577
Change-Id: Id839d183b9463baa18a92a629370b4b8374f1ffd
updateUpstreamPrefix()
This CL changes the signature of
PrivateAddressCoordinator#updateUpstreamPrefix to replace the
UpstreamNetworkState parameter with its member class. This is because we
want to make updateUpstreamPrefix() an AIDL API soon and
UpstreamNetworkState is not parcelable while its member fields are.
Bug: 369282577
Change-Id: Icf71d02d48c8c0d5dc2b21ee351efba956b6752d
* changes:
Support active session metrics sampling
Add unit test for get max counter when removing tethering client
Track tethering active sessions counts
Junyu Laiauthored and Gerrit Code Reviewcommited 2024-09-10 02:53:47 +00:00
modules should specify the submodule of java_sdk_library that the module
actually depends on
Test: CI
Bug: 358613520
Change-Id: I0367068c901df98483f6cf95160d3e7801881b0a
This commit introduces a feature to monitor and upload active
tethering connection metrics. This will help us understand
the usage of tethering and improve the user experience.
The feature is disabled by default and will be gradually
rolled out.
Test: atest TetheringTests:com.android.networkstack.tethering.BpfCoordinatorTest
Test: manual test with:
adb shell device_config put tethering tether_active_sessions_metrics 3
m statsd_testdrive && statsd_testdrive -e 925
Bug: 354619988
Change-Id: I3b3f5ae068b127192c35541c6d9439b7367d54bd
This commit implements the necessary counters to bookkeep
max connection count, which will be used in follow-up changes
to monitor and upload active tethering session metrics.
The feature is disabled by default and will be gradually
rolled out.
Test: atest TetheringTests:com.android.networkstack.tethering.BpfCoordinatorTest
Bug: 354619988
Change-Id: Iaf251b0ec08bde95c1b12df022db2e03179309de
In some cases, the test device may already have an existing CLAT
interface, causing the test to fail because it assumes no CLAT
interface exists before running the test. This change fixes the issue
by retrieving the correct test CLAT interface by its name.
Bug: 361219545
Test: atest EthernetTetheringTest#testTetherClatBpfOffloadUdp
Change-Id: Ie2cdd9c9a6fd143c8419636a448297b36f3c1c40
* changes:
Process all accesses to TetheringMetrics on the handler thread
Calculate and populate TX/RX bytes for each upstream in TetheringMetrics
Initialize upstream data usage after tethering is turned on
Paul Huauthored and Gerrit Code Reviewcommited 2024-09-04 07:30:52 +00:00