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

Commit b975e352 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Revert back to isDualBandSupported() for Wifi tethering." into oc-mr1-dev

parents adef5b23 d52c17c7
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.settings.wifi.tether;

import static android.net.wifi.WifiConfiguration.AP_BAND_2GHZ;
import static android.net.wifi.WifiConfiguration.AP_BAND_5GHZ;

import android.content.Context;
import android.net.wifi.WifiConfiguration;
import android.support.v7.preference.ListPreference;
@@ -24,9 +27,6 @@ import android.support.v7.preference.PreferenceScreen;

import com.android.settings.R;

import static android.net.wifi.WifiConfiguration.AP_BAND_2GHZ;
import static android.net.wifi.WifiConfiguration.AP_BAND_5GHZ;

public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferenceController {

    private static final String PREF_KEY = "wifi_tether_network_ap_band";
@@ -41,10 +41,14 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
        super(context, listener);
        mBandEntries = mContext.getResources().getStringArray(R.array.wifi_ap_band_config_full);
        final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
        if (config != null) {
        if (config == null) {
            mBandIndex = 0;
        } else if (is5GhzBandSupported()) {
            mBandIndex = config.apBand;
        } else {
            mBandIndex = 0;
            config.apBand = 0;
            mWifiManager.setWifiApConfiguration(config);
            mBandIndex = config.apBand;
        }
    }

@@ -77,10 +81,11 @@ public class WifiTetherApBandPreferenceController extends WifiTetherBasePreferen
    }

    private boolean is5GhzBandSupported() {
        if (mBandIndex > 0) {
            return true;
        final String countryCode = mWifiManager.getCountryCode();
        if (!mWifiManager.isDualBandSupported() || countryCode == null) {
            return false;
        }
        return mWifiManager.is5GHzBandSupported();
        return true;
    }

    public int getBandIndex() {
+22 −8
Original line number Diff line number Diff line
@@ -16,6 +16,12 @@

package com.android.settings.wifi.tether;

import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
@@ -35,12 +41,6 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class WifiTetherApBandPreferenceControllerTest {
@@ -75,16 +75,30 @@ public class WifiTetherApBandPreferenceControllerTest {

    @Test
    public void display_5GhzSupported_shouldDisplayFullList() {
        when(mWifiManager.is5GHzBandSupported()).thenReturn(true);
        when(mWifiManager.getCountryCode()).thenReturn("US");
        when(mWifiManager.isDualBandSupported()).thenReturn(true);

        mController.displayPreference(mScreen);

        assertThat(mListPreference.getEntries().length).isEqualTo(2);
    }

    @Test
    public void display_noCountryCode_shouldDisable() {
        when(mWifiManager.getCountryCode()).thenReturn(null);
        when(mWifiManager.isDualBandSupported()).thenReturn(true);

        mController.displayPreference(mScreen);

        assertThat(mListPreference.getEntries()).isNull();
        assertThat(mListPreference.isEnabled()).isFalse();
        assertThat(mListPreference.getSummary())
                .isEqualTo(RuntimeEnvironment.application.getString(R.string.wifi_ap_choose_2G));
    }

    @Test
    public void display_5GhzNotSupported_shouldDisable() {
        when(mWifiManager.is5GHzBandSupported()).thenReturn(false);
        when(mWifiManager.isDualBandSupported()).thenReturn(false);

        mController.displayPreference(mScreen);