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

Commit 1a2667f8 authored by Roshan Pius's avatar Roshan Pius
Browse files

WifiManager: Add public API for STA + STA concurrency support

Bug: 158666312
Test: atest android.net.wifi
Change-Id: I56b8b13537c940936cb0e62f4e2d3b926b654a15
parent 9bca9776
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31570,6 +31570,7 @@ package android.net.wifi {
    method public boolean isEasyConnectSupported();
    method public boolean isEnhancedOpenSupported();
    method public boolean isEnhancedPowerReportingSupported();
    method public boolean isMultiStaConcurrencySupported();
    method public boolean isP2pSupported();
    method public boolean isPreferredNetworkOffloadSupported();
    method @Deprecated public boolean isScanAlwaysAvailable();
+1 −0
Original line number Diff line number Diff line
@@ -332,6 +332,7 @@ package android.net.wifi {
    method public boolean isEasyConnectSupported();
    method public boolean isEnhancedOpenSupported();
    method public boolean isEnhancedPowerReportingSupported();
    method public boolean isMultiStaConcurrencySupported();
    method public boolean isP2pSupported();
    method public boolean isPreferredNetworkOffloadSupported();
    method @Deprecated public boolean isScanAlwaysAvailable();
+13 −8
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.net.wifi.hotspot2.IProvisioningCallback;
import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.net.wifi.hotspot2.ProvisioningCallback;
import android.net.wifi.util.SdkLevelUtil;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
@@ -2479,6 +2480,18 @@ public class WifiManager {
        return isFeatureSupported(WIFI_FEATURE_AP_STA);
    }

    /**
     * Query whether the device supports 2 or more concurrent stations (STA) or not.
     *
     * @return true if this device supports multiple STA concurrency, false otherwise.
     */
    public boolean isMultiStaConcurrencySupported() {
        if (!SdkLevelUtil.isAtLeastS()) {
            throw new UnsupportedOperationException();
        }
        return isFeatureSupported(WIFI_FEATURE_ADDITIONAL_STA);
    }

    /**
     * @deprecated Please use {@link android.content.pm.PackageManager#hasSystemFeature(String)}
     * with {@link android.content.pm.PackageManager#FEATURE_WIFI_RTT} and
@@ -2511,14 +2524,6 @@ public class WifiManager {
        return isFeatureSupported(WIFI_FEATURE_PNO);
    }

    /**
     * @return true if this adapter supports multiple simultaneous connections
     * @hide
     */
    public boolean isAdditionalStaSupported() {
        return isFeatureSupported(WIFI_FEATURE_ADDITIONAL_STA);
    }

    /**
     * @return true if this adapter supports Tunnel Directed Link Setup
     */
+32 −1
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ import static android.net.wifi.WifiManager.STATUS_SUGGESTION_CONNECTION_FAILURE_
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLING;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_FAILED;
import static android.net.wifi.WifiManager.WIFI_FEATURE_ADDITIONAL_STA;
import static android.net.wifi.WifiManager.WIFI_FEATURE_AP_STA;
import static android.net.wifi.WifiManager.WIFI_FEATURE_DPP;
import static android.net.wifi.WifiManager.WIFI_FEATURE_OWE;
import static android.net.wifi.WifiManager.WIFI_FEATURE_P2P;
@@ -49,6 +51,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.nullable;
import static org.mockito.Mockito.any;
@@ -83,6 +86,7 @@ import android.net.wifi.WifiManager.SoftApCallback;
import android.net.wifi.WifiManager.SuggestionConnectionStatusListener;
import android.net.wifi.WifiManager.TrafficStateCallback;
import android.net.wifi.WifiManager.WifiConnectedNetworkScorer;
import android.net.wifi.util.SdkLevelUtil;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerExecutor;
@@ -1707,6 +1711,34 @@ public class WifiManagerTest {
        assertFalse(mWifiManager.isEasyConnectSupported());
    }

    /**
     * Test behavior of isStaApConcurrencySupported
     */
    @Test
    public void testIsStaApConcurrencyOpenSupported() throws Exception {
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(WIFI_FEATURE_AP_STA));
        assertTrue(mWifiManager.isStaApConcurrencySupported());
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(~WIFI_FEATURE_AP_STA));
        assertFalse(mWifiManager.isStaApConcurrencySupported());
    }

    /**
     * Test behavior of isMultiStaConcurrencySupported
     */
    @Test
    public void testIsMultiStaConcurrencyOpenSupported() throws Exception {
        assumeTrue(SdkLevelUtil.isAtLeastS());

        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(WIFI_FEATURE_ADDITIONAL_STA));
        assertTrue(mWifiManager.isMultiStaConcurrencySupported());
        when(mWifiService.getSupportedFeatures())
                .thenReturn(new Long(~WIFI_FEATURE_ADDITIONAL_STA));
        assertFalse(mWifiManager.isMultiStaConcurrencySupported());
    }

    /**
     * Test behavior of {@link WifiManager#addNetwork(WifiConfiguration)}
     */
@@ -1858,7 +1890,6 @@ public class WifiManagerTest {
        assertFalse(mWifiManager.isDeviceToDeviceRttSupported());
        assertFalse(mWifiManager.isDeviceToApRttSupported());
        assertFalse(mWifiManager.isPreferredNetworkOffloadSupported());
        assertFalse(mWifiManager.isAdditionalStaSupported());
        assertFalse(mWifiManager.isTdlsSupported());
        assertFalse(mWifiManager.isOffChannelTdlsSupported());
        assertFalse(mWifiManager.isEnhancedPowerReportingSupported());