native service, EGL, native test client
This commit is contained in:
@@ -1,26 +1,38 @@
|
||||
#include <jni.h>
|
||||
#include <android/binder_ibinder_jni.h>
|
||||
#include <aidl/com/omixlab/mosis/BnMosisService.h>
|
||||
#include "egl_context.h"
|
||||
#include "logger.h"
|
||||
|
||||
using namespace aidl::com::omixlab::mosis;
|
||||
|
||||
class NativeService : public BnMosisService {
|
||||
std::unique_ptr<egl::Context> m_egl_context;
|
||||
public:
|
||||
ndk::ScopedAStatus getNumber(int32_t *_aidl_return) override {
|
||||
NativeService() = default;
|
||||
ndk::ScopedAStatus getNumber(int32_t *_aidl_return) override
|
||||
{
|
||||
*_aidl_return = 100;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
ndk::ScopedAStatus initOS(bool *_aidl_return) override {
|
||||
if (!m_egl_context)
|
||||
{
|
||||
m_egl_context = std::make_unique<egl::Context>();
|
||||
*_aidl_return = m_egl_context->create();
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Log("OS already initialized");
|
||||
*_aidl_return = true;
|
||||
}
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
};
|
||||
|
||||
static std::shared_ptr<NativeService> g_service;
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_com_omixlab_mosis_NativeService_getBinderNative(JNIEnv *env, jobject thiz) {
|
||||
if (!g_service)
|
||||
{
|
||||
g_service = ndk::SharedRefBase::make<NativeService>();
|
||||
|
||||
}
|
||||
static std::shared_ptr<NativeService> g_service = ndk::SharedRefBase::make<NativeService>();
|
||||
return AIBinder_toJavaBinder(env, g_service->asBinder().get());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user