From 823dde54c72ec8b7ea59abe63d71a1b36d1e678e Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Thu, 26 Oct 2017 15:56:41 -0700 Subject: [PATCH] Misc clean up in search - Remove updateFromClassNameResource() because it's just a no-op method. - Simplify SearchIndexResources - Update some pref pages to have unique keys. Change-Id: I51e542d9947aafd046861ce7be0b4c7213fcd01d Fixes: 64951285 Test: UniquePreferenceKeyTest Test: robotest Bug: 67852637 --- res/xml/accessibility_settings.xml | 1 + res/xml/ambient_display_settings.xml | 11 +++-- res/xml/app_and_notification.xml | 1 + res/xml/app_default_settings.xml | 1 + res/xml/connected_devices.xml | 1 + res/xml/data_usage.xml | 5 ++- res/xml/data_usage_cellular.xml | 1 + res/xml/data_usage_wifi.xml | 1 + res/xml/date_time_prefs.xml | 1 + res/xml/device_info_settings.xml | 1 + res/xml/device_info_status.xml | 1 + res/xml/display_settings.xml | 1 + res/xml/double_tap_power_settings.xml | 8 ++-- res/xml/double_tap_screen_settings.xml | 12 +++--- res/xml/double_twist_gesture_settings.xml | 12 +++--- res/xml/dream_fragment_overview.xml | 5 ++- res/xml/gestures.xml | 1 + res/xml/language_and_input.xml | 6 ++- .../language_and_input_new_advance_button.xml | 5 ++- res/xml/manage_assist.xml | 1 + res/xml/network_and_internet.xml | 15 +++---- res/xml/physical_keyboard_settings.xml | 4 +- res/xml/power_usage_advanced.xml | 1 + res/xml/power_usage_summary.xml | 1 + res/xml/print_settings.xml | 30 +++++++------- res/xml/security_lockscreen_settings.xml | 1 + res/xml/security_settings_chooser.xml | 1 + res/xml/security_settings_encrypted.xml | 1 + res/xml/security_settings_lockscreen.xml | 1 + .../security_settings_lockscreen_profile.xml | 1 + res/xml/security_settings_misc.xml | 9 +++-- res/xml/security_settings_password.xml | 1 + .../security_settings_password_profile.xml | 1 + res/xml/security_settings_password_sub.xml | 1 + res/xml/security_settings_pattern.xml | 1 + res/xml/security_settings_pattern_profile.xml | 1 + res/xml/security_settings_pattern_sub.xml | 1 + res/xml/security_settings_pin_profile.xml | 1 + res/xml/security_settings_pin_sub.xml | 1 + res/xml/security_settings_slide_sub.xml | 1 + res/xml/security_settings_unencrypted.xml | 1 + res/xml/sound_settings.xml | 2 + res/xml/special_access.xml | 1 + res/xml/storage_dashboard_fragment.xml | 1 + res/xml/swipe_to_notification_settings.xml | 1 + res/xml/system_dashboard_fragment.xml | 1 + res/xml/tts_settings.xml | 1 + res/xml/user_and_accounts_settings.xml | 1 + res/xml/virtual_keyboard_settings.xml | 4 +- res/xml/wifi_configure_settings.xml | 1 + .../android/settings/SecuritySettings.java | 9 ----- .../accounts/AccountPreferenceController.java | 3 -- .../UserAndAccountDashboardFragment.java | 3 -- .../search/DatabaseIndexingManager.java | 40 ++----------------- .../search/SearchIndexableResources.java | 22 +--------- .../settings/search/indexing/IndexData.java | 9 ++--- .../settings/search/XmlParserUtilTest.java | 1 + 57 files changed, 124 insertions(+), 127 deletions(-) diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml index 02b9949065d..36cb62ea38a 100644 --- a/res/xml/accessibility_settings.xml +++ b/res/xml/accessibility_settings.xml @@ -15,6 +15,7 @@ --> diff --git a/res/xml/ambient_display_settings.xml b/res/xml/ambient_display_settings.xml index 47fed8a8c5f..a8ded0d9e77 100644 --- a/res/xml/ambient_display_settings.xml +++ b/res/xml/ambient_display_settings.xml @@ -16,11 +16,13 @@ --> + xmlns:android="http://schemas.android.com/apk/res/android" + android:key="ambient_display_preference_screen" + android:title="@string/ambient_display_screen_title"> + android:key="ambient_display_category_when_to_show" + android:title="@string/ambient_display_category_triggers"> - + - diff --git a/res/xml/device_info_settings.xml b/res/xml/device_info_settings.xml index 1771799edb1..cb02540ef25 100644 --- a/res/xml/device_info_settings.xml +++ b/res/xml/device_info_settings.xml @@ -15,6 +15,7 @@ --> diff --git a/res/xml/device_info_status.xml b/res/xml/device_info_status.xml index 07bbc4e9939..a784ed99d39 100644 --- a/res/xml/device_info_status.xml +++ b/res/xml/device_info_status.xml @@ -16,6 +16,7 @@ diff --git a/res/xml/double_tap_power_settings.xml b/res/xml/double_tap_power_settings.xml index 4d89de6da9a..26d0415beba 100644 --- a/res/xml/double_tap_power_settings.xml +++ b/res/xml/double_tap_power_settings.xml @@ -15,9 +15,11 @@ limitations under the License. --> - + - + + app:preview="@drawable/gesture_ambient_tap" /> + app:keywords="@string/keywords_gesture" /> \ No newline at end of file diff --git a/res/xml/double_twist_gesture_settings.xml b/res/xml/double_twist_gesture_settings.xml index 94d97825eb1..a2af1e481ad 100644 --- a/res/xml/double_twist_gesture_settings.xml +++ b/res/xml/double_twist_gesture_settings.xml @@ -15,19 +15,21 @@ limitations under the License. --> - + + app:preview="@drawable/gesture_twist" /> + app:keywords="@string/keywords_gesture" /> \ No newline at end of file diff --git a/res/xml/dream_fragment_overview.xml b/res/xml/dream_fragment_overview.xml index d27a6e3747b..ba689c7c7aa 100644 --- a/res/xml/dream_fragment_overview.xml +++ b/res/xml/dream_fragment_overview.xml @@ -16,7 +16,7 @@ - + - diff --git a/res/xml/power_usage_advanced.xml b/res/xml/power_usage_advanced.xml index 3deec0954dd..67c785746b6 100644 --- a/res/xml/power_usage_advanced.xml +++ b/res/xml/power_usage_advanced.xml @@ -17,6 +17,7 @@ diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml index efdae9214f7..57195f97118 100644 --- a/res/xml/power_usage_summary.xml +++ b/res/xml/power_usage_summary.xml @@ -17,6 +17,7 @@ diff --git a/res/xml/print_settings.xml b/res/xml/print_settings.xml index 3a00f712a72..fe8cac1304d 100644 --- a/res/xml/print_settings.xml +++ b/res/xml/print_settings.xml @@ -14,21 +14,21 @@ limitations under the License. --> - + + + + - - - - - - + android:order="1" /> diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml index d10440e6b4d..fd54ca78db1 100644 --- a/res/xml/security_lockscreen_settings.xml +++ b/res/xml/security_lockscreen_settings.xml @@ -16,6 +16,7 @@ - + - + diff --git a/res/xml/special_access.xml b/res/xml/special_access.xml index 32dcf8e7e42..1198fccb17b 100644 --- a/res/xml/special_access.xml +++ b/res/xml/special_access.xml @@ -17,6 +17,7 @@ diff --git a/res/xml/user_and_accounts_settings.xml b/res/xml/user_and_accounts_settings.xml index a62b839e563..71c8367265a 100644 --- a/res/xml/user_and_accounts_settings.xml +++ b/res/xml/user_and_accounts_settings.xml @@ -17,6 +17,7 @@ diff --git a/res/xml/virtual_keyboard_settings.xml b/res/xml/virtual_keyboard_settings.xml index d5f0496a444..93445f4c109 100644 --- a/res/xml/virtual_keyboard_settings.xml +++ b/res/xml/virtual_keyboard_settings.xml @@ -13,7 +13,9 @@ See the License for the specific language governing permissions and limitations under the License. --> - tilePrefs = mDashboardFeatureProvider.getPreferencesForCategory( diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java index 246baff273e..cc8c9842d80 100644 --- a/src/com/android/settings/accounts/AccountPreferenceController.java +++ b/src/com/android/settings/accounts/AccountPreferenceController.java @@ -54,7 +54,6 @@ import com.android.settings.Utils; import com.android.settings.core.PreferenceControllerMixin; import com.android.settings.core.instrumentation.MetricsFeatureProvider; import com.android.settings.overlay.FeatureFactory; -import com.android.settings.search.SearchFeatureProviderImpl; import com.android.settings.search.SearchIndexableRaw; import com.android.settingslib.RestrictedPreference; import com.android.settingslib.accounts.AuthenticatorHelper; @@ -346,8 +345,6 @@ public class AccountPreferenceController extends AbstractPreferenceController DISALLOW_MODIFY_ACCOUNTS, userInfo.id); } mProfiles.put(userInfo.id, profileData); - new SearchFeatureProviderImpl().getIndexingManager(mContext).updateFromClassNameResource( - UserAndAccountDashboardFragment.class.getName(), true /* includeInSearchResults */); } private DimmableIconPreference newAddAccountPreference(Context context) { diff --git a/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java b/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java index f375cf8f7c8..e116fd1be85 100644 --- a/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java +++ b/src/com/android/settings/accounts/UserAndAccountDashboardFragment.java @@ -20,7 +20,6 @@ import static android.provider.Settings.EXTRA_AUTHORITIES; import android.app.Activity; import android.content.Context; import android.content.pm.UserInfo; -import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; import android.provider.SearchIndexableResource; @@ -31,7 +30,6 @@ import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.SummaryLoader; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settingslib.core.AbstractPreferenceController; -import com.android.settingslib.drawer.Tile; import java.util.ArrayList; import java.util.Arrays; @@ -40,7 +38,6 @@ import java.util.List; public class UserAndAccountDashboardFragment extends DashboardFragment { private static final String TAG = "UserAndAccountDashboard"; - private static final String METADATA_IA_ACCOUNT = "com.android.settings.ia.account"; @Override public int getMetricsCategory() { diff --git a/src/com/android/settings/search/DatabaseIndexingManager.java b/src/com/android/settings/search/DatabaseIndexingManager.java index 5d6fe3b5bb2..fa1981f45b1 100644 --- a/src/com/android/settings/search/DatabaseIndexingManager.java +++ b/src/com/android/settings/search/DatabaseIndexingManager.java @@ -18,20 +18,18 @@ package com.android.settings.search; import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_ID; -import static com.android.settings.search.DatabaseResultLoader - .COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE; +import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_INTENT_ACTION_TARGET_PACKAGE; import static com.android.settings.search.DatabaseResultLoader.COLUMN_INDEX_KEY; import static com.android.settings.search.DatabaseResultLoader.SELECT_COLUMNS; -import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DOCID; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.CLASS_NAME; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_ENTRIES; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_KEYWORDS; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_KEY_REF; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_SUMMARY_ON; -import static com.android.settings.search.IndexDatabaseHelper.IndexColumns - .DATA_SUMMARY_ON_NORMALIZED; +import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_SUMMARY_ON_NORMALIZED; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_TITLE; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DATA_TITLE_NORMALIZED; +import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.DOCID; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.ENABLED; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.ICON; import static com.android.settings.search.IndexDatabaseHelper.IndexColumns.INTENT_ACTION; @@ -53,14 +51,12 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteException; import android.os.AsyncTask; import android.os.Build; -import android.provider.SearchIndexableResource; import android.provider.SearchIndexablesContract; import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.Log; import com.android.settings.overlay.FeatureFactory; - import com.android.settings.search.indexing.IndexData; import com.android.settings.search.indexing.IndexDataConverter; import com.android.settings.search.indexing.PreIndexData; @@ -365,36 +361,6 @@ public class DatabaseIndexingManager { disabledResults.close(); } - /** - * TODO (b/64951285): Deprecate this method - * - * Update the Index for a specific class name resources - * - * @param className the class name (typically a fragment name). - * @param includeInSearchResults true means that you want the bit "enabled" set so that the - * data will be seen included into the search results - */ - public void updateFromClassNameResource(String className, boolean includeInSearchResults) { - if (className == null) { - throw new IllegalArgumentException("class name cannot be null!"); - } - final SearchIndexableResource res = SearchIndexableResources.getResourceByName(className); - if (res == null) { - Log.e(LOG_TAG, "Cannot find SearchIndexableResources for class name: " + className); - return; - } - res.context = mContext; - res.enabled = includeInSearchResults; - AsyncTask.execute(new Runnable() { - @Override - public void run() { -// addIndexableData(res); -// updateDatabase(false, Locale.getDefault().toString()); -// res.enabled = false; - } - }); - } - private SQLiteDatabase getWritableDatabase() { try { return IndexDatabaseHelper.getInstance(mContext).getWritableDatabase(); diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java index 89924bbec41..02d99208adb 100644 --- a/src/com/android/settings/search/SearchIndexableResources.java +++ b/src/com/android/settings/search/SearchIndexableResources.java @@ -19,7 +19,6 @@ package com.android.settings.search; import android.provider.SearchIndexableResource; import android.support.annotation.VisibleForTesting; import android.support.annotation.XmlRes; -import android.text.TextUtils; import com.android.settings.DateTimeSettings; import com.android.settings.DeviceInfoSettings; @@ -92,13 +91,6 @@ import java.util.Collection; import java.util.HashMap; public final class SearchIndexableResources { - - /** - * Identifies subsettings which have an {@link SearchIndexableResource#intentAction} but - * whose intents should still be treated as subsettings inside of Settings. - */ - public static final String SUBSETTING_TARGET_PACKAGE = "subsetting_target_package"; - @XmlRes public static final int NO_RES_ID = 0; @@ -107,20 +99,10 @@ public final class SearchIndexableResources { @VisibleForTesting static void addIndex(Class indexClass) { - addIndex(indexClass, null /* targetAction */); - } - - @VisibleForTesting - static void addIndex(Class indexClass, String targetAction) { String className = indexClass.getName(); SearchIndexableResource resource = new SearchIndexableResource( 0 /* rank */, NO_RES_ID, className, NO_RES_ID); - if (!TextUtils.isEmpty(targetAction)) { - resource.intentAction = targetAction; - resource.intentTargetPackage = SUBSETTING_TARGET_PACKAGE; - } - sResMap.put(className, resource); } @@ -133,11 +115,11 @@ public final class SearchIndexableResources { addIndex(DataUsageSummary.class); addIndex(DataUsageMeteredSettings.class); addIndex(ScreenZoomSettings.class); - addIndex(DisplaySettings.class, "android.settings.DISPLAY_SETTINGS"); + addIndex(DisplaySettings.class); addIndex(AmbientDisplaySettings.class); addIndex(WallpaperTypeSettings.class); addIndex(AppAndNotificationDashboardFragment.class); - addIndex(SoundSettings.class, "android.settings.SOUND_SETTINGS"); + addIndex(SoundSettings.class); addIndex(ZenModeSettings.class); addIndex(StorageSettings.class); addIndex(PowerUsageAdvanced.class); diff --git a/src/com/android/settings/search/indexing/IndexData.java b/src/com/android/settings/search/indexing/IndexData.java index 9dad3fe5caf..1e839761a14 100644 --- a/src/com/android/settings/search/indexing/IndexData.java +++ b/src/com/android/settings/search/indexing/IndexData.java @@ -26,7 +26,6 @@ import com.android.settings.SettingsActivity; import com.android.settings.search.DatabaseIndexingUtils; import com.android.settings.search.ResultPayload; import com.android.settings.search.ResultPayloadUtils; -import com.android.settings.search.SearchIndexableResources; import java.text.Normalizer; import java.util.Objects; @@ -269,12 +268,10 @@ public class IndexData { boolean isEmptyIntentAction = TextUtils.isEmpty(mIntentAction); // No intent action is set, or the intent action is for a subsetting. - if (isEmptyIntentAction - || TextUtils.equals(mIntentTargetPackage, - SearchIndexableResources.SUBSETTING_TARGET_PACKAGE)) { + if (isEmptyIntentAction) { // Action is null, we will launch it as a sub-setting - intent = DatabaseIndexingUtils.buildSearchResultPageIntent(context, mClassName, mKey, - mScreenTitle); + intent = DatabaseIndexingUtils.buildSearchResultPageIntent(context, mClassName, + mKey, mScreenTitle); } else { intent = new Intent(mIntentAction); final String targetClass = mIntentTargetClass; diff --git a/tests/robotests/src/com/android/settings/search/XmlParserUtilTest.java b/tests/robotests/src/com/android/settings/search/XmlParserUtilTest.java index b2ce3a7703f..6050b32396f 100644 --- a/tests/robotests/src/com/android/settings/search/XmlParserUtilTest.java +++ b/tests/robotests/src/com/android/settings/search/XmlParserUtilTest.java @@ -120,6 +120,7 @@ public class XmlParserUtilTest { // Null checks @Test + @Config(qualifiers = "mcc999") public void testDataKeyInvalid_ReturnsNull() { XmlResourceParser parser = getParentPrimedParser(R.xml.display_settings); final AttributeSet attrs = Xml.asAttributeSet(parser);