diff --git a/.gitignore b/.gitignore index 964c785..1d4eafc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,7 @@ src/ir_decoder/.idea src/ir_encoder/.idea src/ir_decoder/out +src/ir_decoder/libs +src/ir_decoder/obj files/ files/* \ No newline at end of file diff --git a/src/ir_decoder/Android.mk b/src/ir_decoder/Android.mk index ad337bf..bac4d47 100644 --- a/src/ir_decoder/Android.mk +++ b/src/ir_decoder/Android.mk @@ -6,7 +6,7 @@ LOCAL_CFLAGS := -DBOARD_ANDROID LOCAL_MODULE := libirdecode LOCAL_SRC_FILES := irda_decode_jni.c \ irda_decode.c \ - irda_lib.c \ + irda_tv_parse.c \ irda_apply.c \ irda_irframe.c \ irda_parse_ac_parameter.c \ @@ -14,9 +14,6 @@ LOCAL_SRC_FILES := irda_decode_jni.c \ irda_parse_frame_parameter.c \ irda_utils.c \ -LOCAL_MODULE_TAGS := optional -LOCAL_PRELINK_MODULE := false - -LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog include $(BUILD_SHARED_LIBRARY) \ No newline at end of file diff --git a/src/ir_decoder/Application.mk b/src/ir_decoder/Application.mk new file mode 100644 index 0000000..6ae9bff --- /dev/null +++ b/src/ir_decoder/Application.mk @@ -0,0 +1 @@ +APP_BUILD_SCRIPT := Android.mk \ No newline at end of file diff --git a/src/ir_decoder/CleanSpec.mk b/src/ir_decoder/CleanSpec.mk deleted file mode 100644 index b84e1b6..0000000 --- a/src/ir_decoder/CleanSpec.mk +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (C) 2007 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# If you don't need to do a full clean build but would like to touch -# a file or delete some intermediate files, add a clean step to the end -# of the list. These steps will only be run once, if they haven't been -# run before. -# -# E.g.: -# $(call add-clean-step, touch -c external/sqlite/sqlite3.h) -# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) -# -# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with -# files that are missing or have been moved. -# -# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. -# Use $(OUT_DIR) to refer to the "out" directory. -# -# If you need to re-do something that's already mentioned, just copy -# the command and add it to the bottom of the list. E.g., if a change -# that you made last week required touching a file and a change you -# made today requires touching the same file, just copy the old -# touch step and add it to the end of the list. -# -# ************************************************ -# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST -# ************************************************ - -# For example: -#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) -#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) -#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) -#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) - -# ************************************************ -# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST -# ************************************************ diff --git a/src/ir_decoder/include/irda_decode_jni.h b/src/ir_decoder/include/irda_decode_jni.h index e210103..5264165 100644 --- a/src/ir_decoder/include/irda_decode_jni.h +++ b/src/ir_decoder/include/irda_decode_jni.h @@ -143,62 +143,6 @@ JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_irdaTVCo JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_irdaTVLibClose (JNIEnv *, jobject); -/* - * Class: net_irext_remote_service_DecodeService - * Method: bcLibOpen - * Signature: (Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_bcLibOpen - (JNIEnv *, jobject, jstring); - -/* - * Class: net_irext_remote_service_DecodeService - * Method: bcGetNeedConnAck - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_bcGetNeedConnAck - (JNIEnv *, jobject); - -/* - * Class: net_irext_remote_service_DecodeService - * Method: bcGetDeviceName - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_net_irext_remote_service_DecodeService_bcGetDeviceName - (JNIEnv *, jobject); - -/* - * Class: net_irext_remote_service_DecodeService - * Method: bcGetValidKeys - * Signature: ()[I - */ -JNIEXPORT jintArray JNICALL Java_net_irext_remote_service_DecodeService_bcGetValidKeys - (JNIEnv *, jobject); - -/* - * Class: net_irext_remote_service_DecodeService - * Method: bcLibClose - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_net_irext_remote_service_DecodeService_bcLibClose - (JNIEnv *, jobject); - -/* - * Class: net_irext_remote_service_DecodeService - * Method: bcGetConnAck - * Signature: ()Lcom/irext/remote/bean/jnibean/JNIBCCommands; - */ -JNIEXPORT jobject JNICALL Java_net_irext_remote_service_DecodeService_bcGetConnAck - (JNIEnv *, jobject); - -/* - * Class: net_irext_remote_service_DecodeService - * Method: bcGetCommand - * Signature: (I)Lcom/irext/remote/bean/jnibean/JNIBCCommands; - */ -JNIEXPORT jobject JNICALL Java_net_irext_remote_service_DecodeService_bcGetCommand - (JNIEnv *, jobject, jint); - #ifdef __cplusplus } #endif diff --git a/src/ir_decoder/irda_decode_jni.c b/src/ir_decoder/irda_decode_jni.c index 109938b..8cd4ae3 100644 --- a/src/ir_decoder/irda_decode_jni.c +++ b/src/ir_decoder/irda_decode_jni.c @@ -9,19 +9,88 @@ Revision log: * 2016-03-21: created by strawmanbobi **************************************************************************************************/ #include +#include #include -#include "include/irda_decode_jni.h" -#include "irda_defs.h" -#include "irda_decode.h" +#include +#include "./include/irda_decode_jni.h" +#include "./include/irda_defs.h" +#include "./include/irda_decode.h" -// function declaration -void FillBCCommandValuesToJni(JNIEnv* env, jobject j_bc_command, jclass bccommand_class, t_bc_command bc_command); +// global variable definition +UINT16 binary_length = 0; +UINT8 *binary_content = NULL; + +INT8 irda_ac_file_open(const char* file_name) +{ + FILE *stream = fopen(file_name, "rb"); + if (NULL == stream) + { + IR_PRINTF("\nfile open failed : %d\n", errno); + return IR_DECODE_FAILED; + } + + fseek(stream, 0, SEEK_END); + binary_length = ftell(stream); + binary_content = (UINT8*) irda_malloc(binary_length); + + if (NULL == binary_content) + { + IR_PRINTF("\nfailed to alloc memory for binary\n"); + return IR_DECODE_FAILED; + } + + fseek(stream, 0, SEEK_SET); + fread(binary_content, binary_length, 1, stream); + fclose(stream); + + if (IR_DECODE_FAILED == irda_ac_lib_open(binary_content, binary_length)) + { + irda_free(binary_content); + binary_length = 0; + return IR_DECODE_FAILED; + } + + return IR_DECODE_SUCCEEDED; +} + +INT8 irda_tv_file_open(const char* file_name) +{ + int print_index = 0; + FILE *stream = fopen(file_name, "rb"); + + IR_PRINTF("file name = %s\n", file_name); + + if (stream == NULL) + { + IR_PRINTF("\nfile open failed : %d\n", errno); + return IR_DECODE_FAILED; + } + + fseek(stream, 0, SEEK_END); + binary_length = ftell(stream); + IR_PRINTF("length of binary = %d\n", binary_length); + + binary_content = (UINT8*) irda_malloc(binary_length); + + fseek(stream, 0, SEEK_SET); + fread(binary_content, binary_length, 1, stream); + fclose(stream); + + if (IR_DECODE_FAILED == irda_tv_lib_open(binary_content, binary_length)) + { + irda_free(binary_content); + binary_length = 0; + return IR_DECODE_FAILED; + } + + return IR_DECODE_SUCCEEDED; +} JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaACLibOpen (JNIEnv *env, jobject this_obj, jstring file_name) { const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0); - if (IR_DECODE_FAILED == irda_ac_lib_open(n_file_name)) + if (IR_DECODE_FAILED == irda_ac_file_open(n_file_name)) { irda_ac_lib_close(); (*env)->ReleaseStringUTFChars(env, file_name, n_file_name); @@ -167,7 +236,7 @@ JNIEXPORT jint JNICALL Java_net_irext_remote_service_DecodeService_irdaTVLibOpen { const char *n_file_name = (*env)->GetStringUTFChars(env, file_name, 0); - if (IR_DECODE_FAILED == irda_tv_lib_open(n_file_name)) + if (IR_DECODE_FAILED == irda_tv_file_open(n_file_name)) { (*env)->ReleaseStringUTFChars(env, file_name, n_file_name); return IR_DECODE_FAILED;