updated open binary jni
This commit is contained in:
@@ -23,6 +23,9 @@ import net.irext.ircontrol.ui.activity.ControlActivity;
|
|||||||
import net.irext.ircontrol.utils.FileUtils;
|
import net.irext.ircontrol.utils.FileUtils;
|
||||||
import net.irext.ircontrol.utils.MessageUtil;
|
import net.irext.ircontrol.utils.MessageUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +137,21 @@ public class ControlFragment extends Fragment implements View.OnClickListener {
|
|||||||
mCurrentRemoteControl.getRemoteMap() + FileUtils.FILE_NAME_EXT;
|
mCurrentRemoteControl.getRemoteMap() + FileUtils.FILE_NAME_EXT;
|
||||||
|
|
||||||
/* decode SDK - load binary file */
|
/* decode SDK - load binary file */
|
||||||
int ret = mIRDecode.openBinary(category, mCurrentRemoteControl.getSubCategory(), binFileName);
|
// int ret = mIRDecode.openBinary(category, mCurrentRemoteControl.getSubCategory(), binFileName);
|
||||||
|
File binFile = new File(binFileName);
|
||||||
|
byte []binaries = new byte[(int)binFile.length()];
|
||||||
|
try {
|
||||||
|
if (null != binFile) {
|
||||||
|
FileInputStream fin = new FileInputStream(binFile);
|
||||||
|
fin.read(binaries);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
int ret = mIRDecode.openBinary(category, mCurrentRemoteControl.getSubCategory(),
|
||||||
|
binaries, binaries.length);
|
||||||
|
|
||||||
|
Log.d(TAG, "binary opened : " + ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -35,6 +35,25 @@ JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpen
|
|||||||
return IR_DECODE_SUCCEEDED;
|
return IR_DECODE_SUCCEEDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpenBinary
|
||||||
|
(JNIEnv *env, jobject this_obj, jint category_id, jint sub_cate,
|
||||||
|
jbyteArray binaries, jint bin_length)
|
||||||
|
{
|
||||||
|
jbyte* j_buffer = (*env)->GetByteArrayElements(env, binaries, 0);
|
||||||
|
unsigned char* buffer = (unsigned char*)j_buffer;
|
||||||
|
|
||||||
|
if (IR_DECODE_FAILED == ir_binary_open(category_id, sub_cate, buffer, bin_length))
|
||||||
|
{
|
||||||
|
ir_close();
|
||||||
|
(*env)->ReleaseByteArrayElements(env, binaries, j_buffer, JNI_ABORT);
|
||||||
|
return IR_DECODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*env)->ReleaseByteArrayElements(env, binaries, j_buffer, JNI_ABORT);
|
||||||
|
|
||||||
|
return IR_DECODE_SUCCEEDED;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
|
JNIEXPORT jintArray JNICALL Java_net_irext_decodesdk_IRDecode_irDecode
|
||||||
(JNIEnv *env, jobject this_obj, jint key_code, jobject jni_ac_status, jint change_wind_direction)
|
(JNIEnv *env, jobject this_obj, jint key_code, jobject jni_ac_status, jint change_wind_direction)
|
||||||
{
|
{
|
||||||
@@ -102,8 +121,12 @@ JNIEXPORT jobject JNICALL Java_net_irext_decodesdk_IRDecode_irACGetTemperatureRa
|
|||||||
int tempMax = 0;
|
int tempMax = 0;
|
||||||
|
|
||||||
jobject temperature_range = NULL;
|
jobject temperature_range = NULL;
|
||||||
jclass temperature_range_class = (*env)->FindClass(env, "com/irext/remote/bean/jnibean/JNITemperatureRange");
|
jclass temperature_range_class =
|
||||||
jmethodID temperature_range_mid = (*env)->GetMethodID(env, temperature_range_class, "<init>", "()V");
|
(*env)->FindClass(env, "com/irext/remote/bean/jnibean/JNITemperatureRange");
|
||||||
|
|
||||||
|
jmethodID temperature_range_mid =
|
||||||
|
(*env)->GetMethodID(env, temperature_range_class, "<init>", "()V");
|
||||||
|
|
||||||
jfieldID min_temp_fid = (*env)->GetFieldID(env, temperature_range_class, "tempMin", "I");
|
jfieldID min_temp_fid = (*env)->GetFieldID(env, temperature_range_class, "tempMin", "I");
|
||||||
jfieldID max_temp_fid = (*env)->GetFieldID(env, temperature_range_class, "tempMax", "I");
|
jfieldID max_temp_fid = (*env)->GetFieldID(env, temperature_range_class, "tempMax", "I");
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,14 @@ extern "C" {
|
|||||||
JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpen
|
JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpen
|
||||||
(JNIEnv *, jobject, jint, jint, jstring);
|
(JNIEnv *, jobject, jint, jint, jstring);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: net_irext_decodesdk_IRDecode
|
||||||
|
* Method: irOpenBinary
|
||||||
|
* Signature: II(Ljava/lang/String;)
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_net_irext_decodesdk_IRDecode_irOpenBinary
|
||||||
|
(JNIEnv *, jobject, jint, jint, jbyteArray, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: net_irext_decodesdk_IRDecode
|
* Class: net_irext_decodesdk_IRDecode
|
||||||
* Method: irDecode
|
* Method: irDecode
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public class IRDecode {
|
|||||||
|
|
||||||
private native int irOpen(int category, int subCate, String fileName);
|
private native int irOpen(int category, int subCate, String fileName);
|
||||||
|
|
||||||
|
private native int irOpenBinary(int category, int subCate, byte[] binaries, int binLength);
|
||||||
|
|
||||||
private native int[] irDecode(int keyCode, ACStatus acStatus, int changeWindDirection);
|
private native int[] irDecode(int keyCode, ACStatus acStatus, int changeWindDirection);
|
||||||
|
|
||||||
private native void irClose();
|
private native void irClose();
|
||||||
@@ -45,10 +47,14 @@ public class IRDecode {
|
|||||||
return mInstance;
|
return mInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int openBinary(int category, int subCate, String fileName) {
|
public int openFile(int category, int subCate, String fileName) {
|
||||||
return irOpen(category, subCate, fileName);
|
return irOpen(category, subCate, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int openBinary(int category, int subCate, byte[] binaries, int binLength) {
|
||||||
|
return irOpenBinary(category, subCate, binaries, binLength);
|
||||||
|
}
|
||||||
|
|
||||||
public int[] decodeBinary(int keyCode, ACStatus acStatus, int changeWindDir) {
|
public int[] decodeBinary(int keyCode, ACStatus acStatus, int changeWindDir) {
|
||||||
return irDecode(keyCode, acStatus, changeWindDir);
|
return irDecode(keyCode, acStatus, changeWindDir);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user