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 String
LEGACY_CONTROLLER_PACKAGE_NAME = "android.media.session.MediaController"

The getPackageName of legacy controllers if a more precise package cannot be obtained.

static final int

The controller version of legacy controllers.

Public fields

final Bundle
final int
final boolean
final int

Public methods

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

This method is deprecated.

Use createTestOnlyControllerInfo instead.

static MediaSession.ControllerInfo
@VisibleForTesting(otherwise = 2)
createTestOnlyControllerInfo(
    String packageName,
    int pid,
    int uid,
    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.

int

Returns the max number of commands for a media item.

String

Returns the package name, or LEGACY_CONTROLLER_PACKAGE_NAME on API ≤ 24.

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_PACKAGE_NAME

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

The getPackageName of legacy controllers if a more precise package cannot be obtained.

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

maxCommandsForMediaItems

public final int maxCommandsForMediaItems

Public methods

createTestOnlyControllerInfo

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

createTestOnlyControllerInfo

@VisibleForTesting(otherwise = 2)
public static MediaSession.ControllerInfo createTestOnlyControllerInfo(
    String packageName,
    int pid,
    int uid,
    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.

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 LEGACY_CONTROLLER_PACKAGE_NAME on API ≤ 24.

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()

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()