Replace isTetheringWithSoftApConfig flag with B SDK check
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
This commit is contained in:
parent
d093ea69b0
commit
a10437f133
4 changed files with 28 additions and 35 deletions
|
|
@ -148,7 +148,6 @@ import com.android.internal.util.MessageUtils;
|
|||
import com.android.internal.util.State;
|
||||
import com.android.internal.util.StateMachine;
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.net.flags.Flags;
|
||||
import com.android.net.module.util.BaseNetdUnsolicitedEventListener;
|
||||
import com.android.net.module.util.CollectionUtils;
|
||||
import com.android.net.module.util.HandlerUtils;
|
||||
|
|
@ -463,9 +462,8 @@ public class Tethering {
|
|||
return mSettingsObserver;
|
||||
}
|
||||
|
||||
// TODO: Replace with SdkLevel.isAtLeastB() once the feature is fully implemented.
|
||||
boolean isTetheringWithSoftApConfigEnabled() {
|
||||
return SdkLevel.isAtLeastB() && Flags.tetheringWithSoftApConfig();
|
||||
return mDeps.isTetheringWithSoftApConfigEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.net.flags.Flags;
|
||||
import com.android.net.module.util.RoutingCoordinatorManager;
|
||||
import com.android.net.module.util.RoutingCoordinatorService;
|
||||
import com.android.net.module.util.SharedLog;
|
||||
|
|
@ -211,9 +210,9 @@ public abstract class TetheringDependencies {
|
|||
}
|
||||
|
||||
/**
|
||||
* Wrapper for tethering_with_soft_ap_config feature flag.
|
||||
* Returns true if the tethering with soft ap config feature is enabled.
|
||||
*/
|
||||
public boolean isTetheringWithSoftApConfigEnabled() {
|
||||
return SdkLevel.isAtLeastB() && Flags.tetheringWithSoftApConfig();
|
||||
return SdkLevel.isAtLeastB();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,6 @@ 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.assumeFalse;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.notNull;
|
||||
|
|
@ -201,7 +200,6 @@ import androidx.test.runner.AndroidJUnit4;
|
|||
import com.android.internal.util.test.BroadcastInterceptingContext;
|
||||
import com.android.internal.util.test.FakeSettingsProvider;
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.net.flags.Flags;
|
||||
import com.android.net.module.util.CollectionUtils;
|
||||
import com.android.net.module.util.InterfaceParams;
|
||||
import com.android.net.module.util.PrivateAddressCoordinator;
|
||||
|
|
@ -344,6 +342,7 @@ public class TetheringTest {
|
|||
private TestConnectivityManager mCm;
|
||||
private boolean mForceEthernetServiceUnavailable = false;
|
||||
private int mBinderCallingUid = TEST_CALLER_UID;
|
||||
private boolean mTetheringWithSoftApConfigEnabled = SdkLevel.isAtLeastB();
|
||||
|
||||
private class TestContext extends BroadcastInterceptingContext {
|
||||
TestContext(Context base) {
|
||||
|
|
@ -584,6 +583,11 @@ public class TetheringTest {
|
|||
public int getBinderCallingUid() {
|
||||
return mBinderCallingUid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTetheringWithSoftApConfigEnabled() {
|
||||
return mTetheringWithSoftApConfigEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
private static LinkProperties buildUpstreamLinkProperties(String interfaceName,
|
||||
|
|
@ -720,6 +724,7 @@ public class TetheringTest {
|
|||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)).thenReturn(true);
|
||||
when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT)).thenReturn(true);
|
||||
mIpServerDependencies = spy(new MockIpServerDependencies());
|
||||
mTetheringWithSoftApConfigEnabled = SdkLevel.isAtLeastB();
|
||||
}
|
||||
|
||||
// In order to interact with syncSM from the test, tethering must be created in test thread.
|
||||
|
|
@ -2437,7 +2442,7 @@ public class TetheringTest {
|
|||
|
||||
@Test
|
||||
public void testSoftApConfigInTetheringEventCallback() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(mTetheringDependencies.isTetheringWithSoftApConfigEnabled());
|
||||
when(mContext.checkCallingOrSelfPermission(NETWORK_SETTINGS))
|
||||
.thenReturn(PERMISSION_DENIED);
|
||||
when(mContext.checkCallingOrSelfPermission(NETWORK_STACK))
|
||||
|
|
@ -2533,13 +2538,9 @@ public class TetheringTest {
|
|||
callback.assertNoCallback();
|
||||
}
|
||||
|
||||
private boolean isTetheringWithSoftApConfigEnabled() {
|
||||
return SdkLevel.isAtLeastB() && Flags.tetheringWithSoftApConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFuzzyMatchedWifiCannotBeAdded() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(mTetheringDependencies.isTetheringWithSoftApConfigEnabled());
|
||||
initTetheringOnTestThread();
|
||||
TestTetheringEventCallback callback = new TestTetheringEventCallback();
|
||||
SoftApConfiguration softApConfig = new SoftApConfiguration.Builder().setWifiSsid(
|
||||
|
|
@ -2623,7 +2624,7 @@ public class TetheringTest {
|
|||
|
||||
@Test
|
||||
public void testFuzzyMatchedWifiCanBeAddedAfterIpServerStopped() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(mTetheringDependencies.isTetheringWithSoftApConfigEnabled());
|
||||
when(mWifiManager.startTetheredHotspot(null)).thenReturn(true);
|
||||
initTetheringOnTestThread();
|
||||
|
||||
|
|
@ -2656,7 +2657,7 @@ public class TetheringTest {
|
|||
|
||||
@Test
|
||||
public void testFuzzyMatchedWifiCanBeAddedAfterIpServerUnwanted() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(mTetheringDependencies.isTetheringWithSoftApConfigEnabled());
|
||||
when(mWifiManager.startTetheredHotspot(null)).thenReturn(true);
|
||||
initTetheringOnTestThread();
|
||||
|
||||
|
|
@ -2689,7 +2690,7 @@ public class TetheringTest {
|
|||
|
||||
@Test
|
||||
public void testFuzzyMatchedWifiCanBeAddedAfterIpServerError() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(mTetheringDependencies.isTetheringWithSoftApConfigEnabled());
|
||||
when(mWifiManager.startTetheredHotspot(null)).thenReturn(true);
|
||||
initTetheringOnTestThread();
|
||||
|
||||
|
|
@ -2717,7 +2718,7 @@ public class TetheringTest {
|
|||
|
||||
@Test
|
||||
public void testFuzzyMatchedWifiCanBeAddedAfterStoppingPendingRequest() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(mTetheringDependencies.isTetheringWithSoftApConfigEnabled());
|
||||
when(mWifiManager.startTetheredHotspot(null)).thenReturn(true);
|
||||
initTetheringOnTestThread();
|
||||
|
||||
|
|
@ -2749,7 +2750,7 @@ public class TetheringTest {
|
|||
|
||||
@Test
|
||||
public void testFuzzyMatchedWifiCanBeAddedAfterStoppingServingRequest() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(mTetheringDependencies.isTetheringWithSoftApConfigEnabled());
|
||||
when(mWifiManager.startTetheredHotspot(null)).thenReturn(true);
|
||||
initTetheringOnTestThread();
|
||||
|
||||
|
|
@ -2782,7 +2783,7 @@ public class TetheringTest {
|
|||
|
||||
@Test
|
||||
public void testStopTetheringWithMatchingRequest() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(mTetheringDependencies.isTetheringWithSoftApConfigEnabled());
|
||||
when(mContext.checkCallingOrSelfPermission(NETWORK_SETTINGS)).thenReturn(PERMISSION_DENIED);
|
||||
initTetheringOnTestThread();
|
||||
UpstreamNetworkState upstreamState = buildMobileDualStackUpstreamState();
|
||||
|
|
@ -2830,7 +2831,7 @@ public class TetheringTest {
|
|||
|
||||
@Test
|
||||
public void testStopTetheringWithSettingsPermission() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(mTetheringDependencies.isTetheringWithSoftApConfigEnabled());
|
||||
initTetheringOnTestThread();
|
||||
UpstreamNetworkState upstreamState = buildMobileDualStackUpstreamState();
|
||||
initTetheringUpstream(upstreamState);
|
||||
|
|
@ -3126,7 +3127,7 @@ public class TetheringTest {
|
|||
|
||||
@Test
|
||||
public void testMultipleStartTetheringLegacy() throws Exception {
|
||||
assumeFalse(isTetheringWithSoftApConfigEnabled());
|
||||
mTetheringWithSoftApConfigEnabled = false;
|
||||
initTetheringOnTestThread();
|
||||
final LinkAddress serverLinkAddr = new LinkAddress("192.168.20.1/24");
|
||||
final LinkAddress clientLinkAddr = new LinkAddress("192.168.20.42/24");
|
||||
|
|
@ -3907,7 +3908,7 @@ public class TetheringTest {
|
|||
@Test
|
||||
public void testStartBluetoothTetheringFailsWhenTheresAnExistingRequestWaitingForPanService()
|
||||
throws Exception {
|
||||
assumeFalse(isTetheringWithSoftApConfigEnabled());
|
||||
mTetheringWithSoftApConfigEnabled = false;
|
||||
initTetheringOnTestThread();
|
||||
|
||||
mockBluetoothSettings(true /* bluetoothOn */, true /* tetheringOn */);
|
||||
|
|
|
|||
|
|
@ -86,7 +86,6 @@ import androidx.test.InstrumentationRegistry;
|
|||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.modules.utils.build.SdkLevel;
|
||||
import com.android.net.flags.Flags;
|
||||
import com.android.testutils.ParcelUtils;
|
||||
import com.android.testutils.com.android.testutils.CarrierConfigRule;
|
||||
|
||||
|
|
@ -237,7 +236,7 @@ public class TetheringManagerTest {
|
|||
|
||||
@Test
|
||||
public void testStartTetheringDuplicateRequestRejected() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(SdkLevel.isAtLeastB());
|
||||
final TestTetheringEventCallback tetherEventCallback =
|
||||
mCtsTetheringUtils.registerTetheringEventCallback();
|
||||
try {
|
||||
|
|
@ -405,13 +404,13 @@ public class TetheringManagerTest {
|
|||
tetherEventCallback.assumeWifiTetheringSupported(mContext);
|
||||
tetherEventCallback.expectNoTetheringActive();
|
||||
|
||||
SoftApConfiguration softApConfig = isTetheringWithSoftApConfigEnabled()
|
||||
SoftApConfiguration softApConfig = SdkLevel.isAtLeastB()
|
||||
? createSoftApConfiguration("SSID") : null;
|
||||
final TetheringInterface tetheredIface =
|
||||
mCtsTetheringUtils.startWifiTethering(tetherEventCallback, softApConfig);
|
||||
|
||||
assertNotNull(tetheredIface);
|
||||
if (isTetheringWithSoftApConfigEnabled()) {
|
||||
if (SdkLevel.isAtLeastB()) {
|
||||
assertEquals(softApConfig, tetheredIface.getSoftApConfiguration());
|
||||
}
|
||||
|
||||
|
|
@ -484,7 +483,7 @@ public class TetheringManagerTest {
|
|||
|
||||
@Test
|
||||
public void testStopTetheringRequestNoMatchFailure() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(SdkLevel.isAtLeastB());
|
||||
final TestTetheringEventCallback tetherEventCallback =
|
||||
mCtsTetheringUtils.registerTetheringEventCallback();
|
||||
try {
|
||||
|
|
@ -504,7 +503,7 @@ public class TetheringManagerTest {
|
|||
|
||||
@Test
|
||||
public void testStopTetheringRequestMatchSuccess() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(SdkLevel.isAtLeastB());
|
||||
final TestTetheringEventCallback tetherEventCallback =
|
||||
mCtsTetheringUtils.registerTetheringEventCallback();
|
||||
try {
|
||||
|
|
@ -528,7 +527,7 @@ public class TetheringManagerTest {
|
|||
|
||||
@Test
|
||||
public void testStopTetheringRequestFuzzyMatchSuccess() throws Exception {
|
||||
assumeTrue(isTetheringWithSoftApConfigEnabled());
|
||||
assumeTrue(SdkLevel.isAtLeastB());
|
||||
final TestTetheringEventCallback tetherEventCallback =
|
||||
mCtsTetheringUtils.registerTetheringEventCallback();
|
||||
try {
|
||||
|
|
@ -554,10 +553,6 @@ public class TetheringManagerTest {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isTetheringWithSoftApConfigEnabled() {
|
||||
return SdkLevel.isAtLeastB() && Flags.tetheringWithSoftApConfig();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartTetheringNoPermission() throws Exception {
|
||||
final StartTetheringCallback startTetheringCallback = new StartTetheringCallback();
|
||||
|
|
@ -568,7 +563,7 @@ public class TetheringManagerTest {
|
|||
startTetheringCallback.expectTetheringFailed(TETHER_ERROR_NO_CHANGE_TETHERING_PERMISSION);
|
||||
|
||||
// WRITE_SETTINGS not sufficient
|
||||
if (isTetheringWithSoftApConfigEnabled()) {
|
||||
if (SdkLevel.isAtLeastB()) {
|
||||
runAsShell(WRITE_SETTINGS, () -> {
|
||||
mTM.startTethering(new TetheringRequest.Builder(TETHERING_WIFI).build(),
|
||||
c -> c.run() /* executor */, startTetheringCallback);
|
||||
|
|
|
|||
Loading…
Reference in a new issue