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()
This commit is contained in:
roynatech2544 2022-10-12 01:54:08 +09:00
commit ef97fdeb77
18 changed files with 209 additions and 30 deletions

View file

@ -0,0 +1,12 @@
#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);
}