added get version API to JNI

This commit is contained in:
strawmanbobi
2020-03-08 20:18:41 +08:00
parent 3c0d06a9f4
commit 3e73729f90
4 changed files with 18 additions and 4 deletions

View File

@@ -4,8 +4,8 @@ cmake_minimum_required(VERSION 3.2)
project(ir_decoder)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-DBOARD_PC)
# add_definitions(-DBOARD_PC -DBOARD_PC_JNI)
add_definitions(-DDEBUG)
# add_definitions(-DBOARD_PC_JNI)
# add_definitions(-DDEBUG)
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
MESSAGE("compile platform : Linux")

View File

@@ -26,6 +26,8 @@ public class IRDecode {
private static Object mSync = new Object();
private native String irGetVersion();
private native int irOpen(int category, int subCate, String fileName);
private native int irOpenBinary(int category, int subCate, byte[] binaries, int binLength);
@@ -59,6 +61,10 @@ public class IRDecode {
System.load(libPath);
}
public String getVersion() {
return irGetVersion();
}
public int openFile(int category, int subCate, String fileName) {
return irOpen(category, subCate, fileName);
}

View File

@@ -12,13 +12,20 @@ Revision log:
#include <stdio.h>
#include "ir_decode_jni.h"
#include "../../include/ir_defs.h"
#include "../../include/ir_decode.h"
#include "../../src/include/ir_defs.h"
#include "../../src/include/ir_decode.h"
// global variable definition
extern size_t binary_length;
extern UINT8 *binary_content;
JNIEXPORT const jstring JNICALL Java_net_irext_decode_sdk_IRDecode_irGetVersion
(JNIEnv *env, jobject this_obj)
{
char *version = (char*) get_lib_version();
return (*env)->NewStringUTF(env, version);
}
JNIEXPORT jint JNICALL Java_net_irext_decode_sdk_IRDecode_irOpen
(JNIEnv *env, jobject this_obj, jint category_id, jint sub_cate, jstring file_name)
{

View File

@@ -59,6 +59,7 @@ extern "C" {
#define net_irext_decode_sdk_IRDecode_START_STICKY 1L
#undef net_irext_decode_sdk_IRDecode_START_STICKY_COMPATIBILITY
#define net_irext_decode_sdk_IRDecode_START_STICKY_COMPATIBILITY 0L
/*
* Class: net_irext_decode_sdk_IRDecode
* Method: irOpen