diff options
7 files changed, 86 insertions, 2 deletions
diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl index 84b9c9ebfc18..38fc71711f7d 100644 --- a/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl +++ b/media/java/android/media/tv/interactive/ITvInteractiveAppManager.aidl @@ -64,6 +64,7 @@ interface ITvInteractiveAppManager { void notifyContentBlocked(in IBinder sessionToken, in String rating, int userId); void notifySignalStrength(in IBinder sessionToken, int stength, int userId); void notifyRecordingStarted(in IBinder sessionToken, in String recordingId, int userId); + void notifyRecordingStopped(in IBinder sessionToken, in String recordingId, int userId); void setSurface(in IBinder sessionToken, in Surface surface, int userId); void dispatchSurfaceChanged(in IBinder sessionToken, int format, int width, int height, int userId); diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl index 95b4ffa3ef5e..9e3353672af2 100644 --- a/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl +++ b/media/java/android/media/tv/interactive/ITvInteractiveAppSession.aidl @@ -54,6 +54,7 @@ oneway interface ITvInteractiveAppSession { void notifyContentBlocked(in String rating); void notifySignalStrength(int strength); void notifyRecordingStarted(in String recordingId); + void notifyRecordingStopped(in String recordingId); void setSurface(in Surface surface); void dispatchSurfaceChanged(int format, int width, int height); void notifyBroadcastInfoResponse(in BroadcastInfoResponse response); diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionWrapper.java b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionWrapper.java index 042cb153226d..a2fdfe01ccec 100644 --- a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionWrapper.java +++ b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionWrapper.java @@ -82,6 +82,7 @@ public class ITvInteractiveAppSessionWrapper private static final int DO_RELAYOUT_MEDIA_VIEW = 28; private static final int DO_REMOVE_MEDIA_VIEW = 29; private static final int DO_NOTIFY_RECORDING_STARTED = 30; + private static final int DO_NOTIFY_RECORDING_STOPPED = 31; private final HandlerCaller mCaller; private Session mSessionImpl; @@ -169,6 +170,10 @@ public class ITvInteractiveAppSessionWrapper mSessionImpl.notifyRecordingStarted((String) msg.obj); break; } + case DO_NOTIFY_RECORDING_STOPPED: { + mSessionImpl.notifyRecordingStopped((String) msg.obj); + break; + } case DO_SEND_SIGNING_RESULT: { SomeArgs args = (SomeArgs) msg.obj; mSessionImpl.sendSigningResult((String) args.arg1, (byte[]) args.arg2); @@ -392,6 +397,12 @@ public class ITvInteractiveAppSessionWrapper } @Override + public void notifyRecordingStopped(String recordingId) { + mCaller.executeOrSendMessage(mCaller.obtainMessageO( + DO_NOTIFY_RECORDING_STOPPED, recordingId)); + } + + @Override public void setSurface(Surface surface) { mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_SURFACE, surface)); } diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java index 0f1140706328..287df40d0d31 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java @@ -1071,6 +1071,18 @@ public final class TvInteractiveAppManager { } } + void notifyRecordingStopped(String recordingId) { + if (mToken == null) { + Log.w(TAG, "The session has been already released"); + return; + } + try { + mService.notifyRecordingStopped(mToken, recordingId, 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"); diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppService.java b/media/java/android/media/tv/interactive/TvInteractiveAppService.java index 9ef65032a78d..90eed9ec83ca 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppService.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppService.java @@ -463,6 +463,16 @@ public abstract class TvInteractiveAppService extends Service { } /** + * Receives stopped recording's ID. + * + * @param recordingId The ID of the recording stopped + * @hide + */ + public void onRecordingStopped(@NonNull String recordingId) { + } + + + /** * Receives signing result. * @param signingId the ID to identify the request. It's the same as the corresponding ID in * {@link Session#requestSigning(String, String, String, byte[])} @@ -1178,11 +1188,21 @@ public abstract class TvInteractiveAppService extends Service { onAdResponse(response); } + /** + * Calls {@link #onRecordingStarted(String)}. + */ void notifyRecordingStarted(String recordingId) { onRecordingStarted(recordingId); } /** + * Calls {@link #onRecordingStopped(String)}. + */ + void notifyRecordingStopped(String recordingId) { + onRecordingStopped(recordingId); + } + + /** * Notifies when the session state is changed. * * @param state the current session state. diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppView.java b/media/java/android/media/tv/interactive/TvInteractiveAppView.java index c21b28851afd..fcd781b85aca 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppView.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppView.java @@ -581,9 +581,10 @@ public class TvInteractiveAppView extends ViewGroup { } /** - * Alerts the TV interactive app that a recording has been started with recordingId + * Alerts the TV interactive app that a recording has been started. * - * @param recordingId The ID of the recording started + * @param recordingId The ID of the recording started. This ID is created and maintained by the + * TV app and is used to identify the recording in the future. */ public void notifyRecordingStarted(@NonNull String recordingId) { if (DEBUG) { @@ -595,6 +596,23 @@ public class TvInteractiveAppView extends ViewGroup { } /** + * Alerts the TV interactive app that a recording has been stopped. + * + * @param recordingId The ID of the recording stopped. This ID is created and maintained + * by the TV app when a recording is started. + * @see TvInteractiveAppView#notifyRecordingStarted(String) + * @hide + */ + public void notifyRecordingStopped(@NonNull String recordingId) { + if (DEBUG) { + Log.d(TAG, "notifyRecordingStopped"); + } + if (mSession != null) { + mSession.notifyRecordingStopped(recordingId); + } + } + + /** * Sends signing result to related TV interactive app. * * <p>This is used when the corresponding server of the broadcast-independent interactive 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 dbddb41b601c..2c8fd967ae8a 100644 --- a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java +++ b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java @@ -1066,7 +1066,28 @@ public class TvInteractiveAppManagerService extends SystemService { } finally { Binder.restoreCallingIdentity(identity); } + } + @Override + public void notifyRecordingStopped(IBinder sessionToken, String recordingId, int userId) { + final int callingUid = Binder.getCallingUid(); + final int callingPid = Binder.getCallingPid(); + final int resolvedUserId = resolveCallingUserId(callingPid, callingUid, userId, + "notifyRecordingStopped"); + final long identity = Binder.clearCallingIdentity(); + try { + synchronized (mLock) { + try { + SessionState sessionState = getSessionStateLocked(sessionToken, callingUid, + resolvedUserId); + getSessionLocked(sessionState).notifyRecordingStopped(recordingId); + } catch (RemoteException | SessionNotFoundException e) { + Slogf.e(TAG, "error in notifyRecordingStopped", e); + } + } + } finally { + Binder.restoreCallingIdentity(identity); + } } @Override |