Merge "Use SdkLevel.isAtLeastB() instead of SDK_INT" into main am: b453055426

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3535279

Change-Id: I3106560464c886df0b7764b57fe7935003dd61cf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Quang Luong 2025-03-11 15:04:20 -07:00 • committed by Automerger Merge Worker
commit db67ad9102
5 changed files with 12 additions and 13 deletions

View file

@ -111,6 +111,7 @@ java_defaults {
"sdk_module-lib_current_framework-wifi",
],
static_libs: [
"modules-utils-build",
"com.android.net.flags-aconfig-java",
],
aidl: {

View file

@ -42,6 +42,7 @@ import android.util.ArraySet;
import android.util.Log;
import com.android.internal.annotations.GuardedBy;
import com.android.modules.utils.build.SdkLevel;
import com.android.net.flags.Flags;
import java.lang.annotation.Retention;
@ -664,7 +665,7 @@ public class TetheringManager {
}
private void unsupportedAfterV() {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM) {
if (SdkLevel.isAtLeastB()) {
throw new UnsupportedOperationException("Not supported after SDK version "
+ Build.VERSION_CODES.VANILLA_ICE_CREAM);
}

View file

@ -117,7 +117,6 @@ import android.net.wifi.p2p.WifiP2pGroup;
import android.net.wifi.p2p.WifiP2pInfo;
import android.net.wifi.p2p.WifiP2pManager;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@ -146,6 +145,7 @@ 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;
@ -461,7 +461,7 @@ public class Tethering {
}
boolean isTetheringWithSoftApConfigEnabled() {
return mDeps.isTetheringWithSoftApConfigEnabled();
return SdkLevel.isAtLeastB() && Flags.tetheringWithSoftApConfig();
}
/**
@ -635,7 +635,7 @@ public class Tethering {
// TODO: fix the teardown path to stop depending on interface state notifications.
// These are not necessary since most/all link layers have their own teardown
// notifications, and can race with those notifications.
if (enabled && Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM) {
if (enabled && SdkLevel.isAtLeastB()) {
return;
}
@ -1082,7 +1082,7 @@ public class Tethering {
}
private void handleLegacyTether(String iface, final IIntResultListener listener) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM) {
if (SdkLevel.isAtLeastB()) {
// After V, the TetheringManager and ConnectivityManager tether and untether methods
// throw UnsupportedOperationException, so this cannot happen in normal use. Ensure
// that this code cannot run even if callers use raw binder calls or other
@ -1183,7 +1183,7 @@ public class Tethering {
}
void legacyUntether(String iface, final IIntResultListener listener) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM) {
if (SdkLevel.isAtLeastB()) {
// After V, the TetheringManager and ConnectivityManager tether and untether methods
// throw UnsupportedOperationException, so this cannot happen in normal use. Ensure
// that this code cannot run even if callers use raw binder calls or other

View file

@ -214,7 +214,6 @@ public abstract class TetheringDependencies {
* Wrapper for tethering_with_soft_ap_config feature flag.
*/
public boolean isTetheringWithSoftApConfigEnabled() {
return Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM
&& Flags.tetheringWithSoftApConfig();
return SdkLevel.isAtLeastB() && Flags.tetheringWithSoftApConfig();
}
}

View file

@ -73,7 +73,6 @@ import android.net.cts.util.CtsTetheringUtils.TestTetheringEventCallback;
import android.net.wifi.SoftApConfiguration;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiSsid;
import android.os.Build;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.os.ResultReceiver;
@ -391,7 +390,7 @@ public class TetheringManagerTest {
mCtsTetheringUtils.stopWifiTethering(tetherEventCallback);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
if (!SdkLevel.isAtLeastB()) {
try {
final int ret = runAsShell(TETHER_PRIVILEGED,
() -> mTM.tether(wifiTetheringIface));
@ -480,8 +479,7 @@ public class TetheringManagerTest {
}
private boolean isTetheringWithSoftApConfigEnabled() {
return Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM
&& Flags.tetheringWithSoftApConfig();
return SdkLevel.isAtLeastB() && Flags.tetheringWithSoftApConfig();
}
@Test
@ -636,7 +634,7 @@ public class TetheringManagerTest {
@Test
public void testLegacyTetherApisThrowUnsupportedOperationExceptionAfterV() {
assumeTrue(Build.VERSION.SDK_INT > Build.VERSION_CODES.VANILLA_ICE_CREAM);
assumeTrue(SdkLevel.isAtLeastB());
assertThrows(UnsupportedOperationException.class, () -> mTM.tether("iface"));
assertThrows(UnsupportedOperationException.class, () -> mTM.untether("iface"));
}