Monado OpenXR Runtime
org.freedesktop.monado.ipc.Client Class Reference

Provides the client-side code to initiate connection to Monado IPC service. More...

Inheritance diagram for org.freedesktop.monado.ipc.Client:
Collaboration diagram for org.freedesktop.monado.ipc.Client:

Public Member Functions

 Client (long nativePointer)
 Constructor. More...
 
void markAsDiscardedByNative ()
 Let the native code notify us that it is no longer using this class. More...
 
int blockingConnect (Context context_, String packageName)
 Bind to the Monado IPC service, and block until it is fully connected. More...
 
boolean bind (Context context_, String packageName)
 Bind to the Monado IPC service - this asynchronously starts connecting (and launching the service if it's not already running) More...
 
void onServiceConnected (ComponentName name, IBinder service)
 Handle the asynchronous connection of the binder IPC. More...
 
void onServiceDisconnected (ComponentName name)
 Handle asynchronous disconnect. More...
 

Data Fields

IMonado monado = null
 Pointer to local IPC proxy: calling methods on it automatically transports arguments across binder IPC. More...
 
boolean failed = false
 Indicates that we tried to connect but failed. More...
 

Detailed Description

Provides the client-side code to initiate connection to Monado IPC service.

This class will get loaded into the OpenXR client application by our native code.

Constructor & Destructor Documentation

◆ Client()

org.freedesktop.monado.ipc.Client.Client ( long  nativePointer)
inline

Constructor.

Parameters
nativePointerthe corresponding native object's pointer.

References org.freedesktop.monado.auxiliary.NativeCounterpart.markAsUsedByNativeCode().

Member Function Documentation

◆ bind()

boolean org.freedesktop.monado.ipc.Client.bind ( Context  context_,
String  packageName 
)
inline

Bind to the Monado IPC service - this asynchronously starts connecting (and launching the service if it's not already running)

Parameters
context_Context to use to make the connection. (We get the application context from it.)
packageNameThe package name containing the Monado runtime. The caller is guaranteed to know this because it had to load this class from that package. There's a define in xrt_config_android.h to use for this.

Various builds, variants, etc. will have different package names, but we must specify the package name explicitly to avoid violating security restrictions.

Referenced by org.freedesktop.monado.ipc.Client.blockingConnect().

◆ blockingConnect()

int org.freedesktop.monado.ipc.Client.blockingConnect ( Context  context_,
String  packageName 
)
inline

Bind to the Monado IPC service, and block until it is fully connected.

The IPC client code on Android should load this class (from the right package), instantiate this class (retaining a reference to it!), and call this method.

This method must not be called from the main (UI) thread.

Parameters
context_Context to use to make the connection. (We get the application context from it.)
packageNameThe package name containing the Monado runtime. The caller is guaranteed to know this because it had to load this class from that package. There's a define in xrt_config_android.h to use for this.
Returns
the fd number - do not close! (dup if you want to be able to close it) Returns -1 if something went wrong.

Various builds, variants, etc. will have different package names, but we must specify the package name explicitly to avoid violating security restrictions.

References org.freedesktop.monado.ipc.Client.bind(), and org.freedesktop.monado.ipc.Client.monado.

◆ markAsDiscardedByNative()

void org.freedesktop.monado.ipc.Client.markAsDiscardedByNative ( )
inline

Let the native code notify us that it is no longer using this class.

References org.freedesktop.monado.auxiliary.NativeCounterpart.markAsDiscardedByNative().

◆ onServiceConnected()

void org.freedesktop.monado.ipc.Client.onServiceConnected ( ComponentName  name,
IBinder  service 
)
inline

Handle the asynchronous connection of the binder IPC.

Parameters
nameshould match the preceding intent, but not used.
servicethe associated service, which we cast in this function.

References org.freedesktop.monado.ipc.Client.monado.

◆ onServiceDisconnected()

void org.freedesktop.monado.ipc.Client.onServiceDisconnected ( ComponentName  name)
inline

Handle asynchronous disconnect.

Parameters
nameshould match the preceding intent, but not used.

Field Documentation

◆ failed

boolean org.freedesktop.monado.ipc.Client.failed = false

Indicates that we tried to connect but failed.

Used to distinguish a "not yet fully connected" null monado member from a "tried and failed" null monado member.

◆ monado

IMonado org.freedesktop.monado.ipc.Client.monado = null

Pointer to local IPC proxy: calling methods on it automatically transports arguments across binder IPC.

May be null!

Referenced by org.freedesktop.monado.ipc.Client.blockingConnect(), and org.freedesktop.monado.ipc.Client.onServiceConnected().


The documentation for this class was generated from the following file: