From 14d4fca2e5db7a72199a9e5034fc4abbe6d221d2 Mon Sep 17 00:00:00 2001 From: shubang Date: Thu, 3 Mar 2022 22:06:43 -0800 Subject: [PATCH] TIAF API review: Setup Interactive App session Bug: 217450737 Test: CTS Change-Id: I96cf62938f03820ab4cce082c687af9e6006ec8b --- core/api/current.txt | 32 +++++++++---------- .../interactive/TvInteractiveAppManager.java | 5 +-- .../interactive/TvInteractiveAppService.java | 20 ++++++++++-- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index ec87591918bd3..52c39669113a2 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -26087,7 +26087,7 @@ package android.media.tv.interactive { method @NonNull public java.util.List getTvInteractiveAppServiceList(); method public void prepare(@NonNull String, int); method public void registerAppLinkInfo(@NonNull String, @NonNull android.media.tv.interactive.AppLinkInfo); - method public void registerCallback(@NonNull android.media.tv.interactive.TvInteractiveAppManager.TvInteractiveAppCallback, @NonNull java.util.concurrent.Executor); + method public void registerCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.tv.interactive.TvInteractiveAppManager.TvInteractiveAppCallback); method public void sendAppLinkCommand(@NonNull String, @NonNull android.os.Bundle); method public void unregisterAppLinkInfo(@NonNull String, @NonNull android.media.tv.interactive.AppLinkInfo); method public void unregisterCallback(@NonNull android.media.tv.interactive.TvInteractiveAppManager.TvInteractiveAppCallback); @@ -26157,10 +26157,10 @@ package android.media.tv.interactive { public abstract static class TvInteractiveAppService.Session implements android.view.KeyEvent.Callback { ctor public TvInteractiveAppService.Session(@NonNull android.content.Context); - method public void layoutSurface(int, int, int, int); - method public final void notifyBiInteractiveAppCreated(@NonNull android.net.Uri, @Nullable String); - method public void notifySessionStateChanged(int, int); - method public final void notifyTeletextAppStateChanged(int); + method @CallSuper public void layoutSurface(int, int, int, int); + method @CallSuper public final void notifyBiInteractiveAppCreated(@NonNull android.net.Uri, @Nullable String); + method @CallSuper public void notifySessionStateChanged(int, int); + method @CallSuper public final void notifyTeletextAppStateChanged(int); method public void onAdResponse(@NonNull android.media.tv.AdResponse); method public void onBroadcastInfoResponse(@NonNull android.media.tv.BroadcastInfoResponse); method public void onContentAllowed(); @@ -26194,17 +26194,17 @@ package android.media.tv.interactive { method public void onTuned(@NonNull android.net.Uri); method public void onVideoAvailable(); method public void onVideoUnavailable(int); - method public void removeBroadcastInfo(int); - method public void requestAd(@NonNull android.media.tv.AdRequest); - method public void requestBroadcastInfo(@NonNull android.media.tv.BroadcastInfoRequest); - method public void requestCurrentChannelLcn(); - method public void requestCurrentChannelUri(); - method public void requestCurrentTvInputId(); - method public void requestStreamVolume(); - method public void requestTrackInfoList(); - method public void sendPlaybackCommandRequest(@NonNull String, @Nullable android.os.Bundle); - method public void setMediaViewEnabled(boolean); - method public void setVideoBounds(@NonNull android.graphics.Rect); + method @CallSuper public void removeBroadcastInfo(int); + method @CallSuper public void requestAd(@NonNull android.media.tv.AdRequest); + method @CallSuper public void requestBroadcastInfo(@NonNull android.media.tv.BroadcastInfoRequest); + method @CallSuper public void requestCurrentChannelLcn(); + method @CallSuper public void requestCurrentChannelUri(); + method @CallSuper public void requestCurrentTvInputId(); + method @CallSuper public void requestStreamVolume(); + method @CallSuper public void requestTrackInfoList(); + method @CallSuper public void sendPlaybackCommandRequest(@NonNull String, @Nullable android.os.Bundle); + method @CallSuper public void setMediaViewEnabled(boolean); + method @CallSuper public void setVideoBounds(@NonNull android.graphics.Rect); } public class TvInteractiveAppView extends android.view.ViewGroup { diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java index f75aa56813ab7..3111ee7d9d666 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java @@ -626,6 +626,7 @@ public final class TvInteractiveAppManager { /** * This is called when the state of the interactive app service is changed. * + * @param iAppServiceId The ID of the TV Interactive App service. * @param type the interactive app type * @param state the current state of the service of the given type * @param err the error code for error state. {@link #ERROR_NONE} is used when the state is @@ -805,8 +806,8 @@ public final class TvInteractiveAppManager { * @param executor A {@link Executor} that the status change will be delivered to. */ public void registerCallback( - @NonNull TvInteractiveAppCallback callback, - @CallbackExecutor @NonNull Executor executor) { + @CallbackExecutor @NonNull Executor executor, + @NonNull TvInteractiveAppCallback callback) { Preconditions.checkNotNull(callback); Preconditions.checkNotNull(executor); synchronized (mLock) { diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppService.java b/media/java/android/media/tv/interactive/TvInteractiveAppService.java index 52b00b7b43e5f..9a0818e7e73c0 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppService.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppService.java @@ -16,6 +16,7 @@ package android.media.tv.interactive; +import android.annotation.CallSuper; import android.annotation.MainThread; import android.annotation.NonNull; import android.annotation.Nullable; @@ -351,6 +352,7 @@ public abstract class TvInteractiveAppService extends Service { * @param enable {@code true} if you want to enable the media view. {@code false} * otherwise. */ + @CallSuper public void setMediaViewEnabled(final boolean enable) { mHandler.post(new Runnable() { @Override @@ -467,11 +469,11 @@ public abstract class TvInteractiveAppService extends Service { * in {@link #onSetSurface}. This method is always called at least once, after * {@link #onSetSurface} is called with non-null surface. * - * @param format The new PixelFormat of the surface. + * @param format The new {@link PixelFormat} of the surface. * @param width The new width of the surface. * @param height The new height of the surface. */ - public void onSurfaceChanged(int format, int width, int height) { + public void onSurfaceChanged(@PixelFormat.Format int format, int width, int height) { } /** @@ -631,6 +633,7 @@ public abstract class TvInteractiveAppService extends Service { * @param right Right position in pixels, relative to the overlay view. * @param bottom Bottom position in pixels, relative to the overlay view. */ + @CallSuper public void layoutSurface(final int left, final int top, final int right, final int bottom) { if (left > right || top > bottom) { @@ -659,6 +662,7 @@ public abstract class TvInteractiveAppService extends Service { * Requests broadcast related information from the related TV input. * @param request the request for broadcast info */ + @CallSuper public void requestBroadcastInfo(@NonNull final BroadcastInfoRequest request) { executeOrPostRunnableOnMainThread(new Runnable() { @MainThread @@ -683,6 +687,7 @@ public abstract class TvInteractiveAppService extends Service { * Remove broadcast information request from the related TV input. * @param requestId the ID of the request */ + @CallSuper public void removeBroadcastInfo(final int requestId) { executeOrPostRunnableOnMainThread(new Runnable() { @MainThread @@ -709,6 +714,7 @@ public abstract class TvInteractiveAppService extends Service { * @param cmdType type of the specific command * @param parameters parameters of the specific command */ + @CallSuper public void sendPlaybackCommandRequest( @PlaybackCommandType @NonNull String cmdType, @Nullable Bundle parameters) { executeOrPostRunnableOnMainThread(new Runnable() { @@ -733,6 +739,7 @@ public abstract class TvInteractiveAppService extends Service { /** * Sets broadcast video bounds. */ + @CallSuper public void setVideoBounds(@NonNull Rect rect) { executeOrPostRunnableOnMainThread(new Runnable() { @MainThread @@ -755,6 +762,7 @@ public abstract class TvInteractiveAppService extends Service { /** * Requests the URI of the current channel. */ + @CallSuper public void requestCurrentChannelUri() { executeOrPostRunnableOnMainThread(new Runnable() { @MainThread @@ -777,6 +785,7 @@ public abstract class TvInteractiveAppService extends Service { /** * Requests the logic channel number (LCN) of the current channel. */ + @CallSuper public void requestCurrentChannelLcn() { executeOrPostRunnableOnMainThread(new Runnable() { @MainThread @@ -799,6 +808,7 @@ public abstract class TvInteractiveAppService extends Service { /** * Requests stream volume. */ + @CallSuper public void requestStreamVolume() { executeOrPostRunnableOnMainThread(new Runnable() { @MainThread @@ -821,6 +831,7 @@ public abstract class TvInteractiveAppService extends Service { /** * Requests the list of {@link TvTrackInfo}. */ + @CallSuper public void requestTrackInfoList() { executeOrPostRunnableOnMainThread(new Runnable() { @MainThread @@ -845,6 +856,7 @@ public abstract class TvInteractiveAppService extends Service { * * @see android.media.tv.TvInputInfo */ + @CallSuper public void requestCurrentTvInputId() { executeOrPostRunnableOnMainThread(new Runnable() { @MainThread @@ -869,6 +881,7 @@ public abstract class TvInteractiveAppService extends Service { * * @param request The advertisement request */ + @CallSuper public void requestAd(@NonNull final AdRequest request) { executeOrPostRunnableOnMainThread(new Runnable() { @MainThread @@ -1032,6 +1045,7 @@ public abstract class TvInteractiveAppService extends Service { * used when the state is not * {@link TvInteractiveAppManager#INTERACTIVE_APP_STATE_ERROR}. */ + @CallSuper public void notifySessionStateChanged( @TvInteractiveAppManager.InteractiveAppState int state, @TvInteractiveAppManager.ErrorCode int err) { @@ -1062,6 +1076,7 @@ public abstract class TvInteractiveAppService extends Service { * * @see #onCreateBiInteractiveApp(Uri, Bundle) */ + @CallSuper public final void notifyBiInteractiveAppCreated( @NonNull Uri biIAppUri, @Nullable String biIAppId) { executeOrPostRunnableOnMainThread(new Runnable() { @@ -1087,6 +1102,7 @@ public abstract class TvInteractiveAppService extends Service { * Notifies when the digital teletext app state is changed. * @param state the current state. */ + @CallSuper public final void notifyTeletextAppStateChanged( @TvInteractiveAppManager.TeletextAppState int state) { executeOrPostRunnableOnMainThread(new Runnable() {