MediaSessionManager.RemoteUserInfo

public static final class MediaSessionManager.RemoteUserInfo
extends Object

java.lang.Object
   ↳ android.media.session.MediaSessionManager.RemoteUserInfo


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

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

Summary

Public constructors

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

Public methods

boolean equals(Object obj)

Returns equality of two RemoteUserInfo.

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

Returns a hash code value for the object.

Inherited methods

Public constructors

MediaSessionManager.RemoteUserInfo

added in API level 28
public MediaSessionManager.RemoteUserInfo (String packageName, 
                int pid, 
                int uid)

Parameters
packageName String

This value must never be null.

pid int

uid int

Public methods

equals

added in API level 28
public boolean equals (Object obj)

Returns equality of two RemoteUserInfo. Two RemoteUserInfos are the same only if they're sent to the same controller (either MediaController or MediaBrowser. If it's not nor one of them is triggered by the key presses, they would be considered as different one.

If you only want to compare the caller's package, compare them with the getPackageName(), getPid(), and/or getUid() directly.

Parameters
obj Object: the reference object with which to compare.

Returns
boolean true if equals, false otherwise

getPackageName

added in API level 28
public String getPackageName ()

Returns
String package name of the controller

getPid

added in API level 28
public int getPid ()

Returns
int pid of the controller

getUid

added in API level 28
public int getUid ()

Returns
int uid of the controller

hashCode

added in API level 28
public int hashCode ()

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the Java™ programming language.)

Returns
int a hash code value for this object.