am c936967b: am 0c2b6c52: Merge "TIF: Add a way to notify whether the current program content is allowed" into lmp-dev

* commit 'c936967b84ef7ba70f948bcd99b8355fbdd3c9a4':
  TIF: Add a way to notify whether the current program content is allowed
This commit is contained in:
Jae Seo
2014-07-20 18:03:09 +00:00
committed by Android Git Automerger
7 changed files with 156 additions and 38 deletions

View File

@@ -16732,6 +16732,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 dispatchContentAllowed();
method public void dispatchContentBlocked(android.media.tv.TvContentRating);
method public void dispatchTrackInfoChanged(java.util.List<android.media.tv.TvTrackInfo>);
method public void dispatchVideoAvailable();
@@ -16826,6 +16827,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 onContentAllowed(java.lang.String);
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>);

View File

@@ -36,5 +36,6 @@ oneway interface ITvInputClient {
void onTrackInfoChanged(in List<TvTrackInfo> tracks, int seq);
void onVideoAvailable(int seq);
void onVideoUnavailable(int reason, int seq);
void onContentAllowed(int seq);
void onContentBlocked(in String rating, int seq);
}

View File

@@ -33,5 +33,6 @@ oneway interface ITvInputSessionCallback {
void onTrackInfoChanged(in List<TvTrackInfo> tracks);
void onVideoAvailable();
void onVideoUnavailable(int reason);
void onContentAllowed();
void onContentBlocked(in String rating);
}

View File

@@ -187,7 +187,17 @@ public final class TvInputManager {
}
/**
* This is called when the current program content is blocked by parental controls.
* This is called when the current program content turns out to be allowed to watch since
* its content rating is not blocked by parental controls.
*
* @param session A {@link TvInputManager.Session} associated with this callback
*/
public void onContentAllowed(Session session) {
}
/**
* This is called when the current program content turns out to be not allowed to watch
* since its content rating is blocked by parental controls.
*
* @param session A {@link TvInputManager.Session} associated with this callback
* @param rating The content ration of the blocked program.
@@ -274,6 +284,15 @@ public final class TvInputManager {
});
}
public void postContentAllowed() {
mHandler.post(new Runnable() {
@Override
public void run() {
mSessionCallback.onContentAllowed(mSession);
}
});
}
public void postContentBlocked(final TvContentRating rating) {
mHandler.post(new Runnable() {
@Override
@@ -456,6 +475,18 @@ public final class TvInputManager {
}
}
@Override
public void onContentAllowed(int seq) {
synchronized (mSessionCallbackRecordMap) {
SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
if (record == null) {
Log.e(TAG, "Callback not found for seq " + seq);
return;
}
record.postContentAllowed();
}
}
@Override
public void onContentBlocked(String rating, int seq) {
synchronized (mSessionCallbackRecordMap) {

View File

@@ -305,42 +305,6 @@ public abstract class TvInputService extends Service {
});
}
/**
* Informs the application that the current program content is blocked by parent controls.
* <p>
* Each TV input service is 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 {@link TvParentalControlManager#isEnabled}. Whether
* the TV input service should block the content or not is determined by invoking
* {@link 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.
* </p><p>
* Each TV input service also needs to continuously listen to any changes made to the
* parental control settings by registering a
* {@link TvParentalControlManager.ParentalControlCallback} to the manager and immediately
* reevaluate the current program with the new parental control settings.
* </p>
*
* @param rating The content rating for the current TV program.
*/
public void dispatchContentBlocked(final TvContentRating rating) {
mHandler.post(new Runnable() {
@Override
public void run() {
try {
if (DEBUG) Log.d(TAG, "dispatchContentBlocked");
mSessionCallback.onContentBlocked(rating.flattenToString());
} catch (RemoteException e) {
Log.w(TAG, "error in dispatchContentBlocked");
}
}
});
}
/**
* Informs the application that video is not available, so the TV input cannot continue
* playing the TV stream.
@@ -371,6 +335,84 @@ public abstract class TvInputService extends Service {
});
}
/**
* Informs the application that the user is allowed to watch the current program content.
* <p>
* Each TV input service is 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
* enabled (i.e. {@link TvParentalControlManager#isEnabled
* TvParentalControlManager.isEnabled()} returns {@code true}). Whether the TV input service
* should block the content or not is determined by invoking
* {@link TvParentalControlManager#isRatingBlocked
* TvParentalControlManager.isRatingBlocked(TvContentRating)} with the content rating for
* the current program. Then the {@link 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 allowed by the user, the TV input service must call
* this method to notify the application that is permitted to show the content.
* </p><p>
* Each TV input service also needs to continuously listen to any changes made to the
* parental control settings by registering a
* {@link TvParentalControlManager.ParentalControlCallback} to the manager and immediately
* reevaluate the current program with the new parental control settings.
* </p>
*
* @see #dispatchContentBlocked
* @see TvParentalControlManager
*/
public void dispatchContentAllowed() {
mHandler.post(new Runnable() {
@Override
public void run() {
try {
if (DEBUG) Log.d(TAG, "dispatchContentAllowed");
mSessionCallback.onContentAllowed();
} catch (RemoteException e) {
Log.w(TAG, "error in dispatchContentAllowed");
}
}
});
}
/**
* Informs the application that the current program content is blocked by parent controls.
* <p>
* Each TV input service is 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
* enabled (i.e. {@link TvParentalControlManager#isEnabled
* TvParentalControlManager.isEnabled()} returns {@code true}). Whether the TV input service
* should block the content or not is determined by invoking
* {@link TvParentalControlManager#isRatingBlocked
* TvParentalControlManager.isRatingBlocked(TvContentRating)} with the content rating for
* the current program. Then the {@link 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.
* </p><p>
* Each TV input service also needs to continuously listen to any changes made to the
* parental control settings by registering a
* {@link TvParentalControlManager.ParentalControlCallback} to the manager and immediately
* reevaluate the current program with the new parental control settings.
* </p>
*
* @param rating The content rating for the current TV program.
* @see #dispatchContentAllowed
* @see TvParentalControlManager
*/
public void dispatchContentBlocked(final TvContentRating rating) {
mHandler.post(new Runnable() {
@Override
public void run() {
try {
if (DEBUG) Log.d(TAG, "dispatchContentBlocked");
mSessionCallback.onContentBlocked(rating.flattenToString());
} catch (RemoteException e) {
Log.w(TAG, "error in dispatchContentBlocked");
}
}
});
}
/**
* Called when the session is released.
*/

View File

@@ -576,7 +576,17 @@ public class TvView extends ViewGroup {
}
/**
* This is called when the current program content is blocked by parental controls.
* This is called when the current program content turns out to be allowed to watch since
* its content rating is not blocked by parental controls.
*
* @param inputId The ID of the TV input bound to this view.
*/
public void onContentAllowed(String inputId) {
}
/**
* This is called when the current program content turns out to be not allowed to watch
* since its content rating is blocked by parental controls.
*
* @param inputId The ID of the TV input bound to this view.
* @param rating The content rating of the blocked program.
@@ -718,6 +728,19 @@ public class TvView extends ViewGroup {
}
}
@Override
public void onContentAllowed(Session session) {
if (this != mSessionCallback) {
return;
}
if (DEBUG) {
Log.d(TAG, "onContentAllowed()");
}
if (mListener != null) {
mListener.onContentAllowed(mInputId);
}
}
@Override
public void onContentBlocked(Session session, TvContentRating rating) {
if (DEBUG) {
@@ -728,6 +751,7 @@ public class TvView extends ViewGroup {
}
}
@Override
public void onSessionEvent(Session session, String eventType, Bundle eventArgs) {
if (this != mSessionCallback) {
return;

View File

@@ -564,6 +564,23 @@ public final class TvInputManagerService extends SystemService {
}
}
@Override
public void onContentAllowed() {
synchronized (mLock) {
if (DEBUG) {
Slog.d(TAG, "onContentAllowed()");
}
if (sessionState.mSession == null || sessionState.mClient == null) {
return;
}
try {
sessionState.mClient.onContentAllowed(sessionState.mSeq);
} catch (RemoteException e) {
Slog.e(TAG, "error in onContentAllowed");
}
}
}
@Override
public void onContentBlocked(String rating) {
synchronized (mLock) {