Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6057102d authored by Jae Seo's avatar Jae Seo
Browse files

TIF: Add TvParentalControlManager

Each TV input service is now required to query the system whether the
user is allowed to watch the current program before showing it to the
user if the parental control is turned on, which can be checked by
calling TvParentalControlManager.isEnabled(). Whether the TV input
service should block the content or not is determined by invoking
TvParentalControlManager.isRatingBlocked() with the content rating for
the current program. Then the TvParentalControlManager makes a judgment
based on the user blocked ratings stored in the secure settings and
returns the result. If the rating in question turns out to be blocked,
the TV input service must immediately block the content and call this
method with the content rating of the current program to prompt the PIN
verification screen.

Each TV input service also needs to continuously listen to any changes
made to the parental control settings by registering a
TvParentalControlManager.ParentalControlCallback() to the manager and
immediately reevaluate the current program with the new parental control
settings.

Bug: 13172379
Change-Id: I8e1900d4b8d28c56798986d5c3906bd418ab97ac
parent f83ccb96
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -7213,6 +7213,7 @@ package android.content {
    field public static final java.lang.String TELEPHONY_SERVICE = "phone";
    field public static final java.lang.String TEXT_SERVICES_MANAGER_SERVICE = "textservices";
    field public static final java.lang.String TV_INPUT_SERVICE = "tv_input";
    field public static final java.lang.String TV_PARENTAL_CONTROL_SERVICE = "tv_parental_control";
    field public static final java.lang.String UI_MODE_SERVICE = "uimode";
    field public static final java.lang.String USB_SERVICE = "usb";
    field public static final java.lang.String USER_SERVICE = "user";
@@ -16402,10 +16403,12 @@ package android.media.session {
package android.media.tv {
  public class TvContentRating {
  public final class TvContentRating {
    ctor public TvContentRating(java.lang.String);
    ctor public TvContentRating(java.lang.String, java.lang.String[]);
    method public java.lang.String flattenToString();
    method public java.lang.String getRating();
    method public java.util.List<java.lang.String> getSubRatings();
    method public static android.media.tv.TvContentRating unflattenFromString(java.lang.String);
    field public static final java.lang.String RATING_KR_12 = "RATING_KR_12";
    field public static final java.lang.String RATING_KR_15 = "RATING_KR_15";
@@ -16600,6 +16603,7 @@ package android.media.tv {
  public abstract class TvInputService.Session implements android.view.KeyEvent.Callback {
    ctor public TvInputService.Session();
    method public void dispatchChannelRetuned(android.net.Uri);
    method public void dispatchContentBlocked(android.media.tv.TvContentRating);
    method public void dispatchTrackInfoChanged(java.util.List<android.media.tv.TvTrackInfo>);
    method public void dispatchVideoAvailable();
    method public void dispatchVideoUnavailable(int);
@@ -16621,6 +16625,19 @@ package android.media.tv {
    method public void setOverlayViewEnabled(boolean);
  }
  public final class TvParentalControlManager {
    method public void addParentalControlCallback(android.media.tv.TvParentalControlManager.ParentalControlCallback, android.os.Handler);
    method public final boolean isEnabled();
    method public final boolean isRatingBlocked(android.media.tv.TvContentRating);
    method public void removeParentalControlCallback(android.media.tv.TvParentalControlManager.ParentalControlCallback);
  }
  public static abstract class TvParentalControlManager.ParentalControlCallback {
    ctor public TvParentalControlManager.ParentalControlCallback();
    method public void onBlockedRatingsChanged();
    method public void onEnabledChanged(boolean);
  }
  public final class TvTrackInfo implements android.os.Parcelable {
    method public boolean containsKey(java.lang.String);
    method public int describeContents();
@@ -16678,6 +16695,7 @@ package android.media.tv {
  public static abstract class TvView.TvInputListener {
    ctor public TvView.TvInputListener();
    method public void onChannelRetuned(java.lang.String, android.net.Uri);
    method public void onContentBlocked(java.lang.String, android.media.tv.TvContentRating);
    method public void onError(java.lang.String, int);
    method public void onTrackInfoChanged(java.lang.String, java.util.List<android.media.tv.TvTrackInfo>);
    method public void onVideoAvailable(java.lang.String);
+6 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import android.media.AudioManager;
import android.media.MediaRouter;
import android.media.session.MediaSessionManager;
import android.media.tv.ITvInputManager;
import android.media.tv.TvParentalControlManager;
import android.media.tv.TvInputManager;
import android.net.ConnectivityManager;
import android.net.IConnectivityManager;
@@ -729,6 +730,11 @@ class ContextImpl extends Context {
                return new TvInputManager(service, UserHandle.myUserId());
            }});

        registerService(TV_PARENTAL_CONTROL_SERVICE, new ServiceFetcher() {
                public Object getService(ContextImpl ctx) {
                    return new TvParentalControlManager(ctx);
                }});

        registerService(NETWORK_SCORE_SERVICE, new ServiceFetcher() {
            public Object createService(ContextImpl ctx) {
                return new NetworkScoreManager(ctx);
+10 −0
Original line number Diff line number Diff line
@@ -2821,6 +2821,16 @@ public abstract class Context {
     */
    public static final String TV_INPUT_SERVICE = "tv_input";

    /**
     * Use with {@link #getSystemService} to retrieve a
     * {@link android.media.tv.TvParentalControlManager} for obtaining parental
     * control settings and listening to their changes.
     *
     * @see #getSystemService
     * @see android.media.tv.TvParentalControlManager
     */
    public static final String TV_PARENTAL_CONTROL_SERVICE = "tv_parental_control";

    /**
     * {@link android.net.NetworkScoreManager} for managing network scoring.
     * @see #getSystemService
+14 −0
Original line number Diff line number Diff line
@@ -3627,6 +3627,20 @@ public final class Settings {
         */
        public static final String PARENTAL_CONTROL_REDIRECT_URL = "parental_control_redirect_url";


        /**
         * Whether the TV parental control is enabled.
         * @hide
         */
        public static final String TV_PARENTAL_CONTROL_ENABLED = "tv_parental_control_enabled";

        /**
         * List of TV content ratings blocked by the user. (comma-delimited)
         * @hide
         */
        public static final String TV_PARENTAL_CONTROL_BLOCKED_RATINGS =
                "tv_parental_control_blocked_ratings";

        /**
         * Settings classname to launch when Settings is clicked from All
         * Applications.  Needed because of user testing between the old
+1 −0
Original line number Diff line number Diff line
@@ -36,4 +36,5 @@ oneway interface ITvInputClient {
    void onTrackInfoChanged(in List<TvTrackInfo> tracks, int seq);
    void onVideoAvailable(int seq);
    void onVideoUnavailable(int reason, int seq);
    void onContentBlocked(in String rating, int seq);
}
Loading