# MediaCas.Session

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Methods](https://developer.android.com/reference/android/media/MediaCas.Session#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/media/MediaCas.Session#inhmethods)  

# MediaCas.Session

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/media/MediaCas.Session "View this page in Kotlin")\|Java

`
public

final

class
MediaCas.Session
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable)`


`

|---|--------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.MediaCas.Session |

<br />

*** ** * ** ***

Class for an open session with the CA system.

## Summary

|                                                                                                                   ### Public methods                                                                                                                   ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`    | ` `[close](https://developer.android.com/reference/android/media/MediaCas.Session#close())`() ` Close the session.                                                                                                                         |
| ` boolean` | ` `[equals](https://developer.android.com/reference/android/media/MediaCas.Session#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Query if an object equal current Session object. |
| ` byte[]`  | ` `[getSessionId](https://developer.android.com/reference/android/media/MediaCas.Session#getSessionId())`() ` Get Session Id.                                                                                                              |
| ` void`    | ` `[processEcm](https://developer.android.com/reference/android/media/MediaCas.Session#processEcm(byte[]))`(byte[] data) ` Send a received ECM packet to the specified session of the CA system.                                           |
| ` void`    | ` `[processEcm](https://developer.android.com/reference/android/media/MediaCas.Session#processEcm(byte[],%20int,%20int))`(byte[] data, int offset, int length) ` Send a received ECM packet to the specified session of the CA system.     |
| ` void`    | ` `[sendSessionEvent](https://developer.android.com/reference/android/media/MediaCas.Session#sendSessionEvent(int,%20int,%20byte[]))`(int event, int arg, byte[] data) ` Send a session event to a CA system.                              |
| ` void`    | ` `[setPrivateData](https://developer.android.com/reference/android/media/MediaCas.Session#setPrivateData(byte[]))`(byte[] data) ` Set the private data for a session.                                                                     |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/lang/AutoCloseable#close())`() ` Closes this resource, relinquishing any underlying resources. | ||

## Public methods

### close

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void close ()
```

Close the session.

<br />

|                                                                     Throws                                                                     ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if the MediaCas instance is not valid. |
| [MediaCasStateException](https://developer.android.com/reference/android/media/MediaCasStateException) | for CAS-specific state exceptions.     |

### equals

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public boolean equals (Object obj)
```

Query if an object equal current Session object.

<br />

|                               Parameters                                ||
|-------|------------------------------------------------------------------|
| `obj` | `Object`: an object to compare to current Session object. <br /> |

|                               Returns                                ||
|-----------|-----------------------------------------------------------|
| `boolean` | Whether input object equal current Session object. <br /> |

### getSessionId

Added in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public byte[] getSessionId ()
```

Get Session Id.

<br />

|                                 Returns                                 ||
|----------|---------------------------------------------------------------|
| `byte[]` | session Id of the session. This value cannot be`null`. <br /> |

|                                                                  Throws                                                                  ||
|--------------------------------------------------------------------------------------------------|----------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if the MediaCas instance is not valid. |

### processEcm

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void processEcm (byte[] data)
```

Send a received ECM packet to the specified session of the CA system. This is similar to[Session.processEcm(byte[], int, int)](https://developer.android.com/reference/android/media/MediaCas.Session#processEcm(byte[],%20int,%20int))except that the entire byte array is sent.

<br />

|                                   Parameters                                   ||
|--------|------------------------------------------------------------------------|
| `data` | `byte`: byte array of the ECM data. This value cannot be`null`. <br /> |

|                                                                     Throws                                                                     ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if the MediaCas instance is not valid. |
| [MediaCasException](https://developer.android.com/reference/android/media/MediaCasException)           | for CAS-specific errors.               |
| [MediaCasStateException](https://developer.android.com/reference/android/media/MediaCasStateException) | for CAS-specific state exceptions.     |

### processEcm

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void processEcm (byte[] data, 
                int offset, 
                int length)
```

Send a received ECM packet to the specified session of the CA system.

<br />

|                                    Parameters                                    ||
|----------|------------------------------------------------------------------------|
| `data`   | `byte`: byte array of the ECM data. This value cannot be`null`. <br /> |
| `offset` | `int`: position within data where the ECM data begins. <br />          |
| `length` | `int`: length of the data (starting from offset). <br />               |

|                                                                     Throws                                                                     ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if the MediaCas instance is not valid. |
| [MediaCasException](https://developer.android.com/reference/android/media/MediaCasException)           | for CAS-specific errors.               |
| [MediaCasStateException](https://developer.android.com/reference/android/media/MediaCasStateException) | for CAS-specific state exceptions.     |

### sendSessionEvent

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void sendSessionEvent (int event, 
                int arg, 
                byte[] data)
```

Send a session event to a CA system. The format of the event is scheme-specific and is opaque to the framework.

<br />

|                                                  Parameters                                                  ||
|---------|-----------------------------------------------------------------------------------------------------|
| `event` | `int`: an integer denoting a scheme-specific event to be sent. <br />                               |
| `arg`   | `int`: a scheme-specific integer argument for the event. <br />                                     |
| `data`  | `byte`: a byte array containing scheme-specific data for the event. This value may be`null`. <br /> |

|                                                                     Throws                                                                     ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if the MediaCas instance is not valid. |
| [MediaCasException](https://developer.android.com/reference/android/media/MediaCasException)           | for CAS-specific errors.               |
| [MediaCasStateException](https://developer.android.com/reference/android/media/MediaCasStateException) | for CAS-specific state exceptions.     |

### setPrivateData

Added in[API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setPrivateData (byte[] data)
```

Set the private data for a session.

<br />

|                                     Parameters                                     ||
|--------|----------------------------------------------------------------------------|
| `data` | `byte`: byte array of the private data. This value cannot be`null`. <br /> |

|                                                                     Throws                                                                     ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)       | if the MediaCas instance is not valid. |
| [MediaCasException](https://developer.android.com/reference/android/media/MediaCasException)           | for CAS-specific errors.               |
| [MediaCasStateException](https://developer.android.com/reference/android/media/MediaCasStateException) | for CAS-specific state exceptions.     |