init
This commit is contained in:
26
src/main/cpp/mosis-service.cpp
Normal file
26
src/main/cpp/mosis-service.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <jni.h>
|
||||
#include <android/binder_ibinder_jni.h>
|
||||
#include <aidl/com/omixlab/mosis/BnMosisService.h>
|
||||
|
||||
using namespace aidl::com::omixlab::mosis;
|
||||
|
||||
class NativeService : public BnMosisService {
|
||||
public:
|
||||
ndk::ScopedAStatus getNumber(int32_t *_aidl_return) override {
|
||||
*_aidl_return = 100;
|
||||
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>();
|
||||
|
||||
}
|
||||
return AIBinder_toJavaBinder(env, g_service->asBinder().get());
|
||||
}
|
||||
Reference in New Issue
Block a user