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

Commit a759b111 authored by Jae Seo's avatar Jae Seo
Browse files

TIF: Add sendAppPrivateCommand()

Added a way to send a private command from the application to the TV
input. This can be used to provide domain-specific features that are
only known between certain TV inputs and their clients.

Change-Id: I7548311a64147b8ff27562ec680b941e2ec10bc0
parent a37cb8b6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.media.tv.TvInputHardwareInfo;
import android.media.tv.TvInputInfo;
import android.media.tv.TvTrackInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.Surface;

/**
@@ -51,6 +52,9 @@ interface ITvInputManager {
    void selectTrack(in IBinder sessionToken, in TvTrackInfo track, int userId);
    void unselectTrack(in IBinder sessionToken, in TvTrackInfo track, int userId);

    void sendAppPrivateCommand(in IBinder sessionToken, in String action, in Bundle data,
            int userId);

    void createOverlayView(in IBinder sessionToken, in IBinder windowToken, in Rect frame,
            int userId);
    void relayoutOverlayView(in IBinder sessionToken, in Rect frame, int userId);
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.media.tv;
import android.graphics.Rect;
import android.media.tv.TvTrackInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.Surface;

/**
@@ -38,6 +39,8 @@ oneway interface ITvInputSession {
    void selectTrack(in TvTrackInfo track);
    void unselectTrack(in TvTrackInfo track);

    void appPrivateCommand(in String action, in Bundle data);

    void createOverlayView(in IBinder windowToken, in Rect frame);
    void relayoutOverlayView(in Rect frame);
    void removeOverlayView();
+18 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.media.tv;
import android.content.Context;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
@@ -48,10 +49,11 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
    private static final int DO_SET_CAPTION_ENABLED = 6;
    private static final int DO_SELECT_TRACK = 7;
    private static final int DO_UNSELECT_TRACK = 8;
    private static final int DO_CREATE_OVERLAY_VIEW = 9;
    private static final int DO_RELAYOUT_OVERLAY_VIEW = 10;
    private static final int DO_REMOVE_OVERLAY_VIEW = 11;
    private static final int DO_REQUEST_UNBLOCK_CONTENT = 12;
    private static final int DO_APP_PRIVATE_COMMAND = 9;
    private static final int DO_CREATE_OVERLAY_VIEW = 10;
    private static final int DO_RELAYOUT_OVERLAY_VIEW = 11;
    private static final int DO_REMOVE_OVERLAY_VIEW = 12;
    private static final int DO_REQUEST_UNBLOCK_CONTENT = 13;

    private final HandlerCaller mCaller;

@@ -119,6 +121,12 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
                mTvInputSessionImpl.unselectTrack((TvTrackInfo) msg.obj);
                return;
            }
            case DO_APP_PRIVATE_COMMAND: {
                SomeArgs args = (SomeArgs) msg.obj;
                mTvInputSessionImpl.appPrivateCommand((String) args.arg1, (Bundle) args.arg2);
                args.recycle();
                return;
            }
            case DO_CREATE_OVERLAY_VIEW: {
                SomeArgs args = (SomeArgs) msg.obj;
                mTvInputSessionImpl.createOverlayView((IBinder) args.arg1, (Rect) args.arg2);
@@ -185,6 +193,12 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_UNSELECT_TRACK, track));
    }

    @Override
    public void appPrivateCommand(String action, Bundle data) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_APP_PRIVATE_COMMAND, action,
                data));
    }

    @Override
    public void createOverlayView(IBinder windowToken, Rect frame) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_CREATE_OVERLAY_VIEW, windowToken,
+24 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.media.tv;

import android.annotation.SystemApi;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
@@ -893,6 +894,29 @@ public final class TvInputManager {
            mTracks = tracks;
        }

        /**
         * Call {@link TvInputService.Session#appPrivateCommand(String, Bundle)
         * TvInputService.Session.appPrivateCommand()} on the current TvView.
         *
         * @param action Name of the command to be performed. This <em>must</em> be a scoped name,
         *            i.e. prefixed with a package name you own, so that different developers will
         *            not create conflicting commands.
         * @param data Any data to include with the command.
         * @hide
         */
        @SystemApi
        public void sendAppPrivateCommand(String action, Bundle data) {
            if (mToken == null) {
                Log.w(TAG, "The session has been already released");
                return;
            }
            try {
                mService.sendAppPrivateCommand(mToken, action, data, mUserId);
            } catch (RemoteException e) {
                throw new RuntimeException(e);
            }
        }

        /**
         * Creates an overlay view. Once the overlay view is created, {@link #relayoutOverlayView}
         * should be called whenever the layout of its containing view is changed.
+22 −0
Original line number Diff line number Diff line
@@ -518,6 +518,21 @@ public abstract class TvInputService extends Service {
            return false;
        }

        /**
         * Processes a private command sent from the application to the TV input. This can be used
         * to provide domain-specific features that are only known between certain TV inputs and
         * their clients.
         *
         * @param action Name of the command to be performed. This <em>must</em> be a scoped name,
         *            i.e. prefixed with a package name you own, so that different developers will
         *            not create conflicting commands.
         * @param data Any data to include with the command.
         * @hide
         */
        @SystemApi
        public void onAppPrivateCommand(String action, Bundle data) {
        }

        /**
         * Called when an application requests to create an overlay view. Each session
         * implementation can override this method and return its own view.
@@ -725,6 +740,13 @@ public abstract class TvInputService extends Service {
            // TODO: Handle failure.
        }

        /**
         * Calls {@link #onAppPrivateCommand}.
         */
        void appPrivateCommand(String action, Bundle data) {
            onAppPrivateCommand(action, data);
        }

        /**
         * Creates an overlay view. This calls {@link #onCreateOverlayView} to get a view to attach
         * to the overlay window.
Loading