diff --git a/app_main/build.gradle b/app_main/build.gradle
index 77f1c503..5d3cb5a5 100644
--- a/app_main/build.gradle
+++ b/app_main/build.gradle
@@ -52,7 +52,9 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0'
- implementation project(':io_redirect')
+ // This my project maven from github release!
+ implementation 'com.github.xianglin1998:IORedirector:1.0'
+
implementation project(':utils')
implementation project(':mfkey_32_64')
implementation project(':libnfc_pn53x')
diff --git a/io_redirect/.gitignore b/io_redirect/.gitignore
deleted file mode 100644
index 3889eda0..00000000
--- a/io_redirect/.gitignore
+++ /dev/null
@@ -1,62 +0,0 @@
-# Built application files
-*.apk
-*.ap_
-
-# Files for the ART/Dalvik VM
-*.dex
-
-# Java class files
-*.class
-
-# Generated files
-bin/
-gen/
-out/
-
-# Cmake gen
-.cxx/
-
-# Gradle files
-.gradle/
-build/
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Log Files
-*.log
-
-# Android Studio Navigation editor temp files
-.navigation/
-
-# Android Studio captures folder
-captures/
-
-# IntelliJ
-*.iml
-.idea/
-
-# Keystore files
-# Uncomment the following line if you do not want to check your keystore files in.
-#*.jks
-
-# External native build folder generated in Android Studio 2.2 and later
-.externalNativeBuild
-
-# Google Services (e.g. APIs or Firebase)
-google-services.json
-
-# Freeline
-freeline.py
-freeline/
-freeline_project_description.json
-
-# fastlane
-fastlane/report.xml
-fastlane/Preview.html
-fastlane/screenshots
-fastlane/test_output
-fastlane/readme.md
diff --git a/io_redirect/build.gradle b/io_redirect/build.gradle
deleted file mode 100644
index f55ac1a7..00000000
--- a/io_redirect/build.gradle
+++ /dev/null
@@ -1,44 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 29
- buildToolsVersion "29.0.2"
-
- defaultConfig {
- minSdkVersion 19
- targetSdkVersion 29
- externalNativeBuild {
- cmake {
- arguments '-DANDROID_STL=c++_static'
- abiFilters "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
- }
- //abiFilters "armeabi"
- /*abiFilters "arm64-v8a"*/
- /*abiFilters "x86_64"*/
- /*abiFilters "arm64-v8a"
- abiFilters "mips"
- abiFilters "mips64"
- abiFilters "x86"
- abiFilters "x86_64"*/
- }
- }
- externalNativeBuild {
- cmake {
- version '3.10.2'
- path 'src/main/cpp/CMakeLists.txt'
- }
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
-
-}
-
-dependencies {
- implementation fileTree(dir: 'libs', include: ['*.jar'])
- implementation 'androidx.appcompat:appcompat:1.1.0'
-}
\ No newline at end of file
diff --git a/io_redirect/proguard-rules.pro b/io_redirect/proguard-rules.pro
deleted file mode 100644
index f1b42451..00000000
--- a/io_redirect/proguard-rules.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-# Add project specific ProGuard rules here.
-# You can control the set of applied configuration files using the
-# proguardFiles setting in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
-
-# Uncomment this to preserve the line number information for
-# debugging stack traces.
-#-keepattributes SourceFile,LineNumberTable
-
-# If you keep the line number information, uncomment this to
-# hide the original source file name.
-#-renamesourcefileattribute SourceFile
diff --git a/io_redirect/src/main/AndroidManifest.xml b/io_redirect/src/main/AndroidManifest.xml
deleted file mode 100644
index 78f84e7a..00000000
--- a/io_redirect/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-
diff --git a/io_redirect/src/main/cpp/CMakeLists.txt b/io_redirect/src/main/cpp/CMakeLists.txt
deleted file mode 100644
index b9c948c8..00000000
--- a/io_redirect/src/main/cpp/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-#需要的最cmake版本
-cmake_minimum_required(VERSION 3.4.1)
-
-#添加动态库定义
-add_library(freopen SHARED util.c)
-
-#添加头文件配置
-target_include_directories(freopen PRIVATE)
-
-#添加动态库链接!
-target_link_libraries(freopen android)
\ No newline at end of file
diff --git a/io_redirect/src/main/cpp/util.c b/io_redirect/src/main/cpp/util.c
deleted file mode 100644
index de78d738..00000000
--- a/io_redirect/src/main/cpp/util.c
+++ /dev/null
@@ -1,228 +0,0 @@
-//
-// Created by DXL on 2019/3/4.
-//
-#include
-#include
-#include
-#include
-#include
-
-/*
- * 全局的重定向文件句柄缓存!
- * */
-static FILE *ofp;
-static FILE *efp;
-static FILE *ifp;
-
-/*
- * 从文件指针获得文件路径!
- * *//*
-static char *GetPathFromFP(FILE *FP) {
- if (!FP) return NULL;
- //取得文件描述符!
- int fdi = fileno(FP);
- char proclnk[512] = {0};
- char path[512] = {0};
- //进行链接路径拼接!
- sprintf(proclnk, "/proc/self/fd/%d", fdi);
- ssize_t r = readlink(proclnk, path, sizeof(path));
- //LOGD("底层打印ResetStdEO路径: %s", path);
- if (r <= 0) {
- //LOGD("GetPathFromFP获取路径失败!");
- return NULL;
- }
- return strdup(path);
-}*/
-
-/*
- * 标准输出重定向!
- * */
-jboolean SetStdEO(JNIEnv *env, jclass clz, jstring file, jint type) {
- //判断传入的参数的可用性!
- if (!file) return false;
- jboolean isCopy = false;
- //解析为char *;
- const char *_file = (*env)->GetStringUTFChars(env, file, &isCopy);
- //尝试打开文件
- switch (type) {
- case 0:
- //尝试关闭句柄!
- if (ofp) {
- fclose(ofp);
- ofp = NULL;
- }
- if (!(ofp = freopen(_file, "w+", stdout))) {
- //谨记释放内存!
- (*env)->ReleaseStringUTFChars(env, file, _file);
- return false;
- }
- //TODO 非常重要,必须清空文件!
- ftruncate(fileno(ofp), 0);
- setbuf(stdout, NULL);
- break;
- case 1:
- //尝试关闭句柄!
- if (efp) {
- fclose(efp);
- efp = NULL;
- }
- if (!(efp = freopen(_file, "w+", stderr))) {
- //谨记释放内存!
- (*env)->ReleaseStringUTFChars(env, file, _file);
- return false;
- }
- //TODO 非常重要,必须清空文件!
- ftruncate(fileno(efp), 0);
- setbuf(stderr, NULL);
- break;
- default:
- //谨记释放内存!
- (*env)->ReleaseStringUTFChars(env, file, _file);
- return false;
- }
- //谨记释放内存!
- (*env)->ReleaseStringUTFChars(env, file, _file);
- return true;
-}
-
-/*
- * 标准输出重定向!
- * */
-jboolean SetStdIN(JNIEnv *env, jclass clz, jstring file) {
- //判断传入的参数的可用性!
- if (!file) return false;
- jboolean isCopy = false;
- //解析为char *;
- const char *_file = (*env)->GetStringUTFChars(env, file, &isCopy);
- //尝试打开文件
- //尝试关闭句柄!
- if (ifp) {
- fclose(ifp);
- ifp = NULL;
- }
- if (!(ifp = freopen(_file, "w+", stdin))) {
- //谨记释放内存!
- (*env)->ReleaseStringUTFChars(env, file, _file);
- return false;
- }
- //TODO 非常重要,必须清空文件!
- ftruncate(fileno(ifp), 0);
- setbuf(stdin, NULL);
- //谨记释放内存!
- (*env)->ReleaseStringUTFChars(env, file, _file);
- return true;
-}
-
-/*
- * 标准输出重定向!
- * */
-jboolean Close(JNIEnv *env, jclass clz, jstring file, jint type) {
- //判断传入的参数的可用性!
- if (!file) return false;
- jboolean isCopy = false;
- //解析为char *;
- const char *_file = (*env)->GetStringUTFChars(env, file, &isCopy);
- bool ret = true;
- //尝试打开文件
- switch (type) {
- case 0:
- //尝试关闭句柄!
- if (ofp) {
- if (fclose(ofp) == 0) {
- ret = false;
- } else {
- ret = true;
- }
- ofp = NULL;
- }
- break;
- case 1:
- //尝试关闭句柄!
- if (efp) {
- if (fclose(efp) == 0) {
- ret = false;
- } else {
- ret = true;
- }
- efp = NULL;
- }
- break;
- case 2:
- //尝试关闭句柄!
- if (ifp) {
- if (fclose(ifp) == 0) {
- ret = false;
- } else {
- ret = true;
- }
- ifp = NULL;
- }
- break;
- default:
- //谨记释放内存!
- (*env)->ReleaseStringUTFChars(env, file, _file);
- return false;
- }
- //谨记释放内存!
- (*env)->ReleaseStringUTFChars(env, file, _file);
- return (jboolean) ret;
-}
-
-//清空标准输入缓冲区!
-void clearStdIN(JNIEnv *env, jclass clz) {
- if (ifp) {
- //在循环中读取有效字符,相当于清空缓冲区!
- char tmp[1];
- int fd = fileno(ifp);
- if (fd != -1) {
- while (read(fd, tmp, 1) > 0);
- }
- }
-}
-
-/*
- * 更改工作目录
- * */
-jboolean chdir_m(JNIEnv *env, jclass clz, jstring path) {
- //判断传入的参数的可用性!
- if (!path) return false;
- jboolean isCopy = false;
- //解析为char *;
- const char *_path = (*env)->GetStringUTFChars(env, path, &isCopy);
- // 更改工作目录
- jboolean ret = (jboolean) (chdir(_path) != 0);
- //谨记释放内存!
- (*env)->ReleaseStringUTFChars(env, path, _path);
- return ret;
-}
-
-/*
- * jvm加载so时的映射回调
- * */
-JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
- JNIEnv *jniEnv = NULL;
- //得到当前的jvm环境指针
- if ((*vm)->GetEnv(vm, (void **) &jniEnv, JNI_VERSION_1_4) != JNI_OK) return -1;
- //初始化全局的jvm函数指针
- (*jniEnv)->GetJavaVM(jniEnv, &vm);
- //得到native函数的定义类
- jclass clazz = (*jniEnv)->FindClass(jniEnv, "cn/rrg/freo/IORedirector");
- if (clazz == NULL) {
- return -1;
- }
- //构建和初始化函数结构体,分别是java层的函数名称,签名,对应的函数指针
- JNINativeMethod methods[] = {
- {"setStdEO", "(Ljava/lang/String;I)Z", (void *) SetStdEO},
- {"setStdIN", "(Ljava/lang/String;)Z", (void *) SetStdIN},
- {"clearStdIN", "()V", (void *) clearStdIN},
- {"close", "(Ljava/lang/String;I)Z", (void *) Close},
- {"chdir", "(Ljava/lang/String;)Z", (void *) chdir_m}
- };
- //注册函数
- if ((*jniEnv)->RegisterNatives(jniEnv, clazz, methods, sizeof(methods) / sizeof(methods[0])) !=
- JNI_OK) {
- return -1;
- }
- //最后一定要返回jni的版本。
- return JNI_VERSION_1_4;
-}
\ No newline at end of file
diff --git a/io_redirect/src/main/java/cn/rrg/freo/IORedirector.java b/io_redirect/src/main/java/cn/rrg/freo/IORedirector.java
deleted file mode 100644
index 6a73f62c..00000000
--- a/io_redirect/src/main/java/cn/rrg/freo/IORedirector.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package cn.rrg.freo;
-
-/*
- * 标准流重定向工具!
- * */
-public class IORedirector {
-
- static {
- //加载动态库!
- System.loadLibrary("freopen");
- }
-
- /**
- * 规范化类型传递!
- * STD_OUT 标准输出
- * STD_ERR 标准异常
- * STD_IN 标准输入!
- */
- public static final int STD_OUT = 0;
- public static final int STD_ERR = 1;
- public static final int STD_IN = 2;
-
- /**
- * 设置STDOUT、STDERR的重定向!
- *
- * @param file 文件地址,绝对路径!
- * @param type 类型,O或者E,对应{STD_OUT}、{STD_ERR}
- * @return 设置结果,可能的结果:文件不存在、文件无权限、文件被占用 or 成功!
- */
- public static native boolean setStdEO(String file, int type);
-
- /**
- * 设置的STD_IN重定向!
- *
- * @param file 文件地址,绝对路径!
- * @return 设置结果,可能的结果:文件不存在、文件无权限、文件被占用 or 成功!
- */
- public static native boolean setStdIN(String file);
-
- //清空标准输入的缓冲区,防止多次执行stop的误判!
- public static native void clearStdIN();
-
- /**
- * 关闭重定向,实际是关闭底层的文件!
- * * @param file 文件地址,绝对路径!
- */
- public static native boolean close(String file, int type);
-
- /* *//*
- * 进行重定向的流的flush,根据系统的实现不一定可用!
- * @param 0 = out, 1 = err
- * *//*
- public static native void flushStdEO(int type);
-
- *//*
- * 进行重定向文件的清空,与BUF的清空
- * @param type 需要被清空的标准流的类型,同上!
- * *//*
- public static native void resetStdEO(int type);*/
-
- /**
- * 更改工作目录,使一些相对路径的函数可以发现相关的文件
- *
- * @param path 绝对路径,最终程序的工作目录
- * @return 设置结果,如果参数不符合需求或者没有权限将会返回false,
- * 设置成功返回true
- */
- public static native boolean chdir(String path);
-}
diff --git a/io_redirect/src/main/res/values/strings.xml b/io_redirect/src/main/res/values/strings.xml
deleted file mode 100644
index 0d34ec76..00000000
--- a/io_redirect/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- freo
-
diff --git a/settings.gradle b/settings.gradle
index 3a253b97..139a2ee2 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,2 +1,2 @@
-include ':app_main', ':utils', ':io_redirect', ':crapto1', ':mfkey_32_64', ':console', ':chameleon', ':communication', ':libnfc_pn53x', ':pm3official', ':pm3iceman', ':pm3rdv4rrg', ':mifaretag'
+include ':app_main', ':utils', ':crapto1', ':mfkey_32_64', ':console', ':chameleon', ':communication', ':libnfc_pn53x', ':pm3official', ':pm3iceman', ':pm3rdv4rrg', ':mifaretag'
include ':pm3flasher'