Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3e52bf4 authored by David Su's avatar David Su Committed by Android (Google) Code Review
Browse files

Merge "Migrate existing Build.VERSION.SDK_INT checks to SdkLevelUtil"

parents 0572a76b b93c97d7
Loading
Loading
Loading
Loading
+6 −7
Original line number Original line Diff line number Diff line
@@ -16,10 +16,11 @@


package android.net.wifi;
package android.net.wifi;


import android.os.Build;
import android.net.wifi.util.SdkLevelUtil;
import android.os.Parcel;
import android.os.Parcel;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;


import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;


@@ -92,14 +93,12 @@ public class SoftApCapabilityTest {


    @Test(expected = IllegalArgumentException.class)
    @Test(expected = IllegalArgumentException.class)
    public void testGetSupportedChannelListWithInvalidBand() {
    public void testGetSupportedChannelListWithInvalidBand() {
        assumeTrue(SdkLevelUtil.isAtLeastS());

        long testSoftApFeature = SoftApCapability.SOFTAP_FEATURE_CLIENT_FORCE_DISCONNECT
        long testSoftApFeature = SoftApCapability.SOFTAP_FEATURE_CLIENT_FORCE_DISCONNECT
                | SoftApCapability.SOFTAP_FEATURE_ACS_OFFLOAD;
                | SoftApCapability.SOFTAP_FEATURE_ACS_OFFLOAD;
        SoftApCapability capability = new SoftApCapability(testSoftApFeature);
        SoftApCapability capability = new SoftApCapability(testSoftApFeature);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
        capability.getSupportedChannelList(
        capability.getSupportedChannelList(
                SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ);
                SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ);
        } else {
            throw new IllegalArgumentException("API doesn't support in current SDK version");
        }
    }
    }
}
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNull;


import android.net.MacAddress;
import android.net.MacAddress;
import android.os.Build;
import android.net.wifi.util.SdkLevelUtil;
import android.os.Parcel;
import android.os.Parcel;


import androidx.test.filters.SmallTest;
import androidx.test.filters.SmallTest;
@@ -81,7 +81,7 @@ public class SoftApConfigurationTest {
        assertThat(original.getChannel()).isEqualTo(0);
        assertThat(original.getChannel()).isEqualTo(0);
        assertThat(original.isHiddenSsid()).isEqualTo(false);
        assertThat(original.isHiddenSsid()).isEqualTo(false);
        assertThat(original.getMaxNumberOfClients()).isEqualTo(0);
        assertThat(original.getMaxNumberOfClients()).isEqualTo(0);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
        if (SdkLevelUtil.isAtLeastS()) {
            assertThat(original.getMacRandomizationSetting())
            assertThat(original.getMacRandomizationSetting())
                    .isEqualTo(SoftApConfiguration.RANDOMIZATION_PERSISTENT);
                    .isEqualTo(SoftApConfiguration.RANDOMIZATION_PERSISTENT);
        }
        }
@@ -137,7 +137,7 @@ public class SoftApConfigurationTest {
                .setClientControlByUserEnabled(true)
                .setClientControlByUserEnabled(true)
                .setBlockedClientList(testBlockedClientList)
                .setBlockedClientList(testBlockedClientList)
                .setAllowedClientList(testAllowedClientList);
                .setAllowedClientList(testAllowedClientList);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
        if (SdkLevelUtil.isAtLeastS()) {
            originalBuilder.setMacRandomizationSetting(SoftApConfiguration.RANDOMIZATION_NONE);
            originalBuilder.setMacRandomizationSetting(SoftApConfiguration.RANDOMIZATION_NONE);
        }
        }
        SoftApConfiguration original = originalBuilder.build();
        SoftApConfiguration original = originalBuilder.build();
@@ -153,7 +153,7 @@ public class SoftApConfigurationTest {
        assertThat(original.isClientControlByUserEnabled()).isEqualTo(true);
        assertThat(original.isClientControlByUserEnabled()).isEqualTo(true);
        assertThat(original.getBlockedClientList()).isEqualTo(testBlockedClientList);
        assertThat(original.getBlockedClientList()).isEqualTo(testBlockedClientList);
        assertThat(original.getAllowedClientList()).isEqualTo(testAllowedClientList);
        assertThat(original.getAllowedClientList()).isEqualTo(testAllowedClientList);
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
        if (SdkLevelUtil.isAtLeastS()) {
            assertThat(original.getMacRandomizationSetting())
            assertThat(original.getMacRandomizationSetting())
                    .isEqualTo(SoftApConfiguration.RANDOMIZATION_NONE);
                    .isEqualTo(SoftApConfiguration.RANDOMIZATION_NONE);
        }
        }