# MediaSession.ControllerInfo

Artifact: [androidx.media3:media3-session](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/session/MediaSession.java+class:androidx.media3.session.MediaSession.ControllerInfo)

*** ** * ** ***


```
public final class MediaSession.ControllerInfo
```

<br />

*** ** * ** ***

Information of a `https://developer.android.com/reference/androidx/media3/session/MediaController` or a `https://developer.android.com/reference/androidx/media3/session/MediaBrowser`.

## Summary

| ### Constants |
|---|---|
| `static final int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#LEGACY_CONTROLLER_INTERFACE_VERSION() = 0` The `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getInterfaceVersion()` interface version} of a platform `https://developer.android.com/reference/android/media/session/MediaController.html` or legacy ` android.support.v4.media.session.MediaControllerCompat`. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#LEGACY_CONTROLLER_PACKAGE_NAME() = "android.media.session.MediaController"` The `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getPackageName()` of a platform `https://developer.android.com/reference/android/media/session/MediaController.html` or legacy `android.support.v4.media.session.MediaControllerCompat` if a more precise package cannot be obtained. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#LEGACY_CONTROLLER_VERSION() = 0` The `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getControllerVersion()` of a platform `https://developer.android.com/reference/android/media/session/MediaController.html` or legacy ` android.support.v4.media.session.MediaControllerCompat`. |

| ### Public fields |
|---|---|
| `final https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#connectionHints()` |
| `final int` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#interfaceVersion()` |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#isPackageNameVerified()` |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#isTrusted()` |
| `final int` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#maxCommandsForMediaItems()` |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/annotation/VisibleForTesting(otherwise = 2) https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#createTestOnlyControllerInfo(java.lang.String,int,int,int,int,boolean,android.os.Bundle,boolean)( https://developer.android.com/reference/java/lang/String.html packageName, int pid, int uid, int libraryVersion, int interfaceVersion, boolean trusted, https://developer.android.com/reference/android/os/Bundle.html connectionHints, boolean isPackageNameVerified )` Returns a `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo` suitable for use when testing client code. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` |
| `https://developer.android.com/reference/android/os/Bundle.html` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getConnectionHints()()` Returns the connection hints sent from controller. |
| `int` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getControllerVersion()()` Returns the library version of the controller. |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getInterfaceVersion()()` Returns the `https://developer.android.com/reference/androidx/media3/common/MediaLibraryInfo#INTERFACE_VERSION()` of the controller, or `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#LEGACY_CONTROLLER_INTERFACE_VERSION()` if the controller is a platform `https://developer.android.com/reference/android/media/session/MediaController.html` or legacy ` android.support.v4.media.session.MediaControllerCompat`. |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getMaxCommandsForMediaItems()()` Returns the max number of commands for a media item. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getPackageName()()` Returns the package name, or `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#LEGACY_CONTROLLER_PACKAGE_NAME()` if the package name cannot be obtained. |
| `int` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getUid()()` Returns the UID of the controller. |
| `int` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#hashCode()()` |
| `boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#isPackageNameVerified()()` Returns whether the value returned from `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getPackageName()` has been verified to be a valid package name belonging to `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getUid()`. |
| `boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#isTrusted()()` Returns whether the controller is trusted by the user to control and access media. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#toString()()` |

## Constants

### LEGACY_CONTROLLER_INTERFACE_VERSION

```
@UnstableApi
public static final int LEGACY_CONTROLLER_INTERFACE_VERSION = 0
```

The `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getInterfaceVersion()` interface version} of a platform `https://developer.android.com/reference/android/media/session/MediaController.html` or legacy `
android.support.v4.media.session.MediaControllerCompat`.

### LEGACY_CONTROLLER_PACKAGE_NAME

```
public static final String LEGACY_CONTROLLER_PACKAGE_NAME = "android.media.session.MediaController"
```

The `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getPackageName()` of a platform `https://developer.android.com/reference/android/media/session/MediaController.html` or legacy `android.support.v4.media.session.MediaControllerCompat` if a more precise package cannot be obtained.

### LEGACY_CONTROLLER_VERSION

```
public static final int LEGACY_CONTROLLER_VERSION = 0
```

The `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getControllerVersion()` of a platform `https://developer.android.com/reference/android/media/session/MediaController.html` or legacy `
android.support.v4.media.session.MediaControllerCompat`.

## Public fields

### connectionHints

```
public final Bundle connectionHints
```

### interfaceVersion

```
public final int interfaceVersion
```

### isPackageNameVerified

```
public final boolean isPackageNameVerified
```

### isTrusted

```
public final boolean isTrusted
```

### maxCommandsForMediaItems

```
public final int maxCommandsForMediaItems
```

## Public methods

### createTestOnlyControllerInfo

```
@UnstableApi
@VisibleForTesting(otherwise = 2)
public static MediaSession.ControllerInfo createTestOnlyControllerInfo(
    String packageName,
    int pid,
    int uid,
    int libraryVersion,
    int interfaceVersion,
    boolean trusted,
    Bundle connectionHints,
    boolean isPackageNameVerified
)
```

Returns a `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo` suitable for use when testing client code.

### equals

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

### getConnectionHints

```
public Bundle getConnectionHints()
```

Returns the connection hints sent from controller.

### getControllerVersion

```
public int getControllerVersion()
```

Returns the library version of the controller.

It will be the same as `https://developer.android.com/reference/androidx/media3/common/MediaLibraryInfo#VERSION_INT()` of the controller, or `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#LEGACY_CONTROLLER_VERSION()` if the controller is a platform `https://developer.android.com/reference/android/media/session/MediaController.html` or legacy `
android.support.v4.media.session.MediaControllerCompat`.

### getInterfaceVersion

```
@UnstableApi
public int getInterfaceVersion()
```

Returns the `https://developer.android.com/reference/androidx/media3/common/MediaLibraryInfo#INTERFACE_VERSION()` of the controller, or `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#LEGACY_CONTROLLER_INTERFACE_VERSION()` if the controller is a platform `https://developer.android.com/reference/android/media/session/MediaController.html` or legacy `
android.support.v4.media.session.MediaControllerCompat`.

### getMaxCommandsForMediaItems

```
@UnstableApi
public int getMaxCommandsForMediaItems()
```

Returns the max number of commands for a media item. A positive number or 0 (zero) to indicate that the feature is not supported by the controller.

### getPackageName

```
public String getPackageName()
```

Returns the package name, or `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#LEGACY_CONTROLLER_PACKAGE_NAME()` if the package name cannot be obtained.

In some cases the correctness of the package name cannot be verified, for example when a controller from another app connects directly with a `https://developer.android.com/reference/androidx/media3/session/SessionToken` and the app's package is not visible from this app. Refer to the [package visibility guidelines](https://developer.android.com/training/package-visibility) for more details and how to ensure specific packages are visible if required.

### getUid

```
public int getUid()
```

Returns the UID of the controller. Can be a negative value for interoperability.

Interoperability: If `SDK_INT < 28`, then UID would be a negative value because it cannot be obtained.

### hashCode

```
public int hashCode()
```

### isPackageNameVerified

```
@UnstableApi
public boolean isPackageNameVerified()
```

Returns whether the value returned from `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getPackageName()` has been verified to be a valid package name belonging to `https://developer.android.com/reference/androidx/media3/session/MediaSession.ControllerInfo#getUid()`.

### isTrusted

```
@UnstableApi
public boolean isTrusted()
```

Returns whether the controller is trusted by the user to control and access media.

One or more of the following must be true for the controller to be trusted:

- The controller is part of the current app and user (using `https://developer.android.com/reference/android/os/Process.html#myUid()`).
- The controller is part of the Android system (using `https://developer.android.com/reference/android/os/Process.html#SYSTEM_UID`).
- The controller has been granted `android.permission.MEDIA_CONTENT_CONTROL`.
- The controller has been granted `android.permission.STATUS_BAR_SERVICE`.
- The controller has an enabled notification listener.

### toString

```
public String toString()
```