Restrict screen saver settings searches to enabled users.

If a user can't enable screen saver, they shouldn't be able to
accidentally find screen saver related settings in Settings.

Bug: 260276394
Test: atest ScreenSaverPreferenceControllerTest
Test: manually by settings up a second user on a device that supports
screen saver, switching to that user, and making sure that searches for
"screen saver" don't accidentally reveal settings that can't be
accessed.

Change-Id: If2f465b2acb548455f0868507cf47217ea1a626f
This commit is contained in:
Will Leshner
2023-02-16 11:06:05 -08:00
parent 3a445a3ea1
commit ca1379f0b3
4 changed files with 43 additions and 21 deletions

View File

@@ -36,6 +36,7 @@ import androidx.preference.Preference;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
@@ -213,6 +214,17 @@ public class DreamSettings extends DashboardFragment implements OnMainSwitchChan
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.dream_fragment_overview);
new SearchIndexProvider(R.xml.dream_fragment_overview);
static class SearchIndexProvider extends BaseSearchIndexProvider {
SearchIndexProvider(int xmlRes) {
super(xmlRes);
}
@Override
protected boolean isPageSearchEnabled(Context context) {
return Utils.areDreamsAvailableToCurrentUser(context);
}
}
}