MediaSession.ControllerInfo


public final class MediaSession.ControllerInfo


Information of a MediaController or a MediaBrowser.

Summary

Constants

static final int

The getInterfaceVersion interface version} of legacy controllers.

static final int

The controller version of legacy controllers.

Public fields

final Bundle
final int
final boolean

Public methods

static MediaSession.ControllerInfo
@VisibleForTesting(otherwise = 2)
createTestOnlyControllerInfo(
    MediaSessionManager.RemoteUserInfo remoteUserInfo,
    int libraryVersion,
    int interfaceVersion,
    boolean trusted,
    Bundle connectionHints
)

Returns a ControllerInfo suitable for use when testing client code.

boolean
Bundle

Returns the connection hints sent from controller.

int

Returns the library version of the controller.

int

Returns the interface version of the controller, or 0 if it's a legacy controller.

String

Returns the package name.

int

Returns the UID of the controller.

int
boolean

Returns if the controller has been granted android.permission.MEDIA_CONTENT_CONTROL or has an enabled notification listener so it can be trusted to accept connection and incoming command requests.

String

Constants

LEGACY_CONTROLLER_INTERFACE_VERSION

@UnstableApi
public static final int LEGACY_CONTROLLER_INTERFACE_VERSION = 0

The getInterfaceVersion interface version} of legacy controllers.

LEGACY_CONTROLLER_VERSION

public static final int LEGACY_CONTROLLER_VERSION = 0

The controller version of legacy controllers.

Public fields

connectionHints

public final Bundle connectionHints

interfaceVersion

public final int interfaceVersion

isTrusted

public final boolean isTrusted

Public methods

createTestOnlyControllerInfo

@VisibleForTesting(otherwise = 2)
public static MediaSession.ControllerInfo createTestOnlyControllerInfo(
    MediaSessionManager.RemoteUserInfo remoteUserInfo,
    int libraryVersion,
    int interfaceVersion,
    boolean trusted,
    Bundle connectionHints
)

Returns a 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 VERSION_INT of the controller, or less than 1000000 if the controller is a legacy controller.

getInterfaceVersion

@UnstableApi
public int getInterfaceVersion()

Returns the interface version of the controller, or 0 if it's a legacy controller.

getPackageName

public String getPackageName()

Returns the package name. Can be LEGACY_CONTROLLER for interoperability.

Interoperability: Package name may not be precisely obtained for legacy controller API on older device. Here are details.

Summary when package name isn't precise
SDK version when package name isn't precise for legacy controller
SDK_INT < 21 Actual package name via getNameForUid with UID. It's sufficient for most cases, but doesn't precisely distinguish caller if it uses shared user ID.
21 <= SDK_INT < 24 LEGACY_CONTROLLER

getUid

public int getUid()

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

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

hashCode

public int hashCode()

isTrusted

@UnstableApi
public boolean isTrusted()

Returns if the controller has been granted android.permission.MEDIA_CONTENT_CONTROL or has an enabled notification listener so it can be trusted to accept connection and incoming command requests.

toString

public String toString()