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
This commit is contained in:
Quang Anh Luong 2024-12-06 16:44:36 +09:00
commit 30d8a25db3

View file

@ -44,6 +44,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
@ -65,6 +66,7 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.net.ConnectivityManager.NetworkCallback;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
@ -669,4 +671,12 @@ public class ConnectivityManagerTest {
// No callbacks overridden -> do not use the optimization
eq(~0));
}
@Test
public void testLegacyTetherApisThrowUnsupportedOperationExceptionAfterV() {
assumeTrue(Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM);
final ConnectivityManager manager = new ConnectivityManager(mCtx, mService);
assertThrows(UnsupportedOperationException.class, () -> manager.tether("iface"));
assertThrows(UnsupportedOperationException.class, () -> manager.untether("iface"));
}
}