新增:签名工具支持保存签名参数

新增:反编译打包工具在打包结束后询问是否进行签名
新增:text_dialog支持传view
修改:TextToDalog重命名TextToDialog
修复:打包工具打包失败or反编译失败不再闪退
修复:签名工具偶尔会卡住的问题
修复:打包工具点击关闭未杀死线程导致挂起
This commit is contained in:
yutou 2020-10-09 18:25:47 +08:00
parent bddb4d1243
commit 862c17c90f
13 changed files with 352 additions and 132 deletions

View File

@ -1,16 +1,16 @@
package com.qy.ui;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.*;
import com.qy.utils.ApkSignTools;
import com.qy.utils.Tools;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import java.awt.event.ActionListener;
import java.io.File;
import java.awt.event.ActionEvent;
import java.util.*;
public class ApkSignUi extends JFrame {
public static void main(String[] args) {
@ -27,9 +27,10 @@ public class ApkSignUi extends JFrame {
private ApkSignTools tools;
private JLabel lblApkpath ;
private JLabel lblSginpath;
private LinkedHashMap<String,String> keyMap;
public ApkSignUi() {
setTitle("\u7B7E\u540D\u5DE5\u5177v1.1");
setTitle("\u7B7E\u540D\u5DE5\u5177v1.2");
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// TODO Auto-generated constructor stub
@ -72,15 +73,18 @@ public class ApkSignUi extends JFrame {
button.setBounds(36, 96, 105, 27);
getContentPane().add(button);
JButton button_1 = new JButton("\u4F7F\u7528\u9ED8\u8BA4\u7B7E\u540D");
JButton button_1 = new JButton("保存签名");
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
File sign=new File("/media/yutou/_dde_data/AndroidKeys/langtian.jks");
lblSginpath.setText(sign.getAbsolutePath());
tools.setSignFile(sign);
txtName.setText("langtian");
txtPass.setText("134679");
txtSpass.setText("134679");
JSONObject key=new JSONObject();
key.put("alias",txtName.getText());
key.put("alias_password",txtSpass.getText());
key.put("password",txtPass.getText());
key.put("file",lblSginpath.getText());
key.put("name",tools.getSignFile().getName());
saveKey(key);
keyMap=loadKeys();
}
});
button_1.setBounds(220, 96, 130, 27);
@ -108,6 +112,33 @@ public class ApkSignUi extends JFrame {
getContentPane().add(txtName);
txtName.setColumns(10);
keyMap=loadKeys();
Vector<String> adbList = new Vector<>(keyMap.keySet());
JComboBox<String> keysList=new JComboBox<String>(adbList);
keysList.setBounds(157, 173, 200, 27);
keysList.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String key=adbList.get(keysList.getSelectedIndex());
String tmp=keyMap.get(key);
if(!StringUtils.isEmpty(tmp)){
JSONObject json=new JSONObject(tmp);
txtName.setText(json.getString("alias"));
txtSpass.setText(json.getString("alias_password"));
txtPass.setText(json.getString("password"));
lblSginpath.setText(json.getString("file"));
tools.setSignFile(new File(lblSginpath.getText()));
}else{
txtName.setText("别名");
txtSpass.setText("别名密码");
txtPass.setText("密码");
lblSginpath.setText("");
tools.setSignFile(null);
}
}
});
getContentPane().add(keysList);
JButton btnSign = new JButton("\u7B7E\u540D");
btnSign.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -116,17 +147,48 @@ public class ApkSignUi extends JFrame {
tools.setSignKey(txtPass.getText());
if(tools.chack()) {
if(tools.sign()) {
new TextToDalog("成功", "签名完成");
new TextToDialog("成功", "签名完成");
}else{
new TextToDalog("失败", "签名异常");
new TextToDialog("失败", "签名异常");
}
}else {
new TextToDalog("错误", "APK文件或签名文件不存在");
new TextToDialog("错误", "APK文件或签名文件不存在");
}
}
});
btnSign.setBounds(263, 246, 105, 27);
getContentPane().add(btnSign);
setVisible(true);
keyMap=loadKeys();
}
private void saveKey(JSONObject key) {
JSONObject keyJson= Tools.loadConfig(new File("keys.json"));
if(keyJson==null)
keyJson=new JSONObject();
keyJson.put(key.getString("file"),key);
Tools.saveConfig(new File("keys.json"),keyJson.toString());
}
public static LinkedHashMap<String,String> loadKeys(){
LinkedHashMap<String,String> map=new LinkedHashMap<>();
map.put("默认","");
JSONObject keyJson= Tools.loadConfig(new File("keys.json"));
if(keyJson==null)
{
keyJson=new JSONObject();
}
Iterator<String> keys=keyJson.keys();
while (keys.hasNext()){
String key=keys.next();
map.put(keyJson.getJSONObject(key).getString("name")+"|"+new File(key).getParentFile().getName(), keyJson.getJSONObject(key).toString());
}
return map;
}
}

View File

@ -2,9 +2,6 @@ package com.qy.ui;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
@ -13,7 +10,6 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.Permission;
import java.util.*;
import java.util.Timer;
@ -21,12 +17,10 @@ import javax.swing.*;
import javax.swing.border.LineBorder;
import com.qy.utils.*;
import com.sun.javaws.exceptions.ExitException;
import org.json.JSONArray;
import org.json.JSONObject;
import com.qy.Interfaces.SmaliApkToolsPath;
import org.json.JSONTokener;
public class AppMain extends JFrame {
private JList<String> configList;
@ -250,7 +244,7 @@ public class AppMain extends JFrame {
@Override
public void mouseClicked(MouseEvent e) {
if (configList.getSelectedIndex() < 0) {
new TextToDalog("警告", "列表未选择");
new TextToDialog("警告", "列表未选择");
return;
}
json.put("switch", configList.getSelectedIndex() + 1 + "");
@ -288,7 +282,7 @@ public class AppMain extends JFrame {
@Override
public void mouseClicked(MouseEvent e) {
if (configList.getSelectedIndex() < 0) {
new TextToDalog("警告", "列表未选择");
new TextToDialog("警告", "列表未选择");
return;
}
json.put("switch", configList.getSelectedIndex() + 1 + "");
@ -439,7 +433,7 @@ public class AppMain extends JFrame {
fileName += "_decrypt.jar";
}
EncryptJar.FileData data = new EncryptJar().decrypt(file, fileName);
new TextToDalog("解码提示", data.toString());
new TextToDialog("解码提示", data.toString());
//JarToBase.start(file.getAbsolutePath(), false);
log.setText("已解码");
}
@ -654,7 +648,7 @@ public class AppMain extends JFrame {
}
public void autoPackageSdk() {
new AutoPackageSDK(path -> new TextToDalog("提示", String.format("打包完成%s", path)), version, packageName);
new AutoPackageSDK(path -> new TextToDialog("提示", String.format("打包完成%s", path)), version, packageName);
}
});
menu.add(autoSDK);

View File

@ -13,8 +13,6 @@ import com.qy.utils.Tools;
import javax.swing.JList;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
@ -78,7 +76,7 @@ public class ModifySdkUi extends JFrame{
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
new TextToDalog("提示", "处理完毕,文件路径:"+path);
new TextToDialog("提示", "处理完毕,文件路径:"+path);
}
});
}
@ -90,14 +88,14 @@ public class ModifySdkUi extends JFrame{
@Override
public void smaliPath(String path) {
// TODO Auto-generated method stub
new TextToDalog("提示", "处理完毕,文件路径:"+path);
new TextToDialog("提示", "处理完毕,文件路径:"+path);
}
});
}
}else {
new TextToDalog("警告", "未选择文件或未选择列表配置");
new TextToDialog("警告", "未选择文件或未选择列表配置");
}
}
});

View File

@ -63,11 +63,11 @@ public class OneWayTools {
+ File.separator + "sdk" + File.separator + "c" + File.separator + "c.smali");
if (!activity.exists()) {
System.out.println(activity.getAbsolutePath());
new TextToDalog("警告", "Unit.smali文件不存在!");
new TextToDialog("警告", "Unit.smali文件不存在!");
return;
}
if (!provider.exists()) {
new TextToDalog("警告", "c.smali文件不存在!");
new TextToDialog("警告", "c.smali文件不存在!");
return;
}
@ -169,10 +169,10 @@ public class OneWayTools {
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
new TextToDalog("错误", "处理unit.smali文件失败" + e.getMessage());
new TextToDialog("错误", "处理unit.smali文件失败" + e.getMessage());
return;
}
new TextToDalog("警告", "Unit.smali文件没有包含指定代码请手动检查");
new TextToDialog("警告", "Unit.smali文件没有包含指定代码请手动检查");
}
private void updateProvider(String path) {
@ -210,9 +210,9 @@ public class OneWayTools {
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
new TextToDalog("错误", "处理c.smali文件失败" + e.getMessage());
new TextToDialog("错误", "处理c.smali文件失败" + e.getMessage());
return;
}
new TextToDalog("警告", "c.smali文件没有包含指定代码请手动检查");
new TextToDialog("警告", "c.smali文件没有包含指定代码请手动检查");
}
}

View File

@ -71,7 +71,7 @@ public class SMSToolsUi extends JFrame {
SDKTools.start(new File("").getAbsolutePath());
btnNewButton.setText(path);
btnNewButton.setEnabled(true);
new TextToDalog("提示", "计费SDK生成成功请选择保存位置", new DalogAbs() {
new TextToDialog("提示", "计费SDK生成成功请选择保存位置", new DalogAbs() {
File sdk;
@Override
@ -85,7 +85,7 @@ public class SMSToolsUi extends JFrame {
File sdk_ = new File(
sdk.getAbsolutePath() + "/" + "计费sdk" + SDKTools.version + ".zip");
SDKTools.buildSDK(sdk_);
new TextToDalog("完成", "任务已完成", new DalogAbs() {
new TextToDialog("完成", "任务已完成", new DalogAbs() {
@Override
public void onSuccess() {
@ -101,7 +101,7 @@ public class SMSToolsUi extends JFrame {
});
} else {
new TextToDalog("错误", "已放弃本次任务");
new TextToDialog("错误", "已放弃本次任务");
}
}
});

View File

@ -4,31 +4,24 @@ import java.awt.Color;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.qy.Interfaces.DalogAbs;
import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.utils.ApkSignTools;
import com.qy.utils.SmaliUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
public class SmaliUi extends JFrame {
/**
@ -56,6 +49,42 @@ public class SmaliUi extends JFrame {
vector = new Vector<>();
fileList = new ArrayList<>();
timer = new Timer();
addWindowListener(new WindowListener() {//监听关闭按钮要取消timer不然会一直线程挂起
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void windowClosing(WindowEvent e) {
}
@Override
public void windowClosed(WindowEvent e) {
timer.cancel();
}
@Override
public void windowIconified(WindowEvent e) {
}
@Override
public void windowDeiconified(WindowEvent e) {
}
@Override
public void windowActivated(WindowEvent e) {
}
@Override
public void windowDeactivated(WindowEvent e) {
}
});
initView();
}
@ -66,7 +95,7 @@ public class SmaliUi extends JFrame {
// TODO: handle exception
e.printStackTrace();
}
setTitle("Smali\u53CD\u7F16\u8BD1\u5DE5\u5177v1.2");
setTitle("Smali\u53CD\u7F16\u8BD1\u5DE5\u5177v1.3");
// TODO Auto-generated constructor stub
setSize(900, 673);
getContentPane().setLayout(null);
@ -278,7 +307,7 @@ public class SmaliUi extends JFrame {
public void run() {
// TODO Auto-generated method stub
if(jarPath.getText().trim().length()==0) {
new TextToDalog("警告", "没有选择目标文件");
new TextToDialog("警告", "没有选择目标文件");
return;
}
utils.unPack(jarPath.getText(), new SmaliApkToolsPath() {
@ -309,11 +338,11 @@ public class SmaliUi extends JFrame {
if(savePath.getText().trim().length()==0) {
savePath.setText(smaliHome);
lblInfo.setText("没有填写保存路径,默认保存在当前目录");
new TextToDalog("警告", "没有填写保存路径,默认保存在当前目录");
new TextToDialog("警告", "没有填写保存路径,默认保存在当前目录");
}
if(jarPath.getText().trim().length()==0) {
path="dex.zip";
new TextToDalog("警告", "没有填写保存文件名默认为dex.zip");
new TextToDialog("警告", "没有填写保存文件名默认为dex.zip");
}else {
path=new File(jarPath.getText()).getName();
}
@ -324,7 +353,42 @@ public class SmaliUi extends JFrame {
public void run() {
// TODO Auto-generated method stub
utils.bale(smaliPath.getText(), savePath.getText() + File.separator+path);
if(SmaliUtils.packageError){
return;
}
lblInfo.setText("打包完成,保存路径为:" + savePath.getText());
LinkedHashMap<String,String> keyMap=ApkSignUi.loadKeys();
Vector<String> adbList = new Vector<String>(keyMap.keySet());
JComboBox<String> keysList=new JComboBox<String>(adbList);
keysList.setBounds(157, 50, 200, 27);
new TextToDialog("选择签名", keysList, new DalogAbs() {
@Override
public void onSuccess() {
String key=adbList.get(keysList.getSelectedIndex());
String tmp=keyMap.get(key);
if(!StringUtils.isEmpty(tmp)){
lblInfo.setText("开始签名...");
JSONObject json=new JSONObject(tmp);
ApkSignTools signTools=new ApkSignTools();
signTools.setSignFile(new File(json.getString("file")));
signTools.setApkFile(new File(savePath.getText()+ File.separator+path));
signTools.setKeyStorePassword(json.getString("alias_password"));
signTools.setName(json.getString("alias"));
signTools.setSignKey(json.getString("password"));
if(signTools.sign()){
try {
Desktop.getDesktop().open(new File(signTools.getApkFile().getAbsolutePath()+"_sign.apk").getParentFile());
lblInfo.setText("签名完成");
System.out.println("签名完成");
} catch (IOException ioException) {
ioException.printStackTrace();
}
}else {
new TextToDialog("警告","签名失败");
}
}
}
});
}
}, 100);
}
@ -382,6 +446,7 @@ public class SmaliUi extends JFrame {
@Override
public void smaliPath(String path) {
lblInfo.setText("完成");
}
});

View File

@ -41,7 +41,7 @@ public class TestAdSrc {
File file = new File(obj.toString().substring(1, obj.toString().length() - 1));
System.out.println(file.getAbsolutePath());
if (!file.getName().endsWith(".apk")) {
new TextToDalog("警告", "并非一个apk文件:" + file.getAbsolutePath());
new TextToDialog("警告", "并非一个apk文件:" + file.getAbsolutePath());
return true;
}
if (checkBox.isSelected()) {
@ -116,9 +116,9 @@ public class TestAdSrc {
}
}
if(msg.equals("")){
new TextToDalog("提示",file.getName()+"不包含已知广告源");
new TextToDialog("提示",file.getName()+"不包含已知广告源");
}else{
new TextToDalog("提示","已扫描到:"+msg);
new TextToDialog("提示","已扫描到:"+msg);
}
} catch (Exception e) {
e.printStackTrace();

View File

@ -1,61 +0,0 @@
package com.qy.ui;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JButton;
import javax.swing.JTextArea;
import com.qy.Interfaces.DalogAbs;
import javax.swing.JFrame;
import javax.swing.UIManager;
public class TextToDalog extends JFrame {
/**
*
*/
DalogAbs abs;
private static final long serialVersionUID = 1L;
public TextToDalog(String title,String text,DalogAbs abs) {
super(title);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.abs=abs;
initView(text);
}
/**
* @wbp.parser.constructor
*/
public TextToDalog(String title,String text) {
// TODO Auto-generated constructor stub
new TextToDalog(title, text,null);
}
public void initView(String text) {
// TODO Auto-generated constructor stub
setSize(636, 231);
getContentPane().setLayout(null);
JTextArea lblNewLabel = new JTextArea(text);
lblNewLabel.setBackground(UIManager.getColor("Label.background"));
lblNewLabel.setEditable(false);
lblNewLabel.setLineWrap(true);
lblNewLabel.setBounds(42, 37, 438, 106);
getContentPane().add(lblNewLabel);
JButton btnOk = new JButton("ok");
btnOk.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
TextToDalog.this.dispose();
if(abs!=null) {
abs.onSuccess();
}
}
});
btnOk.setBounds(491, 144, 113, 27);
getContentPane().add(btnOk);
setVisible(true);
}
}

View File

@ -0,0 +1,67 @@
package com.qy.ui;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.*;
import com.qy.Interfaces.DalogAbs;
public class TextToDialog extends JFrame {
/**
*
*/
DalogAbs abs;
private static final long serialVersionUID = 1L;
public TextToDialog(String title, String text, DalogAbs abs) {
super(title);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.abs=abs;
initView(text,null);
}
public TextToDialog(String title, JComponent view,DalogAbs abs){
super(title);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.abs=abs;
initView(null,view);
}
/**
* @wbp.parser.constructor
*/
public TextToDialog(String title, String text) {
// TODO Auto-generated constructor stub
new TextToDialog(title, text,null);
}
public void initView(String text,JComponent view) {
// TODO Auto-generated constructor stub
setSize(636, 231);
getContentPane().setLayout(null);
if(view==null) {
JTextArea lblNewLabel = new JTextArea(text);
lblNewLabel.setBackground(UIManager.getColor("Label.background"));
lblNewLabel.setEditable(false);
lblNewLabel.setLineWrap(true);
lblNewLabel.setBounds(42, 37, 438, 106);
getContentPane().add(lblNewLabel);
}else{
getContentPane().add(view);
}
JButton btnOk = new JButton("ok");
btnOk.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
TextToDialog.this.dispose();
if(abs!=null) {
abs.onSuccess();
}
}
});
btnOk.setBounds(491, 144, 113, 27);
getContentPane().add(btnOk);
setVisible(true);
}
}

View File

@ -1,7 +1,9 @@
package com.qy.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
public class ApkSignTools {
@ -29,7 +31,13 @@ public class ApkSignTools {
+ " -storepass " + keyStorePassword + " -signedjar \"" + apkFile.getAbsolutePath()+"_sign.apk" + "\" \"" + apkFile.getAbsolutePath() + "\" " + name;
System.out.println(exec);
try {
Runtime.getRuntime().exec(exec).waitFor();
Process process=Runtime.getRuntime().exec(exec);
BufferedReader reader=new BufferedReader(new InputStreamReader(process.getInputStream()));
String tmp;
while ((tmp=reader.readLine())!=null){
System.out.println(tmp);
}
reader.close();
return true;
} catch (Exception e) {
// TODO Auto-generated catch block

View File

@ -1,8 +1,6 @@
package com.qy.utils;
import java.awt.Desktop;
import java.io.*;
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -13,7 +11,6 @@ import com.qy.ui.EditToDalog;
import org.json.JSONArray;
import org.json.JSONObject;
import com.qy.Interfaces.DalogAbs;
/*
配置JSON格式
{
@ -47,7 +44,6 @@ import com.qy.Interfaces.DalogAbs;
}
*/
import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.ui.TextToDalog;
public class AutoRandomAdSDK {
private File sdk;

View File

@ -1,18 +1,24 @@
package com.qy.utils;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.*;
import java.nio.ByteBuffer;
import java.security.Permission;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import brut.androlib.Androlib;
import brut.androlib.res.xml.ResXmlPatcher;
import com.qy.Interfaces.SmaliApkToolsPath;
import brut.apktool.Main;
import com.qy.ui.TextToDialog;
import com.sun.javaws.exceptions.ExitException;
public class SmaliUtils {
//private String str = "";
@ -232,15 +238,45 @@ public class SmaliUtils {
}
public void bale(String path, String smaliPath) {
run=false;
packageError=false;
bale(path, smaliPath, null);
}
public boolean run = false;
public static StringBuffer error=new StringBuffer();
public void bale(String smaliPath, String path, SmaliApkToolsPath inter) {
String[] args = new String[]{"b", "-f", smaliPath, "-o", path};
for (String string : args) {
System.out.print(string + " ");
}
try {
run = true;
error=new StringBuffer();
new Thread(new Runnable() {
@Override
public void run() {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(outputStream);
PrintStream old=System.err;
System.setErr(printStream);
while (run) {
byte[] bs = outputStream.toByteArray();
if (bs.length > 0) {
error.append(new String(outputStream.toByteArray())).append("\n");
outputStream.reset();
}
}
System.setErr(old);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
System.setSecurityManager(new NoExitSecurityManager());
Main.main(args);
if (inter != null) {
inter.smaliPath(path);
@ -252,6 +288,8 @@ public class SmaliUtils {
inter.smaliPath("error");
}
}
System.setSecurityManager(null);
run = false;
}
List<String> list;
@ -268,4 +306,36 @@ public class SmaliUtils {
public void setFilter(List<String> list) {
this.list = list;
}
public static boolean packageError=false;
public static class NoExitSecurityManager extends SecurityManager {
public NoExitSecurityManager() {
}
@Override
public void checkExit(int status) {
super.checkExit(status);
throw new SmaliUtils.ExitException(status);
}
@Override
public void checkPermission(Permission perm) {
}
@Override
public void checkPermission(Permission perm, Object context) {
}
}
private static class ExitException extends SecurityException {
public ExitException(int status) {
System.out.println("print exit :" + status);
if(error.length()>0){
packageError=true;
new TextToDialog("打包异常",error.toString());
}
}
}
}

View File

@ -2,6 +2,7 @@ package com.qy.utils;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.rmi.server.ExportException;
import java.util.Random;
import java.util.jar.JarOutputStream;
import java.util.zip.CRC32;
@ -184,7 +185,26 @@ public class Tools {
}
return true;
}
public static void saveConfig(File file,String data){
if(!file.exists()){
try {
if(!file.createNewFile()){
return;
}
} catch (IOException e) {
e.printStackTrace();
}
}
try {
FileWriter writer=new FileWriter(file);
writer.write(data);
writer.flush();
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static JSONObject loadConfig(File file) {
JSONObject json = null;
BufferedReader reader;
@ -202,6 +222,7 @@ public class Tools {
while ((tmp = reader.readLine()) != null) {
str += tmp;
}
reader.close();
json = new JSONObject(str);
} catch (Exception e) {
// TODO Auto-generated catch block