TIAF: cleanup playback command and remaining public APIs
Bug: 213836031
Test: atest android.media.tv.interactive.cts.TvInteractiveAppViewTest
Test: atest android.media.tv.interactive.cts.TvInteractiveAppManagerTest
Test: atest android.media.tv.interactive.cts.TvInteractiveAppServiceTest
Change-Id: I305c2d98184d5907aec864a5ff7cfa01db2282ba
diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java
index 6c25a70..a769d9f 100644
--- a/media/java/android/media/tv/TvView.java
+++ b/media/java/android/media/tv/TvView.java
@@ -1079,12 +1079,13 @@
/**
* This is called when signal strength is updated.
+ *
* @param inputId The ID of the TV input bound to this view.
* @param strength The current signal strength.
- *
* @hide
*/
- public void onSignalStrength(String inputId, @TvInputManager.SignalStrength int strength) {
+ public void onSignalStrength(
+ @NonNull String inputId, @TvInputManager.SignalStrength int strength) {
}
/**
@@ -1093,7 +1094,7 @@
* @param channelUri The URI of a channel.
* @hide
*/
- public void onTuned(String inputId, Uri channelUri) {
+ public void onTuned(@NonNull String inputId, @NonNull Uri channelUri) {
}
}
diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java
index 2861bd3..29e619c 100755
--- a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java
+++ b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java
@@ -174,17 +174,17 @@
public @interface TeletextAppState {}
/**
- * Show state of Teletext app.
+ * State of Teletext app: show
* @hide
*/
public static final int TELETEXT_APP_STATE_SHOW = 1;
/**
- * Hide state of Teletext app.
+ * State of Teletext app: hide
* @hide
*/
public static final int TELETEXT_APP_STATE_HIDE = 2;
/**
- * Error state of Teletext app.
+ * State of Teletext app: error
* @hide
*/
public static final int TELETEXT_APP_STATE_ERROR = 3;
@@ -206,33 +206,6 @@
public static final String KEY_CLASS_NAME = "class_name";
/**
- * Key for URI scheme in app link.
- * <p>Type: String
- *
- * @see #registerAppLinkInfo(String, Bundle)
- * @hide
- */
- public static final String KEY_URI_SCHEME = "uri_scheme";
-
- /**
- * Key for URI host in app link.
- * <p>Type: String
- *
- * @see #registerAppLinkInfo(String, Bundle)
- * @hide
- */
- public static final String KEY_URI_HOST = "uri_host";
-
- /**
- * Key for URI prefix in app link.
- * <p>Type: String
- *
- * @see #registerAppLinkInfo(String, Bundle)
- * @hide
- */
- public static final String KEY_URI_PREFIX = "uri_prefix";
-
- /**
* Key for command type in app link command.
* <p>Type: String
*
@@ -256,6 +229,71 @@
*/
public static final String KEY_BACK_URI = "back_uri";
+ /**
+ * Broadcast intent action to send app command to TV app.
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @hide
+ */
+ public static final String ACTION_APP_LINK_COMMAND =
+ "android.media.tv.interactive.action.APP_LINK_COMMAND";
+
+ /**
+ * Intent key for TV input ID. It's used to send app command to TV app.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @see #ACTION_APP_LINK_COMMAND
+ * @hide
+ */
+ public static final String INTENT_KEY_TV_INPUT_ID = "tv_input_id";
+
+ /**
+ * Intent key for TV interactive app ID. It's used to send app command to TV app.
+ * <p>Type: String
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @see #ACTION_APP_LINK_COMMAND
+ * @see android.media.tv.interactive.TvInteractiveAppInfo#getId()
+ * @hide
+ */
+ public static final String INTENT_KEY_INTERACTIVE_APP_SERVICE_ID = "interactive_app_id";
+
+ /**
+ * Intent key for TV channel URI. It's used to send app command to TV app.
+ * <p>Type: android.net.Uri
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @see #ACTION_APP_LINK_COMMAND
+ * @hide
+ */
+ public static final String INTENT_KEY_CHANNEL_URI = "channel_uri";
+
+ /**
+ * Intent key for broadcast-independent(BI) interactive app type. It's used to send app command
+ * to TV app.
+ * <p>Type: int
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @see #ACTION_APP_LINK_COMMAND
+ * @see android.media.tv.interactive.TvInteractiveAppInfo#getSupportedTypes()
+ * @see Session#createBiInteractiveApp(Uri, Bundle)
+ * @hide
+ */
+ public static final String INTENT_KEY_BI_INTERACTIVE_APP_TYPE = "bi_interactive_app_type";
+
+ /**
+ * Intent key for broadcast-independent(BI) interactive app URI. It's used to send app command
+ * to TV app.
+ * <p>Type: android.net.Uri
+ *
+ * @see #sendAppLinkCommand(String, Bundle)
+ * @see #ACTION_APP_LINK_COMMAND
+ * @see Session#createBiInteractiveApp(Uri, Bundle)
+ * @hide
+ */
+ public static final String INTENT_KEY_BI_INTERACTIVE_APP_URI = "bi_interactive_app_uri";
+
private final ITvInteractiveAppManager mService;
private final int mUserId;
@@ -351,7 +389,7 @@
@Override
public void onCommandRequest(
- @TvInteractiveAppService.InteractiveAppServiceCommandType String cmdType,
+ @TvInteractiveAppService.PlaybackCommandType String cmdType,
Bundle parameters,
int seq) {
synchronized (mSessionCallbackRecordMap) {
@@ -723,7 +761,7 @@
}
/**
- * Prepares TV Interactive App service for the given type.
+ * Prepares TV Interactive App service environment for the given type.
* @hide
*/
public void prepare(@NonNull String tvIAppServiceId, int type) {
@@ -1557,7 +1595,7 @@
}
void postCommandRequest(
- final @TvInteractiveAppService.InteractiveAppServiceCommandType String cmdType,
+ final @TvInteractiveAppService.PlaybackCommandType String cmdType,
final Bundle parameters) {
mHandler.post(new Runnable() {
@Override
@@ -1705,7 +1743,7 @@
*/
public void onCommandRequest(
Session session,
- @TvInteractiveAppService.InteractiveAppServiceCommandType String cmdType,
+ @TvInteractiveAppService.PlaybackCommandType String cmdType,
Bundle parameters) {
}
diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppService.java b/media/java/android/media/tv/interactive/TvInteractiveAppService.java
index dbfd713..17f3035 100755
--- a/media/java/android/media/tv/interactive/TvInteractiveAppService.java
+++ b/media/java/android/media/tv/interactive/TvInteractiveAppService.java
@@ -32,6 +32,7 @@
import android.media.tv.BroadcastInfoRequest;
import android.media.tv.BroadcastInfoResponse;
import android.media.tv.TvContentRating;
+import android.media.tv.TvInputInfo;
import android.media.tv.TvInputManager;
import android.media.tv.TvTrackInfo;
import android.media.tv.TvView;
@@ -97,42 +98,90 @@
/** @hide */
@Retention(RetentionPolicy.SOURCE)
- @StringDef(prefix = "INTERACTIVE_APP_SERVICE_COMMAND_TYPE_", value = {
- INTERACTIVE_APP_SERVICE_COMMAND_TYPE_TUNE,
- INTERACTIVE_APP_SERVICE_COMMAND_TYPE_TUNE_NEXT,
- INTERACTIVE_APP_SERVICE_COMMAND_TYPE_TUNE_PREV,
- INTERACTIVE_APP_SERVICE_COMMAND_TYPE_STOP,
- INTERACTIVE_APP_SERVICE_COMMAND_TYPE_SET_STREAM_VOLUME,
- INTERACTIVE_APP_SERVICE_COMMAND_TYPE_SELECT_TRACK
+ @StringDef(prefix = "PLAYBACK_COMMAND_TYPE_", value = {
+ PLAYBACK_COMMAND_TYPE_TUNE,
+ PLAYBACK_COMMAND_TYPE_TUNE_NEXT,
+ PLAYBACK_COMMAND_TYPE_TUNE_PREV,
+ PLAYBACK_COMMAND_TYPE_STOP,
+ PLAYBACK_COMMAND_TYPE_SET_STREAM_VOLUME,
+ PLAYBACK_COMMAND_TYPE_SELECT_TRACK
})
- public @interface InteractiveAppServiceCommandType {}
+ public @interface PlaybackCommandType {}
- /** @hide */
- public static final String INTERACTIVE_APP_SERVICE_COMMAND_TYPE_TUNE = "tune";
- /** @hide */
- public static final String INTERACTIVE_APP_SERVICE_COMMAND_TYPE_TUNE_NEXT = "tune_next";
- /** @hide */
- public static final String INTERACTIVE_APP_SERVICE_COMMAND_TYPE_TUNE_PREV = "tune_previous";
- /** @hide */
- public static final String INTERACTIVE_APP_SERVICE_COMMAND_TYPE_STOP = "stop";
- /** @hide */
- public static final String INTERACTIVE_APP_SERVICE_COMMAND_TYPE_SET_STREAM_VOLUME =
+ /**
+ * Playback command type: tune to the given channel.
+ * @see #COMMAND_PARAMETER_KEY_CHANNEL_URI
+ * @hide
+ */
+ public static final String PLAYBACK_COMMAND_TYPE_TUNE = "tune";
+ /**
+ * Playback command type: tune to the next channel.
+ * @hide
+ */
+ public static final String PLAYBACK_COMMAND_TYPE_TUNE_NEXT = "tune_next";
+ /**
+ * Playback command type: tune to the previous channel.
+ * @hide
+ */
+ public static final String PLAYBACK_COMMAND_TYPE_TUNE_PREV = "tune_previous";
+ /**
+ * Playback command type: stop the playback.
+ * @hide
+ */
+ public static final String PLAYBACK_COMMAND_TYPE_STOP = "stop";
+ /**
+ * Playback command type: set the volume.
+ * @hide
+ */
+ public static final String PLAYBACK_COMMAND_TYPE_SET_STREAM_VOLUME =
"set_stream_volume";
- /** @hide */
- public static final String INTERACTIVE_APP_SERVICE_COMMAND_TYPE_SELECT_TRACK = "select_track";
- /** @hide */
+ /**
+ * Playback command type: select the given track.
+ * @hide
+ */
+ public static final String PLAYBACK_COMMAND_TYPE_SELECT_TRACK = "select_track";
+ /**
+ * Playback command parameter: channel URI.
+ * <p>Type: android.net.Uri
+ *
+ * @see #PLAYBACK_COMMAND_TYPE_TUNE
+ * @hide
+ */
public static final String COMMAND_PARAMETER_KEY_CHANNEL_URI = "command_channel_uri";
- /** @hide */
+ /**
+ * Playback command parameter: TV input ID.
+ * <p>Type: String
+ *
+ * @see TvInputInfo#getId()
+ * @hide
+ */
public static final String COMMAND_PARAMETER_KEY_INPUT_ID = "command_input_id";
- /** @hide */
+ /**
+ * Playback command parameter: stream volume.
+ * <p>Type: float
+ *
+ * @see #PLAYBACK_COMMAND_TYPE_SET_STREAM_VOLUME
+ * @hide
+ */
public static final String COMMAND_PARAMETER_KEY_VOLUME = "command_volume";
- /** @hide */
+ /**
+ * Playback command parameter: track type.
+ * <p>Type: int
+ *
+ * @see #PLAYBACK_COMMAND_TYPE_SELECT_TRACK
+ * @see TvTrackInfo#getType()
+ * @hide
+ */
public static final String COMMAND_PARAMETER_KEY_TRACK_TYPE = "command_track_type";
- /** @hide */
+ /**
+ * Playback command parameter: track ID.
+ * <p>Type: String
+ *
+ * @see #PLAYBACK_COMMAND_TYPE_SELECT_TRACK
+ * @see TvTrackInfo#getId()
+ * @hide
+ */
public static final String COMMAND_PARAMETER_KEY_TRACK_ID = "command_track_id";
- /** @hide */
- public static final String COMMAND_PARAMETER_KEY_TRACK_SELECT_MODE =
- "command_track_select_mode";
/**
* Command to quiet channel change. No channel banner or channel info is shown.
* <p>Refer to HbbTV Spec 2.0.4 chapter A.2.4.3.
@@ -210,16 +259,14 @@
* Registers App link info.
* @hide
*/
- public void onRegisterAppLinkInfo(AppLinkInfo appLinkInfo) {
- // TODO: make it abstract when unhide
+ public void onRegisterAppLinkInfo(@NonNull AppLinkInfo appLinkInfo) {
}
/**
* Unregisters App link info.
* @hide
*/
- public void onUnregisterAppLinkInfo(AppLinkInfo appLinkInfo) {
- // TODO: make it abstract when unhide
+ public void onUnregisterAppLinkInfo(@NonNull AppLinkInfo appLinkInfo) {
}
/**
@@ -383,7 +430,7 @@
/**
* To toggle Digital Teletext Application if there is one in AIT app list.
- * @param enable
+ * @param enable {@code true} to enable teletext app; {@code false} otherwise.
* @hide
*/
public void onSetTeletextAppEnabled(boolean enable) {
@@ -404,7 +451,7 @@
}
/**
- * Receives stream volume.
+ * Receives current stream volume.
* @hide
*/
public void onStreamVolume(float volume) {
@@ -495,14 +542,14 @@
* Called when the corresponding TV input selected to a track.
* @hide
*/
- public void onTrackSelected(int type, String trackId) {
+ public void onTrackSelected(@TvTrackInfo.Type int type, @NonNull String trackId) {
}
/**
* Called when the tracks are changed.
* @hide
*/
- public void onTracksChanged(List<TvTrackInfo> tracks) {
+ public void onTracksChanged(@NonNull List<TvTrackInfo> tracks) {
}
/**
@@ -516,7 +563,7 @@
* Called when video is unavailable.
* @hide
*/
- public void onVideoUnavailable(int reason) {
+ public void onVideoUnavailable(@TvInputManager.VideoUnavailableReason int reason) {
}
/**
@@ -530,7 +577,7 @@
* Called when content is blocked.
* @hide
*/
- public void onContentBlocked(TvContentRating rating) {
+ public void onContentBlocked(@NonNull TvContentRating rating) {
}
/**
@@ -553,40 +600,33 @@
public void onAdResponse(@NonNull AdResponse response) {
}
- /**
- * TODO: JavaDoc of APIs related to input events.
- * @hide
- */
@Override
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
return false;
}
- /**
- * @hide
- */
@Override
public boolean onKeyLongPress(int keyCode, @NonNull KeyEvent event) {
return false;
}
- /**
- * @hide
- */
@Override
public boolean onKeyMultiple(int keyCode, int count, @NonNull KeyEvent event) {
return false;
}
- /**
- * @hide
- */
@Override
public boolean onKeyUp(int keyCode, @NonNull KeyEvent event) {
return false;
}
/**
+ * Implement this method to handle touch screen motion events on the current session.
+ *
+ * @param event The motion event being received.
+ * @return If you handled the event, return {@code true}. If you want to allow the event to
+ * be handled by the next receiver, return {@code false}.
+ * @see View#onTouchEvent
* @hide
*/
public boolean onTouchEvent(@NonNull MotionEvent event) {
@@ -594,6 +634,12 @@
}
/**
+ * Implement this method to handle trackball events on the current session.
+ *
+ * @param event The motion event being received.
+ * @return If you handled the event, return {@code true}. If you want to allow the event to
+ * be handled by the next receiver, return {@code false}.
+ * @see View#onTrackballEvent
* @hide
*/
public boolean onTrackballEvent(@NonNull MotionEvent event) {
@@ -601,6 +647,12 @@
}
/**
+ * Implement this method to handle generic motion events on the current session.
+ *
+ * @param event The motion event being received.
+ * @return If you handled the event, return {@code true}. If you want to allow the event to
+ * be handled by the next receiver, return {@code false}.
+ * @see View#onGenericMotionEvent
* @hide
*/
public boolean onGenericMotionEvent(@NonNull MotionEvent event) {
@@ -691,13 +743,14 @@
}
/**
- * requests a specific command to be processed by the related TV input.
+ * Sends a specific playback command to be processed by the related TV input.
+ *
* @param cmdType type of the specific command
* @param parameters parameters of the specific command
* @hide
*/
- public void requestCommand(
- @InteractiveAppServiceCommandType String cmdType, Bundle parameters) {
+ public void sendPlaybackCommandRequest(
+ @PlaybackCommandType @NonNull String cmdType, @Nullable Bundle parameters) {
executeOrPostRunnableOnMainThread(new Runnable() {
@MainThread
@Override
@@ -721,7 +774,7 @@
* Sets broadcast video bounds.
* @hide
*/
- public void setVideoBounds(Rect rect) {
+ public void setVideoBounds(@NonNull Rect rect) {
executeOrPostRunnableOnMainThread(new Runnable() {
@MainThread
@Override
diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppView.java b/media/java/android/media/tv/interactive/TvInteractiveAppView.java
index 2922bae..fdeeb6e 100755
--- a/media/java/android/media/tv/interactive/TvInteractiveAppView.java
+++ b/media/java/android/media/tv/interactive/TvInteractiveAppView.java
@@ -213,7 +213,7 @@
/** @hide */
@Override
- protected void onVisibilityChanged(View changedView, int visibility) {
+ protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);
mSurfaceView.setVisibility(visibility);
if (visibility == View.VISIBLE) {
@@ -330,6 +330,11 @@
/**
* Dispatches an unhandled input event to the next receiver.
+ *
+ * It gives the host application a chance to dispatch the unhandled input events.
+ *
+ * @param event The input event.
+ * @return {@code true} if the event was handled by the view, {@code false} otherwise.
* @hide
*/
public boolean dispatchUnhandledInputEvent(@NonNull InputEvent event) {
@@ -356,14 +361,24 @@
}
/**
- * Registers a callback to be invoked when an input event is not handled
+ * Sets a listener to be invoked when an input event is not handled
* by the TV Interactive App.
*
* @param listener The callback to be invoked when the unhandled input event is received.
* @hide
*/
- public void setOnUnhandledInputEventListener(@NonNull OnUnhandledInputEventListener listener) {
+ public void setOnUnhandledInputEventListener(
+ @NonNull @CallbackExecutor Executor executor,
+ @NonNull OnUnhandledInputEventListener listener) {
mOnUnhandledInputEventListener = listener;
+ // TODO: handle CallbackExecutor
+ }
+ /**
+ * Clears the {@link OnUnhandledInputEventListener}
+ * @hide
+ */
+ public void clearOnUnhandledInputEventListener() {
+ mOnUnhandledInputEventListener = null;
}
@Override
@@ -440,9 +455,12 @@
/**
* Sends current channel URI to related TV interactive app.
+ *
+ * @param channelUri The current channel URI; {@code null} if there is no currently tuned
+ * channel.
* @hide
*/
- public void sendCurrentChannelUri(Uri channelUri) {
+ public void sendCurrentChannelUri(@Nullable Uri channelUri) {
if (DEBUG) {
Log.d(TAG, "sendCurrentChannelUri");
}
@@ -481,7 +499,7 @@
* Sends track info list to related TV interactive app.
* @hide
*/
- public void sendTrackInfoList(List<TvTrackInfo> tracks) {
+ public void sendTrackInfoList(@Nullable List<TvTrackInfo> tracks) {
if (DEBUG) {
Log.d(TAG, "sendTrackInfoList");
}
@@ -588,7 +606,11 @@
/**
* To toggle Digital Teletext Application if there is one in AIT app list.
- * @param enable
+ *
+ * <p>A Teletext Application is a broadcast-related application to display text and basic
+ * graphics.
+ *
+ * @param enable {@code true} to enable Teletext app; {@code false} to disable it.
* @hide
*/
public void setTeletextAppEnabled(boolean enable) {
@@ -607,17 +629,18 @@
// TODO: unhide the following public APIs
/**
- * This is called when a command is requested to be processed by the related TV input.
+ * This is called when a playback command is requested to be processed by the related TV
+ * input.
*
* @param iAppServiceId The ID of the TV interactive app service bound to this view.
* @param cmdType type of the command
* @param parameters parameters of the command
* @hide
*/
- public void onCommandRequest(
+ public void onPlaybackCommandRequest(
@NonNull String iAppServiceId,
- @NonNull @TvInteractiveAppService.InteractiveAppServiceCommandType String cmdType,
- @Nullable Bundle parameters) {
+ @NonNull @TvInteractiveAppService.PlaybackCommandType String cmdType,
+ @NonNull Bundle parameters) {
}
/**
@@ -818,7 +841,7 @@
@Override
public void onCommandRequest(
Session session,
- @TvInteractiveAppService.InteractiveAppServiceCommandType String cmdType,
+ @TvInteractiveAppService.PlaybackCommandType String cmdType,
Bundle parameters) {
if (DEBUG) {
Log.d(TAG, "onCommandRequest (cmdType=" + cmdType + ", parameters="
@@ -833,7 +856,8 @@
mCallbackExecutor.execute(() -> {
synchronized (mCallbackLock) {
if (mCallback != null) {
- mCallback.onCommandRequest(mIAppServiceId, cmdType, parameters);
+ mCallback.onPlaybackCommandRequest(
+ mIAppServiceId, cmdType, parameters);
}
}
});
diff --git a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java
index 28ca26c..d850536 100644
--- a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java
+++ b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java
@@ -2095,7 +2095,7 @@
@Override
public void onCommandRequest(
- @TvInteractiveAppService.InteractiveAppServiceCommandType String cmdType,
+ @TvInteractiveAppService.PlaybackCommandType String cmdType,
Bundle parameters) {
synchronized (mLock) {
if (DEBUG) {