MediaSession.ControllerInfo


class MediaSession.ControllerInfo


Information of a MediaController or a MediaBrowser.

Summary

Constants

const String!
@UnstableApi
FALLBACK_PACKAGE_NAME = "androidx.media3.session.MediaSessionService"

The getPackageName of a fallback ControllerInfo created by MediaSessionService when a more specific package name is not available (for example, when the service is started by a media button intent without a component name, or restarted by the system after a crash).

const Int

The getInterfaceVersion interface version} of a platform android.media.session.MediaController or legacy android.support.v4.media.session.MediaControllerCompat.

const String!
LEGACY_CONTROLLER_PACKAGE_NAME = "android.media.session.MediaController"

The getPackageName of a platform android.media.session.MediaController or legacy android.support.v4.media.session.MediaControllerCompat if a more precise package cannot be obtained.

const Int

The controller version of a platform android.media.session.MediaController or legacy android.support.v4.media.session.MediaControllerCompat.

const String!
@UnstableApi
TYPE_CRASH_RECOVERY = "androidx.media3.session.sticky.crash"

The value for CONNECTION_HINT_KEY_CONTROLLER_INFO_TYPE in getConnectionHints when a fallback ControllerInfo is created because MediaSessionService was restarted by the system after a crash with a null intent (START_STICKY).

Public functions

java-static MediaSession.ControllerInfo!
@UnstableApi
@VisibleForTesting(otherwise = 2)
createTestOnlyControllerInfo(
    packageName: String!,
    pid: Int,
    uid: Int,
    libraryVersion: Int,
    interfaceVersion: Int,
    trusted: Boolean,
    connectionHints: Bundle!,
    isPackageNameVerified: Boolean
)

Returns a ControllerInfo suitable for use when testing client code.

Boolean
equals(obj: Any?)
Int

Returns the library version of the controller.

String!

Returns the package name, or LEGACY_CONTROLLER_PACKAGE_NAME if the package name cannot be obtained.

Int

Returns the UID of the controller.

Int
String!

Constants

FALLBACK_PACKAGE_NAME

@UnstableApi
const val FALLBACK_PACKAGE_NAME = "androidx.media3.session.MediaSessionService": String!

The getPackageName of a fallback ControllerInfo created by MediaSessionService when a more specific package name is not available (for example, when the service is started by a media button intent without a component name, or restarted by the system after a crash).

LEGACY_CONTROLLER_INTERFACE_VERSION

@UnstableApi
const val LEGACY_CONTROLLER_INTERFACE_VERSION = 0: Int

The getInterfaceVersion interface version} of a platform android.media.session.MediaController or legacy android.support.v4.media.session.MediaControllerCompat.

LEGACY_CONTROLLER_PACKAGE_NAME

const val LEGACY_CONTROLLER_PACKAGE_NAME = "android.media.session.MediaController": String!

The getPackageName of a platform android.media.session.MediaController or legacy android.support.v4.media.session.MediaControllerCompat if a more precise package cannot be obtained.

LEGACY_CONTROLLER_VERSION

const val LEGACY_CONTROLLER_VERSION = 0: Int

The controller version of a platform android.media.session.MediaController or legacy android.support.v4.media.session.MediaControllerCompat.

TYPE_CRASH_RECOVERY

@UnstableApi
const val TYPE_CRASH_RECOVERY = "androidx.media3.session.sticky.crash": String!

The value for CONNECTION_HINT_KEY_CONTROLLER_INFO_TYPE in getConnectionHints when a fallback ControllerInfo is created because MediaSessionService was restarted by the system after a crash with a null intent (START_STICKY).

Public functions

createTestOnlyControllerInfo

@UnstableApi
@VisibleForTesting(otherwise = 2)
java-static fun createTestOnlyControllerInfo(
    packageName: String!,
    pid: Int,
    uid: Int,
    libraryVersion: Int,
    interfaceVersion: Int,
    trusted: Boolean,
    connectionHints: Bundle!,
    isPackageNameVerified: Boolean
): MediaSession.ControllerInfo!

Returns a ControllerInfo suitable for use when testing client code.

equals

fun equals(obj: Any?): Boolean

getControllerVersion

fun getControllerVersion(): Int

Returns the library version of the controller.

It will be the same as VERSION_INT of the controller, or LEGACY_CONTROLLER_VERSION if the controller is a platform android.media.session.MediaController or legacy android.support.v4.media.session.MediaControllerCompat.

getPackageName

fun getPackageName(): String!

Returns the package name, or 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 SessionToken and the app's package is not visible from this app. Refer to the package visibility guidelines for more details and how to ensure specific packages are visible if required.

getUid

fun getUid(): Int

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

fun hashCode(): Int

toString

fun toString(): String!

Public properties

connectionHints

val connectionHints: Bundle!

interfaceVersion

val interfaceVersion: Int

isPackageNameVerified

val isPackageNameVerified: Boolean

isTrusted

val isTrusted: Boolean

maxCommandsForMediaItems

val maxCommandsForMediaItems: Int