Index wi-fi preferences.

- Add xml file to index "Saved network" and "Wifi data usage"
preferences.
- Disable the "Saved network" if the access points is empty.
- Disable the "Wifi data usage" if there is no wifi radio.

Fixes: 146823365
Test: manual
Change-Id: I049d0463fd58f186dae1d5f54dcc914f52031da7
This commit is contained in:
Stanley Wang
2019-12-24 19:43:06 +08:00
parent 066d3f693d
commit 0577751718
3 changed files with 50 additions and 29 deletions

View File

@@ -7319,6 +7319,8 @@
<string name="keywords_wifi">wifi, wi-fi, network connection, internet, wireless, data, wi fi</string> <string name="keywords_wifi">wifi, wi-fi, network connection, internet, wireless, data, wi fi</string>
<!-- Search keyword for "Open Network Notification" settings. [CHAR_LIMIT=NONE]--> <!-- Search keyword for "Open Network Notification" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string> <string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
<!-- Search keyword for "Wi-fi data usage" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_wifi_data_usage">data usage</string>
<!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]--> <!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
<string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string> <string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
<!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]--> <!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->

View File

@@ -17,19 +17,21 @@
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto" xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/wifi_settings" android:title="@string/wifi_settings">
settings:keywords="@string/keywords_wifi">
<com.android.settings.wifi.LinkablePreference <com.android.settings.wifi.LinkablePreference
android:key="wifi_status_message"/> android:key="wifi_status_message"
settings:searchable="false"/>
<PreferenceCategory <PreferenceCategory
android:key="connected_access_point" android:key="connected_access_point"
android:layout="@layout/preference_category_no_label"/> android:layout="@layout/preference_category_no_label"
settings:searchable="false"/>
<PreferenceCategory <PreferenceCategory
android:key="access_points" android:key="access_points"
android:layout="@layout/preference_category_no_label"/> android:layout="@layout/preference_category_no_label"
settings:searchable="false"/>
<Preference <Preference
android:key="configure_settings" android:key="configure_settings"
@@ -44,5 +46,6 @@
<com.android.settings.datausage.DataUsagePreference <com.android.settings.datausage.DataUsagePreference
android:key="wifi_data_usage" android:key="wifi_data_usage"
android:title="@string/wifi_data_usage"/> android:title="@string/wifi_data_usage"
settings:keywords="@string/keywords_wifi_data_usage"/>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -1210,28 +1210,6 @@ public class WifiSettings extends RestrictedSettingsFragment
((AccessPointPreference) accessPoint.getTag()).onLevelChanged(); ((AccessPointPreference) accessPoint.getTag()).onLevelChanged();
} }
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
boolean enabled) {
final List<SearchIndexableRaw> result = new ArrayList<>();
final Resources res = context.getResources();
// 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;
}
};
private void handleConfigNetworkSubmitEvent(Intent data) { private void handleConfigNetworkSubmitEvent(Intent data) {
final WifiConfiguration wifiConfiguration = data.getParcelableExtra( final WifiConfiguration wifiConfiguration = data.getParcelableExtra(
ConfigureAccessPointFragment.NETWORK_CONFIG_KEY); ConfigureAccessPointFragment.NETWORK_CONFIG_KEY);
@@ -1257,4 +1235,42 @@ public class WifiSettings extends RestrictedSettingsFragment
.setResultListener(this, CONFIG_NETWORK_REQUEST) .setResultListener(this, CONFIG_NETWORK_REQUEST)
.launch(); .launch();
} }
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.wifi_settings) {
@Override
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
boolean enabled) {
final List<SearchIndexableRaw> result = new ArrayList<>();
final Resources res = context.getResources();
// 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;
}
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
final WifiManager wifiManager = context.getSystemService(WifiManager.class);
final List<AccessPoint> accessPoints = WifiSavedConfigUtils.getAllConfigs(
context, wifiManager);
if (accessPoints == null || accessPoints.size() <= 0) {
keys.add(PREF_KEY_SAVED_NETWORKS);
}
if (!DataUsageUtils.hasWifiRadio(context)) {
keys.add(PREF_KEY_DATA_USAGE);
}
return keys;
}
};
} }