android_device_samsung_a20/universal7885-common/apps/SamsungParts/jni/SwapCallbackNative.cpp
roynatech2544 ef97fdeb77 universal7885: parts-aidl: Just send callback through setSwapOn()
- Set callback on JNI, since Java class cant be sent through, use the ndk backend to implement callback and send to swapon()
2022-10-12 22:31:27 +09:00

12 lines
494 B
C++

#include "SwapCallbackImpl.h"
#include <android/binder_manager.h>
#include <aidl/vendor/eureka/hardware/parts/BnSwapOnData.h>
extern "C" JNIEXPORT void JNICALL
Java_com_eurekateam_samsungextras_interfaces_Swap_setSwapOn
(JNIEnv *env, jclass clazz, jboolean cb) {
auto svc = ISwapOnData::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService("vendor.eureka.hardware.parts.ISwapOnData/default")));
svc->setSwapOn(cb ? ndk::SharedRefBase::make<SwapCallbackImpl>(env, clazz) : nullptr);
}