Add test and fix null keys in search providers.
- Add keys to some screens. - Remove dynamic saved network/turst agent from search provider. - Remove dynamic print services from printsettings. Bug: 69384409 Test: atest Change-Id: I62dce27d52585badb2a8953a05084e35dbae2f7d
This commit is contained in:
@@ -14,8 +14,10 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/network_restrictions">
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:key="data_usage_metered_prefs"
|
||||
android:title="@string/network_restrictions">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="mobile"
|
||||
@@ -37,6 +39,7 @@
|
||||
|
||||
<com.android.settingslib.widget.FooterPreference
|
||||
android:title="@string/data_usage_metered_body"
|
||||
android:key="footer_preference"
|
||||
android:selectable="false" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -14,20 +14,22 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/location_mode_screen_title">
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:key="location_mode_settings"
|
||||
android:title="@string/location_mode_screen_title">
|
||||
|
||||
<com.android.settings.widget.RadioButtonPreference
|
||||
android:key="high_accuracy"
|
||||
android:title="@string/location_mode_high_accuracy_title"
|
||||
android:summary="@string/location_mode_high_accuracy_description" />
|
||||
<com.android.settings.widget.RadioButtonPreference
|
||||
android:key="battery_saving"
|
||||
android:title="@string/location_mode_battery_saving_title"
|
||||
android:summary="@string/location_mode_battery_saving_description" />
|
||||
<com.android.settings.widget.RadioButtonPreference
|
||||
android:key="sensors_only"
|
||||
android:title="@string/location_mode_sensors_only_title"
|
||||
android:summary="@string/location_mode_sensors_only_description" />
|
||||
<com.android.settings.widget.RadioButtonPreference
|
||||
android:key="high_accuracy"
|
||||
android:title="@string/location_mode_high_accuracy_title"
|
||||
android:summary="@string/location_mode_high_accuracy_description" />
|
||||
<com.android.settings.widget.RadioButtonPreference
|
||||
android:key="battery_saving"
|
||||
android:title="@string/location_mode_battery_saving_title"
|
||||
android:summary="@string/location_mode_battery_saving_description" />
|
||||
<com.android.settings.widget.RadioButtonPreference
|
||||
android:key="sensors_only"
|
||||
android:title="@string/location_mode_sensors_only_title"
|
||||
android:summary="@string/location_mode_sensors_only_description" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -14,11 +14,13 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/screen_pinning_title">
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:key="screen_pinning_settings_screen"
|
||||
android:title="@string/screen_pinning_title">
|
||||
|
||||
<SwitchPreference
|
||||
android:key="use_screen_lock"
|
||||
android:title="@string/screen_pinning_unlock_none" />
|
||||
<SwitchPreference
|
||||
android:key="use_screen_lock"
|
||||
android:title="@string/screen_pinning_unlock_none" />
|
||||
|
||||
</PreferenceScreen>
|
||||
|
@@ -75,7 +75,7 @@
|
||||
android:key="screen_pinning_settings"
|
||||
android:title="@string/screen_pinning_title"
|
||||
android:summary="@string/switch_off_text"
|
||||
android:fragment="com.android.settings.ScreenPinningSettings"/>
|
||||
android:fragment="com.android.settings.security.ScreenPinningSettings"/>
|
||||
|
||||
<Preference android:key="security_misc_usage_access"
|
||||
android:title="@string/usage_access_title"
|
||||
|
@@ -14,27 +14,26 @@
|
||||
|
||||
package com.android.settings.datausage;
|
||||
|
||||
import static android.net.wifi.WifiInfo.removeDoubleQuotes;
|
||||
|
||||
import android.app.backup.BackupManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.net.NetworkPolicyManager;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.support.v7.preference.DropDownPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceCategory;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settingslib.NetworkPolicyEditor;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -134,49 +133,11 @@ public class DataUsageMeteredSettings extends SettingsPreferenceFragment impleme
|
||||
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
|
||||
final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
|
||||
final Resources res = context.getResources();
|
||||
|
||||
// Add fragment title
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.data_usage_menu_metered);
|
||||
data.screenTitle = res.getString(R.string.data_usage_menu_metered);
|
||||
result.add(data);
|
||||
|
||||
// Body
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.data_usage_metered_body);
|
||||
data.screenTitle = res.getString(R.string.data_usage_menu_metered);
|
||||
result.add(data);
|
||||
|
||||
// Wi-Fi networks category
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.data_usage_metered_wifi);
|
||||
data.screenTitle = res.getString(R.string.data_usage_menu_metered);
|
||||
result.add(data);
|
||||
|
||||
final WifiManager wifiManager =
|
||||
(WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||
if (DataUsageUtils.hasWifiRadio(context) && wifiManager.isWifiEnabled()) {
|
||||
for (WifiConfiguration config : wifiManager.getConfiguredNetworks()) {
|
||||
if (config.SSID != null) {
|
||||
final String networkId = config.SSID;
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = removeDoubleQuotes(networkId);
|
||||
data.screenTitle = res.getString(R.string.data_usage_menu_metered);
|
||||
result.add(data);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.data_usage_metered_wifi_disabled);
|
||||
data.screenTitle = res.getString(R.string.data_usage_menu_metered);
|
||||
result.add(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.data_usage_metered_prefs;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -16,7 +16,8 @@
|
||||
|
||||
package com.android.settings.deviceinfo;
|
||||
|
||||
import android.app.Activity;
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.Fragment;
|
||||
@@ -63,8 +64,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
|
||||
/**
|
||||
* Panel showing both internal storage (both built-in storage and private
|
||||
* volumes) and removable storage (public volumes).
|
||||
@@ -545,13 +544,7 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
||||
|
||||
|
||||
public static final SummaryLoader.SummaryProviderFactory SUMMARY_PROVIDER_FACTORY
|
||||
= new SummaryLoader.SummaryProviderFactory() {
|
||||
@Override
|
||||
public SummaryLoader.SummaryProvider createSummaryProvider(Activity activity,
|
||||
SummaryLoader summaryLoader) {
|
||||
return new SummaryProvider(activity, summaryLoader);
|
||||
}
|
||||
};
|
||||
= (activity, summaryLoader) -> new SummaryProvider(activity, summaryLoader);
|
||||
|
||||
/** Enable indexing of searchable data */
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
@@ -559,15 +552,17 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
||||
@Override
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
|
||||
final List<SearchIndexableRaw> result = new ArrayList<>();
|
||||
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = context.getString(R.string.storage_settings);
|
||||
data.key = "storage_settings";
|
||||
data.screenTitle = context.getString(R.string.storage_settings);
|
||||
result.add(data);
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = context.getString(R.string.internal_storage);
|
||||
data.key = "storage_settings_internal_storage";
|
||||
data.screenTitle = context.getString(R.string.storage_settings);
|
||||
result.add(data);
|
||||
|
||||
@@ -577,6 +572,7 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
||||
for (VolumeInfo vol : vols) {
|
||||
if (isInteresting(vol)) {
|
||||
data.title = storage.getBestVolumeDescription(vol);
|
||||
data.key = "storage_settings_volume_" +vol.id;
|
||||
data.screenTitle = context.getString(R.string.storage_settings);
|
||||
result.add(data);
|
||||
}
|
||||
@@ -584,36 +580,43 @@ public class StorageSettings extends SettingsPreferenceFragment implements Index
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = context.getString(R.string.memory_size);
|
||||
data.key = "storage_settings_memory_size";
|
||||
data.screenTitle = context.getString(R.string.storage_settings);
|
||||
result.add(data);
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = context.getString(R.string.memory_available);
|
||||
data.key = "storage_settings_memory_available";
|
||||
data.screenTitle = context.getString(R.string.storage_settings);
|
||||
result.add(data);
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = context.getString(R.string.memory_apps_usage);
|
||||
data.key = "storage_settings_apps_space";
|
||||
data.screenTitle = context.getString(R.string.storage_settings);
|
||||
result.add(data);
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = context.getString(R.string.memory_dcim_usage);
|
||||
data.key = "storage_settings_dcim_space";
|
||||
data.screenTitle = context.getString(R.string.storage_settings);
|
||||
result.add(data);
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = context.getString(R.string.memory_music_usage);
|
||||
data.key = "storage_settings_music_space";
|
||||
data.screenTitle = context.getString(R.string.storage_settings);
|
||||
result.add(data);
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = context.getString(R.string.memory_media_misc_usage);
|
||||
data.key = "storage_settings_misc_space";
|
||||
data.screenTitle = context.getString(R.string.storage_settings);
|
||||
result.add(data);
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = context.getString(R.string.storage_menu_free);
|
||||
data.key = "storage_settings_free_space";
|
||||
data.screenTitle = context.getString(R.string.storage_menu_free);
|
||||
// We need to define all three in order for this to trigger properly.
|
||||
data.intentAction = StorageManager.ACTION_MANAGE_STORAGE;
|
||||
|
@@ -22,6 +22,7 @@ import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.PreviewSeekBarPreferenceFragment;
|
||||
import com.android.settings.R;
|
||||
@@ -48,7 +49,7 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment impleme
|
||||
mActivityLayoutResId = R.layout.screen_zoom_activity;
|
||||
|
||||
// This should be replaced once the final preview sample screen is in place.
|
||||
mPreviewSampleResIds = new int[]{R.layout.screen_zoom_preview_1,
|
||||
mPreviewSampleResIds = new int[] {R.layout.screen_zoom_preview_1,
|
||||
R.layout.screen_zoom_preview_2,
|
||||
R.layout.screen_zoom_preview_settings};
|
||||
|
||||
@@ -60,8 +61,8 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment impleme
|
||||
// connect to the window manager service. Just use the current
|
||||
// density and don't let the user change anything.
|
||||
final int densityDpi = getResources().getDisplayMetrics().densityDpi;
|
||||
mValues = new int[] { densityDpi };
|
||||
mEntries = new String[] { getString(DisplayDensityUtils.SUMMARY_DEFAULT) };
|
||||
mValues = new int[] {densityDpi};
|
||||
mEntries = new String[] {getString(DisplayDensityUtils.SUMMARY_DEFAULT)};
|
||||
mInitialIndex = 0;
|
||||
mDefaultDensity = densityDpi;
|
||||
} else {
|
||||
@@ -109,10 +110,12 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment impleme
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final Resources res = context.getResources();
|
||||
final SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.screen_zoom_title);
|
||||
data.key = "screen_zoom_settings";
|
||||
data.screenTitle = res.getString(R.string.screen_zoom_title);
|
||||
data.keywords = res.getString(R.string.screen_zoom_keywords);
|
||||
|
||||
|
@@ -55,7 +55,6 @@ import com.android.settings.R;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.utils.ProfileSettingsPreferenceFragment;
|
||||
|
||||
import java.text.DateFormat;
|
||||
@@ -616,49 +615,11 @@ public class PrintSettingsFragment extends ProfileSettingsPreferenceFragment
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
|
||||
List<SearchIndexableRaw> indexables = new ArrayList<SearchIndexableRaw>();
|
||||
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
PrintManager printManager = (PrintManager) context.getSystemService(
|
||||
Context.PRINT_SERVICE);
|
||||
|
||||
String screenTitle = context.getResources().getString(R.string.print_settings);
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = screenTitle;
|
||||
data.screenTitle = screenTitle;
|
||||
indexables.add(data);
|
||||
|
||||
// Indexing all services, regardless if enabled. Please note that the index will not be
|
||||
// updated until this function is called again
|
||||
List<PrintServiceInfo> services =
|
||||
printManager.getPrintServices(PrintManager.ALL_SERVICES);
|
||||
|
||||
if (services != null) {
|
||||
final int serviceCount = services.size();
|
||||
for (int i = 0; i < serviceCount; i++) {
|
||||
PrintServiceInfo service = services.get(i);
|
||||
|
||||
ComponentName componentName = new ComponentName(
|
||||
service.getResolveInfo().serviceInfo.packageName,
|
||||
service.getResolveInfo().serviceInfo.name);
|
||||
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.key = componentName.flattenToString();
|
||||
data.title = service.getResolveInfo().loadLabel(packageManager).toString();
|
||||
data.screenTitle = screenTitle;
|
||||
indexables.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
return indexables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
List<SearchIndexableResource> indexables = new ArrayList<SearchIndexableResource>();
|
||||
List<SearchIndexableResource> indexables = new ArrayList<>();
|
||||
SearchIndexableResource indexable = new SearchIndexableResource(context);
|
||||
indexable.xmlResId = R.xml.print_settings;
|
||||
indexables.add(indexable);
|
||||
|
@@ -22,7 +22,6 @@ import com.android.settings.DateTimeSettings;
|
||||
import com.android.settings.DeviceInfoSettings;
|
||||
import com.android.settings.DisplaySettings;
|
||||
import com.android.settings.LegalSettings;
|
||||
import com.android.settings.ScreenPinningSettings;
|
||||
import com.android.settings.accessibility.AccessibilitySettings;
|
||||
import com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment;
|
||||
import com.android.settings.accessibility.MagnificationPreferenceFragment;
|
||||
@@ -73,6 +72,7 @@ import com.android.settings.notification.ZenModeSettings;
|
||||
import com.android.settings.print.PrintSettingsFragment;
|
||||
import com.android.settings.security.EncryptionAndCredential;
|
||||
import com.android.settings.security.LockscreenDashboardFragment;
|
||||
import com.android.settings.security.ScreenPinningSettings;
|
||||
import com.android.settings.security.SecuritySettings;
|
||||
import com.android.settings.security.screenlock.ScreenLockSettings;
|
||||
import com.android.settings.sim.SimSettings;
|
||||
|
@@ -13,14 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings;
|
||||
package com.android.settings.security;
|
||||
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import android.support.v14.preference.SwitchPreference;
|
||||
import android.support.v7.preference.Preference;
|
||||
@@ -33,13 +33,15 @@ import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settings.password.ChooseLockGeneric;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -210,33 +212,13 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
|
||||
*/
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
|
||||
final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
|
||||
|
||||
final Resources res = context.getResources();
|
||||
|
||||
// Add fragment title
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.screen_pinning_title);
|
||||
data.screenTitle = res.getString(R.string.screen_pinning_title);
|
||||
result.add(data);
|
||||
|
||||
if (isLockToAppEnabled(context)) {
|
||||
// Screen lock option
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.screen_pinning_unlock_none);
|
||||
data.screenTitle = res.getString(R.string.screen_pinning_title);
|
||||
result.add(data);
|
||||
} else {
|
||||
// Screen pinning description.
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.screen_pinning_description);
|
||||
data.screenTitle = res.getString(R.string.screen_pinning_title);
|
||||
result.add(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.screen_pinning_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
};
|
||||
}
|
@@ -823,6 +823,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = screenTitle;
|
||||
data.key = "security_settings_screen";
|
||||
data.screenTitle = screenTitle;
|
||||
result.add(data);
|
||||
|
||||
@@ -834,11 +835,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
// This catches the title which can be overloaded in an overlay
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.security_settings_fingerprint_preference_title);
|
||||
data.key = "security_fingerprint";
|
||||
data.screenTitle = screenTitle;
|
||||
result.add(data);
|
||||
// Fallback for when the above doesn't contain "fingerprint"
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.fingerprint_manage_category_title);
|
||||
data.key = "security_managed_fingerprint";
|
||||
data.screenTitle = screenTitle;
|
||||
result.add(data);
|
||||
}
|
||||
@@ -853,22 +856,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
||||
profileUserId)) {
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.lock_settings_profile_unification_title);
|
||||
data.screenTitle = screenTitle;
|
||||
result.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
// Advanced
|
||||
if (lockPatternUtils.isSecure(MY_USER_ID)) {
|
||||
final TrustAgentManager trustAgentManager =
|
||||
FeatureFactory.getFactory(context).getSecurityFeatureProvider()
|
||||
.getTrustAgentManager();
|
||||
final List<TrustAgentComponentInfo> agents =
|
||||
trustAgentManager.getActiveTrustAgents(context, lockPatternUtils);
|
||||
for (int i = 0; i < agents.size(); i++) {
|
||||
final TrustAgentComponentInfo agent = agents.get(i);
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = agent.title;
|
||||
data.key = "security_use_one_lock";
|
||||
data.screenTitle = screenTitle;
|
||||
result.add(data);
|
||||
}
|
||||
|
@@ -1136,6 +1136,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
final Resources res = context.getResources();
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = res.getString(R.string.user_settings_title);
|
||||
data.key = "users_settings";
|
||||
data.screenTitle = res.getString(R.string.user_settings_title);
|
||||
result.add(data);
|
||||
|
||||
@@ -1145,6 +1146,7 @@ public class UserSettings extends SettingsPreferenceFragment
|
||||
R.string.user_add_user_or_profile_menu
|
||||
: R.string.user_add_user_menu);
|
||||
data.screenTitle = res.getString(R.string.user_settings_title);
|
||||
data.key = "user_settings_add_users";
|
||||
result.add(data);
|
||||
}
|
||||
return result;
|
||||
|
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.settings.wallpaper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -113,6 +112,7 @@ public class WallpaperTypeSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
SearchIndexableRaw data = new SearchIndexableRaw(context);
|
||||
data.title = label.toString();
|
||||
data.key = "wallpaper_type_settings";
|
||||
data.screenTitle = context.getResources().getString(
|
||||
R.string.wallpaper_settings_fragment_title);
|
||||
data.intentAction = Intent.ACTION_SET_WALLPAPER;
|
||||
|
@@ -68,7 +68,6 @@ import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
import com.android.settingslib.wifi.AccessPoint.AccessPointListener;
|
||||
import com.android.settingslib.wifi.AccessPointPreference;
|
||||
import com.android.settingslib.wifi.WifiSavedConfigUtils;
|
||||
import com.android.settingslib.wifi.WifiTracker;
|
||||
import com.android.settingslib.wifi.WifiTrackerFactory;
|
||||
|
||||
@@ -1117,18 +1116,6 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
data.key = DATA_KEY_REFERENCE;
|
||||
result.add(data);
|
||||
|
||||
// Add saved Wi-Fi access points
|
||||
final List<AccessPoint> accessPoints =
|
||||
WifiSavedConfigUtils.getAllConfigs(context,
|
||||
context.getSystemService(WifiManager.class));
|
||||
for (AccessPoint accessPoint : accessPoints) {
|
||||
data = new SearchIndexableRaw(context);
|
||||
data.title = accessPoint.getSsidStr();
|
||||
data.screenTitle = res.getString(R.string.wifi_settings);
|
||||
data.enabled = enabled;
|
||||
result.add(data);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
@@ -33,6 +33,7 @@ import android.util.Xml;
|
||||
|
||||
import com.android.settings.search.DatabaseIndexingUtils;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.search.SearchIndexableRaw;
|
||||
import com.android.settings.search.SearchIndexableResources;
|
||||
import com.android.settings.search.XmlParserUtils;
|
||||
|
||||
@@ -64,7 +65,7 @@ public class UniquePreferenceTest {
|
||||
|
||||
"dashboard_tile_placeholder" // This is the placeholder pref for injecting dynamic
|
||||
// tiles.
|
||||
);
|
||||
);
|
||||
|
||||
private Context mContext;
|
||||
|
||||
@@ -91,13 +92,13 @@ public class UniquePreferenceTest {
|
||||
final Set<String> nullKeyClasses = new HashSet<>();
|
||||
final Set<String> duplicatedKeys = new HashSet<>();
|
||||
for (Class<?> clazz : SearchIndexableResources.providerValues()) {
|
||||
verifyPreferenceIdInXml(uniqueKeys, duplicatedKeys, nullKeyClasses, clazz);
|
||||
verifyPreferenceKeys(uniqueKeys, duplicatedKeys, nullKeyClasses, clazz);
|
||||
}
|
||||
|
||||
if (!nullKeyClasses.isEmpty()) {
|
||||
final StringBuilder nullKeyErrors = new StringBuilder()
|
||||
.append("Each preference must have a key, ")
|
||||
.append("the following classes have pref without keys:\n");
|
||||
.append("Each preference/SearchIndexableData must have a key, ")
|
||||
.append("the following classes have null keys:\n");
|
||||
for (String c : nullKeyClasses) {
|
||||
nullKeyErrors.append(c).append("\n");
|
||||
}
|
||||
@@ -114,7 +115,7 @@ public class UniquePreferenceTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyPreferenceIdInXml(Set<String> uniqueKeys, Set<String> duplicatedKeys,
|
||||
private void verifyPreferenceKeys(Set<String> uniqueKeys, Set<String> duplicatedKeys,
|
||||
Set<String> nullKeyClasses, Class<?> clazz)
|
||||
throws IOException, XmlPullParserException, Resources.NotFoundException {
|
||||
if (clazz == null) {
|
||||
@@ -123,8 +124,16 @@ public class UniquePreferenceTest {
|
||||
final String className = clazz.getName();
|
||||
final Indexable.SearchIndexProvider provider =
|
||||
DatabaseIndexingUtils.getSearchIndexProvider(clazz);
|
||||
final List<SearchIndexableRaw> rawsToIndex = provider.getRawDataToIndex(mContext, true);
|
||||
final List<SearchIndexableResource> resourcesToIndex =
|
||||
provider.getXmlResourcesToIndex(mContext, true);
|
||||
verifyResources(className, resourcesToIndex, uniqueKeys, duplicatedKeys, nullKeyClasses);
|
||||
verifyRaws(className, rawsToIndex, uniqueKeys, duplicatedKeys, nullKeyClasses);
|
||||
}
|
||||
|
||||
private void verifyResources(String className, List<SearchIndexableResource> resourcesToIndex,
|
||||
Set<String> uniqueKeys, Set<String> duplicatedKeys, Set<String> nullKeyClasses)
|
||||
throws IOException, XmlPullParserException, Resources.NotFoundException {
|
||||
if (resourcesToIndex == null) {
|
||||
Log.d(TAG, className + "is not providing SearchIndexableResource, skipping");
|
||||
return;
|
||||
@@ -172,4 +181,25 @@ public class UniquePreferenceTest {
|
||||
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth));
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyRaws(String className, List<SearchIndexableRaw> rawsToIndex,
|
||||
Set<String> uniqueKeys, Set<String> duplicatedKeys, Set<String> nullKeyClasses) {
|
||||
if (rawsToIndex == null) {
|
||||
Log.d(TAG, className + "is not providing SearchIndexableRaw, skipping");
|
||||
return;
|
||||
}
|
||||
for (SearchIndexableRaw raw : rawsToIndex) {
|
||||
if (TextUtils.isEmpty(raw.key)) {
|
||||
Log.e(TAG, "Every SearchIndexableRaw must have an key; found null key"
|
||||
+ " in " + className);
|
||||
nullKeyClasses.add(className);
|
||||
continue;
|
||||
}
|
||||
if (uniqueKeys.contains(raw.key) && !WHITELISTED_DUPLICATE_KEYS.contains(raw.key)) {
|
||||
Log.e(TAG, "Every SearchIndexableRaw key must unique; found " + raw.key
|
||||
+ " in " + className);
|
||||
duplicatedKeys.add(raw.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user