MediaSessionManager.RemoteUserInfo

public static final class MediaSessionManager.RemoteUserInfo
extends Object

java.lang.Object
   ↳ androidx.media.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(Object) to take a look at how it differentiate media controller.

Summary

Constants

String LEGACY_CONTROLLER

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

Public constructors

MediaSessionManager.RemoteUserInfo(String packageName, int pid, int uid)

Public constructor.

Public methods

boolean equals(Object obj)

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

String getPackageName()
int getPid()
int getUid()
int hashCode()

Inherited methods

Constants

LEGACY_CONTROLLER

public static final String LEGACY_CONTROLLER

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

Constant Value: "android.media.session.MediaController"

Public constructors

MediaSessionManager.RemoteUserInfo

public MediaSessionManager.RemoteUserInfo (String packageName, 
                int pid, 
                int uid)

Public constructor.

Can be used for MediaSessionManager.isTrustedForMediaControl(RemoteUserInfo)}.

Parameters
packageName String: package name of the remote user

pid int: pid of the remote user

uid int: uid of the remote user

Public methods

equals

public boolean equals (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
obj Object: the reference object with which to compare.

Returns
boolean true if equals, false otherwise

getPackageName

public String getPackageName ()

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

getPid

public int getPid ()

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

getUid

public int getUid ()

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

hashCode

public int hashCode ()

Returns
int