Loading media/java/android/media/tv/TvInputManager.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.media.AudioDeviceInfo; import android.media.AudioFormat.Encoding; import android.media.AudioFormat.Encoding; import android.media.AudioPresentation; import android.media.AudioPresentation; import android.media.PlaybackParams; import android.media.PlaybackParams; import android.media.tv.ad.TvAdManager; import android.media.tv.interactive.TvInteractiveAppManager; import android.media.tv.interactive.TvInteractiveAppManager; import android.net.Uri; import android.net.Uri; import android.os.Binder; import android.os.Binder; Loading Loading @@ -2744,6 +2745,7 @@ public final class TvInputManager { private int mVideoHeight; private int mVideoHeight; private TvInteractiveAppManager.Session mIAppSession; private TvInteractiveAppManager.Session mIAppSession; private TvAdManager.Session mAdSession; private boolean mIAppNotificationEnabled = false; private boolean mIAppNotificationEnabled = false; private Session(IBinder token, InputChannel channel, ITvInputManager service, int userId, private Session(IBinder token, InputChannel channel, ITvInputManager service, int userId, Loading @@ -2764,6 +2766,14 @@ public final class TvInputManager { this.mIAppSession = iAppSession; this.mIAppSession = iAppSession; } } public TvAdManager.Session getAdSession() { return mAdSession; } public void setAdSession(TvAdManager.Session adSession) { this.mAdSession = adSession; } /** /** * Releases this session. * Releases this session. */ */ Loading media/java/android/media/tv/ad/ITvAdManager.aidl +15 −0 Original line number Original line Diff line number Diff line Loading @@ -17,9 +17,12 @@ package android.media.tv.ad; package android.media.tv.ad; import android.graphics.Rect; import android.graphics.Rect; import android.media.tv.TvTrackInfo; import android.media.tv.ad.ITvAdClient; import android.media.tv.ad.ITvAdClient; import android.media.tv.ad.ITvAdManagerCallback; import android.media.tv.ad.ITvAdManagerCallback; import android.media.tv.ad.TvAdServiceInfo; import android.media.tv.ad.TvAdServiceInfo; import android.net.Uri; import android.os.Bundle; import android.view.Surface; import android.view.Surface; /** /** Loading @@ -32,10 +35,22 @@ interface ITvAdManager { in ITvAdClient client, in String serviceId, in String type, int seq, int userId); in ITvAdClient client, in String serviceId, in String type, int seq, int userId); void releaseSession(in IBinder sessionToken, int userId); void releaseSession(in IBinder sessionToken, int userId); void startAdService(in IBinder sessionToken, int userId); void startAdService(in IBinder sessionToken, int userId); void stopAdService(in IBinder sessionToken, int userId); void resetAdService(in IBinder sessionToken, int userId); void setSurface(in IBinder sessionToken, in Surface surface, int userId); void setSurface(in IBinder sessionToken, in Surface surface, int userId); void dispatchSurfaceChanged(in IBinder sessionToken, int format, int width, int height, void dispatchSurfaceChanged(in IBinder sessionToken, int format, int width, int height, int userId); int userId); void sendCurrentVideoBounds(in IBinder sessionToken, in Rect bounds, int userId); void sendCurrentChannelUri(in IBinder sessionToken, in Uri channelUri, int userId); void sendTrackInfoList(in IBinder sessionToken, in List<TvTrackInfo> tracks, int userId); void sendCurrentTvInputId(in IBinder sessionToken, in String inputId, int userId); void sendSigningResult(in IBinder sessionToken, in String signingId, in byte[] result, int userId); void notifyError(in IBinder sessionToken, in String errMsg, in Bundle params, int userId); void notifyTvMessage(in IBinder sessionToken, in int type, in Bundle data, int userId); void registerCallback(in ITvAdManagerCallback callback, int userId); void registerCallback(in ITvAdManagerCallback callback, int userId); void unregisterCallback(in ITvAdManagerCallback callback, int userId); void unregisterCallback(in ITvAdManagerCallback callback, int userId); Loading media/java/android/media/tv/ad/ITvAdSession.aidl +14 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,9 @@ package android.media.tv.ad; package android.media.tv.ad; import android.graphics.Rect; import android.graphics.Rect; import android.media.tv.TvTrackInfo; import android.net.Uri; import android.os.Bundle; import android.view.Surface; import android.view.Surface; /** /** Loading @@ -26,9 +29,20 @@ import android.view.Surface; oneway interface ITvAdSession { oneway interface ITvAdSession { void release(); void release(); void startAdService(); void startAdService(); void stopAdService(); void resetAdService(); void setSurface(in Surface surface); void setSurface(in Surface surface); void dispatchSurfaceChanged(int format, int width, int height); void dispatchSurfaceChanged(int format, int width, int height); void sendCurrentVideoBounds(in Rect bounds); void sendCurrentChannelUri(in Uri channelUri); void sendTrackInfoList(in List<TvTrackInfo> tracks); void sendCurrentTvInputId(in String inputId); void sendSigningResult(in String signingId, in byte[] result); void notifyError(in String errMsg, in Bundle params); void notifyTvMessage(int type, in Bundle data); void createMediaView(in IBinder windowToken, in Rect frame); void createMediaView(in IBinder windowToken, in Rect frame); void relayoutMediaView(in Rect frame); void relayoutMediaView(in Rect frame); void removeMediaView(); void removeMediaView(); Loading media/java/android/media/tv/ad/ITvAdSessionWrapper.java +115 −0 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,13 @@ package android.media.tv.ad; package android.media.tv.ad; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.graphics.Rect; import android.media.tv.TvTrackInfo; import android.net.Uri; import android.os.Bundle; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; Loading @@ -31,6 +36,8 @@ import android.view.Surface; import com.android.internal.os.HandlerCaller; import com.android.internal.os.HandlerCaller; import com.android.internal.os.SomeArgs; import com.android.internal.os.SomeArgs; import java.util.List; /** /** * Implements the internal ITvAdSession interface. * Implements the internal ITvAdSession interface. * @hide * @hide Loading @@ -48,6 +55,16 @@ public class ITvAdSessionWrapper private static final int DO_CREATE_MEDIA_VIEW = 4; private static final int DO_CREATE_MEDIA_VIEW = 4; private static final int DO_RELAYOUT_MEDIA_VIEW = 5; private static final int DO_RELAYOUT_MEDIA_VIEW = 5; private static final int DO_REMOVE_MEDIA_VIEW = 6; private static final int DO_REMOVE_MEDIA_VIEW = 6; private static final int DO_START_AD_SERVICE = 7; private static final int DO_STOP_AD_SERVICE = 8; private static final int DO_RESET_AD_SERVICE = 9; private static final int DO_SEND_CURRENT_VIDEO_BOUNDS = 10; private static final int DO_SEND_CURRENT_CHANNEL_URI = 11; private static final int DO_SEND_TRACK_INFO_LIST = 12; private static final int DO_SEND_CURRENT_TV_INPUT_ID = 13; private static final int DO_SEND_SIGNING_RESULT = 14; private static final int DO_NOTIFY_ERROR = 15; private static final int DO_NOTIFY_TV_MESSAGE = 16; private final HandlerCaller mCaller; private final HandlerCaller mCaller; private TvAdService.Session mSessionImpl; private TvAdService.Session mSessionImpl; Loading Loading @@ -117,6 +134,52 @@ public class ITvAdSessionWrapper mSessionImpl.removeMediaView(true); mSessionImpl.removeMediaView(true); break; break; } } case DO_START_AD_SERVICE: { mSessionImpl.startAdService(); break; } case DO_STOP_AD_SERVICE: { mSessionImpl.stopAdService(); break; } case DO_RESET_AD_SERVICE: { mSessionImpl.resetAdService(); break; } case DO_SEND_CURRENT_VIDEO_BOUNDS: { mSessionImpl.sendCurrentVideoBounds((Rect) msg.obj); break; } case DO_SEND_CURRENT_CHANNEL_URI: { mSessionImpl.sendCurrentChannelUri((Uri) msg.obj); break; } case DO_SEND_TRACK_INFO_LIST: { mSessionImpl.sendTrackInfoList((List<TvTrackInfo>) msg.obj); break; } case DO_SEND_CURRENT_TV_INPUT_ID: { mSessionImpl.sendCurrentTvInputId((String) msg.obj); break; } case DO_SEND_SIGNING_RESULT: { SomeArgs args = (SomeArgs) msg.obj; mSessionImpl.sendSigningResult((String) args.arg1, (byte[]) args.arg2); args.recycle(); break; } case DO_NOTIFY_ERROR: { SomeArgs args = (SomeArgs) msg.obj; mSessionImpl.notifyError((String) args.arg1, (Bundle) args.arg2); args.recycle(); break; } case DO_NOTIFY_TV_MESSAGE: { SomeArgs args = (SomeArgs) msg.obj; mSessionImpl.notifyTvMessage((Integer) args.arg1, (Bundle) args.arg2); args.recycle(); break; } default: { default: { Log.w(TAG, "Unhandled message code: " + msg.what); Log.w(TAG, "Unhandled message code: " + msg.what); break; break; Loading @@ -135,7 +198,17 @@ public class ITvAdSessionWrapper @Override @Override public void startAdService() throws RemoteException { public void startAdService() throws RemoteException { mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_START_AD_SERVICE)); } @Override public void stopAdService() { mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_STOP_AD_SERVICE)); } @Override public void resetAdService() { mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_RESET_AD_SERVICE)); } } @Override @Override Loading @@ -149,6 +222,48 @@ public class ITvAdSessionWrapper mCaller.obtainMessageIIII(DO_DISPATCH_SURFACE_CHANGED, format, width, height, 0)); mCaller.obtainMessageIIII(DO_DISPATCH_SURFACE_CHANGED, format, width, height, 0)); } } @Override public void sendCurrentVideoBounds(@Nullable Rect bounds) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SEND_CURRENT_VIDEO_BOUNDS, bounds)); } @Override public void sendCurrentChannelUri(@Nullable Uri channelUri) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SEND_CURRENT_CHANNEL_URI, channelUri)); } @Override public void sendTrackInfoList(@NonNull List<TvTrackInfo> tracks) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SEND_TRACK_INFO_LIST, tracks)); } @Override public void sendCurrentTvInputId(@Nullable String inputId) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SEND_CURRENT_TV_INPUT_ID, inputId)); } @Override public void sendSigningResult(@NonNull String signingId, @NonNull byte[] result) { mCaller.executeOrSendMessage( mCaller.obtainMessageOO(DO_SEND_SIGNING_RESULT, signingId, result)); } @Override public void notifyError(@NonNull String errMsg, @NonNull Bundle params) { mCaller.executeOrSendMessage( mCaller.obtainMessageOO(DO_NOTIFY_ERROR, errMsg, params)); } @Override public void notifyTvMessage(int type, Bundle data) { mCaller.executeOrSendMessage( mCaller.obtainMessageOO(DO_NOTIFY_TV_MESSAGE, type, data)); } @Override @Override public void createMediaView(IBinder windowToken, Rect frame) { public void createMediaView(IBinder windowToken, Rect frame) { mCaller.executeOrSendMessage( mCaller.executeOrSendMessage( Loading media/java/android/media/tv/ad/TvAdManager.java +122 −0 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,10 @@ import android.annotation.SystemService; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.graphics.Rect; import android.media.tv.TvInputManager; import android.media.tv.TvInputManager; import android.media.tv.TvTrackInfo; import android.media.tv.flags.Flags; import android.media.tv.flags.Flags; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Handler; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; Loading Loading @@ -252,6 +255,14 @@ public class TvAdManager { mSessionCallbackRecordMap = sessionCallbackRecordMap; mSessionCallbackRecordMap = sessionCallbackRecordMap; } } public TvInputManager.Session getInputSession() { return mInputSession; } public void setInputSession(TvInputManager.Session inputSession) { mInputSession = inputSession; } /** /** * Releases this session. * Releases this session. */ */ Loading Loading @@ -411,6 +422,117 @@ public class TvAdManager { } } } } void stopAdService() { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.stopAdService(mToken, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void resetAdService() { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.resetAdService(mToken, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendCurrentVideoBounds(@NonNull Rect bounds) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendCurrentVideoBounds(mToken, bounds, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendCurrentChannelUri(@Nullable Uri channelUri) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendCurrentChannelUri(mToken, channelUri, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendTrackInfoList(@NonNull List<TvTrackInfo> tracks) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendTrackInfoList(mToken, tracks, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendCurrentTvInputId(@Nullable String inputId) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendCurrentTvInputId(mToken, inputId, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendSigningResult(@NonNull String signingId, @NonNull byte[] result) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendSigningResult(mToken, signingId, result, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void notifyError(@NonNull String errMsg, @NonNull Bundle params) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.notifyError(mToken, errMsg, params, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Notifies AD service session when a new TV message is received. */ public void notifyTvMessage(int type, Bundle data) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.notifyTvMessage(mToken, type, data, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } private final class InputEventHandler extends Handler { private final class InputEventHandler extends Handler { public static final int MSG_SEND_INPUT_EVENT = 1; public static final int MSG_SEND_INPUT_EVENT = 1; public static final int MSG_TIMEOUT_INPUT_EVENT = 2; public static final int MSG_TIMEOUT_INPUT_EVENT = 2; Loading Loading
media/java/android/media/tv/TvInputManager.java +10 −0 Original line number Original line Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.media.AudioDeviceInfo; import android.media.AudioFormat.Encoding; import android.media.AudioFormat.Encoding; import android.media.AudioPresentation; import android.media.AudioPresentation; import android.media.PlaybackParams; import android.media.PlaybackParams; import android.media.tv.ad.TvAdManager; import android.media.tv.interactive.TvInteractiveAppManager; import android.media.tv.interactive.TvInteractiveAppManager; import android.net.Uri; import android.net.Uri; import android.os.Binder; import android.os.Binder; Loading Loading @@ -2744,6 +2745,7 @@ public final class TvInputManager { private int mVideoHeight; private int mVideoHeight; private TvInteractiveAppManager.Session mIAppSession; private TvInteractiveAppManager.Session mIAppSession; private TvAdManager.Session mAdSession; private boolean mIAppNotificationEnabled = false; private boolean mIAppNotificationEnabled = false; private Session(IBinder token, InputChannel channel, ITvInputManager service, int userId, private Session(IBinder token, InputChannel channel, ITvInputManager service, int userId, Loading @@ -2764,6 +2766,14 @@ public final class TvInputManager { this.mIAppSession = iAppSession; this.mIAppSession = iAppSession; } } public TvAdManager.Session getAdSession() { return mAdSession; } public void setAdSession(TvAdManager.Session adSession) { this.mAdSession = adSession; } /** /** * Releases this session. * Releases this session. */ */ Loading
media/java/android/media/tv/ad/ITvAdManager.aidl +15 −0 Original line number Original line Diff line number Diff line Loading @@ -17,9 +17,12 @@ package android.media.tv.ad; package android.media.tv.ad; import android.graphics.Rect; import android.graphics.Rect; import android.media.tv.TvTrackInfo; import android.media.tv.ad.ITvAdClient; import android.media.tv.ad.ITvAdClient; import android.media.tv.ad.ITvAdManagerCallback; import android.media.tv.ad.ITvAdManagerCallback; import android.media.tv.ad.TvAdServiceInfo; import android.media.tv.ad.TvAdServiceInfo; import android.net.Uri; import android.os.Bundle; import android.view.Surface; import android.view.Surface; /** /** Loading @@ -32,10 +35,22 @@ interface ITvAdManager { in ITvAdClient client, in String serviceId, in String type, int seq, int userId); in ITvAdClient client, in String serviceId, in String type, int seq, int userId); void releaseSession(in IBinder sessionToken, int userId); void releaseSession(in IBinder sessionToken, int userId); void startAdService(in IBinder sessionToken, int userId); void startAdService(in IBinder sessionToken, int userId); void stopAdService(in IBinder sessionToken, int userId); void resetAdService(in IBinder sessionToken, int userId); void setSurface(in IBinder sessionToken, in Surface surface, int userId); void setSurface(in IBinder sessionToken, in Surface surface, int userId); void dispatchSurfaceChanged(in IBinder sessionToken, int format, int width, int height, void dispatchSurfaceChanged(in IBinder sessionToken, int format, int width, int height, int userId); int userId); void sendCurrentVideoBounds(in IBinder sessionToken, in Rect bounds, int userId); void sendCurrentChannelUri(in IBinder sessionToken, in Uri channelUri, int userId); void sendTrackInfoList(in IBinder sessionToken, in List<TvTrackInfo> tracks, int userId); void sendCurrentTvInputId(in IBinder sessionToken, in String inputId, int userId); void sendSigningResult(in IBinder sessionToken, in String signingId, in byte[] result, int userId); void notifyError(in IBinder sessionToken, in String errMsg, in Bundle params, int userId); void notifyTvMessage(in IBinder sessionToken, in int type, in Bundle data, int userId); void registerCallback(in ITvAdManagerCallback callback, int userId); void registerCallback(in ITvAdManagerCallback callback, int userId); void unregisterCallback(in ITvAdManagerCallback callback, int userId); void unregisterCallback(in ITvAdManagerCallback callback, int userId); Loading
media/java/android/media/tv/ad/ITvAdSession.aidl +14 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,9 @@ package android.media.tv.ad; package android.media.tv.ad; import android.graphics.Rect; import android.graphics.Rect; import android.media.tv.TvTrackInfo; import android.net.Uri; import android.os.Bundle; import android.view.Surface; import android.view.Surface; /** /** Loading @@ -26,9 +29,20 @@ import android.view.Surface; oneway interface ITvAdSession { oneway interface ITvAdSession { void release(); void release(); void startAdService(); void startAdService(); void stopAdService(); void resetAdService(); void setSurface(in Surface surface); void setSurface(in Surface surface); void dispatchSurfaceChanged(int format, int width, int height); void dispatchSurfaceChanged(int format, int width, int height); void sendCurrentVideoBounds(in Rect bounds); void sendCurrentChannelUri(in Uri channelUri); void sendTrackInfoList(in List<TvTrackInfo> tracks); void sendCurrentTvInputId(in String inputId); void sendSigningResult(in String signingId, in byte[] result); void notifyError(in String errMsg, in Bundle params); void notifyTvMessage(int type, in Bundle data); void createMediaView(in IBinder windowToken, in Rect frame); void createMediaView(in IBinder windowToken, in Rect frame); void relayoutMediaView(in Rect frame); void relayoutMediaView(in Rect frame); void removeMediaView(); void removeMediaView(); Loading
media/java/android/media/tv/ad/ITvAdSessionWrapper.java +115 −0 Original line number Original line Diff line number Diff line Loading @@ -16,8 +16,13 @@ package android.media.tv.ad; package android.media.tv.ad; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.graphics.Rect; import android.media.tv.TvTrackInfo; import android.net.Uri; import android.os.Bundle; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; import android.os.Message; import android.os.Message; Loading @@ -31,6 +36,8 @@ import android.view.Surface; import com.android.internal.os.HandlerCaller; import com.android.internal.os.HandlerCaller; import com.android.internal.os.SomeArgs; import com.android.internal.os.SomeArgs; import java.util.List; /** /** * Implements the internal ITvAdSession interface. * Implements the internal ITvAdSession interface. * @hide * @hide Loading @@ -48,6 +55,16 @@ public class ITvAdSessionWrapper private static final int DO_CREATE_MEDIA_VIEW = 4; private static final int DO_CREATE_MEDIA_VIEW = 4; private static final int DO_RELAYOUT_MEDIA_VIEW = 5; private static final int DO_RELAYOUT_MEDIA_VIEW = 5; private static final int DO_REMOVE_MEDIA_VIEW = 6; private static final int DO_REMOVE_MEDIA_VIEW = 6; private static final int DO_START_AD_SERVICE = 7; private static final int DO_STOP_AD_SERVICE = 8; private static final int DO_RESET_AD_SERVICE = 9; private static final int DO_SEND_CURRENT_VIDEO_BOUNDS = 10; private static final int DO_SEND_CURRENT_CHANNEL_URI = 11; private static final int DO_SEND_TRACK_INFO_LIST = 12; private static final int DO_SEND_CURRENT_TV_INPUT_ID = 13; private static final int DO_SEND_SIGNING_RESULT = 14; private static final int DO_NOTIFY_ERROR = 15; private static final int DO_NOTIFY_TV_MESSAGE = 16; private final HandlerCaller mCaller; private final HandlerCaller mCaller; private TvAdService.Session mSessionImpl; private TvAdService.Session mSessionImpl; Loading Loading @@ -117,6 +134,52 @@ public class ITvAdSessionWrapper mSessionImpl.removeMediaView(true); mSessionImpl.removeMediaView(true); break; break; } } case DO_START_AD_SERVICE: { mSessionImpl.startAdService(); break; } case DO_STOP_AD_SERVICE: { mSessionImpl.stopAdService(); break; } case DO_RESET_AD_SERVICE: { mSessionImpl.resetAdService(); break; } case DO_SEND_CURRENT_VIDEO_BOUNDS: { mSessionImpl.sendCurrentVideoBounds((Rect) msg.obj); break; } case DO_SEND_CURRENT_CHANNEL_URI: { mSessionImpl.sendCurrentChannelUri((Uri) msg.obj); break; } case DO_SEND_TRACK_INFO_LIST: { mSessionImpl.sendTrackInfoList((List<TvTrackInfo>) msg.obj); break; } case DO_SEND_CURRENT_TV_INPUT_ID: { mSessionImpl.sendCurrentTvInputId((String) msg.obj); break; } case DO_SEND_SIGNING_RESULT: { SomeArgs args = (SomeArgs) msg.obj; mSessionImpl.sendSigningResult((String) args.arg1, (byte[]) args.arg2); args.recycle(); break; } case DO_NOTIFY_ERROR: { SomeArgs args = (SomeArgs) msg.obj; mSessionImpl.notifyError((String) args.arg1, (Bundle) args.arg2); args.recycle(); break; } case DO_NOTIFY_TV_MESSAGE: { SomeArgs args = (SomeArgs) msg.obj; mSessionImpl.notifyTvMessage((Integer) args.arg1, (Bundle) args.arg2); args.recycle(); break; } default: { default: { Log.w(TAG, "Unhandled message code: " + msg.what); Log.w(TAG, "Unhandled message code: " + msg.what); break; break; Loading @@ -135,7 +198,17 @@ public class ITvAdSessionWrapper @Override @Override public void startAdService() throws RemoteException { public void startAdService() throws RemoteException { mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_START_AD_SERVICE)); } @Override public void stopAdService() { mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_STOP_AD_SERVICE)); } @Override public void resetAdService() { mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_RESET_AD_SERVICE)); } } @Override @Override Loading @@ -149,6 +222,48 @@ public class ITvAdSessionWrapper mCaller.obtainMessageIIII(DO_DISPATCH_SURFACE_CHANGED, format, width, height, 0)); mCaller.obtainMessageIIII(DO_DISPATCH_SURFACE_CHANGED, format, width, height, 0)); } } @Override public void sendCurrentVideoBounds(@Nullable Rect bounds) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SEND_CURRENT_VIDEO_BOUNDS, bounds)); } @Override public void sendCurrentChannelUri(@Nullable Uri channelUri) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SEND_CURRENT_CHANNEL_URI, channelUri)); } @Override public void sendTrackInfoList(@NonNull List<TvTrackInfo> tracks) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SEND_TRACK_INFO_LIST, tracks)); } @Override public void sendCurrentTvInputId(@Nullable String inputId) { mCaller.executeOrSendMessage( mCaller.obtainMessageO(DO_SEND_CURRENT_TV_INPUT_ID, inputId)); } @Override public void sendSigningResult(@NonNull String signingId, @NonNull byte[] result) { mCaller.executeOrSendMessage( mCaller.obtainMessageOO(DO_SEND_SIGNING_RESULT, signingId, result)); } @Override public void notifyError(@NonNull String errMsg, @NonNull Bundle params) { mCaller.executeOrSendMessage( mCaller.obtainMessageOO(DO_NOTIFY_ERROR, errMsg, params)); } @Override public void notifyTvMessage(int type, Bundle data) { mCaller.executeOrSendMessage( mCaller.obtainMessageOO(DO_NOTIFY_TV_MESSAGE, type, data)); } @Override @Override public void createMediaView(IBinder windowToken, Rect frame) { public void createMediaView(IBinder windowToken, Rect frame) { mCaller.executeOrSendMessage( mCaller.executeOrSendMessage( Loading
media/java/android/media/tv/ad/TvAdManager.java +122 −0 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,10 @@ import android.annotation.SystemService; import android.content.Context; import android.content.Context; import android.graphics.Rect; import android.graphics.Rect; import android.media.tv.TvInputManager; import android.media.tv.TvInputManager; import android.media.tv.TvTrackInfo; import android.media.tv.flags.Flags; import android.media.tv.flags.Flags; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Handler; import android.os.IBinder; import android.os.IBinder; import android.os.Looper; import android.os.Looper; Loading Loading @@ -252,6 +255,14 @@ public class TvAdManager { mSessionCallbackRecordMap = sessionCallbackRecordMap; mSessionCallbackRecordMap = sessionCallbackRecordMap; } } public TvInputManager.Session getInputSession() { return mInputSession; } public void setInputSession(TvInputManager.Session inputSession) { mInputSession = inputSession; } /** /** * Releases this session. * Releases this session. */ */ Loading Loading @@ -411,6 +422,117 @@ public class TvAdManager { } } } } void stopAdService() { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.stopAdService(mToken, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void resetAdService() { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.resetAdService(mToken, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendCurrentVideoBounds(@NonNull Rect bounds) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendCurrentVideoBounds(mToken, bounds, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendCurrentChannelUri(@Nullable Uri channelUri) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendCurrentChannelUri(mToken, channelUri, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendTrackInfoList(@NonNull List<TvTrackInfo> tracks) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendTrackInfoList(mToken, tracks, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendCurrentTvInputId(@Nullable String inputId) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendCurrentTvInputId(mToken, inputId, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void sendSigningResult(@NonNull String signingId, @NonNull byte[] result) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.sendSigningResult(mToken, signingId, result, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } void notifyError(@NonNull String errMsg, @NonNull Bundle params) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.notifyError(mToken, errMsg, params, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Notifies AD service session when a new TV message is received. */ public void notifyTvMessage(int type, Bundle data) { if (mToken == null) { Log.w(TAG, "The session has been already released"); return; } try { mService.notifyTvMessage(mToken, type, data, mUserId); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } private final class InputEventHandler extends Handler { private final class InputEventHandler extends Handler { public static final int MSG_SEND_INPUT_EVENT = 1; public static final int MSG_SEND_INPUT_EVENT = 1; public static final int MSG_TIMEOUT_INPUT_EVENT = 2; public static final int MSG_TIMEOUT_INPUT_EVENT = 2; Loading