diff options
Diffstat (limited to 'src/com/android/tv/parental/ParentalControlSettings.java')
-rw-r--r-- | src/com/android/tv/parental/ParentalControlSettings.java | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/src/com/android/tv/parental/ParentalControlSettings.java b/src/com/android/tv/parental/ParentalControlSettings.java index 2471c565..db1f0a4d 100644 --- a/src/com/android/tv/parental/ParentalControlSettings.java +++ b/src/com/android/tv/parental/ParentalControlSettings.java @@ -19,30 +19,22 @@ package com.android.tv.parental; import android.content.Context; import android.media.tv.TvContentRating; import android.media.tv.TvInputManager; - -import com.android.tv.experiments.Experiments; +import com.android.tv.common.experiments.Experiments; import com.android.tv.parental.ContentRatingSystem.Rating; import com.android.tv.parental.ContentRatingSystem.SubRating; import com.android.tv.util.TvSettings; import com.android.tv.util.TvSettings.ContentRatingLevel; - import java.util.HashSet; import java.util.Set; public class ParentalControlSettings { - /** - * The rating and all of its sub-ratings are blocked. - */ + /** The rating and all of its sub-ratings are blocked. */ public static final int RATING_BLOCKED = 0; - /** - * The rating is blocked but not all of its sub-ratings are blocked. - */ + /** The rating is blocked but not all of its sub-ratings are blocked. */ public static final int RATING_BLOCKED_PARTIAL = 1; - /** - * The rating is not blocked. - */ + /** The rating is not blocked. */ public static final int RATING_NOT_BLOCKED = 2; private final Context mContext; @@ -65,8 +57,10 @@ public class ParentalControlSettings { mTvInputManager.setParentalControlsEnabled(enabled); } - public void setContentRatingSystemEnabled(ContentRatingsManager manager, - ContentRatingSystem contentRatingSystem, boolean enabled) { + public void setContentRatingSystemEnabled( + ContentRatingsManager manager, + ContentRatingSystem contentRatingSystem, + boolean enabled) { if (enabled) { TvSettings.addContentRatingSystem(mContext, contentRatingSystem.getId()); @@ -118,8 +112,8 @@ public class ParentalControlSettings { } } - public void setContentRatingLevel(ContentRatingsManager manager, - @ContentRatingLevel int level) { + public void setContentRatingLevel( + ContentRatingsManager manager, @ContentRatingLevel int level) { @ContentRatingLevel int currentLevel = getContentRatingLevel(); if (level == currentLevel) { return; @@ -167,18 +161,17 @@ public class ParentalControlSettings { /** * Sets the blocked status of a given content rating. - * <p> - * Note that a call to this method automatically changes the current rating level to - * {@code TvSettings.CONTENT_RATING_LEVEL_CUSTOM} if needed. - * </p> + * + * <p>Note that a call to this method automatically changes the current rating level to {@code + * TvSettings.CONTENT_RATING_LEVEL_CUSTOM} if needed. * * @param contentRatingSystem The content rating system where the given rating belongs. * @param rating The content rating to set. * @return {@code true} if changed, {@code false} otherwise. * @see #setSubRatingBlocked */ - public boolean setRatingBlocked(ContentRatingSystem contentRatingSystem, Rating rating, - boolean blocked) { + public boolean setRatingBlocked( + ContentRatingSystem contentRatingSystem, Rating rating, boolean blocked) { return setRatingBlockedInternal(contentRatingSystem, rating, null, blocked); } @@ -225,10 +218,9 @@ public class ParentalControlSettings { /** * Sets the blocked status of a given content sub-rating. - * <p> - * Note that a call to this method automatically changes the current rating level to - * {@code TvSettings.CONTENT_RATING_LEVEL_CUSTOM} if needed. - * </p> + * + * <p>Note that a call to this method automatically changes the current rating level to {@code + * TvSettings.CONTENT_RATING_LEVEL_CUSTOM} if needed. * * @param contentRatingSystem The content rating system where the given rating belongs. * @param rating The content rating associated with the given sub-rating. @@ -236,8 +228,11 @@ public class ParentalControlSettings { * @return {@code true} if changed, {@code false} otherwise. * @see #setRatingBlocked */ - public boolean setSubRatingBlocked(ContentRatingSystem contentRatingSystem, Rating rating, - SubRating subRating, boolean blocked) { + public boolean setSubRatingBlocked( + ContentRatingSystem contentRatingSystem, + Rating rating, + SubRating subRating, + boolean blocked) { return setRatingBlockedInternal(contentRatingSystem, rating, subRating, blocked); } @@ -249,16 +244,20 @@ public class ParentalControlSettings { * @param subRating The content sub-rating to check. * @return {@code true} if blocked, {@code false} otherwise. */ - public boolean isSubRatingEnabled(ContentRatingSystem contentRatingSystem, Rating rating, - SubRating subRating) { + public boolean isSubRatingEnabled( + ContentRatingSystem contentRatingSystem, Rating rating, SubRating subRating) { return mRatings.contains(toTvContentRating(contentRatingSystem, rating, subRating)); } - private boolean setRatingBlockedInternal(ContentRatingSystem contentRatingSystem, Rating rating, - SubRating subRating, boolean blocked) { - TvContentRating tvContentRating = (subRating == null) - ? toTvContentRating(contentRatingSystem, rating) - : toTvContentRating(contentRatingSystem, rating, subRating); + private boolean setRatingBlockedInternal( + ContentRatingSystem contentRatingSystem, + Rating rating, + SubRating subRating, + boolean blocked) { + TvContentRating tvContentRating = + (subRating == null) + ? toTvContentRating(contentRatingSystem, rating) + : toTvContentRating(contentRatingSystem, rating, subRating); boolean changed; if (blocked) { changed = mRatings.add(tvContentRating); @@ -280,8 +279,8 @@ public class ParentalControlSettings { } /** - * Returns the blocked status of a given rating. The status can be one of the followings: - * {@link #RATING_BLOCKED}, {@link #RATING_BLOCKED_PARTIAL} and {@link #RATING_NOT_BLOCKED} + * Returns the blocked status of a given rating. The status can be one of the followings: {@link + * #RATING_BLOCKED}, {@link #RATING_BLOCKED_PARTIAL} and {@link #RATING_NOT_BLOCKED} */ public int getBlockedStatus(ContentRatingSystem contentRatingSystem, Rating rating) { if (isRatingBlocked(contentRatingSystem, rating)) { @@ -295,15 +294,18 @@ public class ParentalControlSettings { return RATING_NOT_BLOCKED; } - private TvContentRating toTvContentRating(ContentRatingSystem contentRatingSystem, - Rating rating) { - return TvContentRating.createRating(contentRatingSystem.getDomain(), - contentRatingSystem.getName(), rating.getName()); + private TvContentRating toTvContentRating( + ContentRatingSystem contentRatingSystem, Rating rating) { + return TvContentRating.createRating( + contentRatingSystem.getDomain(), contentRatingSystem.getName(), rating.getName()); } - private TvContentRating toTvContentRating(ContentRatingSystem contentRatingSystem, - Rating rating, SubRating subRating) { - return TvContentRating.createRating(contentRatingSystem.getDomain(), - contentRatingSystem.getName(), rating.getName(), subRating.getName()); + private TvContentRating toTvContentRating( + ContentRatingSystem contentRatingSystem, Rating rating, SubRating subRating) { + return TvContentRating.createRating( + contentRatingSystem.getDomain(), + contentRatingSystem.getName(), + rating.getName(), + subRating.getName()); } } |