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

Commit cd7d4450 authored by Yixiao Luo's avatar Yixiao Luo Committed by Android (Google) Code Review
Browse files

Merge "TIAF: add Content Availability related functions"

parents d80c67c9 5738ea3d
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -764,6 +764,9 @@ public final class TvInputManager {
                @Override
                @Override
                public void run() {
                public void run() {
                    mSessionCallback.onVideoAvailable(mSession);
                    mSessionCallback.onVideoAvailable(mSession);
                    if (mSession.mIAppNotificationEnabled && mSession.getIAppSession() != null) {
                        mSession.getIAppSession().notifyVideoAvailable();
                    }
                }
                }
            });
            });
        }
        }
@@ -773,6 +776,9 @@ public final class TvInputManager {
                @Override
                @Override
                public void run() {
                public void run() {
                    mSessionCallback.onVideoUnavailable(mSession, reason);
                    mSessionCallback.onVideoUnavailable(mSession, reason);
                    if (mSession.mIAppNotificationEnabled && mSession.getIAppSession() != null) {
                        mSession.getIAppSession().notifyVideoUnavailable(reason);
                    }
                }
                }
            });
            });
        }
        }
@@ -782,6 +788,9 @@ public final class TvInputManager {
                @Override
                @Override
                public void run() {
                public void run() {
                    mSessionCallback.onContentAllowed(mSession);
                    mSessionCallback.onContentAllowed(mSession);
                    if (mSession.mIAppNotificationEnabled && mSession.getIAppSession() != null) {
                        mSession.getIAppSession().notifyContentAllowed();
                    }
                }
                }
            });
            });
        }
        }
@@ -791,6 +800,9 @@ public final class TvInputManager {
                @Override
                @Override
                public void run() {
                public void run() {
                    mSessionCallback.onContentBlocked(mSession, rating);
                    mSessionCallback.onContentBlocked(mSession, rating);
                    if (mSession.mIAppNotificationEnabled && mSession.getIAppSession() != null) {
                        mSession.getIAppSession().notifyContentBlocked(rating);
                    }
                }
                }
            });
            });
        }
        }
+4 −0
Original line number Original line Diff line number Diff line
@@ -51,6 +51,10 @@ interface ITvIAppManager {
    void notifyTuned(in IBinder sessionToken, in Uri channelUri, int userId);
    void notifyTuned(in IBinder sessionToken, in Uri channelUri, int userId);
    void notifyTrackSelected(in IBinder sessionToken, int type, in String trackId, int userId);
    void notifyTrackSelected(in IBinder sessionToken, int type, in String trackId, int userId);
    void notifyTracksChanged(in IBinder sessionToken, in List<TvTrackInfo> tracks, int userId);
    void notifyTracksChanged(in IBinder sessionToken, in List<TvTrackInfo> tracks, int userId);
    void notifyVideoAvailable(in IBinder sessionToken, int userId);
    void notifyVideoUnavailable(in IBinder sessionToken, int reason, int userId);
    void notifyContentAllowed(in IBinder sessionToken, int userId);
    void notifyContentBlocked(in IBinder sessionToken, in String rating, 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);
+4 −0
Original line number Original line Diff line number Diff line
@@ -42,6 +42,10 @@ oneway interface ITvIAppSession {
    void notifyTuned(in Uri channelUri);
    void notifyTuned(in Uri channelUri);
    void notifyTrackSelected(int type, in String trackId);
    void notifyTrackSelected(int type, in String trackId);
    void notifyTracksChanged(in List<TvTrackInfo> tracks);
    void notifyTracksChanged(in List<TvTrackInfo> tracks);
    void notifyVideoAvailable();
    void notifyVideoUnavailable(int reason);
    void notifyContentAllowed();
    void notifyContentBlocked(in String rating);
    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 notifyBroadcastInfoResponse(in BroadcastInfoResponse response);
    void notifyBroadcastInfoResponse(in BroadcastInfoResponse response);
+61 −0
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import android.media.tv.AdRequest;
import android.media.tv.AdResponse;
import android.media.tv.AdResponse;
import android.media.tv.BroadcastInfoRequest;
import android.media.tv.BroadcastInfoRequest;
import android.media.tv.BroadcastInfoResponse;
import android.media.tv.BroadcastInfoResponse;
import android.media.tv.TvContentRating;
import android.media.tv.TvInputManager;
import android.media.tv.TvInputManager;
import android.media.tv.TvTrackInfo;
import android.media.tv.TvTrackInfo;
import android.net.Uri;
import android.net.Uri;
@@ -1037,6 +1038,66 @@ public final class TvIAppManager {
            }
            }
        }
        }


        /**
         * Notifies IAPP session when video is available.
         */
        public void notifyVideoAvailable() {
            if (mToken == null) {
                Log.w(TAG, "The session has been already released");
                return;
            }
            try {
                mService.notifyVideoAvailable(mToken, mUserId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }

        /**
         * Notifies IAPP session when video is unavailable.
         */
        public void notifyVideoUnavailable(int reason) {
            if (mToken == null) {
                Log.w(TAG, "The session has been already released");
                return;
            }
            try {
                mService.notifyVideoUnavailable(mToken, reason, mUserId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }

        /**
         * Notifies IAPP session when content is allowed.
         */
        public void notifyContentAllowed() {
            if (mToken == null) {
                Log.w(TAG, "The session has been already released");
                return;
            }
            try {
                mService.notifyContentAllowed(mToken, mUserId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }

        /**
         * Notifies IAPP session when content is blocked.
         */
        public void notifyContentBlocked(TvContentRating rating) {
            if (mToken == null) {
                Log.w(TAG, "The session has been already released");
                return;
            }
            try {
                mService.notifyContentBlocked(mToken, rating.flattenToString(), mUserId);
            } catch (RemoteException e) {
                throw e.rethrowFromSystemServer();
            }
        }

        private void flushPendingEventsLocked() {
        private void flushPendingEventsLocked() {
            mHandler.removeMessages(InputEventHandler.MSG_FLUSH_INPUT_EVENT);
            mHandler.removeMessages(InputEventHandler.MSG_FLUSH_INPUT_EVENT);


+76 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import android.media.tv.AdRequest;
import android.media.tv.AdResponse;
import android.media.tv.AdResponse;
import android.media.tv.BroadcastInfoRequest;
import android.media.tv.BroadcastInfoRequest;
import android.media.tv.BroadcastInfoResponse;
import android.media.tv.BroadcastInfoResponse;
import android.media.tv.TvContentRating;
import android.media.tv.TvTrackInfo;
import android.media.tv.TvTrackInfo;
import android.net.Uri;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.AsyncTask;
@@ -441,6 +442,34 @@ public abstract class TvIAppService extends Service {
        public void onTracksChanged(List<TvTrackInfo> tracks) {
        public void onTracksChanged(List<TvTrackInfo> tracks) {
        }
        }


        /**
         * Called when video is available.
         * @hide
         */
        public void onVideoAvailable() {
        }

        /**
         * Called when video is unavailable.
         * @hide
         */
        public void onVideoUnavailable(int reason) {
        }

        /**
         * Called when content is allowed.
         * @hide
         */
        public void onContentAllowed() {
        }

        /**
         * Called when content is blocked.
         * @hide
         */
        public void onContentBlocked(TvContentRating rating) {
        }

        /**
        /**
         * Called when a broadcast info response is received.
         * Called when a broadcast info response is received.
         * @hide
         * @hide
@@ -816,6 +845,33 @@ public abstract class TvIAppService extends Service {
            onTracksChanged(tracks);
            onTracksChanged(tracks);
        }
        }


        void notifyVideoAvailable() {
            if (DEBUG) {
                Log.d(TAG, "notifyVideoAvailable");
            }
            onVideoAvailable();
        }

        void notifyVideoUnavailable(int reason) {
            if (DEBUG) {
                Log.d(TAG, "notifyVideoAvailable (reason=" + reason + ")");
            }
            onVideoUnavailable(reason);
        }

        void notifyContentAllowed() {
            if (DEBUG) {
                Log.d(TAG, "notifyContentAllowed");
            }
            notifyContentAllowed();
        }

        void notifyContentBlocked(TvContentRating rating) {
            if (DEBUG) {
                Log.d(TAG, "notifyContentBlocked (rating=" + rating.flattenToString() + ")");
            }
            onContentBlocked(rating);
        }


        /**
        /**
         * Calls {@link #onBroadcastInfoResponse}.
         * Calls {@link #onBroadcastInfoResponse}.
@@ -1181,6 +1237,26 @@ public abstract class TvIAppService extends Service {
            mSessionImpl.notifyTracksChanged(tracks);
            mSessionImpl.notifyTracksChanged(tracks);
        }
        }


        @Override
        public void notifyVideoAvailable() {
            mSessionImpl.notifyVideoAvailable();
        }

        @Override
        public void notifyVideoUnavailable(int reason) {
            mSessionImpl.notifyVideoUnavailable(reason);
        }

        @Override
        public void notifyContentAllowed() {
            mSessionImpl.notifyContentAllowed();
        }

        @Override
        public void notifyContentBlocked(String rating) {
            mSessionImpl.notifyContentBlocked(TvContentRating.unflattenFromString(rating));
        }

        @Override
        @Override
        public void setSurface(Surface surface) {
        public void setSurface(Surface surface) {
            mSessionImpl.setSurface(surface);
            mSessionImpl.setSurface(surface);
Loading