public final class

MediaSessionManager.RemoteUserInfo

extends java.lang.Object

 java.lang.Object

↳androidx.media3.session.legacy.MediaSessionManager.RemoteUserInfo

Overview

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 MediaSessionManager.RemoteUserInfo.equals(Object) to take a look at how it differentiate media controller.

Summary

Fields
public static final java.lang.StringLEGACY_CONTROLLER

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

public static final intUNKNOWN_PID

Represents an unknown pid of an application.

public static final intUNKNOWN_UID

Represents an unknown uid of an application.

Constructors
publicRemoteUserInfo(android.media.session.MediaSessionManager.RemoteUserInfo remoteUserInfo)

Public constructor for internal uses.

publicRemoteUserInfo(java.lang.String packageName, int pid, int uid)

Public constructor.

Methods
public booleanequals(java.lang.Object obj)

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

public java.lang.StringgetPackageName()

public intgetPid()

public intgetUid()

public inthashCode()

from java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

Fields

public static final java.lang.String LEGACY_CONTROLLER

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

public static final int UNKNOWN_PID

Represents an unknown pid of an application.

public static final int UNKNOWN_UID

Represents an unknown uid of an application.

Constructors

public RemoteUserInfo(java.lang.String packageName, int pid, int uid)

Public constructor.

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

Parameters:

packageName: package name of the remote user
pid: pid of the remote user
uid: uid of the remote user

public RemoteUserInfo(android.media.session.MediaSessionManager.RemoteUserInfo remoteUserInfo)

Public constructor for internal uses.

Internal code MUST use this on SDK >= 28 to distinguish individual RemoteUserInfos in a process.

Parameters:

remoteUserInfo: Framework RemoteUserInfo

Methods

public java.lang.String getPackageName()

Returns:

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

public int getPid()

Returns:

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

public int getUid()

Returns:

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

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

Returns:

true if equals, false otherwise

public int hashCode()