Add search index into WallpaperSuggestionActivity

.Use the Indexable interface for WallpaperSuggestionActivity and implement the getRawDataToIndex
.Remove the search index in the WallpaperTypeSettings
.Add full class name of the WallpaperTypeSettings into grandfather_not_implementing_index_provider

Bug: 63117104
Test: robotest & Manual View
Change-Id: I73f43e4996efbe857d74df297ea0d08eb1b640ac
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9f6cdb5..c83c14d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -795,7 +795,8 @@
 
         <activity android:name="Settings$WallpaperSettingsActivity"
                   android:label="@string/wallpaper_settings_fragment_title"
-                  android:icon="@drawable/ic_wallpaper">
+                  android:icon="@drawable/ic_wallpaper"
+                  android:exported="true">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.wallpaper.WallpaperTypeSettings" />
         </activity>
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index 14564b1..0713872 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -28,10 +28,18 @@
 
 import com.android.settings.R;
 import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.search.SearchIndexableRaw;
+import com.android.settingslib.search.SearchIndexable;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
 
-public class WallpaperSuggestionActivity extends Activity {
+import java.util.ArrayList;
+import java.util.List;
+
+@SearchIndexable
+public class WallpaperSuggestionActivity extends Activity implements Indexable {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -79,4 +87,30 @@
         return context.getResources().getBoolean(
                 com.android.internal.R.bool.config_enableWallpaperService);
     }
+
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                private static final String SUPPORT_SEARCH_INDEX_KEY = "wallpaper_type";
+
+                @Override
+                public List<SearchIndexableRaw> getRawDataToIndex(Context context,
+                        boolean enabled) {
+
+                    final List<SearchIndexableRaw> result = new ArrayList<>();
+
+                    SearchIndexableRaw data = new SearchIndexableRaw(context);
+                    data.title = context.getString(R.string.wallpaper_settings_fragment_title);
+                    data.screenTitle = context.getString(
+                            R.string.wallpaper_settings_fragment_title);
+                    data.intentTargetPackage = context.getString(
+                            R.string.config_wallpaper_picker_package);
+                    data.intentTargetClass = context.getString(
+                            R.string.config_wallpaper_picker_class);
+                    data.intentAction = Intent.ACTION_MAIN;
+                    data.key = SUPPORT_SEARCH_INDEX_KEY;
+                    result.add(data);
+
+                    return result;
+                }
+            };
 }
diff --git a/src/com/android/settings/wallpaper/WallpaperTypeSettings.java b/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
index 0e0f8df..2d4a16f 100644
--- a/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
+++ b/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
@@ -17,21 +17,11 @@
 package com.android.settings.wallpaper;
 
 import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
 
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.SearchIndexableRaw;
-import com.android.settingslib.search.SearchIndexable;
 
-import java.util.ArrayList;
-import java.util.List;
 
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
 public class WallpaperTypeSettings extends DashboardFragment {
     private static final String TAG = "WallpaperTypeSettings";
 
@@ -54,42 +44,4 @@
     protected int getPreferenceScreenResId() {
         return R.xml.wallpaper_settings;
     }
-
-    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<>();
-
-                final Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
-                final PackageManager pm = context.getPackageManager();
-                final List<ResolveInfo> rList = pm.queryIntentActivities(intent,
-                        PackageManager.MATCH_DEFAULT_ONLY);
-
-                // Add indexable data for package that is in config_wallpaper_picker_package
-                final String wallpaperPickerPackage =
-                        context.getString(R.string.config_wallpaper_picker_package);
-                for (ResolveInfo info : rList) {
-                    if (!wallpaperPickerPackage.equals(info.activityInfo.packageName)) {
-                        continue;
-                    }
-                    CharSequence label = info.loadLabel(pm);
-                    if (label == null) {
-                        label = info.activityInfo.packageName;
-                    }
-                    final 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;
-                    data.intentTargetPackage = info.activityInfo.packageName;
-                    data.intentTargetClass = info.activityInfo.name;
-                    data.keywords = context.getString(R.string.keywords_wallpaper);
-                    result.add(data);
-                }
-
-                return result;
-            }
-        };
 }
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 8ca65ff..d7e5585 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -75,6 +75,7 @@
 com.android.settings.users.UserDetailsSettings
 com.android.settings.vpn2.AppManagementFragment
 com.android.settings.vpn2.VpnSettings
+com.android.settings.wallpaper.WallpaperTypeSettings
 com.android.settings.wifi.calling.WifiCallingSettingsForSub
 com.android.settings.wifi.ChangeWifiStateDetails
 com.android.settings.wifi.details.WifiNetworkDetailsFragment