Restrict screen saver settings searches to enabled users. am: 3358e2a0a1
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/21454411 Change-Id: I20b547eb56aac56837de97473671d902b2e524fa Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1229,4 +1229,22 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
public static int getHomepageIconColorHighlight(Context context) {
|
||||
return context.getColor(R.color.accent_select_primary_text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if dreams are available to the current user.
|
||||
*/
|
||||
public static boolean areDreamsAvailableToCurrentUser(Context context) {
|
||||
if (!context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_dreamsSupported)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final UserManager userManager = context.getSystemService(UserManager.class);
|
||||
return userManager != null && userManager.isSystemUser();
|
||||
}
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ import android.content.Context;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.dream.DreamSettings;
|
||||
@@ -35,13 +36,7 @@ public class ScreenSaverPreferenceController extends BasePreferenceController im
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
final boolean dreamsSupported = mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_dreamsSupported);
|
||||
final boolean dreamsOnlyEnabledForDockUser = mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_dreamsOnlyEnabledForDockUser);
|
||||
// TODO(b/257333623): Allow the Dock User to be non-SystemUser user in HSUM.
|
||||
return (dreamsSupported && (!dreamsOnlyEnabledForDockUser || isSystemUser()))
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
return Utils.areDreamsAvailableToCurrentUser(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,9 +48,4 @@ public class ScreenSaverPreferenceController extends BasePreferenceController im
|
||||
return DreamSettings.getSummaryTextWithDreamName(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSystemUser() {
|
||||
final UserManager userManager = mContext.getSystemService(UserManager.class);
|
||||
return userManager.isSystemUser();
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
@@ -251,6 +252,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user