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

Commit 9a22f0f0 authored by Youngsang Cho's avatar Youngsang Cho
Browse files

Add overlay view in Tv Input Framework

A TvInputService app developers sometimes want to draw UI above a surface
playing TV. For this purpose, we add a window in TIS and allow developers to
attach their customized view on the TV surface.

Change-Id: I65c3dffa17580b8d4c42fac58bbfc8dad338c185
parent a2c8a1b8
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -27822,7 +27822,6 @@ package android.tv {
  public static final class TvInputManager.Session {
    method public void release();
    method public void setSurface(android.view.Surface);
    method public void setVolume(float);
    method public void tune(android.net.Uri);
  }
@@ -27844,12 +27843,22 @@ package android.tv {
    field public static final java.lang.String SERVICE_INTERFACE = "android.tv.TvInputService";
  }
  public static abstract class TvInputService.TvInputSessionImpl {
  public abstract class TvInputService.TvInputSessionImpl {
    ctor public TvInputService.TvInputSessionImpl();
    method public android.view.View onCreateOverlayView();
    method public abstract void onRelease();
    method public abstract boolean onSetSurface(android.view.Surface);
    method public abstract void onSetVolume(float);
    method public abstract boolean onTune(android.net.Uri);
    method public void setOverlayViewEnabled(boolean);
  }
  public class TvView extends android.view.SurfaceView {
    ctor public TvView(android.content.Context);
    ctor public TvView(android.content.Context, android.util.AttributeSet);
    ctor public TvView(android.content.Context, android.util.AttributeSet, int);
    method public void bindTvInput(android.content.ComponentName, android.tv.TvInputManager.SessionCreateCallback);
    method public void unbindTvInput();
  }
}
+6 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.tv;

import android.content.ComponentName;
import android.graphics.Rect;
import android.net.Uri;
import android.tv.ITvInputClient;
import android.tv.TvInputInfo;
@@ -40,4 +41,9 @@ interface ITvInputManager {
    void setSurface(in IBinder sessionToken, in Surface surface, int userId);
    void setVolume(in IBinder sessionToken, float volume, int userId);
    void tune(in IBinder sessionToken, in Uri channelUri, 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);
    void removeOverlayView(in IBinder sessionToken, int userId);
}
+0 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.tv;

import android.tv.ITvInputServiceCallback;
import android.tv.ITvInputSession;
import android.tv.ITvInputSessionCallback;

/**
+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.tv;

import android.graphics.Rect;
import android.net.Uri;
import android.view.Surface;

@@ -31,4 +32,8 @@ oneway interface ITvInputSession {
    // is to introduce some new concepts that will solve a number of problems in audio policy today.
    void setVolume(float volume);
    void tune(in Uri channelUri);

    void createOverlayView(in IBinder windowToken, in Rect frame);
    void relayoutOverlayView(in Rect frame);
    void removeOverlayView();
}
+36 −0
Original line number Diff line number Diff line
@@ -17,13 +17,16 @@
package android.tv;

import android.content.Context;
import android.graphics.Rect;
import android.net.Uri;
import android.os.IBinder;
import android.os.Message;
import android.tv.TvInputService.TvInputSessionImpl;
import android.util.Log;
import android.view.Surface;

import com.android.internal.os.HandlerCaller;
import com.android.internal.os.SomeArgs;

/**
 * Implements the internal ITvInputSession interface to convert incoming calls on to it back to
@@ -38,6 +41,9 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
    private static final int DO_SET_SURFACE = 2;
    private static final int DO_SET_VOLUME = 3;
    private static final int DO_TUNE = 4;
    private static final int DO_CREATE_OVERLAY_VIEW = 5;
    private static final int DO_RELAYOUT_OVERLAY_VIEW = 6;
    private static final int DO_REMOVE_OVERLAY_VIEW = 7;

    private TvInputSessionImpl mTvInputSession;
    private final HandlerCaller mCaller;
@@ -71,6 +77,20 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
                mTvInputSession.tune((Uri) msg.obj);
                return;
            }
            case DO_CREATE_OVERLAY_VIEW: {
                SomeArgs args = (SomeArgs) msg.obj;
                mTvInputSession.createOverlayView((IBinder) args.arg1, (Rect) args.arg2);
                args.recycle();
                return;
            }
            case DO_RELAYOUT_OVERLAY_VIEW: {
                mTvInputSession.relayoutOverlayView((Rect) msg.obj);
                return;
            }
            case DO_REMOVE_OVERLAY_VIEW: {
                mTvInputSession.removeOverlayView(true);
                return;
            }
            default: {
                Log.w(TAG, "Unhandled message code: " + msg.what);
                return;
@@ -97,4 +117,20 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
    public void tune(Uri channelUri) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_TUNE, channelUri));
    }

    @Override
    public void createOverlayView(IBinder windowToken, Rect frame) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_CREATE_OVERLAY_VIEW, windowToken,
                frame));
    }

    @Override
    public void relayoutOverlayView(Rect frame) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_RELAYOUT_OVERLAY_VIEW, frame));
    }

    @Override
    public void removeOverlayView() {
        mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_REMOVE_OVERLAY_VIEW));
    }
}
Loading