Browse Source

handle se communication failed (#43)

V1.2.0-btc-release
JunZhang 5 years ago
committed by GitHub
parent
commit
88a10d99fa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/src/main/java/com/cobo/cold/selfcheck/SecurityCheck.java
  2. 32
      app/src/main/java/com/cobo/cold/ui/fragment/AttackWarningFragment.java
  3. 4
      app/src/main/res/values-zh-rCN/strings.xml
  4. 4
      app/src/main/res/values/strings.xml

2
app/src/main/java/com/cobo/cold/selfcheck/SecurityCheck.java

@ -48,7 +48,7 @@ public class SecurityCheck {
private static final int CODE_SYS_OK = 0x00;
private static final int CODE_SYS_ATTACKED = 0x01;
private static final int CODE_FW_OK = 0x0000;
private static final int CODE_FW_GET_STATUS_FAILED = 0x0100;
public static final int CODE_FW_GET_STATUS_FAILED = 0x0100;
private static final int CODE_FW_STATUS_NOT_FOUND = 0x0200;
private static final int CODE_FW_STATUS_ATTACKED = 0x0300;
private static final int CODE_FW_ERT_ATTACKED = 0x0400;

32
app/src/main/java/com/cobo/cold/ui/fragment/AttackWarningFragment.java

@ -17,8 +17,12 @@
package com.cobo.cold.ui.fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IPowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.view.View;
@ -34,6 +38,7 @@ import java.util.Locale;
import java.util.Objects;
import java.util.concurrent.Executors;
import static com.cobo.cold.selfcheck.SecurityCheck.CODE_FW_GET_STATUS_FAILED;
import static com.cobo.cold.selfcheck.SecurityCheck.CODE_FW_IN_BOOTMODE;
import static com.cobo.cold.ui.fragment.setting.MainPreferenceFragment.removeAllFingerprint;
@ -59,16 +64,39 @@ public class AttackWarningFragment extends BaseFragment<AttackWarningBinding> {
if (firmware == CODE_FW_IN_BOOTMODE) {
mBinding.text1.setText(R.string.update_failed);
mBinding.hint.setText(getString(R.string.contact_cobo_service,formatErrorCode(data)));
mBinding.hint.setText(getString(R.string.contact_cobo_service, formatErrorCode(data)));
} else if(firmware == CODE_FW_GET_STATUS_FAILED) {
mBinding.text1.setText(R.string.opration_failed);
mBinding.hint.setText(getString(R.string.reboot_hint,formatErrorCode(data)));
}
if (firmware == CODE_FW_GET_STATUS_FAILED) {
mBinding.powerOff.setText(R.string.reboot);
mBinding.powerOff.setOnClickListener(v -> reboot());
} else {
mBinding.powerOff.setText(R.string.clear_and_power_off);
mBinding.powerOff.setOnClickListener(v -> handleAttack(mActivity));
}
mBinding.serialno.setText(getString(R.string.serialno, SystemProperties.get("persist.sys.serialno")));
mBinding.icon.setOnClickListener(new AboutFragment.ExportLogHandler(mActivity, Executors.newSingleThreadExecutor()));
}
private void reboot() {
new Thread("reboot") {
@Override
public void run() {
IPowerManager pm = IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE));
try {
pm.reboot(false, null, false);
} catch (RemoteException e) {
e.printStackTrace();
}
}
}.start();
}
public void handleAttack(AppCompatActivity activity) {
private void handleAttack(AppCompatActivity activity) {
ProgressModalDialog dialog = ProgressModalDialog.newInstance();
dialog.show(Objects.requireNonNull(activity.getSupportFragmentManager()), "");
Executors.newSingleThreadExecutor().execute(() -> {

4
app/src/main/res/values-zh-rCN/strings.xml

@ -453,5 +453,9 @@
<string name="no_signatures">暂无签名记录</string>
<string name="scan_blue_hint">若扫描 BlueWallet 动态二维码困难,您可扫描分页二维码</string>
<string name="scan_wasabi_hint">Wasabi Wallet 暂不支持将交易导成二维码,您可将待签交易导出成文件</string>
<string name="opration_failed">操作失败</string>
<string name="reboot_hint">请重新启动机器,多次重试未果请联系客服:support@cobo.com\n 状态码:%s</string>
<string name="reboot">重新启动</string>
<string name="clear_and_power_off">删除所有信息并关机</string>
</resources>

4
app/src/main/res/values/strings.xml

@ -492,5 +492,9 @@
<string name="no_signatures">No Signatures</string>
<string name="scan_blue_hint">Difficulty scanning with BlueWallet? Try scanning these static QR codes instead of the single dynamic QR code.</string>
<string name="scan_wasabi_hint">Wasabi Wallet does not support exporting transactions by QR code. Please export transactions using microSD.</string>
<string name="opration_failed">Operation Failed</string>
<string name="reboot_hint">Please restart or contact us at support@cobo.com\n Status Code:%s</string>
<string name="reboot">Restart</string>
<string name="clear_and_power_off">Erase all Information and Power off</string>
</resources>

Loading…
Cancel
Save