Merge "Add indexable setting items"
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index f8f916e..4abdeda 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -86,8 +86,7 @@
     <com.android.settings.RestrictedListPreference
         android:key="privacy_lock_screen_notifications"
         android:title="@string/lock_screen_notifs_title"
-        android:summary="@string/summary_placeholder"
-        settings:searchable="false"/>
+        android:summary="@string/summary_placeholder"/>
 
     <!-- Show media on lock screen -->
     <SwitchPreference
@@ -117,8 +116,7 @@
             android:key="privacy_lock_screen_work_profile_notifications"
             android:title="@string/locked_work_profile_notification_title"
             android:summary="@string/summary_placeholder"
-            android:order="999"
-            settings:searchable="false"/>
+            android:order="999"/>
     </PreferenceCategory>
 
     <!-- Content Capture -->
diff --git a/src/com/android/settings/privacy/PrivacyDashboardFragment.java b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
index 75ed225..46a05b0 100644
--- a/src/com/android/settings/privacy/PrivacyDashboardFragment.java
+++ b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
@@ -25,9 +25,12 @@
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.os.Bundle;
+import android.os.UserHandle;
+import android.os.UserManager;
 import android.provider.SearchIndexableResource;
 
 import com.android.settings.R;
+import com.android.settings.Utils;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.notification.LockScreenNotificationPreferenceController;
 import com.android.settings.safetycenter.SafetyCenterManagerWrapper;
@@ -131,5 +134,21 @@
                         Context context) {
                     return buildPreferenceControllers(context, null);
                 }
+
+                @Override
+                public List<String> getNonIndexableKeys(Context context) {
+                    final List<String> keys = super.getNonIndexableKeys(context);
+                    final int profileUserId =
+                            Utils.getManagedProfileId(
+                                    UserManager.get(context), UserHandle.myUserId());
+                    // If work profile is supported, we should keep the search result.
+                    if (profileUserId != UserHandle.USER_NULL) {
+                        return keys;
+                    }
+
+                    // Otherwise, we should hide the search result.
+                    keys.add(KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS);
+                    return keys;
+                }
             };
 }