MediaSession.ControllerInfo
public final class MediaSession.ControllerInfo
Information of a MediaController or a MediaBrowser.
Summary
Constants |
|
|---|---|
static final int |
The |
static final String |
LEGACY_CONTROLLER_PACKAGE_NAME = "android.media.session.MediaController"The |
static final int |
The |
Public fields |
|
|---|---|
final Bundle |
|
final int |
|
final boolean |
|
final boolean |
|
final int |
Public methods |
|
|---|---|
static MediaSession.ControllerInfo |
@VisibleForTesting(otherwise = 2)Returns a |
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 |
int |
Returns the max number of commands for a media item. |
String |
Returns the package name, or |
int |
getUid()Returns the UID of the controller. |
int |
hashCode() |
boolean |
Returns whether the value returned from |
boolean |
Returns whether the controller is trusted by the user to control and access media. |
String |
toString() |
Constants
LEGACY_CONTROLLER_INTERFACE_VERSION
@UnstableApi
public static final int LEGACY_CONTROLLER_INTERFACE_VERSION = 0
The getInterfaceVersion interface version} of a platform android.media.session.MediaController 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 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
public static final int LEGACY_CONTROLLER_VERSION = 0
The controller version of a platform android.media.session.MediaController or legacy
android.support.v4.media.session.MediaControllerCompat.
Public fields
Public methods
createTestOnlyControllerInfo
@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 ControllerInfo suitable for use when testing client code.
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 LEGACY_CONTROLLER_VERSION if the controller is a platform android.media.session.MediaController or legacy
android.support.v4.media.session.MediaControllerCompat.
getInterfaceVersion
@UnstableApi
public int getInterfaceVersion()
Returns the interface version of the controller, or LEGACY_CONTROLLER_INTERFACE_VERSION if the controller is a platform android.media.session.MediaController 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 LEGACY_CONTROLLER_PACKAGE_NAME on API ≤ 24.
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
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.
isPackageNameVerified
@UnstableApi
public boolean isPackageNameVerified()
Returns whether the value returned from getPackageName has been verified to be a valid package name belonging to 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
myUid. - The controller is part of the Android system (using
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.