Add ability to show/hide Wi-Fi settings, and all related sub-settings.

This adds a new boolean flag, config_show_wifi_settings, which when set
to false will hide the "Wi-Fi" page in network & internet (there is no
key value associated with this preference page). It will also hide
nested pages from search results, such as Wi-Fi preferences.

Bug: 62379554
Test: make RunSettingsRoboTests
ROBOTEST_FILTER=ConfigureWifiSettingsTest
and
make RunSettingsRoboTests
ROBOTEST_FILTER=WifiSettingsTest
and
make RunSettingsRoboTests
ROBOTEST_FILTER=WifiMasterSwitchPreferenceControllerTest
all pass.

Change-Id: Iedc6bc272e0cb2b561c6bf25968e70f355aaaa8e
This commit is contained in:
Ben Lin
2017-12-20 12:37:10 -08:00
parent 8a05bef170
commit 848f67d17a
8 changed files with 111 additions and 10 deletions

View File

@@ -44,6 +44,7 @@ public class ConfigureWifiSettings extends DashboardFragment {
private static final String TAG = "ConfigureWifiSettings";
public static final String KEY_WIFI_CONFIGURE = "wifi_configure_settings_screen";
public static final String KEY_IP_ADDRESS = "current_ip_address";
private WifiWakeupPreferenceController mWifiWakeupPreferenceController;
@@ -134,5 +135,10 @@ public class ConfigureWifiSettings extends DashboardFragment {
return keys;
}
protected boolean isPageSearchEnabled(Context context) {
return context.getResources()
.getBoolean(R.bool.config_show_wifi_settings);
}
};
}

View File

@@ -20,6 +20,7 @@ import android.support.v7.preference.PreferenceScreen;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.instrumentation.MetricsFeatureProvider;
import com.android.settings.R;
import com.android.settings.widget.SummaryUpdater;
import com.android.settings.widget.MasterSwitchPreference;
import com.android.settings.widget.MasterSwitchController;
@@ -56,7 +57,7 @@ public class WifiMasterSwitchPreferenceController extends AbstractPreferenceCont
@Override
public boolean isAvailable() {
return true;
return mContext.getResources().getBoolean(R.bool.config_show_wifi_settings);
}
@Override

View File

@@ -167,7 +167,7 @@ public class WifiSettings extends RestrictedSettingsFragment
private LinkablePreference mStatusMessagePreference;
// For Search
private static final String DATA_KEY_REFERENCE = "main_toggle_wifi";
public static final String DATA_KEY_REFERENCE = "main_toggle_wifi";
/**
* Tracks whether the user initiated a connection via clicking in order to autoscroll to the
@@ -1104,13 +1104,15 @@ public class WifiSettings extends RestrictedSettingsFragment
final List<SearchIndexableRaw> result = new ArrayList<>();
final Resources res = context.getResources();
// Add fragment title
SearchIndexableRaw data = new SearchIndexableRaw(context);
data.title = res.getString(R.string.wifi_settings);
data.screenTitle = res.getString(R.string.wifi_settings);
data.keywords = res.getString(R.string.keywords_wifi);
data.key = DATA_KEY_REFERENCE;
result.add(data);
// Add fragment title if we are showing this fragment
if (res.getBoolean(R.bool.config_show_wifi_settings)) {
SearchIndexableRaw data = new SearchIndexableRaw(context);
data.title = res.getString(R.string.wifi_settings);
data.screenTitle = res.getString(R.string.wifi_settings);
data.keywords = res.getString(R.string.keywords_wifi);
data.key = DATA_KEY_REFERENCE;
result.add(data);
}
return result;
}