mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-06 07:06:10 +00:00
android: IPC/service-related cleanups.
This commit is contained in:
parent
974e7bd1d5
commit
4101b3d92d
|
@ -11,32 +11,47 @@
|
||||||
package org.freedesktop.monado.ipc;
|
package org.freedesktop.monado.ipc;
|
||||||
|
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
|
||||||
import androidx.annotation.Keep;
|
import androidx.annotation.Keep;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Java implementation of the IMonado IPC interface.
|
* Java implementation of the IMonado IPC interface.
|
||||||
* <p>
|
* <p>
|
||||||
* (This is the server-side code.)
|
* (This is the server-side code.)
|
||||||
* <p>
|
* <p>
|
||||||
* All this does is delegate calls to native JNI implementations
|
* All this does is delegate calls to native JNI implementations.
|
||||||
|
* The warning suppression is because Android Studio tends to have a hard time finding
|
||||||
|
* the (very real) implementations of these in service-lib.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("JavaJniMissingFunction")
|
|
||||||
@Keep
|
@Keep
|
||||||
public class MonadoImpl extends IMonado.Stub {
|
public class MonadoImpl extends IMonado.Stub {
|
||||||
|
|
||||||
|
private static final String TAG = "MonadoImpl";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Load the shared library with the native parts of this class
|
// Load the shared library with the native parts of this class
|
||||||
// This is the service-lib target.
|
// This is the service-lib target.
|
||||||
System.loadLibrary("monado-service");
|
System.loadLibrary("monado-service");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(ParcelFileDescriptor parcelFileDescriptor) {
|
@Override
|
||||||
|
public void connect(@NotNull ParcelFileDescriptor parcelFileDescriptor) {
|
||||||
|
Log.i(TAG, "connect");
|
||||||
nativeAddClient(parcelFileDescriptor.detachFd());
|
nativeAddClient(parcelFileDescriptor.detachFd());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void passAppSurface(Surface surface) {
|
public void passAppSurface(Surface surface) {
|
||||||
|
Log.i(TAG, "passAppSurface");
|
||||||
|
if (surface == null) {
|
||||||
|
Log.e(TAG, "Received a null Surface from the client!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
nativeAppSurface(surface);
|
nativeAppSurface(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,15 +59,14 @@ public class MonadoImpl extends IMonado.Stub {
|
||||||
* Native handling of receiving a surface: should convert it to an ANativeWindow then do stuff
|
* Native handling of receiving a surface: should convert it to an ANativeWindow then do stuff
|
||||||
* with it.
|
* with it.
|
||||||
* <p>
|
* <p>
|
||||||
* Ignore Android Studio complaining that this function is missing: it is not, it is just in a
|
* Ignore warnings that this function is missing: it is not, it is just in a different module.
|
||||||
* different module. See `src/xrt/targets/service-lib/lib.cpp` for the implementation.
|
* See `src/xrt/targets/service-lib/service_target.cpp` for the implementation.
|
||||||
* (Ignore the warning saying that file isn't included in the build: it is, Android Studio
|
|
||||||
* is just confused.)
|
|
||||||
*
|
*
|
||||||
* @param surface The surface to pass to native code
|
* @param surface The surface to pass to native code
|
||||||
* @todo figure out a good way to make the MonadoImpl pointer a client ID
|
* @todo figure out a good way to make the MonadoImpl pointer a client ID
|
||||||
*/
|
*/
|
||||||
private native void nativeAppSurface(Surface surface);
|
@SuppressWarnings("JavaJniMissingFunction")
|
||||||
|
private native void nativeAppSurface(@NonNull Surface surface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native handling of receiving an FD for a new client: the FD should be used to start up the
|
* Native handling of receiving an FD for a new client: the FD should be used to start up the
|
||||||
|
@ -62,13 +76,12 @@ public class MonadoImpl extends IMonado.Stub {
|
||||||
* running, this will be called in it. If it's not already running, a process will be created,
|
* running, this will be called in it. If it's not already running, a process will be created,
|
||||||
* and this will be the first native code executed in that process.
|
* and this will be the first native code executed in that process.
|
||||||
* <p>
|
* <p>
|
||||||
* Ignore Android Studio complaining that this function is missing: it is not, it is just in a
|
* Ignore warnings that this function is missing: it is not, it is just in a different module.
|
||||||
* different module. See `src/xrt/targets/service-lib/lib.cpp` for the implementation.
|
* See `src/xrt/targets/service-lib/service_target.cpp` for the implementation.
|
||||||
* (Ignore the warning saying that file isn't included in the build: it is, Android Studio
|
|
||||||
* is just confused.)
|
|
||||||
*
|
*
|
||||||
* @param fd The incoming file descriptor: ownership is transferred to native code here.
|
* @param fd The incoming file descriptor: ownership is transferred to native code here.
|
||||||
* @todo figure out a good way to make the MonadoImpl pointer a client ID
|
* @todo figure out a good way to make the MonadoImpl pointer a client ID
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("JavaJniMissingFunction")
|
||||||
private native void nativeAddClient(int fd);
|
private native void nativeAddClient(int fd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
|
|
||||||
add_library(monado-service MODULE
|
add_library(monado-service MODULE
|
||||||
lib.cpp
|
service_target.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(monado-service PRIVATE
|
target_link_libraries(monado-service PRIVATE
|
||||||
|
|
Loading…
Reference in a new issue