Flasher implemented(100%), and stability issues fixed.

This commit is contained in:
dxl
2020-03-13 15:07:41 +08:00
parent cc5da1283a
commit af74dd703e
16 changed files with 79 additions and 74 deletions
@@ -2,6 +2,8 @@ package cn.rrg.rdv.activities.connect;
import android.Manifest;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
@@ -12,6 +14,7 @@ import android.widget.TextView;
import cn.dxl.common.util.DisplayUtil;
import cn.rrg.rdv.R;
import cn.rrg.rdv.activities.main.PM3FlasherMainActivity;
import cn.rrg.rdv.activities.main.Proxmark3Rdv4RRGMain;
import cn.rrg.rdv.activities.tools.DeviceConnectActivity;
import cn.rrg.rdv.callback.ConnectFailedCtxCallback;
@@ -43,9 +46,7 @@ public class Proxmark3Rdv4RRGConnectActivity
@Override
public AbstractDeviceModel[] getModels() {
return new AbstractDeviceModel[]{
//RDV4支持SPP数据源,因此提供SPP的通信!
new Proxmark3Rdv4SppModel(),
//RDV4还支持USB的数据源,同样提供USB的通信!
new Proxmark3Rdv4UsbModel()
};
}
@@ -76,14 +77,17 @@ public class Proxmark3Rdv4RRGConnectActivity
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
int paddingValue = DisplayUtil.dip2px(activity, 16);
TextView msg = new TextView(activity);
msg.setTextIsSelectable(true);
msg.setPadding(paddingValue, paddingValue, paddingValue, paddingValue);
msg.setText(Html.fromHtml(activity.getString(R.string.connect_errr_msg_1)));
new AlertDialog.Builder(activity)
.setTitle(R.string.connect_faild)
.setView(msg).show();
.setMessage(R.string.connect_errr_msg_1)
.setPositiveButton(getString(R.string.flash) + "(OTG)", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(context, PM3FlasherMainActivity.class));
}
})
.setNegativeButton(R.string.cancel, null)
.show();
}
});
}
@@ -42,9 +42,6 @@ public class AppMain extends BaseActivity {
initActions();
gotoFragment(appMainDevicesFragment);
startActivity(new Intent(context, PM3FlasherMainActivity.class));
finish();
}
private void initViews() {
@@ -78,6 +78,8 @@ public class PM3FlasherMainActivity extends BaseActivity implements DevCallback<
}
private void flashDefaultFW() {
if (!mDialogWorkingState.isShowing())
mDialogWorkingState.show();
new Thread(new Runnable() {
@Override
public void run() {
@@ -108,7 +110,7 @@ public class PM3FlasherMainActivity extends BaseActivity implements DevCallback<
}
finishFlash();
ToastUtil.show(context, getString(R.string.finish), false);
mode = MODE.BOOT;
finish();
break;
}
} else {
@@ -125,11 +127,21 @@ public class PM3FlasherMainActivity extends BaseActivity implements DevCallback<
flasher.close(Target.CLIENT);
}
private void closeClient() {
new Thread(new Runnable() {
@Override
public void run() {
flasher.close(Target.CLIENT);
}
}).start();
}
@Override
protected void onDestroy() {
super.onDestroy();
mDialogWorkingState.dismiss();
control.unregister(this);
flasher.close(Target.CLIENT);
closeClient();
}
@Override
@@ -141,7 +153,6 @@ public class PM3FlasherMainActivity extends BaseActivity implements DevCallback<
@Override
public void onDetach(String dev) {
flasher.close(Target.CLIENT);
}
@Override
@@ -454,7 +454,6 @@ public abstract class BaseConsoleActivity extends BaseActivity {
// 我们需要单独处理其中的每个/r,进行视觉更新!
for (String s : newLineReturnArr) {
arr[arr.length - 1] = s;
Log.d(LOG_TAG, "当前被newLineReturnArr拼接的行: " + arr[arr.length - 1]);
// 拼接回去!
StringBuilder sb = new StringBuilder();
for (int j = 0; j < arr.length; ++j) {
@@ -466,7 +465,6 @@ public abstract class BaseConsoleActivity extends BaseActivity {
}
} else {
arr[arr.length - 1] = line;
Log.d(LOG_TAG, "当前被arr拼接的行: " + arr[arr.length - 1]);
// 拼接回去!
StringBuilder sb = new StringBuilder();
for (int i = 0; i < arr.length; ++i) {
@@ -46,7 +46,7 @@ public abstract class DeviceConnectActivity
public abstract ConnectFailedCtxCallback getCallback();
//数据源承载数组!
AbstractDeviceModel[] models;
public AbstractDeviceModel[] models;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -62,16 +62,8 @@ public abstract class DeviceConnectActivity
model.register(this);
}
Bundle data = new Bundle();
data.putSerializable("models", models);
data.putSerializable("target", getTarget());
data.putSerializable("callback", getCallback());
data.putString("msg", getConnectingMsg());
Fragment newDevFragment = new DeviceConnectNewFragment();
Fragment allDevFragment = new DeviceConnectAllFragment();
newDevFragment.setArguments(data);
allDevFragment.setArguments(data);
//初始化分页适配器!
FragmentPagerAdapter mAdapter =
@@ -15,6 +15,7 @@ import android.widget.TextView;
import java.util.ArrayList;
import cn.rrg.rdv.R;
import cn.rrg.rdv.activities.tools.DeviceConnectActivity;
import cn.rrg.rdv.callback.ConnectFailedCtxCallback;
import cn.rrg.rdv.fragment.base.AppMainDevicesFragment;
import cn.rrg.rdv.models.AbstractDeviceModel;
@@ -33,12 +34,13 @@ public abstract class DeviceConnectFragment
@Override
protected void initResource() {
Bundle data = getArguments();
if (data != null) {
this.models = (AbstractDeviceModel[]) data.getSerializable("models");
this.target = (Class) data.getSerializable("target");
this.connectCallback = (ConnectFailedCtxCallback) data.getSerializable("callback");
Activity activity = getActivity();
if (activity == null) return;
if (activity instanceof DeviceConnectActivity) {
this.models = ((DeviceConnectActivity) activity).models;
if (models != null) {
this.target = ((DeviceConnectActivity) activity).getTarget();
this.connectCallback = ((DeviceConnectActivity) activity).getCallback();
for (AbstractDeviceModel m : models) {
//初始化中介者并且绑定视图!
DevicePresenter<DeviceView> presenter = new DevicePresenter<>(m);
@@ -46,15 +48,13 @@ public abstract class DeviceConnectFragment
presenter.attachView(this);
presenters.add(presenter);
}
String msg = ((DeviceConnectActivity) activity).getConnectingMsg();
if (msg != null) {
((TextView) (msgView.findViewById(R.id.text1))).setText(msg);
}
} else {
throw new RuntimeException("Models container null exception!");
throw new RuntimeException("Models not init exception!");
}
String msg = data.getString("msg");
if (msg != null) {
((TextView) (msgView.findViewById(R.id.text1))).setText(msg);
}
} else {
throw new RuntimeException("Models not init exception!");
}
}
@@ -19,18 +19,7 @@ public abstract class AbsUsb2UartModel extends AbstractDeviceModel<String, UsbMa
@Override
public DriverInterface<String, UsbManager> getDriverInterface() {
DriverInterface di = DriverSource.driverMap.get(0x04);
if (di != null) {
ContextHandle contextHandle = (ContextHandle) di;
contextHandle.setContextCallback(new ContextCallback() {
@Override
public Context getContext() {
return AppUtil.getInstance().getApp();
}
});
return di;
}
return null;
return DriverSource.driverMap.get(0x04);
}
@Override
@@ -3,10 +3,12 @@ package cn.rrg.rdv.models;
import android.content.Context;
import android.util.Log;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import cn.dxl.common.util.LogUtils;
import cn.rrg.com.DevCallback;
import cn.rrg.com.DriverInterface;
@@ -172,6 +174,13 @@ public abstract class AbstractDeviceModel<D, A>
if (Com.initCom(mDI, mDevice)) {
callback.onInitSuccess();
} else {
try {
LogUtils.d("初始化失败,将会调用设备封装类关闭设备!");
// close device!
mDevice.close();
} catch (IOException e) {
e.printStackTrace();
}
callback.onInitFail();
}
}
@@ -100,11 +100,16 @@ public class InitUtil {
}
private static void initProxmark3RDV4ImageFile(AssetsUtil au) {
//初始化标准输入的文件!
File boot = new File(Paths.PM3_IMAGE_BOOT_FILE);
File os = new File(Paths.PM3_IMAGE_OS_FILE);
au.moveFile(Paths.PM3_BOOT_FILE_NAME, boot.getAbsolutePath());
au.moveFile(Paths.PM3_OS_FILE_NAME, os.getAbsolutePath());
new Thread(new Runnable() {
@Override
public void run() {
//初始化标准输入的文件!
File boot = new File(Paths.PM3_IMAGE_BOOT_FILE);
File os = new File(Paths.PM3_IMAGE_OS_FILE);
au.moveFile(Paths.PM3_BOOT_FILE_NAME, boot.getAbsolutePath());
au.moveFile(Paths.PM3_OS_FILE_NAME, os.getAbsolutePath());
}
}).start();
}
private static void initMfInfoMapsFile(AssetsUtil au) {
+3 -5
View File
@@ -170,11 +170,9 @@
<string name="go2_proxgrind_website">&lt;p style=&quot;color:black;&quot;&gt;&lt;big&gt;Powered&lt;/big&gt;&lt;/p&gt;&lt;p&gt;By: ProxGrind&lt;/p&gt;&lt;p&gt;&lt;small&gt;Click go to web site&lt;/small&gt;&lt;/p&gt;</string>
<string name="go2_rrg_website">&lt;p style=&quot;color:black;&quot;&gt;&lt;big&gt;Distributed&lt;/big&gt;&lt;/p&gt;&lt;p&gt;By: RFID Research Group (RRG)&lt;/p&gt;&lt;p&gt;&lt;small&gt;Click go to web site&lt;/small&gt;&lt;/p&gt;</string>
<string name="nfc_not_turned_on">NFC not turned on</string>
<string name="connect_errr_msg_1">&lt;p&gt;1、To ensure that firmware versions are consistent, please login at&lt;/p&gt;
&lt;p style=&quot;color:green&quot;&gt;http://proxgrind.com/free-sdk/&lt;/p&gt;
&lt;p&gt;download the corresponding version.&lt;/p&gt;
&lt;p&gt;2.Make sure the battery has sufficient voltage.&lt;/p&gt;
&lt;p&gt;3.Restart the device and APP, reconnect.&lt;/p&gt;</string>
<string name="connect_errr_msg_1">1. Confirm that the firmware version is the same as the app client. You can log in "http://proxgrind.com/free-sdk/" to download the corresponding version, or directly click the button below to flash\n
2. Make sure the battery has enough voltage\n
3. Restart the external device and app and try to connect again</string>
<string name="connect_faild">Connection failed</string>
<string name="nfc_not_open">Your NFC is not open and cannot use this function. Please open your NFC first.</string>
<string name="open">open</string>
+3 -5
View File
@@ -166,11 +166,9 @@
<string name="go2_proxgrind_website">&lt;p style=&quot;color:black;&quot;&gt;&lt;big&gt;技术&lt;/big&gt;&lt;/p&gt;&lt;p&gt;By: ProxGrind&lt;/p&gt;&lt;p&gt;&lt;small&gt;点击前往主页&lt;/small&gt;&lt;/p&gt;</string>
<string name="go2_rrg_website">&lt;p style=&quot;color:black;&quot;&gt;&lt;big&gt;发布&lt;/big&gt;&lt;/p&gt;&lt;p&gt;By: RFID Research Group (RRG)&lt;/p&gt;&lt;p&gt;&lt;small&gt;点击前往主页&lt;/small&gt;&lt;/p&gt;</string>
<string name="nfc_not_turned_on">NFC 未开启</string>
<string name="connect_errr_msg_1">&lt;p&gt;1、为确保固件版本一致,请登录&lt;/p&gt;
&lt;p style=&quot;color:green&quot;&gt;http://proxgrind.com/free-sdk/&lt;/p&gt;
&lt;p&gt;下载相应的版本。&lt;/p&gt;
&lt;p&gt;2.确保电池有足够的电压.&lt;/p&gt;
&lt;p&gt;3.重启外置设备和APP 重新连接&lt;/p&gt;</string>
<string name="connect_errr_msg_1">1、确认固件版本与APP客户端一致,可以登录 http://proxgrind.com/free-sdk/ 下载相应的版本,或直接点击下方按钮刷写
2、确保电池有足够的电压电量
3、重启外置设备和APP并且重新尝试连接</string>
<string name="connect_faild">连接失败</string>
<string name="nfc_not_open">您的NFC未打开,无法使用该功能,请先打开您的NFC</string>
<string name="open">打开</string>
+3 -5
View File
@@ -169,11 +169,9 @@
<string name="go2_proxgrind_website">&lt;p style=&quot;color:black;&quot;&gt;&lt;big&gt;Powered&lt;/big&gt;&lt;/p&gt;&lt;p&gt;By: ProxGrind&lt;/p&gt;&lt;p&gt;&lt;small&gt;Click go to web site&lt;/small&gt;&lt;/p&gt;</string>
<string name="go2_rrg_website">&lt;p style=&quot;color:black;&quot;&gt;&lt;big&gt;Distributed&lt;/big&gt;&lt;/p&gt;&lt;p&gt;By: RFID Research Group (RRG)&lt;/p&gt;&lt;p&gt;&lt;small&gt;Click go to web site&lt;/small&gt;&lt;/p&gt;</string>
<string name="nfc_not_turned_on">NFC not turned on</string>
<string name="connect_errr_msg_1">&lt;p&gt;1.To ensure that firmware versions are consistent, please login at&lt;/p&gt;
&lt;p style=&quot;color:green&quot;&gt;http://proxgrind.com/free-sdk/&lt;/p&gt;
&lt;p&gt;download the corresponding version.&lt;/p&gt;
&lt;p&gt;2.Make sure the battery has sufficient voltage.&lt;/p&gt;
&lt;p&gt;3.Restart the device and APP, reconnect.&lt;/p&gt;</string>
<string name="connect_errr_msg_1">1. Confirm that the firmware version is the same as the app client. You can log in "http://proxgrind.com/free-sdk/" to download the corresponding version, or directly click the button below to flash\n
2. Make sure the battery has enough voltage\n
3. Restart the external device and app and try to connect again</string>
<string name="connect_faild">Connection failed</string>
<string name="nfc_not_open">Your NFC is not open and cannot use this function. Please open your NFC first.</string>
<string name="open">open</string>
-1
View File
@@ -751,7 +751,6 @@ bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms
// Wait until the command is received
while (true) {
while (getReply(response)) {
if (cmd == CMD_UNKNOWN || response->cmd == cmd) {
return true;
+3 -1
View File
@@ -708,7 +708,9 @@ void CloseProxmark(void) {
// Clean up our state
sp = NULL;
memset(&communication_thread, 0, sizeof(pthread_t));
if (communication_thread != 0) {
memset(&communication_thread, 0, sizeof(pthread_t));
}
session.pm3_present = false;
}
+2 -1
View File
@@ -998,7 +998,8 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
{"isExecuting", "()Z", (void *) isExecuting}
};
JNINativeMethod methods1[] = {
{"testPm3", "()Z", (void *) testPm3}
{"testPm3", "()Z", (void *) testPm3},
{"closePm3", "()V", stopPm3}
};
//构建和初始化函数结构体,分别是java层的函数名称,签名,对应的函数指针
JNINativeMethod methods2[] = {
@@ -5,6 +5,7 @@ import java.io.IOException;
import cn.rrg.com.Device;
public class Proxmark3RRGRdv4 implements Device {
static {
System.loadLibrary("pm3rrg_rdv4");
}
@@ -16,8 +17,11 @@ public class Proxmark3RRGRdv4 implements Device {
@Override
public boolean close() throws IOException {
return false;
closePm3();
return true;
}
public native boolean testPm3() throws IOException;
private native boolean testPm3() throws IOException;
private native void closePm3();
}