diff --git a/src/xrt/targets/CMakeLists.txt b/src/xrt/targets/CMakeLists.txt index 88f64ff61..5a805fcda 100644 --- a/src/xrt/targets/CMakeLists.txt +++ b/src/xrt/targets/CMakeLists.txt @@ -19,6 +19,13 @@ if(XRT_HAVE_SDL2) endif() if(XRT_FEATURE_SERVICE) - add_subdirectory(ctl) - add_subdirectory(service) + add_subdirectory(ctl) +endif() + +if(XRT_FEATURE_SERVICE AND XRT_FEATURE_OPENXR) + if(ANDROID) + add_subdirectory(service-lib) + else() + add_subdirectory(service) + endif() endif() diff --git a/src/xrt/targets/service-lib/CMakeLists.txt b/src/xrt/targets/service-lib/CMakeLists.txt new file mode 100644 index 000000000..3ec84f530 --- /dev/null +++ b/src/xrt/targets/service-lib/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright 2020, Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 + + +add_library(monado-service MODULE + lib.cpp + ) + +target_link_libraries(monado-service PRIVATE + aux_util + st_prober + ipc_server + comp_main + target_lists + target_instance + xrt-external-jni-wrap + ) + +set_target_properties(monado-service + PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON) diff --git a/src/xrt/targets/service-lib/lib.cpp b/src/xrt/targets/service-lib/lib.cpp new file mode 100644 index 000000000..37aa51a63 --- /dev/null +++ b/src/xrt/targets/service-lib/lib.cpp @@ -0,0 +1,48 @@ +// Copyright 2020, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Library exposing IPC server. + * @author Ryan Pavlik <ryan.pavlik@collabora.com> + * @ingroup ipc_android + */ + +#include "target_lists.h" + +#include "jnipp.h" +#include "jni.h" + +#include "wrap/android.os.h" +#include "wrap/android.view.h" + +#include <android/native_window.h> +#include <android/native_window_jni.h> + +using wrap::android::os::ParcelFileDescriptor; +using wrap::android::view::Surface; + +extern "C" void +Java_org_freedesktop_monado_ipc_MonadoImpl_nativeAddClient( + JNIEnv *env, jobject thiz, jobject parcel_file_descriptor) +{ + jni::init(env); + //! @todo do something! + // This may be the "entry point" of the native code, or we could already + // have another client running, etc. + + ParcelFileDescriptor pfd(parcel_file_descriptor); + jni::Object monadoImpl(thiz); +} + +extern "C" void +Java_org_freedesktop_monado_ipc_MonadoImpl_nativeAppSurface(JNIEnv *env, + jobject thiz, + jobject surface) +{ + jni::init(env); + Surface surf(surface); + jni::Object monadoImpl(thiz); + ANativeWindow *nativeWindow = ANativeWindow_fromSurface(env, surface); + + //! @todo do something! +}