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

Commit 0cff75d3 authored by Shubang Lu's avatar Shubang Lu
Browse files

CSAI: handle surface

Bug: 319171218
Test: mmm
Change-Id: Ic21728e2ac02ede8d5ca76030055cf5ecf758c63
parent 013f571b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26,4 +26,5 @@ import android.view.InputChannel;
oneway interface ITvAdClient {
    void onSessionCreated(in String serviceId, IBinder token, in InputChannel channel, int seq);
    void onSessionReleased(int seq);
    void onLayoutSurface(int left, int top, int right, int bottom, int seq);
}
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.media.tv.ad;

import android.media.tv.ad.ITvAdClient;
import android.view.Surface;

/**
 * Interface to the TV AD service.
@@ -27,4 +28,7 @@ interface ITvAdManager {
            in ITvAdClient client, in String serviceId, in String type, int seq, int userId);
    void releaseSession(in IBinder sessionToken, int userId);
    void startAdService(in IBinder sessionToken, int userId);
    void setSurface(in IBinder sessionToken, in Surface surface, int userId);
    void dispatchSurfaceChanged(in IBinder sessionToken, int format, int width, int height,
            int userId);
}
+4 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.media.tv.ad;

import android.view.Surface;

/**
 * Sub-interface of ITvAdService.aidl which is created per session and has its own context.
 * @hide
@@ -23,4 +25,6 @@ package android.media.tv.ad;
oneway interface ITvAdSession {
    void release();
    void startAdService();
    void setSurface(in Surface surface);
    void dispatchSurfaceChanged(int format, int width, int height);
}
+1 −0
Original line number Diff line number Diff line
@@ -25,4 +25,5 @@ import android.media.tv.ad.ITvAdSession;
 */
oneway interface ITvAdSessionCallback {
    void onSessionCreated(in ITvAdSession session);
    void onLayoutSurface(int left, int top, int right, int bottom);
}
 No newline at end of file
+26 −0
Original line number Diff line number Diff line
@@ -24,8 +24,10 @@ import android.util.Log;
import android.view.InputChannel;
import android.view.InputEvent;
import android.view.InputEventReceiver;
import android.view.Surface;

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

/**
 * Implements the internal ITvAdSession interface.
@@ -39,6 +41,8 @@ public class ITvAdSessionWrapper
    private static final int EXECUTE_MESSAGE_TIMEOUT_SHORT_MILLIS = 1000;
    private static final int EXECUTE_MESSAGE_TIMEOUT_LONG_MILLIS = 5 * 1000;
    private static final int DO_RELEASE = 1;
    private static final int DO_SET_SURFACE = 2;
    private static final int DO_DISPATCH_SURFACE_CHANGED = 3;

    private final HandlerCaller mCaller;
    private TvAdService.Session mSessionImpl;
@@ -82,6 +86,17 @@ public class ITvAdSessionWrapper
                }
                break;
            }
            case DO_SET_SURFACE: {
                mSessionImpl.setSurface((Surface) msg.obj);
                break;
            }
            case DO_DISPATCH_SURFACE_CHANGED: {
                SomeArgs args = (SomeArgs) msg.obj;
                mSessionImpl.dispatchSurfaceChanged(
                        (Integer) args.argi1, (Integer) args.argi2, (Integer) args.argi3);
                args.recycle();
                break;
            }
            default: {
                Log.w(TAG, "Unhandled message code: " + msg.what);
                break;
@@ -103,6 +118,17 @@ public class ITvAdSessionWrapper

    }

    @Override
    public void setSurface(Surface surface) {
        mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_SURFACE, surface));
    }

    @Override
    public void dispatchSurfaceChanged(int format, int width, int height) {
        mCaller.executeOrSendMessage(
                mCaller.obtainMessageIIII(DO_DISPATCH_SURFACE_CHANGED, format, width, height, 0));
    }

    private final class TvAdEventReceiver extends InputEventReceiver {
        TvAdEventReceiver(InputChannel inputChannel, Looper looper) {
            super(inputChannel, looper);
Loading