Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08953f55 authored by David Zhao's avatar David Zhao
Browse files

Add requestStopRecording APIs

Bug: 256713311
Test: atest
Change-Id: I007f77f9480546095e98eb17670169b1861685d1
parent 76d63ff4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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);
}
+32 −0
Original line number Diff line number Diff line
@@ -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
+27 −0
Original line number Diff line number Diff line
@@ -941,6 +941,33 @@ public abstract class TvInteractiveAppService extends Service {
            });
        }

        /**
         * Requests starting of recording
         *
         * <p> 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.
         *
+27 −0
Original line number Diff line number Diff line
@@ -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) {
Loading