diff options
-rw-r--r-- | api/current.txt | 18 | ||||
-rw-r--r-- | media/java/android/media/tv/ITvInputManager.aidl | 2 | ||||
-rw-r--r-- | media/java/android/media/tv/ITvInputSession.aidl | 2 | ||||
-rw-r--r-- | media/java/android/media/tv/ITvInputSessionWrapper.java | 11 | ||||
-rw-r--r-- | media/java/android/media/tv/TvInputManager.java | 66 | ||||
-rw-r--r-- | media/java/android/media/tv/TvInputService.java | 15 | ||||
-rw-r--r-- | media/java/android/media/tv/TvParentalControlManager.java | 64 | ||||
-rw-r--r-- | media/java/android/media/tv/TvView.java | 8 | ||||
-rw-r--r-- | services/core/java/com/android/server/tv/TvInputManagerService.java | 5 |
9 files changed, 97 insertions, 94 deletions
diff --git a/api/current.txt b/api/current.txt index a065879..52b03e9 100644 --- a/api/current.txt +++ b/api/current.txt @@ -16786,8 +16786,8 @@ package android.media.tv { method public int getInputState(java.lang.String); method public android.media.tv.TvInputInfo getTvInputInfo(java.lang.String); method public java.util.List<android.media.tv.TvInputInfo> getTvInputList(); - method public void registerCallback(android.media.tv.TvInputManager.TvInputCallback, android.os.Handler); - method public void unregisterCallback(android.media.tv.TvInputManager.TvInputCallback); + method public void registerListener(android.media.tv.TvInputManager.TvInputListener, android.os.Handler); + method public void unregisterListener(android.media.tv.TvInputManager.TvInputListener); field public static final int INPUT_STATE_CONNECTED = 0; // 0x0 field public static final int INPUT_STATE_CONNECTED_STANDBY = 1; // 0x1 field public static final int INPUT_STATE_DISCONNECTED = 2; // 0x2 @@ -16797,8 +16797,8 @@ package android.media.tv { field public static final int VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL = 2; // 0x2 } - public static abstract class TvInputManager.TvInputCallback { - ctor public TvInputManager.TvInputCallback(); + public static abstract class TvInputManager.TvInputListener { + ctor public TvInputManager.TvInputListener(); method public void onInputAdded(java.lang.String); method public void onInputRemoved(java.lang.String); method public void onInputStateChanged(java.lang.String, int); @@ -16836,7 +16836,6 @@ package android.media.tv { method public void dispatchTrackInfoChanged(java.util.List<android.media.tv.TvTrackInfo>); method public void dispatchVideoAvailable(); method public void dispatchVideoUnavailable(int); - method public abstract void onContentUnblocked(android.media.tv.TvContentRating); method public android.view.View onCreateOverlayView(); method public boolean onGenericMotionEvent(android.view.MotionEvent); method public boolean onKeyDown(int, android.view.KeyEvent); @@ -16844,6 +16843,7 @@ package android.media.tv { method public boolean onKeyMultiple(int, int, android.view.KeyEvent); method public boolean onKeyUp(int, android.view.KeyEvent); method public abstract void onRelease(); + method public void onRequestUnblockContent(android.media.tv.TvContentRating); method public boolean onSelectTrack(android.media.tv.TvTrackInfo); method public abstract void onSetCaptionEnabled(boolean); method public abstract void onSetStreamVolume(float); @@ -16857,14 +16857,14 @@ package android.media.tv { } public final class TvParentalControlManager { - method public void addParentalControlCallback(android.media.tv.TvParentalControlManager.ParentalControlCallback, android.os.Handler); + method public void addParentalControlListener(android.media.tv.TvParentalControlManager.ParentalControlListener, 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); + method public void removeParentalControlListener(android.media.tv.TvParentalControlManager.ParentalControlListener); } - public static abstract class TvParentalControlManager.ParentalControlCallback { - ctor public TvParentalControlManager.ParentalControlCallback(); + public static abstract class TvParentalControlManager.ParentalControlListener { + ctor public TvParentalControlManager.ParentalControlListener(); method public void onBlockedRatingsChanged(); method public void onEnabledChanged(boolean); } diff --git a/media/java/android/media/tv/ITvInputManager.aidl b/media/java/android/media/tv/ITvInputManager.aidl index 16c4199..7cf619d 100644 --- a/media/java/android/media/tv/ITvInputManager.aidl +++ b/media/java/android/media/tv/ITvInputManager.aidl @@ -56,7 +56,7 @@ interface ITvInputManager { void relayoutOverlayView(in IBinder sessionToken, in Rect frame, int userId); void removeOverlayView(in IBinder sessionToken, int userId); - void unblockContent(in IBinder sessionToken, in String unblockedRating, int userId); + void requestUnblockContent(in IBinder sessionToken, in String unblockedRating, int userId); // For TV input hardware binding List<TvInputHardwareInfo> getHardwareList(); diff --git a/media/java/android/media/tv/ITvInputSession.aidl b/media/java/android/media/tv/ITvInputSession.aidl index a97daf2..efcb1c6 100644 --- a/media/java/android/media/tv/ITvInputSession.aidl +++ b/media/java/android/media/tv/ITvInputSession.aidl @@ -42,5 +42,5 @@ oneway interface ITvInputSession { void relayoutOverlayView(in Rect frame); void removeOverlayView(); - void unblockContent(in String unblockedRating); + void requestUnblockContent(in String unblockedRating); } diff --git a/media/java/android/media/tv/ITvInputSessionWrapper.java b/media/java/android/media/tv/ITvInputSessionWrapper.java index f7dd75c..9683040 100644 --- a/media/java/android/media/tv/ITvInputSessionWrapper.java +++ b/media/java/android/media/tv/ITvInputSessionWrapper.java @@ -51,7 +51,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand private static final int DO_CREATE_OVERLAY_VIEW = 9; private static final int DO_RELAYOUT_OVERLAY_VIEW = 10; private static final int DO_REMOVE_OVERLAY_VIEW = 11; - private static final int DO_UNBLOCK_CONTENT = 12; + private static final int DO_REQUEST_UNBLOCK_CONTENT = 12; private final HandlerCaller mCaller; @@ -133,8 +133,8 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand mTvInputSessionImpl.removeOverlayView(true); return; } - case DO_UNBLOCK_CONTENT: { - mTvInputSessionImpl.unblockContent((String) msg.obj); + case DO_REQUEST_UNBLOCK_CONTENT: { + mTvInputSessionImpl.requestUnblockContent((String) msg.obj); return; } default: { @@ -202,8 +202,9 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand } @Override - public void unblockContent(String unblockedRating) { - mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_UNBLOCK_CONTENT, unblockedRating)); + public void requestUnblockContent(String unblockedRating) { + mCaller.executeOrSendMessage(mCaller.obtainMessageO( + DO_REQUEST_UNBLOCK_CONTENT, unblockedRating)); } private final class TvInputEventReceiver extends InputEventReceiver { diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java index efab74f..200b3e9 100644 --- a/media/java/android/media/tv/TvInputManager.java +++ b/media/java/android/media/tv/TvInputManager.java @@ -73,7 +73,7 @@ public final class TvInputManager { * The TV input is connected. * <p> * State for {@link #getInputState} and {@link - * TvInputManager.TvInputCallback#onInputStateChanged}. + * TvInputManager.TvInputListener#onInputStateChanged}. * </p> */ public static final int INPUT_STATE_CONNECTED = 0; @@ -82,7 +82,7 @@ public final class TvInputManager { * fully ready. * <p> * State for {@link #getInputState} and {@link - * TvInputManager.TvInputCallback#onInputStateChanged}. + * TvInputManager.TvInputListener#onInputStateChanged}. * </p> */ public static final int INPUT_STATE_CONNECTED_STANDBY = 1; @@ -90,7 +90,7 @@ public final class TvInputManager { * The TV input is disconnected. * <p> * State for {@link #getInputState} and {@link - * TvInputManager.TvInputCallback#onInputStateChanged}. + * TvInputManager.TvInputListener#onInputStateChanged}. * </p> */ public static final int INPUT_STATE_DISCONNECTED = 2; @@ -100,8 +100,8 @@ public final class TvInputManager { private final Object mLock = new Object(); // @GuardedBy(mLock) - private final List<TvInputCallbackRecord> mTvInputCallbackRecordsList = - new LinkedList<TvInputCallbackRecord>(); + private final List<TvInputListenerRecord> mTvInputListenerRecordsList = + new LinkedList<TvInputListenerRecord>(); // A mapping from TV input ID to the state of corresponding input. // @GuardedBy(mLock) @@ -315,7 +315,7 @@ public final class TvInputManager { /** * Interface used to monitor status of the TV input. */ - public abstract static class TvInputCallback { + public abstract static class TvInputListener { /** * This is called when the state of a given TV input is changed. * @@ -347,24 +347,24 @@ public final class TvInputManager { } } - private static final class TvInputCallbackRecord { - private final TvInputCallback mCallback; + private static final class TvInputListenerRecord { + private final TvInputListener mListener; private final Handler mHandler; - public TvInputCallbackRecord(TvInputCallback callback, Handler handler) { - mCallback = callback; + public TvInputListenerRecord(TvInputListener listener, Handler handler) { + mListener = listener; mHandler = handler; } - public TvInputCallback getCallback() { - return mCallback; + public TvInputListener getListener() { + return mListener; } public void postInputStateChanged(final String inputId, final int state) { mHandler.post(new Runnable() { @Override public void run() { - mCallback.onInputStateChanged(inputId, state); + mListener.onInputStateChanged(inputId, state); } }); } @@ -373,7 +373,7 @@ public final class TvInputManager { mHandler.post(new Runnable() { @Override public void run() { - mCallback.onInputAdded(inputId); + mListener.onInputAdded(inputId); } }); } @@ -382,7 +382,7 @@ public final class TvInputManager { mHandler.post(new Runnable() { @Override public void run() { - mCallback.onInputRemoved(inputId); + mListener.onInputRemoved(inputId); } }); } @@ -516,7 +516,7 @@ public final class TvInputManager { public void onInputStateChanged(String inputId, int state) { synchronized (mLock) { mStateMap.put(inputId, state); - for (TvInputCallbackRecord record : mTvInputCallbackRecordsList) { + for (TvInputListenerRecord record : mTvInputListenerRecordsList) { record.postInputStateChanged(inputId, state); } } @@ -526,7 +526,7 @@ public final class TvInputManager { public void onInputAdded(String inputId) { synchronized (mLock) { mStateMap.put(inputId, INPUT_STATE_CONNECTED); - for (TvInputCallbackRecord record : mTvInputCallbackRecordsList) { + for (TvInputListenerRecord record : mTvInputListenerRecordsList) { record.postInputAdded(inputId); } } @@ -536,7 +536,7 @@ public final class TvInputManager { public void onInputRemoved(String inputId) { synchronized (mLock) { mStateMap.remove(inputId); - for (TvInputCallbackRecord record : mTvInputCallbackRecordsList) { + for (TvInputListenerRecord record : mTvInputListenerRecordsList) { record.postInputRemoved(inputId); } } @@ -602,39 +602,39 @@ public final class TvInputManager { } /** - * Registers a {@link TvInputCallback}. + * Registers a {@link TvInputListener}. * - * @param callback A callback used to monitor status of the TV inputs. + * @param listener A listener used to monitor status of the TV inputs. * @param handler A {@link Handler} that the status change will be delivered to. * @throws IllegalArgumentException if any of the arguments is {@code null}. */ - public void registerCallback(TvInputCallback callback, Handler handler) { - if (callback == null) { + public void registerListener(TvInputListener listener, Handler handler) { + if (listener == null) { throw new IllegalArgumentException("callback cannot be null"); } if (handler == null) { throw new IllegalArgumentException("handler cannot be null"); } synchronized (mLock) { - mTvInputCallbackRecordsList.add(new TvInputCallbackRecord(callback, handler)); + mTvInputListenerRecordsList.add(new TvInputListenerRecord(listener, handler)); } } /** - * Unregisters the existing {@link TvInputCallback}. + * Unregisters the existing {@link TvInputListener}. * - * @param callback The existing callback to remove. + * @param listener The existing listener to remove. * @throws IllegalArgumentException if any of the arguments is {@code null}. */ - public void unregisterCallback(final TvInputCallback callback) { - if (callback == null) { + public void unregisterListener(final TvInputListener listener) { + if (listener == null) { throw new IllegalArgumentException("callback cannot be null"); } synchronized (mLock) { - for (Iterator<TvInputCallbackRecord> it = mTvInputCallbackRecordsList.iterator(); + for (Iterator<TvInputListenerRecord> it = mTvInputListenerRecordsList.iterator(); it.hasNext(); ) { - TvInputCallbackRecord record = it.next(); - if (record.getCallback() == callback) { + TvInputListenerRecord record = it.next(); + if (record.getListener() == listener) { it.remove(); break; } @@ -963,15 +963,15 @@ public final class TvInputManager { } /** - * Unblock content blocked by parental controls. + * Requests to unblock content blocked by parental controls. */ - void unblockContent(TvContentRating unblockedRating) { + void requestUnblockContent(TvContentRating unblockedRating) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { - mService.unblockContent(mToken, unblockedRating.flattenToString(), mUserId); + mService.requestUnblockContent(mToken, unblockedRating.flattenToString(), mUserId); } catch (RemoteException e) { throw new RuntimeException(e); } diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java index b23cec7..bb91210 100644 --- a/media/java/android/media/tv/TvInputService.java +++ b/media/java/android/media/tv/TvInputService.java @@ -352,7 +352,7 @@ public abstract class TvInputService extends Service { * </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 + * {@link TvParentalControlManager.ParentalControlListener} to the manager and immediately * reevaluate the current program with the new parental control settings. * </p> * @@ -391,7 +391,7 @@ public abstract class TvInputService extends Service { * </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 + * {@link TvParentalControlManager.ParentalControlListener} to the manager and immediately * reevaluate the current program with the new parental control settings. * </p> * @@ -469,7 +469,7 @@ public abstract class TvInputService extends Service { public abstract void onSetCaptionEnabled(boolean enabled); /** - * Called when the user allowed to unblock the content. + * Requests to unblock the content according to the given rating. * <p> * The implementation should unblock the content. * TV input service has responsibility to decide when/how the unblock expires @@ -481,7 +481,8 @@ public abstract class TvInputService extends Service { * * @param unblockedRating An unblocked content rating */ - public abstract void onContentUnblocked(TvContentRating unblockedRating); + public void onRequestUnblockContent(TvContentRating unblockedRating) { + } /** * Selects a given track. @@ -717,10 +718,10 @@ public abstract class TvInputService extends Service { } /** - * Calls {@link #onContentUnblocked}. + * Calls {@link #onRequestUnblockContent}. */ - void unblockContent(String unblockedRating) { - onContentUnblocked(TvContentRating.unflattenFromString(unblockedRating)); + void requestUnblockContent(String unblockedRating) { + onRequestUnblockContent(TvContentRating.unflattenFromString(unblockedRating)); // TODO: Handle failure. } diff --git a/media/java/android/media/tv/TvParentalControlManager.java b/media/java/android/media/tv/TvParentalControlManager.java index 3741991..7b190bb 100644 --- a/media/java/android/media/tv/TvParentalControlManager.java +++ b/media/java/android/media/tv/TvParentalControlManager.java @@ -53,8 +53,8 @@ public final class TvParentalControlManager { private final Object mLock = new Object(); @GuardedBy("mLock") - private final List<ParentalControlCallbackRecord> mParentalControlCallbackRecordList = - new LinkedList<ParentalControlCallbackRecord>(); + private final List<ParentalControlListenerRecord> mParentalControlListenerRecordList = + new LinkedList<ParentalControlListenerRecord>(); @GuardedBy("mLock") private final List<TvContentRating> mBlockedRatings = new ArrayList<TvContentRating>(); @@ -122,26 +122,26 @@ public final class TvParentalControlManager { } /** - * Adds a callback for monitoring the changes in the user's parental control settings. + * Adds a listener for monitoring the changes in the user's parental control settings. * - * @param callback The callback to add. + * @param listener The listener to add. * @param handler a {@link Handler} that the settings change will be delivered to. */ - public void addParentalControlCallback(ParentalControlCallback callback, + public void addParentalControlListener(ParentalControlListener listener, Handler handler) { - if (callback == null) { - throw new IllegalArgumentException("callback cannot be null"); + if (listener == null) { + throw new IllegalArgumentException("listener cannot be null"); } if (handler == null) { throw new IllegalArgumentException("handler cannot be null"); } synchronized (mLock) { - if (mParentalControlCallbackRecordList.isEmpty()) { + if (mParentalControlListenerRecordList.isEmpty()) { registerObserver(Settings.Secure.TV_PARENTAL_CONTROL_ENABLED); registerObserver(Settings.Secure.TV_PARENTAL_CONTROL_BLOCKED_RATINGS); } - mParentalControlCallbackRecordList.add( - new ParentalControlCallbackRecord(callback, handler)); + mParentalControlListenerRecordList.add( + new ParentalControlListenerRecord(listener, handler)); } } @@ -151,19 +151,19 @@ public final class TvParentalControlManager { } /** - * Removes a callback previously added using {@link #addParentalControlCallback}. + * Removes a listener previously added using {@link #addParentalControlListener}. * - * @param callback The callback to remove. + * @param listener The listener to remove. */ - public void removeParentalControlCallback(ParentalControlCallback callback) { - if (callback == null) { - throw new IllegalArgumentException("callback cannot be null"); + public void removeParentalControlListener(ParentalControlListener listener) { + if (listener == null) { + throw new IllegalArgumentException("listener cannot be null"); } synchronized (mLock) { - for (Iterator<ParentalControlCallbackRecord> it = - mParentalControlCallbackRecordList.iterator(); it.hasNext();) { - ParentalControlCallbackRecord record = it.next(); - if (record.getCallback() == callback) { + for (Iterator<ParentalControlListenerRecord> it = + mParentalControlListenerRecordList.iterator(); it.hasNext();) { + ParentalControlListenerRecord record = it.next(); + if (record.getListener() == listener) { it.remove(); break; } @@ -174,7 +174,7 @@ public final class TvParentalControlManager { private void notifyEnabledChanged() { final boolean enabled = isEnabled(); synchronized (mLock) { - for (ParentalControlCallbackRecord record : mParentalControlCallbackRecordList) { + for (ParentalControlListenerRecord record : mParentalControlListenerRecordList) { record.postEnabledChanged(enabled); } } @@ -188,7 +188,7 @@ public final class TvParentalControlManager { if (Settings.Secure.TV_PARENTAL_CONTROL_ENABLED.equals(name)) { notifyEnabledChanged(); } else if (Settings.Secure.TV_PARENTAL_CONTROL_BLOCKED_RATINGS.equals(name)) { - // We only need a single callback when multiple ratings change in rapid + // We only need a single listener when multiple ratings change in rapid // succession. mHandler.removeCallbacks(mBlockedRatingsChangedRunnable); mHandler.post(mBlockedRatingsChangedRunnable); @@ -204,7 +204,7 @@ public final class TvParentalControlManager { @Override public void run() { synchronized (mLock) { - for (ParentalControlCallbackRecord record : mParentalControlCallbackRecordList) { + for (ParentalControlListenerRecord record : mParentalControlListenerRecordList) { record.postBlockedRatingsChanged(); } } @@ -212,9 +212,9 @@ public final class TvParentalControlManager { }; /** - * Callback for changes in parental control settings, including enabled state. + * Listener for changes in parental control settings, including enabled state. */ - public static abstract class ParentalControlCallback { + public static abstract class ParentalControlListener { /** * Called when the parental control enabled state changes. * @@ -234,24 +234,24 @@ public final class TvParentalControlManager { public void onBlockedRatingsChanged() {} } - private static final class ParentalControlCallbackRecord { - private final ParentalControlCallback mCallback; + private static final class ParentalControlListenerRecord { + private final ParentalControlListener mListener; private final Handler mHandler; - public ParentalControlCallbackRecord(ParentalControlCallback callback, Handler handler) { - mCallback = callback; + public ParentalControlListenerRecord(ParentalControlListener listener, Handler handler) { + mListener = listener; mHandler = handler; } - public ParentalControlCallback getCallback() { - return mCallback; + public ParentalControlListener getListener() { + return mListener; } public void postEnabledChanged(final boolean enabled) { mHandler.post(new Runnable() { @Override public void run() { - mCallback.onEnabledChanged(enabled); + mListener.onEnabledChanged(enabled); } }); } @@ -260,7 +260,7 @@ public final class TvParentalControlManager { mHandler.post(new Runnable() { @Override public void run() { - mCallback.onBlockedRatingsChanged(); + mListener.onBlockedRatingsChanged(); } }); } diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java index 6b131f8..4966e27 100644 --- a/media/java/android/media/tv/TvView.java +++ b/media/java/android/media/tv/TvView.java @@ -220,18 +220,18 @@ public class TvView extends ViewGroup { } /** - * Unblock TV content. + * Requests to unblock TV content according to the given rating. * <p> * This notifies TV input that blocked content is now OK to play. * </p> * - * @param unblockedRating a TvContentRating to unblock. + * @param unblockedRating A TvContentRating to unblock. * @see TvInputService.Session#dispatchContentBlocked(TvContentRating) * @hide */ - public void unblockContent(TvContentRating unblockedRating) { + public void requestUnblockContent(TvContentRating unblockedRating) { if (mSession != null) { - mSession.unblockContent(unblockedRating); + mSession.requestUnblockContent(unblockedRating); } } diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java index 78b6883..0115366 100644 --- a/services/core/java/com/android/server/tv/TvInputManagerService.java +++ b/services/core/java/com/android/server/tv/TvInputManagerService.java @@ -1035,7 +1035,8 @@ public final class TvInputManagerService extends SystemService { } @Override - public void unblockContent(IBinder sessionToken, String unblockedRating, int userId) { + public void requestUnblockContent( + IBinder sessionToken, String unblockedRating, int userId) { final int callingUid = Binder.getCallingUid(); final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid, userId, "unblockContent"); @@ -1044,7 +1045,7 @@ public final class TvInputManagerService extends SystemService { synchronized (mLock) { try { getSessionLocked(sessionToken, callingUid, resolvedUserId) - .unblockContent(unblockedRating); + .requestUnblockContent(unblockedRating); } catch (RemoteException e) { Slog.e(TAG, "error in unblockContent", e); } |