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

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

Merge "Remove Instant Hotspot from Settings search" into main

parents 881c1948 3dc78376
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.widget.SettingsMainSwitchBar;
import com.android.settings.wifi.WifiUtils;
import com.android.settings.wifi.repository.SharedConnectivityRepository;
import com.android.settingslib.TetherUtil;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
@@ -346,16 +347,20 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
    static class SearchIndexProvider extends BaseSearchIndexProvider {

        private final WifiRestriction mWifiRestriction;
        private final boolean mIsInstantHotspotEnabled;

        SearchIndexProvider(int xmlRes) {
            super(xmlRes);
            mWifiRestriction = new WifiRestriction();
            mIsInstantHotspotEnabled = SharedConnectivityRepository.isDeviceConfigEnabled();
        }

        @VisibleForTesting
        SearchIndexProvider(int xmlRes, WifiRestriction wifiRestriction) {
        SearchIndexProvider(int xmlRes, WifiRestriction wifiRestriction,
                boolean isInstantHotspotEnabled) {
            super(xmlRes);
            mWifiRestriction = wifiRestriction;
            mIsInstantHotspotEnabled = isInstantHotspotEnabled;
        }

        @Override
@@ -369,6 +374,9 @@ public class WifiTetherSettings extends RestrictedDashboardFragment
                keys.add(KEY_WIFI_TETHER_NETWORK_PASSWORD);
                keys.add(KEY_WIFI_TETHER_AUTO_OFF);
                keys.add(KEY_WIFI_TETHER_MAXIMIZE_COMPATIBILITY);
                keys.add(KEY_INSTANT_HOTSPOT);
            } else if (!mIsInstantHotspotEnabled) {
                keys.add(KEY_INSTANT_HOTSPOT);
            }

            // Remove duplicate
+29 −4
Original line number Diff line number Diff line
@@ -266,7 +266,8 @@ public class WifiTetherSettingsTest {
        when(mWifiRestriction.isTetherAvailable(mContext)).thenReturn(true);
        when(mWifiRestriction.isHotspotAvailable(mContext)).thenReturn(true);
        WifiTetherSettings.SearchIndexProvider searchIndexProvider =
                new WifiTetherSettings.SearchIndexProvider(XML_RES, mWifiRestriction);
                new WifiTetherSettings.SearchIndexProvider(XML_RES, mWifiRestriction,
                        true /* isInstantHotspotEnabled */);

        final List<String> keys = searchIndexProvider.getNonIndexableKeys(mContext);

@@ -275,6 +276,7 @@ public class WifiTetherSettingsTest {
        assertThat(keys).doesNotContain(WifiTetherSettings.KEY_WIFI_TETHER_NETWORK_PASSWORD);
        assertThat(keys).doesNotContain(WifiTetherSettings.KEY_WIFI_TETHER_AUTO_OFF);
        assertThat(keys).doesNotContain(WifiTetherSettings.KEY_WIFI_TETHER_MAXIMIZE_COMPATIBILITY);
        assertThat(keys).doesNotContain(WifiTetherSettings.KEY_INSTANT_HOTSPOT);
    }

    @Test
@@ -282,7 +284,8 @@ public class WifiTetherSettingsTest {
        when(mWifiRestriction.isTetherAvailable(mContext)).thenReturn(false);
        when(mWifiRestriction.isHotspotAvailable(mContext)).thenReturn(true);
        WifiTetherSettings.SearchIndexProvider searchIndexProvider =
                new WifiTetherSettings.SearchIndexProvider(XML_RES, mWifiRestriction);
                new WifiTetherSettings.SearchIndexProvider(XML_RES, mWifiRestriction,
                        true /* isInstantHotspotEnabled */);

        final List<String> keys = searchIndexProvider.getNonIndexableKeys(mContext);

@@ -291,6 +294,7 @@ public class WifiTetherSettingsTest {
        assertThat(keys).contains(WifiTetherSettings.KEY_WIFI_TETHER_NETWORK_PASSWORD);
        assertThat(keys).contains(WifiTetherSettings.KEY_WIFI_TETHER_AUTO_OFF);
        assertThat(keys).contains(WifiTetherSettings.KEY_WIFI_TETHER_MAXIMIZE_COMPATIBILITY);
        assertThat(keys).contains(WifiTetherSettings.KEY_INSTANT_HOTSPOT);
    }

    @Test
@@ -298,7 +302,8 @@ public class WifiTetherSettingsTest {
        when(mWifiRestriction.isTetherAvailable(mContext)).thenReturn(true);
        when(mWifiRestriction.isHotspotAvailable(mContext)).thenReturn(false);
        WifiTetherSettings.SearchIndexProvider searchIndexProvider =
                new WifiTetherSettings.SearchIndexProvider(XML_RES, mWifiRestriction);
                new WifiTetherSettings.SearchIndexProvider(XML_RES, mWifiRestriction,
                        true /* isInstantHotspotEnabled */);

        final List<String> keys = searchIndexProvider.getNonIndexableKeys(mContext);

@@ -307,6 +312,7 @@ public class WifiTetherSettingsTest {
        assertThat(keys).contains(WifiTetherSettings.KEY_WIFI_TETHER_NETWORK_PASSWORD);
        assertThat(keys).contains(WifiTetherSettings.KEY_WIFI_TETHER_AUTO_OFF);
        assertThat(keys).contains(WifiTetherSettings.KEY_WIFI_TETHER_MAXIMIZE_COMPATIBILITY);
        assertThat(keys).contains(WifiTetherSettings.KEY_INSTANT_HOTSPOT);
    }

    @Test
@@ -314,7 +320,8 @@ public class WifiTetherSettingsTest {
        when(mWifiRestriction.isTetherAvailable(mContext)).thenReturn(false);
        when(mWifiRestriction.isHotspotAvailable(mContext)).thenReturn(false);
        WifiTetherSettings.SearchIndexProvider searchIndexProvider =
                new WifiTetherSettings.SearchIndexProvider(XML_RES, mWifiRestriction);
                new WifiTetherSettings.SearchIndexProvider(XML_RES, mWifiRestriction,
                        true /* isInstantHotspotEnabled */);

        final List<String> keys = searchIndexProvider.getNonIndexableKeys(mContext);

@@ -325,6 +332,24 @@ public class WifiTetherSettingsTest {
        assertThat(keys).contains(WifiTetherSettings.KEY_WIFI_TETHER_MAXIMIZE_COMPATIBILITY);
    }

    @Test
    public void getNonIndexableKeys_instantHotspotNotAvailableOnly_keysContainInstantHotspotOnly() {
        when(mWifiRestriction.isTetherAvailable(mContext)).thenReturn(true);
        when(mWifiRestriction.isHotspotAvailable(mContext)).thenReturn(true);
        WifiTetherSettings.SearchIndexProvider searchIndexProvider =
                new WifiTetherSettings.SearchIndexProvider(XML_RES, mWifiRestriction,
                        false /* isInstantHotspotEnabled */);

        final List<String> keys = searchIndexProvider.getNonIndexableKeys(mContext);

        assertThat(keys).doesNotContain(WifiTetherSettings.KEY_WIFI_TETHER_NETWORK_NAME);
        assertThat(keys).doesNotContain(WifiTetherSettings.KEY_WIFI_TETHER_SECURITY);
        assertThat(keys).doesNotContain(WifiTetherSettings.KEY_WIFI_TETHER_NETWORK_PASSWORD);
        assertThat(keys).doesNotContain(WifiTetherSettings.KEY_WIFI_TETHER_AUTO_OFF);
        assertThat(keys).doesNotContain(WifiTetherSettings.KEY_WIFI_TETHER_MAXIMIZE_COMPATIBILITY);
        assertThat(keys).contains(WifiTetherSettings.KEY_INSTANT_HOTSPOT);
    }

    @Test
    public void isPageSearchEnabled_allReady_returnTrue() {
        setCanShowWifiHotspotCached(true);