Add indexable setting items

When work profile is supported on the device,
we should support work profile releated setting items.

Fix: 238055360
Test: Manual
Change-Id: I5b952f958d0c5fc0f7b22838e1f7cfc36239a22e
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;
+                }
             };
 }