MediaSessionManager.RemoteUserInfo

public final class MediaSessionManager.RemoteUserInfo


Information of a remote user of MediaSessionCompat or MediaBrowserServiceCompat. This can be used to decide whether the remote user is trusted app, and also differentiate caller of MediaSessionCompat and MediaBrowserServiceCompat callbacks.

See equals to take a look at how it differentiate media controller.

Summary

Constants

static final String
LEGACY_CONTROLLER = "android.media.session.MediaController"

Used by getPackageName when the session is connected to the legacy controller whose exact package name cannot be obtained.

Public constructors

RemoteUserInfo(@NonNull String packageName, int pid, int uid)

Public constructor.

Public methods

boolean

Returns equality of two RemoteUserInfo by comparing their package name, UID, and PID.

@NonNull String
int
int
int

Constants

LEGACY_CONTROLLER

Added in 1.1.0
public static final String LEGACY_CONTROLLER = "android.media.session.MediaController"

Used by getPackageName when the session is connected to the legacy controller whose exact package name cannot be obtained.

Public constructors

RemoteUserInfo

Added in 1.1.0
public RemoteUserInfo(@NonNull String packageName, int pid, int uid)

Public constructor.

Can be used for isTrustedForMediaControl}.

Parameters
@NonNull String packageName

package name of the remote user

int pid

pid of the remote user

int uid

uid of the remote user

Throws
java.lang.IllegalArgumentException

if package name is empty

Public methods

equals

public boolean equals(@Nullable Object obj)

Returns equality of two RemoteUserInfo by comparing their package name, UID, and PID.

On P and before (API <= 28), two RemoteUserInfo objects equal if following conditions are met:

  1. UID and package name are the same
  2. One of the RemoteUserInfo's PID is UNKNOWN_PID or both of RemoteUserInfo's PID are the same
Parameters
@Nullable Object obj

the reference object with which to compare.

Returns
boolean

true if equals, false otherwise

getPackageName

Added in 1.1.0
public @NonNull String getPackageName()
Returns
@NonNull String

package name of the controller. Can be LEGACY_CONTROLLER if the package name cannot be obtained.

getPid

Added in 1.1.0
public int getPid()
Returns
int

pid of the controller. Can be a negative value if the pid cannot be obtained.

getUid

Added in 1.1.0
public int getUid()
Returns
int

uid of the controller. Can be a negative value if the uid cannot be obtained.

hashCode

public int hashCode()