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

Commit b3544c15 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "MediaCas: rethrow MediaCas specific exception"

parents e259c2c4 dadee0c3
Loading
Loading
Loading
Loading
+29 −18
Original line number Diff line number Diff line
@@ -21818,23 +21818,23 @@ package android.media {
  }
  public final class MediaCas {
    ctor public MediaCas(int) throws android.media.UnsupportedCasException;
    ctor public MediaCas(int) throws android.media.MediaCasException.UnsupportedCasException;
    method public void closeSession(byte[]);
    method public static android.media.MediaCas.PluginDescriptor[] enumeratePlugins();
    method public static boolean isSystemIdSupported(int);
    method public byte[] openSession(int);
    method public byte[] openSession(int, int);
    method public void processEcm(byte[], byte[], int, int);
    method public void processEcm(byte[], byte[]);
    method public void processEmm(byte[], int, int);
    method public void processEmm(byte[]);
    method public void provision(java.lang.String);
    method public void refreshEntitlements(int, byte[]);
    method public byte[] openSession(int) throws android.media.MediaCasException;
    method public byte[] openSession(int, int) throws android.media.MediaCasException;
    method public void processEcm(byte[], byte[], int, int) throws android.media.MediaCasException;
    method public void processEcm(byte[], byte[]) throws android.media.MediaCasException;
    method public void processEmm(byte[], int, int) throws android.media.MediaCasException;
    method public void processEmm(byte[]) throws android.media.MediaCasException;
    method public void provision(java.lang.String) throws android.media.MediaCasException;
    method public void refreshEntitlements(int, byte[]) throws android.media.MediaCasException;
    method public void release();
    method public void sendEvent(int, int, byte[]);
    method public void sendEvent(int, int, byte[]) throws android.media.MediaCasException;
    method public void setEventListener(android.media.MediaCas.EventListener, android.os.Handler);
    method public void setPrivateData(byte[]);
    method public void setSessionPrivateData(byte[], byte[]);
    method public void setPrivateData(byte[]) throws android.media.MediaCasException;
    method public void setSessionPrivateData(byte[], byte[]) throws android.media.MediaCasException;
  }
  public static abstract interface MediaCas.EventListener {
@@ -21847,7 +21847,22 @@ package android.media {
  }
  public class MediaCasException extends java.lang.Exception {
    ctor public MediaCasException(java.lang.String);
  }
  public static final class MediaCasException.DeniedByServerException extends android.media.MediaCasException {
  }
  public static final class MediaCasException.NotProvisionedException extends android.media.MediaCasException {
  }
  public static final class MediaCasException.ResourceBusyException extends android.media.MediaCasException {
  }
  public static final class MediaCasException.UnsupportedCasException extends android.media.MediaCasException {
  }
  public class MediaCasStateException extends java.lang.IllegalStateException {
    method public java.lang.String getDiagnosticInfo();
  }
  public final class MediaCodec {
@@ -22275,7 +22290,7 @@ package android.media {
  }
  public final class MediaDescrambler {
    ctor public MediaDescrambler(int) throws android.media.UnsupportedCasException;
    ctor public MediaDescrambler(int) throws android.media.MediaCasException.UnsupportedCasException;
    method public final int descramble(java.nio.ByteBuffer, int, java.nio.ByteBuffer, int, android.media.MediaCodec.CryptoInfo);
    method public final void release();
    method public final boolean requiresSecureDecoderComponent(java.lang.String);
@@ -23586,10 +23601,6 @@ package android.media {
    field public static final int TONE_SUP_RINGTONE = 23; // 0x17
  }
  public final class UnsupportedCasException extends android.media.MediaCasException {
    ctor public UnsupportedCasException(java.lang.String);
  }
  public final class UnsupportedSchemeException extends android.media.MediaDrmException {
    ctor public UnsupportedSchemeException(java.lang.String);
  }
+29 −18
Original line number Diff line number Diff line
@@ -23605,23 +23605,23 @@ package android.media {
  }
  public final class MediaCas {
    ctor public MediaCas(int) throws android.media.UnsupportedCasException;
    ctor public MediaCas(int) throws android.media.MediaCasException.UnsupportedCasException;
    method public void closeSession(byte[]);
    method public static android.media.MediaCas.PluginDescriptor[] enumeratePlugins();
    method public static boolean isSystemIdSupported(int);
    method public byte[] openSession(int);
    method public byte[] openSession(int, int);
    method public void processEcm(byte[], byte[], int, int);
    method public void processEcm(byte[], byte[]);
    method public void processEmm(byte[], int, int);
    method public void processEmm(byte[]);
    method public void provision(java.lang.String);
    method public void refreshEntitlements(int, byte[]);
    method public byte[] openSession(int) throws android.media.MediaCasException;
    method public byte[] openSession(int, int) throws android.media.MediaCasException;
    method public void processEcm(byte[], byte[], int, int) throws android.media.MediaCasException;
    method public void processEcm(byte[], byte[]) throws android.media.MediaCasException;
    method public void processEmm(byte[], int, int) throws android.media.MediaCasException;
    method public void processEmm(byte[]) throws android.media.MediaCasException;
    method public void provision(java.lang.String) throws android.media.MediaCasException;
    method public void refreshEntitlements(int, byte[]) throws android.media.MediaCasException;
    method public void release();
    method public void sendEvent(int, int, byte[]);
    method public void sendEvent(int, int, byte[]) throws android.media.MediaCasException;
    method public void setEventListener(android.media.MediaCas.EventListener, android.os.Handler);
    method public void setPrivateData(byte[]);
    method public void setSessionPrivateData(byte[], byte[]);
    method public void setPrivateData(byte[]) throws android.media.MediaCasException;
    method public void setSessionPrivateData(byte[], byte[]) throws android.media.MediaCasException;
  }
  public static abstract interface MediaCas.EventListener {
@@ -23634,7 +23634,22 @@ package android.media {
  }
  public class MediaCasException extends java.lang.Exception {
    ctor public MediaCasException(java.lang.String);
  }
  public static final class MediaCasException.DeniedByServerException extends android.media.MediaCasException {
  }
  public static final class MediaCasException.NotProvisionedException extends android.media.MediaCasException {
  }
  public static final class MediaCasException.ResourceBusyException extends android.media.MediaCasException {
  }
  public static final class MediaCasException.UnsupportedCasException extends android.media.MediaCasException {
  }
  public class MediaCasStateException extends java.lang.IllegalStateException {
    method public java.lang.String getDiagnosticInfo();
  }
  public final class MediaCodec {
@@ -24062,7 +24077,7 @@ package android.media {
  }
  public final class MediaDescrambler {
    ctor public MediaDescrambler(int) throws android.media.UnsupportedCasException;
    ctor public MediaDescrambler(int) throws android.media.MediaCasException.UnsupportedCasException;
    method public final int descramble(java.nio.ByteBuffer, int, java.nio.ByteBuffer, int, android.media.MediaCodec.CryptoInfo);
    method public final void release();
    method public final boolean requiresSecureDecoderComponent(java.lang.String);
@@ -25384,10 +25399,6 @@ package android.media {
    field public static final int TONE_SUP_RINGTONE = 23; // 0x17
  }
  public final class UnsupportedCasException extends android.media.MediaCasException {
    ctor public UnsupportedCasException(java.lang.String);
  }
  public final class UnsupportedSchemeException extends android.media.MediaDrmException {
    ctor public UnsupportedSchemeException(java.lang.String);
  }
+29 −18
Original line number Diff line number Diff line
@@ -21929,23 +21929,23 @@ package android.media {
  }
  public final class MediaCas {
    ctor public MediaCas(int) throws android.media.UnsupportedCasException;
    ctor public MediaCas(int) throws android.media.MediaCasException.UnsupportedCasException;
    method public void closeSession(byte[]);
    method public static android.media.MediaCas.PluginDescriptor[] enumeratePlugins();
    method public static boolean isSystemIdSupported(int);
    method public byte[] openSession(int);
    method public byte[] openSession(int, int);
    method public void processEcm(byte[], byte[], int, int);
    method public void processEcm(byte[], byte[]);
    method public void processEmm(byte[], int, int);
    method public void processEmm(byte[]);
    method public void provision(java.lang.String);
    method public void refreshEntitlements(int, byte[]);
    method public byte[] openSession(int) throws android.media.MediaCasException;
    method public byte[] openSession(int, int) throws android.media.MediaCasException;
    method public void processEcm(byte[], byte[], int, int) throws android.media.MediaCasException;
    method public void processEcm(byte[], byte[]) throws android.media.MediaCasException;
    method public void processEmm(byte[], int, int) throws android.media.MediaCasException;
    method public void processEmm(byte[]) throws android.media.MediaCasException;
    method public void provision(java.lang.String) throws android.media.MediaCasException;
    method public void refreshEntitlements(int, byte[]) throws android.media.MediaCasException;
    method public void release();
    method public void sendEvent(int, int, byte[]);
    method public void sendEvent(int, int, byte[]) throws android.media.MediaCasException;
    method public void setEventListener(android.media.MediaCas.EventListener, android.os.Handler);
    method public void setPrivateData(byte[]);
    method public void setSessionPrivateData(byte[], byte[]);
    method public void setPrivateData(byte[]) throws android.media.MediaCasException;
    method public void setSessionPrivateData(byte[], byte[]) throws android.media.MediaCasException;
  }
  public static abstract interface MediaCas.EventListener {
@@ -21958,7 +21958,22 @@ package android.media {
  }
  public class MediaCasException extends java.lang.Exception {
    ctor public MediaCasException(java.lang.String);
  }
  public static final class MediaCasException.DeniedByServerException extends android.media.MediaCasException {
  }
  public static final class MediaCasException.NotProvisionedException extends android.media.MediaCasException {
  }
  public static final class MediaCasException.ResourceBusyException extends android.media.MediaCasException {
  }
  public static final class MediaCasException.UnsupportedCasException extends android.media.MediaCasException {
  }
  public class MediaCasStateException extends java.lang.IllegalStateException {
    method public java.lang.String getDiagnosticInfo();
  }
  public final class MediaCodec {
@@ -22386,7 +22401,7 @@ package android.media {
  }
  public final class MediaDescrambler {
    ctor public MediaDescrambler(int) throws android.media.UnsupportedCasException;
    ctor public MediaDescrambler(int) throws android.media.MediaCasException.UnsupportedCasException;
    method public final int descramble(java.nio.ByteBuffer, int, java.nio.ByteBuffer, int, android.media.MediaCodec.CryptoInfo);
    method public final void release();
    method public final boolean requiresSecureDecoderComponent(java.lang.String);
@@ -23697,10 +23712,6 @@ package android.media {
    field public static final int TONE_SUP_RINGTONE = 23; // 0x17
  }
  public final class UnsupportedCasException extends android.media.MediaCasException {
    ctor public UnsupportedCasException(java.lang.String);
  }
  public final class UnsupportedSchemeException extends android.media.MediaDrmException {
    ctor public UnsupportedSchemeException(java.lang.String);
  }
+69 −54
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.media;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.media.MediaCasException.*;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
@@ -28,6 +29,7 @@ import android.os.Parcelable;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceSpecificException;
import android.util.Log;
import android.util.Singleton;

@@ -84,8 +86,6 @@ import android.util.Singleton;
 * sessionId of the descrambler can be retrieved by {@link MediaExtractor#getDrmInitData}
 * and used to initialize a MediaDescrambler object for MediaCodec.
 * <p>
 * TODO: determine exception handling schemes.
 * <p>
 * <h3>Listeners</h3>
 * <p>The app may register a listener to receive events from the CA system using
 * method {@link #setEventListener}. The exact format of the event is scheme-specific
@@ -382,28 +382,22 @@ public final class MediaCas {
        mEventHandler = new EventHandler(looper);
    }

    /*
     * TODO: handle ServiceSpecificException from the IMediaCas
     * All Drm-specific failures will be thrown by mICas as
     * ServiceSpecificException exception with Drm error code.
     * These need to be re-thrown as crypto exceptions.
     */

    /**
     * Send the private data for the CA system.
     *
     * @param data byte array of the private data.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    /*
     * TODO: need to re-throw DRM-specific exceptions
     */
    public void setPrivateData(@NonNull byte[] data) {
    public void setPrivateData(@NonNull byte[] data) throws MediaCasException {
        validateInternalStates();

        try {
            mICas.setPrivateData(data);
        } catch (ServiceSpecificException e) {
            MediaCasException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
@@ -416,14 +410,17 @@ public final class MediaCas {
     *
     * @return session id of the newly opened session.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid,
     * or IllegalArgumentException if a session for the program already exists.
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    public byte[] openSession(int programNumber) {
    public byte[] openSession(int programNumber) throws MediaCasException {
        validateInternalStates();

        try {
            return mICas.openSession(programNumber);
        } catch (ServiceSpecificException e) {
            MediaCasException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
@@ -438,14 +435,18 @@ public final class MediaCas {
     *
     * @return session id of the newly opened session.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid,
     * or IllegalArgumentException if a session for the stream already exists.
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    public byte[] openSession(int programNumber, int elementaryPID) {
    public byte[] openSession(int programNumber, int elementaryPID)
            throws MediaCasException {
        validateInternalStates();

        try {
            return mICas.openSessionForStream(programNumber, elementaryPID);
        } catch (ServiceSpecificException e) {
            MediaCasException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
@@ -457,14 +458,16 @@ public final class MediaCas {
     *
     * @param sessionId the session to be closed.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid,
     * or IllegalArgumentException if the session is not valid.
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    public void closeSession(@NonNull byte[] sessionId) {
        validateInternalStates();

        try {
            mICas.closeSession(sessionId);
        } catch (ServiceSpecificException e) {
            MediaCasStateException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
@@ -476,17 +479,18 @@ public final class MediaCas {
     * @param sessionId the session for which the private data is intended.
     * @param data byte array of the private data.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid,
     * or IllegalArgumentException if the session is not valid.
     */
    /*
     * TODO: need to re-throw DRM-specific exceptions
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    public void setSessionPrivateData(@NonNull byte[] sessionId, @NonNull byte[] data) {
    public void setSessionPrivateData(@NonNull byte[] sessionId, @NonNull byte[] data)
            throws MediaCasException {
        validateInternalStates();

        try {
            mICas.setSessionPrivateData(sessionId, data);
        } catch (ServiceSpecificException e) {
            MediaCasException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
@@ -500,19 +504,19 @@ public final class MediaCas {
     * @param offset position within data where the ECM data begins.
     * @param length length of the data (starting from offset).
     *
     * @throws IllegalStateException if the MediaCas instance is not valid,
     * or IllegalArgumentException if the session is not valid.
     */
    /*
     * TODO: need to re-throw DRM-specific exceptions
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    public void processEcm(
            @NonNull byte[] sessionId, @NonNull byte[] data, int offset, int length) {
    public void processEcm(@NonNull byte[] sessionId, @NonNull byte[] data,
            int offset, int length) throws MediaCasException {
        validateInternalStates();

        try {
            mCasData.set(data, offset, length);
            mICas.processEcm(sessionId, mCasData);
        } catch (ServiceSpecificException e) {
            MediaCasException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
@@ -526,13 +530,12 @@ public final class MediaCas {
     * @param sessionId the session for which the ECM is intended.
     * @param data byte array of the ECM data.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid,
     * or IllegalArgumentException if the session is not valid.
     */
    /*
     * TODO: need to re-throw DRM-specific exceptions
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    public void processEcm(@NonNull byte[] sessionId, @NonNull byte[] data) {
    public void processEcm(@NonNull byte[] sessionId, @NonNull byte[] data)
            throws MediaCasException {
        processEcm(sessionId, data, 0, data.length);
    }

@@ -544,16 +547,18 @@ public final class MediaCas {
     * @param length length of the data (starting from offset).
     *
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    /*
     * TODO: need to re-throw DRM-specific exceptions
     */
    public void processEmm(@NonNull byte[] data, int offset, int length) {
    public void processEmm(@NonNull byte[] data, int offset, int length)
            throws MediaCasException {
        validateInternalStates();

        try {
            mCasData.set(data, offset, length);
            mICas.processEmm(mCasData);
        } catch (ServiceSpecificException e) {
            MediaCasException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
@@ -567,11 +572,10 @@ public final class MediaCas {
     * @param data byte array of the EMM data.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    /*
     * TODO: need to re-throw DRM-specific exceptions
     */
    public void processEmm(@NonNull byte[] data) {
    public void processEmm(@NonNull byte[] data) throws MediaCasException {
        processEmm(data, 0, data.length);
    }

@@ -584,12 +588,17 @@ public final class MediaCas {
     * @param data a byte array containing scheme-specific data for the event.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    public void sendEvent(int event, int arg, @Nullable byte[] data) {
    public void sendEvent(int event, int arg, @Nullable byte[] data)
            throws MediaCasException {
        validateInternalStates();

        try {
            mICas.sendEvent(event, arg, data);
        } catch (ServiceSpecificException e) {
            MediaCasException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
@@ -603,12 +612,16 @@ public final class MediaCas {
     * specific.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    public void provision(@NonNull String provisionString) {
    public void provision(@NonNull String provisionString) throws MediaCasException {
        validateInternalStates();

        try {
            mICas.provision(provisionString);
        } catch (ServiceSpecificException e) {
            MediaCasException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
@@ -621,15 +634,17 @@ public final class MediaCas {
     * @param refreshData private data associated with the refreshment.
     *
     * @throws IllegalStateException if the MediaCas instance is not valid.
     * @throws MediaCasException for CAS-specific errors.
     * @throws MediaCasStateException for CAS-specific state exceptions.
     */
    /*
     * TODO: define enums for refreshType
     */
    public void refreshEntitlements(int refreshType, @Nullable byte[] refreshData) {
    public void refreshEntitlements(int refreshType, @Nullable byte[] refreshData)
            throws MediaCasException {
        validateInternalStates();

        try {
            mICas.refreshEntitlements(refreshType, refreshData);
        } catch (ServiceSpecificException e) {
            MediaCasException.throwExceptions(e);
        } catch (RemoteException e) {
            cleanupAndRethrowIllegalState();
        }
+93 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading