|
|
|
#include <jni.h>
|
|
|
|
#include <string>
|
|
|
|
#include <TermClient.h>
|
|
|
|
#include "TerminalDevice.h"
|
|
|
|
#include "PhoneDevice.h"
|
|
|
|
#include <camera/NdkCameraCaptureSession.h>
|
|
|
|
#include <camera/NdkCameraDevice.h>
|
|
|
|
#include <camera/NdkCameraError.h>
|
|
|
|
#include <camera/NdkCameraManager.h>
|
|
|
|
|
|
|
|
#include <android/native_window.h>
|
|
|
|
#include <android/native_window_jni.h>
|
|
|
|
|
|
|
|
#include "Camera.h"
|
|
|
|
#include "Camera2Reader.h"
|
|
|
|
|
|
|
|
// #include "client/linux/handler/exception_handler.h"
|
|
|
|
// #include "client/linux/handler/minidump_descriptor.h"
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jstring JNICALL
|
|
|
|
Java_com_xinyingpower_microphoto_MainActivity_stringFromJNI(
|
|
|
|
JNIEnv* env,
|
|
|
|
jobject /* this */) {
|
|
|
|
std::string hello = "Hello from C++";
|
|
|
|
return env->NewStringUTF(hello.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jboolean JNICALL
|
|
|
|
Java_com_xinyingpower_microphoto_MainActivity_takePhoto(
|
|
|
|
JNIEnv* env,
|
|
|
|
jobject pThis, jint channel, jint preset, jstring path, jstring fileName) {
|
|
|
|
|
|
|
|
// ANativeWindow *imgReaderAnw = ANativeWindow_fromSurface(env, surface);
|
|
|
|
|
|
|
|
/*
|
|
|
|
CCamera camera;
|
|
|
|
camera.initCamera(imgReaderAnw);
|
|
|
|
if (camera.isCameraReady())
|
|
|
|
{
|
|
|
|
camera.takePicture();
|
|
|
|
}
|
|
|
|
|
|
|
|
camera.closeCamera();
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (channel < 1 || channel > 0xFF)
|
|
|
|
{
|
|
|
|
return JNI_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char id = (unsigned char)channel - 1;
|
|
|
|
|
|
|
|
|
|
|
|
Camera2Reader *camera = new Camera2Reader(id);
|
|
|
|
const char *pathStr = env->GetStringUTFChars(path, 0);
|
|
|
|
const char *fileNameStr = env->GetStringUTFChars(fileName, 0);
|
|
|
|
|
|
|
|
camera->Open(pathStr, fileNameStr);
|
|
|
|
env->ReleaseStringUTFChars(fileName, fileNameStr);
|
|
|
|
env->ReleaseStringUTFChars(path, pathStr);
|
|
|
|
|
|
|
|
camera->start();
|
|
|
|
|
|
|
|
return JNI_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jboolean JNICALL
|
|
|
|
Java_com_xinyingpower_microphoto_MicroPhotoService_init(
|
|
|
|
JNIEnv* env,
|
|
|
|
jobject pThis, jstring appPath, jstring ip, jint port, jstring cmdid) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
google_breakpad::MinidumpDescriptor descriptor(".");
|
|
|
|
google_breakpad::ExceptionHandler eh(descriptor, NULL, NULL,
|
|
|
|
NULL, true, -1);
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char *appPathStr = env->GetStringUTFChars(appPath, 0);
|
|
|
|
const char *ipStr = env->GetStringUTFChars(ip, 0);
|
|
|
|
const char *cmdidStr = env->GetStringUTFChars(cmdid, 0);
|
|
|
|
|
|
|
|
JavaVM* vm = NULL;
|
|
|
|
jint ret = env->GetJavaVM(&vm);
|
|
|
|
// const string& appPath, const string& termId, const string& server, unsigned short port, const string& bindIp
|
|
|
|
CTermClient& service = CTermClient::GetService();
|
|
|
|
// CTerminalDevice* device = new CTerminalDevice(vm, pThis);
|
|
|
|
CPhoneDevice* device = new CPhoneDevice();
|
|
|
|
bool res = service.InitService(appPathStr, cmdidStr, ipStr, (unsigned short)port, "", device);
|
|
|
|
|
|
|
|
env->ReleaseStringUTFChars(appPath, appPathStr);
|
|
|
|
env->ReleaseStringUTFChars(ip, ipStr);
|
|
|
|
env->ReleaseStringUTFChars(cmdid, cmdidStr);
|
|
|
|
|
|
|
|
return res ? JNI_TRUE : JNI_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jboolean JNICALL
|
|
|
|
Java_com_xinyingpower_microphoto_MicroPhotoService_takePhoto(
|
|
|
|
JNIEnv* env,
|
|
|
|
jobject pThis, jint channel, jint preset, jstring path, jstring fileName) {
|
|
|
|
|
|
|
|
if (channel < 1 || channel > 0xFF)
|
|
|
|
{
|
|
|
|
return JNI_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char id = (unsigned char)channel - 1;
|
|
|
|
|
|
|
|
Camera2Reader *camera = new Camera2Reader(id);
|
|
|
|
const char *pathStr = env->GetStringUTFChars(path, 0);
|
|
|
|
const char *fileNameStr = env->GetStringUTFChars(fileName, 0);
|
|
|
|
|
|
|
|
camera->Open(pathStr, fileNameStr);
|
|
|
|
env->ReleaseStringUTFChars(fileName, fileNameStr);
|
|
|
|
env->ReleaseStringUTFChars(path, pathStr);
|
|
|
|
|
|
|
|
camera->start();
|
|
|
|
|
|
|
|
return JNI_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jboolean JNICALL
|
|
|
|
Java_com_xinyingpower_microphoto_MicroPhotoService_uninit(
|
|
|
|
JNIEnv* env,
|
|
|
|
jobject pThis) {
|
|
|
|
|
|
|
|
CTermClient::GetService().ExitService();
|
|
|
|
|
|
|
|
return JNI_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" JNIEXPORT jlong JNICALL
|
|
|
|
Java_com_xinyingpower_microphoto_MicroPhotoService_getHeartbeatDuration(
|
|
|
|
JNIEnv* env,
|
|
|
|
jobject pThis) {
|
|
|
|
|
|
|
|
// CTermClient::GetService().ExitService();
|
|
|
|
|
|
|
|
return 60000;
|
|
|
|
}
|
|
|
|
|