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

Commit 09426da1 authored by David Zhao's avatar David Zhao Committed by Android (Google) Code Review
Browse files

Merge "Add requestSigning with SSL host" into main

parents 9614500d a433ded5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ oneway interface ITvInteractiveAppClient {
    void onRequestTvRecordingInfoList(in int type, int seq);
    void onRequestSigning(in String id, in String algorithm, in String alias, in byte[] data,
            int seq);
    void onRequestSigning2(in String id, in String algorithm, in String host,
            int port, in byte[] data, int seq);
    void onRequestCertificate(in String host, int port, int seq);
    void onAdRequest(in AdRequest request, int Seq);
}
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ oneway interface ITvInteractiveAppSessionCallback {
    void onRequestTvRecordingInfo(in String recordingId);
    void onRequestTvRecordingInfoList(in int type);
    void onRequestSigning(in String id, in String algorithm, in String alias, in byte[] data);
    void onRequestSigning2(in String id, in String algorithm, in String host, int port, in byte[] data);
    void onRequestCertificate(in String host, int port);
    void onAdRequest(in AdRequest request);
}
+43 −0
Original line number Diff line number Diff line
@@ -656,6 +656,19 @@ public final class TvInteractiveAppManager {
                }
            }

            @Override
            public void onRequestSigning2(
                    String id, String algorithm, String host, int port, byte[] data, int seq) {
                synchronized (mSessionCallbackRecordMap) {
                    SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
                    if (record == null) {
                        Log.e(TAG, "Callback not found for seq " + seq);
                        return;
                    }
                    record.postRequestSigning(id, algorithm, host, port, data);
                }
            }

            @Override
            public void onRequestCertificate(String host, int port, int seq) {
                synchronized (mSessionCallbackRecordMap) {
@@ -2258,6 +2271,17 @@ public final class TvInteractiveAppManager {
            });
        }

        void postRequestSigning(String id, String algorithm, String host, int port,
                byte[] data) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    mSessionCallback.onRequestSigning(mSession, id, algorithm, host,
                            port, data);
                }
            });
        }

        void postRequestCertificate(String host, int port) {
            mHandler.post(new Runnable() {
                @Override
@@ -2608,6 +2632,25 @@ public final class TvInteractiveAppManager {
                Session session, String signingId, String algorithm, String alias, byte[] data) {
        }

        /**
         * This is called when
         * {@link TvInteractiveAppService.Session#requestSigning(String, String, String, int, byte[])} is
         * called.
         *
         * @param session A {@link TvInteractiveAppService.Session} associated with this callback.
         * @param signingId the ID to identify the request.
         * @param algorithm the standard name of the signature algorithm requested, such as
         *                  MD5withRSA, SHA256withDSA, etc.
         * @param host The host of the SSL CLient Authentication Server
         * @param port The port of the SSL Client Authentication Server
         * @param data the original bytes to be signed.
         * @hide
         */
        public void onRequestSigning(
                Session session, String signingId, String algorithm, String host,
                int port, byte[] data) {
        }

        /**
         * This is called when the service requests a SSL certificate for client validation.
         *
+44 −0
Original line number Diff line number Diff line
@@ -1644,6 +1644,50 @@ public abstract class TvInteractiveAppService extends Service {
            });
        }

        /**
         * Requests signing of the given data.
         *
         * <p>This is used when the corresponding server of the broadcast-independent interactive
         * app requires signing during handshaking, and the interactive app service doesn't have
         * the built-in private key. The private key is provided by the content providers and
         * pre-built in the related app, such as TV app.
         *
         * @param signingId the ID to identify the request. When a result is received, this ID can
         *                  be used to correlate the result with the request.
         * @param algorithm the standard name of the signature algorithm requested, such as
         *                  MD5withRSA, SHA256withDSA, etc. The name is from standards like
         *                  FIPS PUB 186-4 and PKCS #1.
         * @param host the host of the SSL client authentication server.
         * @param port the port of the SSL client authentication server.
         * @param data the original bytes to be signed.
         *
         * @see #onSigningResult(String, byte[])
         * @see TvInteractiveAppView#createBiInteractiveApp(Uri, Bundle)
         * @see TvInteractiveAppView#BI_INTERACTIVE_APP_KEY_ALIAS
         * @hide
         */
        @CallSuper
        public void requestSigning(@NonNull String signingId, @NonNull String algorithm,
                @NonNull String host, int port, @NonNull byte[] data) {
            executeOrPostRunnableOnMainThread(new Runnable() {
                @MainThread
                @Override
                public void run() {
                    try {
                        if (DEBUG) {
                            Log.d(TAG, "requestSigning");
                        }
                        if (mSessionCallback != null) {
                            mSessionCallback.onRequestSigning2(signingId, algorithm,
                                    host, port, data);
                        }
                    } catch (RemoteException e) {
                        Log.w(TAG, "error in requestSigning", e);
                    }
                }
            });
        }

        /**
         * Requests a SSL certificate for client validation.
         *
+19 −0
Original line number Diff line number Diff line
@@ -4151,6 +4151,25 @@ public class TvInteractiveAppManagerService extends SystemService {
            }
        }

        @Override
        public void onRequestSigning2(String id, String algorithm, String host,
                int port, byte[] data) {
            synchronized (mLock) {
                if (DEBUG) {
                    Slogf.d(TAG, "onRequestSigning");
                }
                if (mSessionState.mSession == null || mSessionState.mClient == null) {
                    return;
                }
                try {
                    mSessionState.mClient.onRequestSigning2(
                            id, algorithm, host, port, data, mSessionState.mSeq);
                } catch (RemoteException e) {
                    Slogf.e(TAG, "error in onRequestSigning", e);
                }
            }
        }

        @Override
        public void onRequestCertificate(String host, int port) {
            synchronized (mLock) {