|
|
@@ -639,37 +639,30 @@ public class LogoutEtcStep3Activity extends AppActivity { |
|
|
|
/** |
|
|
|
* 写卡操作 |
|
|
|
*/ |
|
|
|
private String writeCard(String commands) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "开始写卡操作,指令: " + commands); |
|
|
|
private String writeCard(String command) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "开始写卡操作,指令: " + command); |
|
|
|
|
|
|
|
String[] commands_arry = commands.split(","); |
|
|
|
String[] results = new String[commands_arry.length]; |
|
|
|
|
|
|
|
Log.i(this.getClass().getSimpleName(), "指令分割后共 " + commands_arry.length + " 条"); |
|
|
|
|
|
|
|
for (int i = 0; i < commands_arry.length; i++) { |
|
|
|
Log.i(this.getClass().getSimpleName(), "执行第 " + (i + 1) + " 条指令: " + commands_arry[i]); |
|
|
|
try { |
|
|
|
// 直接执行单个APDU指令 |
|
|
|
ServiceStatus resp_string = MethodManager.sendApduICC(command); |
|
|
|
String result = resp_string.getServiceInfo(); |
|
|
|
|
|
|
|
// 透传写卡指令 |
|
|
|
ServiceStatus resp_string = MethodManager.sendApduICC(commands_arry[i]); |
|
|
|
results[i] = resp_string.getServiceInfo(); |
|
|
|
Log.i(this.getClass().getSimpleName(), "指令执行结果: " + result); |
|
|
|
|
|
|
|
Log.i(this.getClass().getSimpleName(), "第 " + (i + 1) + " 条指令执行结果: " + results[i]); |
|
|
|
} |
|
|
|
|
|
|
|
// 返回执行结果 |
|
|
|
StringBuilder buffer = new StringBuilder(); |
|
|
|
for (int i = 0; i < results.length; i++) { |
|
|
|
buffer.append(results[i]); |
|
|
|
if (i != results.length - 1) { |
|
|
|
buffer.append(","); |
|
|
|
// 检查指令是否执行成功 |
|
|
|
if (resp_string.getServiceCode() != 0) { |
|
|
|
Log.e(this.getClass().getSimpleName(), "指令执行失败,状态码: " + resp_string.getServiceCode()); |
|
|
|
throw new RuntimeException("指令执行失败,状态码: " + resp_string.getServiceCode()); |
|
|
|
} |
|
|
|
|
|
|
|
Log.i(this.getClass().getSimpleName(), "写卡操作完成,结果: " + result); |
|
|
|
return result; |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
Log.e(this.getClass().getSimpleName(), "写卡操作异常: " + e.getMessage()); |
|
|
|
e.printStackTrace(); |
|
|
|
throw new RuntimeException("写卡操作异常: " + e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
String finalResult = buffer.toString(); |
|
|
|
Log.i(this.getClass().getSimpleName(), "写卡操作完成,最终结果: " + finalResult); |
|
|
|
|
|
|
|
return finalResult; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |