Loading src/com/android/settings/wifi/tether/WifiTetherSettings.java +9 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading @@ -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 Loading tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java +29 −4 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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 Loading @@ -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); Loading @@ -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 Loading @@ -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); Loading @@ -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 Loading @@ -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); Loading @@ -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); Loading Loading
src/com/android/settings/wifi/tether/WifiTetherSettings.java +9 −1 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading @@ -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 Loading
tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java +29 −4 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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 Loading @@ -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); Loading @@ -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 Loading @@ -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); Loading @@ -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 Loading @@ -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); Loading @@ -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); Loading