Skip to content

Commit

Permalink
Merge pull request #54 from xianglin1998/master
Browse files Browse the repository at this point in the history
Minimum support for Android 5.1
  • Loading branch information
xianglin1998 authored Aug 13, 2020
2 parents 3e6304c + 556d071 commit e5e7f69
Show file tree
Hide file tree
Showing 16 changed files with 227 additions and 169 deletions.
6 changes: 3 additions & 3 deletions app_main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ android {
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.rfidresearchgroup.rfidtools"
minSdkVersion 24
minSdkVersion 21
targetSdkVersion 28
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
versionCode 25
versionName "1.4.7 Termux and SimpleView"
versionCode 26
versionName "1.4.8 SDK21 && PM3 CWD"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;

import cn.rrg.rdv.R;
import cn.rrg.rdv.activities.main.PM3FlasherMainActivity;
import cn.rrg.rdv.activities.proxmark3.rdv4_rrg.Proxmark3Rdv4RRGRedTeamConsoleActivity;
import cn.rrg.rdv.activities.tools.DeviceConnectActivity;
import cn.rrg.rdv.activities.proxmark3.rdv4_rrg.Proxmark3NewTerminalInitActivity;
import cn.rrg.rdv.callback.ConnectFailedCtxCallback;
Expand All @@ -20,9 +22,6 @@
import cn.dxl.common.util.PermissionUtil;

/**
* 专供RDV4连接设备
* 可以使用USB 与 SPP两种方式连接设备
*
* @author DXL
*/
public class Proxmark3Rdv4RRGConnectActivity
Expand All @@ -48,7 +47,11 @@ public AbstractDeviceModel[] getModels() {

@Override
public Class getTarget() {
return Proxmark3NewTerminalInitActivity.class;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Proxmark3NewTerminalInitActivity.class;
} else {
return Proxmark3Rdv4RRGRedTeamConsoleActivity.class;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
import android.widget.GridView;
import android.widget.TextView;

import com.termux.app.TermuxService;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -66,13 +63,8 @@ public void onClick(View v) {
initViews();
initActions();

new Thread(new Runnable() {
@Override
public void run() {
// 更改工作目录!
IORedirector.chdir(TermuxService.HOME_PATH + File.separator + Paths.PM3_PATH);
}
}).start();
// 更改工作目录!
IORedirector.chdir(Paths.PM3_CWD);
}

private void initViews() {
Expand Down
2 changes: 2 additions & 0 deletions app_main/src/main/java/cn/rrg/rdv/application/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public class Properties {
public static String k_auto_goto_terminal = "autoGotoTermuxView";
// The type of terminal
public static String k_terminal_type = "terminal_type";
// The enable status of p3m external work directory
public static String k_pm3_externl_cwd_enable = "pm3_cwd_external_enable";
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;

import androidx.annotation.NonNull;
Expand All @@ -20,7 +21,11 @@
import android.view.View;
import android.view.ViewGroup;

import com.termux.app.TermuxService;

import cn.dxl.common.util.AppUtil;
import cn.dxl.common.util.FileUtils;
import cn.dxl.common.util.LogUtils;
import cn.dxl.common.util.RestartUtils;
import cn.rrg.rdv.R;
import cn.rrg.rdv.binder.ItemSingleTextBean;
Expand All @@ -31,10 +36,13 @@
import cn.rrg.rdv.javabean.ItemToggleBean;
import cn.rrg.rdv.javabean.TitleBean;
import cn.rrg.rdv.util.Commons;
import cn.rrg.rdv.util.Paths;
import cn.rrg.rdv.util.Proxmark3Installer;
import me.drakeet.multitype.Items;
import me.drakeet.multitype.MultiTypeAdapter;

import static android.app.Activity.RESULT_OK;

/*
* 主设置活动!
* */
Expand Down Expand Up @@ -119,35 +127,53 @@ public void onClick(View view, int pos) {
pm3Res.setMessage(Commons.isPM3ResInitialled() ? getString(R.string.initialized) : getString(R.string.uninitialized));
items.add(pm3Res);

ItemToggleBean pm3AutoGo = new ItemToggleBean(getString(R.string.title_pm3_autogo_setting)) {
@Override
public void onChange(View view, int pos, boolean checked) {
Commons.setAutoGoToTerminal(checked);
}
};
pm3AutoGo.setSubTitle(getString(R.string.title_sub_pm3_autogo_setting));
pm3AutoGo.setChecked(Commons.getAutoGoToTerminal());
items.add(pm3AutoGo);
// 只有SDK版本大于等于24的时候才使能PM3的高级视图
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {

ItemToggleBean pm3AutoGo = new ItemToggleBean(getString(R.string.title_pm3_autogo_setting)) {
@Override
public void onChange(View view, int pos, boolean checked) {
Commons.setAutoGoToTerminal(checked);
}
};
pm3AutoGo.setSubTitle(getString(R.string.title_sub_pm3_autogo_setting));
pm3AutoGo.setChecked(Commons.getAutoGoToTerminal());
items.add(pm3AutoGo);

ItemTextBean pm3TerminalTypeItem = new ItemTextBean(getString(R.string.title_terminal_type_setting)) {
@Override
public void onClick(View view, int pos) {
String[] languages = new String[]{getString(R.string.item_full_terminal_view), getString(R.string.item_simple_terminal_view)};
new AlertDialog.Builder(view.getContext())
.setTitle(R.string.tips_terminal_select_like)
.setItems(languages, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Commons.setTerminalType(which);
setMessage(currentTerminalType());
multiTypeAdapter.notifyDataSetChanged();
}
}).show();
}
};
pm3TerminalTypeItem.setSubTitle(getString(R.string.title_sub_terminal_type_setting));
pm3TerminalTypeItem.setMessage(currentTerminalType());
items.add(pm3TerminalTypeItem);
}

ItemTextBean pm3TerminalTypeItem = new ItemTextBean(getString(R.string.title_terminal_type_setting)) {
// PM3 work directory select
ItemToggleBean pm3HomePathItem = new ItemToggleBean(getString(R.string.title_pm3_home)) {
@Override
public void onClick(View view, int pos) {
String[] languages = new String[]{getString(R.string.item_full_terminal_view), getString(R.string.item_simple_terminal_view)};
new AlertDialog.Builder(view.getContext())
.setTitle(R.string.tips_terminal_select_like)
.setItems(languages, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Commons.setTerminalType(which);
setMessage(currentTerminalType());
multiTypeAdapter.notifyDataSetChanged();
}
}).show();
public void onChange(View view, int pos, boolean checked) {
Commons.setPM3ExternalWorkDirectoryEnable(checked);
setSubTitle(Commons.updatePM3Cwd());
setChecked(checked);
multiTypeAdapter.notifyDataSetChanged();
}
};
pm3TerminalTypeItem.setSubTitle(getString(R.string.title_sub_terminal_type_setting));
pm3TerminalTypeItem.setMessage(currentTerminalType());
items.add(pm3TerminalTypeItem);
pm3HomePathItem.setSubTitle(Paths.PM3_CWD);
pm3HomePathItem.setChecked(Commons.isPM3ExternalWorkDirectoryEnable());
items.add(pm3HomePathItem);

items.add(new TitleBean(getString(R.string.other)));

Expand All @@ -166,6 +192,20 @@ public void onClick(View view, int pos) {
multiTypeAdapter.notifyDataSetChanged();
}

@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x77 && resultCode == RESULT_OK && data != null) {
Uri uri = data.getData();
if (uri != null) {
// get file path
String path = FileUtils.getFilePathByUri(uri);
// save
LogUtils.d("获取到的路径: " + path);
}
}
}

public static String getVersion(Context context) {
if (context == null) return "unknown";
try {
Expand Down
24 changes: 24 additions & 0 deletions app_main/src/main/java/cn/rrg/rdv/util/Commons.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,28 @@ public static int getTerminalType() {
return getPrivatePreferences()
.getInt(Properties.k_terminal_type, -1);
}

public static void setPM3ExternalWorkDirectoryEnable(boolean enable) {
getPrivatePreferences().edit()
.putBoolean(Properties.k_pm3_externl_cwd_enable, enable)
.apply();
}

public static boolean isPM3ExternalWorkDirectoryEnable() {
return getPrivatePreferences()
.getBoolean(Properties.k_pm3_externl_cwd_enable, false);
}

public static String updatePM3Cwd() {
// init pm3 cwd
if (Commons.isPM3ExternalWorkDirectoryEnable()) {
TermuxService.PM3_CWD = Paths.PM3_CWD_FINAL;
Paths.PM3_CWD = TermuxService.PM3_CWD;
new File(Paths.PM3_CWD).mkdirs();
} else {
Paths.PM3_CWD = TermuxService.HOME_PATH;
TermuxService.PM3_CWD = null;
}
return Paths.PM3_CWD;
}
}
4 changes: 4 additions & 0 deletions app_main/src/main/java/cn/rrg/rdv/util/InitUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import android.content.Context;
import android.util.Log;

import com.termux.app.TermuxActivity;
import com.termux.app.TermuxService;

import java.io.File;
import java.io.IOException;

Expand Down Expand Up @@ -75,6 +78,7 @@ public static void initApplicationResource(Context context) {
initEasyButtonFile(au);
initPM3ForwardFile();
}
Commons.updatePM3Cwd();
}

private static void initCommonInFile() {
Expand Down
111 changes: 57 additions & 54 deletions app_main/src/main/java/cn/rrg/rdv/util/Paths.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,71 +6,74 @@

import java.io.File;

public interface Paths {
public class Paths {

String EXTERNAL_STORAGE_DIRECTORY = Environment.getExternalStorageDirectory().getPath();
String TOOLS_PATH = "NfcTools";
String SETTINGS_PATH = "Settings";
String MCT_PATH = "MifareClassicTool";
String MTools_PATH = "MTools";
String HARDNESTED_PATH = "hardnested";
String LOG_PATH = "log";
String PM3_PATH = "proxmark3";
String COMMON_PATH = "common";
String PN53X_PATH = "pn53x";
String DRIVER_PATH = "driver";
String TENCENT_PATH = "tencent";
String WECAT_PATH = "MicroMsg/Download";
String QQ_PATH = "QQfile_recv";
String KEY_PATH = "keyFile";
String DUMP_PATH = "dumpFile";
String DEFAULT_KEYS_NAME = "default_keys.txt";
String DEFAULT_DUMP_NAME = "BLANK(空白).dump";
String DEFAULT_CMD_NAME = "cmd.json";
public static String EXTERNAL_STORAGE_DIRECTORY = Environment.getExternalStorageDirectory().getPath();
public static String TOOLS_PATH = "NfcTools";
public static String SETTINGS_PATH = "Settings";
public static String MCT_PATH = "MifareClassicTool";
public static String MTools_PATH = "MTools";
public static String HARDNESTED_PATH = "hardnested";
public static String LOG_PATH = "log";
public static String PM3_PATH = "proxmark3";
public static String COMMON_PATH = "common";
public static String PN53X_PATH = "pn53x";
public static String DRIVER_PATH = "driver";
public static String TENCENT_PATH = "tencent";
public static String WECAT_PATH = "MicroMsg/Download";
public static String QQ_PATH = "QQfile_recv";
public static String KEY_PATH = "keyFile";
public static String DUMP_PATH = "dumpFile";
public static String DEFAULT_KEYS_NAME = "default_keys.txt";
public static String DEFAULT_DUMP_NAME = "BLANK(空白).dump";
public static String DEFAULT_CMD_NAME = "cmd.json";

String TOOLS_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + TOOLS_PATH;
String KEY_DIRECTORY = TOOLS_DIRECTORY + "/" + KEY_PATH;
String LOG_DIRECTORY = TOOLS_DIRECTORY + "/" + LOG_PATH;
public static String TOOLS_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + TOOLS_PATH;
public static String KEY_DIRECTORY = TOOLS_DIRECTORY + "/" + KEY_PATH;
public static String LOG_DIRECTORY = TOOLS_DIRECTORY + "/" + LOG_PATH;

String MCT_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + MCT_PATH;
String MCT_DUMP_DIRECTORY = MCT_DIRECTORY + "/" + "dump-files";
String MCT_KEYS_DIRECTORY = MCT_DIRECTORY + "/" + "key-files";
public static String MCT_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + MCT_PATH;
public static String MCT_DUMP_DIRECTORY = MCT_DIRECTORY + "/" + "dump-files";
public static String MCT_KEYS_DIRECTORY = MCT_DIRECTORY + "/" + "key-files";

String MTools_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + MTools_PATH;
String MTools_DUMP_DIRECTORY = MTools_DIRECTORY + "/" + "dump";
String MTools_KEYS_DIRECTORY = MTools_DIRECTORY + "/" + "key";
public static String MTools_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + MTools_PATH;
public static String MTools_DUMP_DIRECTORY = MTools_DIRECTORY + "/" + "dump";
public static String MTools_KEYS_DIRECTORY = MTools_DIRECTORY + "/" + "key";

String COMMON_DIRECTORY = TOOLS_DIRECTORY + "/" + COMMON_PATH;
String DUMP_DIRECTORY = TOOLS_DIRECTORY + "/" + DUMP_PATH;
public static String COMMON_DIRECTORY = TOOLS_DIRECTORY + "/" + COMMON_PATH;
public static String DUMP_DIRECTORY = TOOLS_DIRECTORY + "/" + DUMP_PATH;

String PM3_DIRECTORY = TOOLS_DIRECTORY + "/" + PM3_PATH;
String PN53X_DIRRECTORY = TOOLS_DIRECTORY + "/" + PN53X_PATH;
public static String PM3_DIRECTORY = TOOLS_DIRECTORY + "/" + PM3_PATH;
public static String PN53X_DIRRECTORY = TOOLS_DIRECTORY + "/" + PN53X_PATH;

String WECAT_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + TENCENT_PATH + "/" + WECAT_PATH;
String QQ_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + TENCENT_PATH + "/" + QQ_PATH;
public static String WECAT_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + TENCENT_PATH + "/" + WECAT_PATH;
public static String QQ_DIRECTORY = EXTERNAL_STORAGE_DIRECTORY + "/" + TENCENT_PATH + "/" + QQ_PATH;

String SETTINGS_DIRECTORY = TOOLS_DIRECTORY + "/" + SETTINGS_PATH;
String SETTINGS_FILE = SETTINGS_DIRECTORY + "/" + "set.dat";
public static String SETTINGS_DIRECTORY = TOOLS_DIRECTORY + "/" + SETTINGS_PATH;
public static String SETTINGS_FILE = SETTINGS_DIRECTORY + "/" + "set.dat";

String PM3_BOOT_FILE_NAME = "bootrom.elf";
String PM3_OS_FILE_NAME = "fullimage.elf";
String PM3_FORWARD_O = PM3_DIRECTORY + "/" + "pm3_forward_o.txt";
String PM3_FORWARD_E = PM3_DIRECTORY + "/" + "pm3_forward_e.txt";
public static String PM3_BOOT_FILE_NAME = "bootrom.elf";
public static String PM3_OS_FILE_NAME = "fullimage.elf";
public static String PM3_FORWARD_O = PM3_DIRECTORY + "/" + "pm3_forward_o.txt";
public static String PM3_FORWARD_E = PM3_DIRECTORY + "/" + "pm3_forward_e.txt";
//PM3 Easy Button
String PM3_CMD_FILE = PM3_DIRECTORY + "/" + DEFAULT_CMD_NAME;
public static String PM3_CMD_FILE = PM3_DIRECTORY + "/" + DEFAULT_CMD_NAME;
// PM3 Image
String PM3_IMAGE_BOOT_FILE = TermuxService.HOME_PATH + File.separator + PM3_PATH + File.separator + PM3_BOOT_FILE_NAME;
String PM3_IMAGE_OS_FILE = TermuxService.HOME_PATH + File.separator + PM3_PATH + File.separator + PM3_OS_FILE_NAME;
public static String PM3_IMAGE_BOOT_FILE = TermuxService.HOME_PATH + File.separator + PM3_PATH + File.separator + PM3_BOOT_FILE_NAME;
public static String PM3_IMAGE_OS_FILE = TermuxService.HOME_PATH + File.separator + PM3_PATH + File.separator + PM3_OS_FILE_NAME;
// pm3 cwd -> sdcard
public static String PM3_CWD = PM3_DIRECTORY + File.separator + "home";
public static final String PM3_CWD_FINAL = PM3_DIRECTORY + File.separator + "home";

String PN53X_FORWARD_O = PN53X_DIRRECTORY + "/" + "pn53x_forward_o.txt";
String PN53X_FORWARD_E = PN53X_DIRRECTORY + "/" + "pn53x_forward_e.txt";
String PN53X_FORWARD_MF_O = PN53X_DIRRECTORY + "/" + "pn53x_forward_mf_o.txt";
String PN53X_FORWARD_MF_E = PN53X_DIRRECTORY + "/" + "pn53x_forward_mf_e.txt";
String COMMON_FORWARD_O = COMMON_DIRECTORY + "/" + "common_forward_o.txt";
String COMMON_FORWARD_E = COMMON_DIRECTORY + "/" + "common_forward_e.txt";
String COMMON_FORWARD_I = COMMON_DIRECTORY + "/" + "common_forward_i.txt";
public static String PN53X_FORWARD_O = PN53X_DIRRECTORY + "/" + "pn53x_forward_o.txt";
public static String PN53X_FORWARD_E = PN53X_DIRRECTORY + "/" + "pn53x_forward_e.txt";
public static String PN53X_FORWARD_MF_O = PN53X_DIRRECTORY + "/" + "pn53x_forward_mf_o.txt";
public static String PN53X_FORWARD_MF_E = PN53X_DIRRECTORY + "/" + "pn53x_forward_mf_e.txt";
public static String COMMON_FORWARD_O = COMMON_DIRECTORY + "/" + "common_forward_o.txt";
public static String COMMON_FORWARD_E = COMMON_DIRECTORY + "/" + "common_forward_e.txt";
public static String COMMON_FORWARD_I = COMMON_DIRECTORY + "/" + "common_forward_i.txt";

String DEFAULT_KEYS_FILE = KEY_DIRECTORY + "/" + DEFAULT_KEYS_NAME;
String DEFAULT_DUMP_FILE = DUMP_DIRECTORY + "/" + DEFAULT_DUMP_NAME;
String DRIVER_DIRECTORY = TOOLS_DIRECTORY + "/" + DRIVER_PATH;
public static String DEFAULT_KEYS_FILE = KEY_DIRECTORY + "/" + DEFAULT_KEYS_NAME;
public static String DEFAULT_DUMP_FILE = DUMP_DIRECTORY + "/" + DEFAULT_DUMP_NAME;
public static String DRIVER_DIRECTORY = TOOLS_DIRECTORY + "/" + DRIVER_PATH;
}
Loading

0 comments on commit e5e7f69

Please sign in to comment.