diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl index 6ae7dfb2d9297..9b8ec5e53ae92 100644 --- a/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl +++ b/media/java/android/media/tv/interactive/ITvInteractiveAppClient.aidl @@ -45,6 +45,7 @@ oneway interface ITvInteractiveAppClient { void onRequestTrackInfoList(int seq); void onRequestCurrentTvInputId(int seq); void onRequestStartRecording(in Uri programUri, int seq); + void onRequestStopRecording(in String recordingId, int seq); void onRequestSigning( in String id, in String algorithm, in String alias, in byte[] data, int seq); void onAdRequest(in AdRequest request, int Seq); diff --git a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl index 64780570e6ffc..4ce58711ceac5 100644 --- a/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl +++ b/media/java/android/media/tv/interactive/ITvInteractiveAppSessionCallback.aidl @@ -44,6 +44,7 @@ oneway interface ITvInteractiveAppSessionCallback { void onRequestTrackInfoList(); void onRequestCurrentTvInputId(); void onRequestStartRecording(in Uri programUri); + void onRequestStopRecording(in String recordingId); void onRequestSigning(in String id, in String algorithm, in String alias, in byte[] data); void onAdRequest(in AdRequest request); } diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java index 7d84fb2c431fd..0f1140706328b 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppManager.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppManager.java @@ -498,6 +498,18 @@ public final class TvInteractiveAppManager { } } + @Override + public void onRequestStopRecording(String recordingId, int seq) { + synchronized (mSessionCallbackRecordMap) { + SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq); + if (record == null) { + Log.e(TAG, "Callback not found for seq " + seq); + return; + } + record.postRequestStopRecording(recordingId); + } + } + @Override public void onRequestSigning( String id, String algorithm, String alias, byte[] data, int seq) { @@ -1729,6 +1741,15 @@ public final class TvInteractiveAppManager { }); } + void postRequestStopRecording(String recordingId) { + mHandler.post(new Runnable() { + @Override + public void run() { + mSessionCallback.onRequestStopRecording(mSession, recordingId); + } + }); + } + void postRequestSigning(String id, String algorithm, String alias, byte[] data) { mHandler.post(new Runnable() { @Override @@ -1884,10 +1905,21 @@ public final class TvInteractiveAppManager { * called. * * @param session A {@link TvInteractiveAppService.Session} associated with this callback. + * @param programUri The Uri of the program to be recorded. */ public void onRequestStartRecording(Session session, Uri programUri) { } + /** + * This is called when {@link TvInteractiveAppService.Session#RequestStopRecording} is + * called. + * + * @param session A {@link TvInteractiveAppService.Session} associated with this callback. + * @param recordingId The recordingId of the recording to be stopped. + */ + public void onRequestStopRecording(Session session, String recordingId) { + } + /** * This is called when * {@link TvInteractiveAppService.Session#requestSigning(String, String, String, byte[])} is diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppService.java b/media/java/android/media/tv/interactive/TvInteractiveAppService.java index 2956a0a93e419..9ef65032a78d7 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppService.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppService.java @@ -941,6 +941,33 @@ public abstract class TvInteractiveAppService extends Service { }); } + /** + * Requests starting of recording + * + *

This is used to request the active {@link android.media.tv.TvRecordingClient} to + * call {@link android.media.tv.TvRecordingClient#stopRecording()}. + * @see android.media.tv.TvRecordingClient#stopRecording() + * + * @hide + */ + @CallSuper + public void requestStopRecording(@NonNull String recordingId) { + executeOrPostRunnableOnMainThread(() -> { + try { + if (DEBUG) { + Log.d(TAG, "requestStopRecording"); + } + if (mSessionCallback != null) { + mSessionCallback.onRequestStopRecording(recordingId); + } + } catch (RemoteException e) { + Log.w(TAG, "error in requestStopRecording", e); + } + }); + } + + + /** * Requests signing of the given data. * diff --git a/media/java/android/media/tv/interactive/TvInteractiveAppView.java b/media/java/android/media/tv/interactive/TvInteractiveAppView.java index 1f270d0ba7681..c21b28851afda 100755 --- a/media/java/android/media/tv/interactive/TvInteractiveAppView.java +++ b/media/java/android/media/tv/interactive/TvInteractiveAppView.java @@ -866,6 +866,19 @@ public class TvInteractiveAppView extends ViewGroup { @Nullable Uri programUri) { } + /** + * This is called when {@link TvInteractiveAppService.Session#requestStopRecording()} + * is called. + * + * @param iAppServiceId The ID of the TV interactive app service bound to this view. + * @param recordingId The ID of the recording to stop. + * @hide + */ + public void onRequestStopRecording( + @NonNull String iAppServiceId, + @NonNull String recordingId) { + } + /** * This is called when * {@link TvInteractiveAppService.Session#requestSigning(String, String, String, byte[])} is @@ -1203,6 +1216,20 @@ public class TvInteractiveAppView extends ViewGroup { } } + @Override + public void onRequestStopRecording(Session session, String recordingId) { + if (DEBUG) { + Log.d(TAG, "onRequestStopRecording"); + } + if (this != mSessionCallback) { + Log.w(TAG, "onRequestStopRecording - session not created"); + return; + } + if (mCallback != null) { + mCallback.onRequestStopRecording(mIAppServiceId, recordingId); + } + } + @Override public void onRequestSigning( Session session, String id, String algorithm, String alias, byte[] data) { 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 f52f0b7e308f4..dbddb41b601cd 100644 --- a/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java +++ b/services/core/java/com/android/server/tv/interactive/TvInteractiveAppManagerService.java @@ -2252,6 +2252,23 @@ public class TvInteractiveAppManagerService extends SystemService { } } + @Override + public void onRequestStopRecording(String recordingId) { + synchronized (mLock) { + if (DEBUG) { + Slogf.d(TAG, "onRequestStopRecording"); + } + if (mSessionState.mSession == null || mSessionState.mClient == null) { + return; + } + try { + mSessionState.mClient.onRequestStopRecording(recordingId, mSessionState.mSeq); + } catch (RemoteException e) { + Slogf.e(TAG, "error in onRequestStopRecording", e); + } + } + } + @Override public void onRequestSigning(String id, String algorithm, String alias, byte[] data) { synchronized (mLock) {