Merge "Make it clear that legacyTether always uses IpServer.STATE_TETHERED." into main

This commit is contained in:
Treehugger Robot 2025-01-29 17:30:57 -08:00 • committed by Gerrit Code Review
commit 36e7969920
4 changed files with 8 additions and 10 deletions

View file

@ -1081,8 +1081,7 @@ public class Tethering {
return placeholder;
}
private void handleLegacyTether(String iface, int requestedState,
final IIntResultListener listener) {
private void handleLegacyTether(String iface, final IIntResultListener listener) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM) {
// After V, the TetheringManager and ConnectivityManager tether and untether methods
// throw UnsupportedOperationException, so this cannot happen in normal use. Ensure
@ -1099,7 +1098,7 @@ public class Tethering {
} catch (RemoteException e) { }
}
int result = tetherInternal(null, iface, requestedState);
int result = tetherInternal(null, iface, IpServer.STATE_TETHERED);
switch (type) {
case TETHERING_WIFI:
TerribleErrorLog.logTerribleError(TetheringStatsLog::write,
@ -1147,8 +1146,8 @@ public class Tethering {
* WIFI_(AP/P2P_STATE_CHANGED broadcasts, which makes this API redundant for those types unless
* those broadcasts are disabled by OEM.
*/
void legacyTether(String iface, int requestedState, final IIntResultListener listener) {
mHandler.post(() -> handleLegacyTether(iface, requestedState, listener));
void legacyTether(String iface, final IIntResultListener listener) {
mHandler.post(() -> handleLegacyTether(iface, listener));
}
// TODO: is it possible to make the request @NonNull here?

View file

@ -111,7 +111,7 @@ public class TetheringService extends Service {
IIntResultListener listener) {
if (checkAndNotifyCommonError(callerPkg, callingAttributionTag, listener)) return;
mTethering.legacyTether(iface, IpServer.STATE_TETHERED, listener);
mTethering.legacyTether(iface, listener);
}
@Override

View file

@ -53,7 +53,6 @@ import android.net.ITetheringEventCallback;
import android.net.TetheringManager;
import android.net.TetheringManager.TetheringRequest;
import android.net.TetheringRequestParcel;
import android.net.ip.IpServer;
import android.os.Bundle;
import android.os.ConditionVariable;
import android.os.Handler;
@ -219,7 +218,7 @@ public final class TetheringServiceTest {
mTetheringConnector.tether(TEST_IFACE_NAME, TEST_CALLER_PKG, TEST_ATTRIBUTION_TAG, result);
verify(mTethering).isTetheringSupported();
verify(mTethering).isTetheringAllowed();
verify(mTethering).legacyTether(TEST_IFACE_NAME, IpServer.STATE_TETHERED, result);
verify(mTethering).legacyTether(TEST_IFACE_NAME, result);
}
@Test

View file

@ -3426,7 +3426,7 @@ public class TetheringTest {
mTethering.interfaceStatusChanged(TEST_BT_IFNAME, false);
mTethering.interfaceStatusChanged(TEST_BT_IFNAME, true);
final ResultListener tetherResult = new ResultListener(TETHER_ERROR_NO_ERROR);
mTethering.legacyTether(TEST_BT_IFNAME, IpServer.STATE_TETHERED, tetherResult);
mTethering.legacyTether(TEST_BT_IFNAME, tetherResult);
mLooper.dispatchAll();
tetherResult.assertHasResult();
@ -3476,7 +3476,7 @@ public class TetheringTest {
mTethering.interfaceStatusChanged(TEST_BT_IFNAME, false);
mTethering.interfaceStatusChanged(TEST_BT_IFNAME, true);
final ResultListener tetherResult = new ResultListener(TETHER_ERROR_NO_ERROR);
mTethering.legacyTether(TEST_BT_IFNAME, IpServer.STATE_TETHERED, tetherResult);
mTethering.legacyTether(TEST_BT_IFNAME, tetherResult);
mLooper.dispatchAll();
tetherResult.assertHasResult();
}