update
This commit is contained in:
parent
3430daf931
commit
e93b6f1b1e
@ -41,6 +41,9 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sdkPath":"D:\\AndroidStudio_Data\\ADSDK_v5",
|
"sdkPath":"D:\\Android_src\\kuku-android-sdk",
|
||||||
"csjPackageName":"com.iaalz.tzjyg"
|
"csjPackageName":"com.iaalz.tzjyg",
|
||||||
|
"packageApkTool":"libs/apktool_2.4.1.jar",
|
||||||
|
"unPackageApkTool":"libs/apktool_2.4.1.jar",
|
||||||
|
"encryption":true
|
||||||
}
|
}
|
BIN
libs/SparseBitSet-1.2.jar
Normal file
BIN
libs/SparseBitSet-1.2.jar
Normal file
Binary file not shown.
BIN
libs/activation-1.1.1.jar
Normal file
BIN
libs/activation-1.1.1.jar
Normal file
Binary file not shown.
BIN
libs/commons-codec-1.13.jar
Normal file
BIN
libs/commons-codec-1.13.jar
Normal file
Binary file not shown.
BIN
libs/commons-collections4-4.4.jar
Normal file
BIN
libs/commons-collections4-4.4.jar
Normal file
Binary file not shown.
BIN
libs/commons-compress-1.19.jar
Normal file
BIN
libs/commons-compress-1.19.jar
Normal file
Binary file not shown.
BIN
libs/commons-logging-1.2.jar
Normal file
BIN
libs/commons-logging-1.2.jar
Normal file
Binary file not shown.
BIN
libs/commons-math3-3.6.1.jar
Normal file
BIN
libs/commons-math3-3.6.1.jar
Normal file
Binary file not shown.
BIN
libs/dom4j-2.1.3.jar
Normal file
BIN
libs/dom4j-2.1.3.jar
Normal file
Binary file not shown.
BIN
libs/jaxb-api-2.3.1.jar
Normal file
BIN
libs/jaxb-api-2.3.1.jar
Normal file
Binary file not shown.
BIN
libs/jaxb-core-2.3.0.1.jar
Normal file
BIN
libs/jaxb-core-2.3.0.1.jar
Normal file
Binary file not shown.
BIN
libs/jaxb-impl-2.3.2.jar
Normal file
BIN
libs/jaxb-impl-2.3.2.jar
Normal file
Binary file not shown.
BIN
libs/junit-4.12.jar
Normal file
BIN
libs/junit-4.12.jar
Normal file
Binary file not shown.
BIN
libs/log4j-1.2.17.jar
Normal file
BIN
libs/log4j-1.2.17.jar
Normal file
Binary file not shown.
BIN
libs/poi-4.1.2.jar
Normal file
BIN
libs/poi-4.1.2.jar
Normal file
Binary file not shown.
BIN
libs/poi-excelant-4.1.2.jar
Normal file
BIN
libs/poi-excelant-4.1.2.jar
Normal file
Binary file not shown.
BIN
libs/poi-ooxml-4.1.2.jar
Normal file
BIN
libs/poi-ooxml-4.1.2.jar
Normal file
Binary file not shown.
BIN
libs/poi-ooxml-schemas-4.1.2.jar
Normal file
BIN
libs/poi-ooxml-schemas-4.1.2.jar
Normal file
Binary file not shown.
BIN
libs/poi-scratchpad-4.1.2.jar
Normal file
BIN
libs/poi-scratchpad-4.1.2.jar
Normal file
Binary file not shown.
BIN
libs/xmlbeans-3.1.0.jar
Normal file
BIN
libs/xmlbeans-3.1.0.jar
Normal file
Binary file not shown.
@ -46,7 +46,7 @@ public class SDKTools {
|
|||||||
tools.classPath.add(new File(dataFolder).getAbsolutePath() + "\\androidv4.jar");
|
tools.classPath.add(new File(dataFolder).getAbsolutePath() + "\\androidv4.jar");
|
||||||
tools.saveJavaPath(sdkDatapath);
|
tools.saveJavaPath(sdkDatapath);
|
||||||
tools.javaToClass(sdkDatapath);
|
tools.javaToClass(sdkDatapath);
|
||||||
System.out.println("清理文件:" + sdkDatapath);
|
System.out.println("清理文件:" + sdkDatapath);
|
||||||
tools.deleteJava(sdkDatapath);
|
tools.deleteJava(sdkDatapath);
|
||||||
tools.toJarforJar();
|
tools.toJarforJar();
|
||||||
WorldTools.start(packName, GameSDKManageName, sdkfunction);
|
WorldTools.start(packName, GameSDKManageName, sdkfunction);
|
||||||
@ -75,23 +75,23 @@ public class SDKTools {
|
|||||||
Tools.deleteFiles(sdkPath.getAbsolutePath());
|
Tools.deleteFiles(sdkPath.getAbsolutePath());
|
||||||
}
|
}
|
||||||
File zipFile = new File(new File(dataFolder).getAbsolutePath() + "/sdk.zip");
|
File zipFile = new File(new File(dataFolder).getAbsolutePath() + "/sdk.zip");
|
||||||
System.out.println("解压sdk源码:"+zipFile.getAbsolutePath());
|
System.out.println("解压sdk源码:"+zipFile.getAbsolutePath());
|
||||||
ZipFile zip = new ZipFile(zipFile);
|
ZipFile zip = new ZipFile(zipFile);
|
||||||
for (Enumeration<?> entries = zip.entries(); entries.hasMoreElements();) {
|
for (Enumeration<?> entries = zip.entries(); entries.hasMoreElements();) {
|
||||||
ZipEntry entry = (ZipEntry) entries.nextElement();
|
ZipEntry entry = (ZipEntry) entries.nextElement();
|
||||||
String zipEntryName = entry.getName();
|
String zipEntryName = entry.getName();
|
||||||
InputStream in = zip.getInputStream(entry);
|
InputStream in = zip.getInputStream(entry);
|
||||||
String outPath = (descDir + "/" + zipEntryName).replace("\\", "/");
|
String outPath = (descDir + "/" + zipEntryName).replace("\\", "/");
|
||||||
// 判断路径是否存在,不存在则创建文件路径
|
// 判断路径是否存在,不存在则创建文件路径
|
||||||
File file = new File(outPath.substring(0, outPath.lastIndexOf('/')));
|
File file = new File(outPath.substring(0, outPath.lastIndexOf('/')));
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
}
|
}
|
||||||
// 判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压
|
// 判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压
|
||||||
if (new File(outPath).isDirectory()) {
|
if (new File(outPath).isDirectory()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 输出文件路径信息
|
// 输出文件路径信息
|
||||||
System.out.println(outPath);
|
System.out.println(outPath);
|
||||||
OutputStream out = new FileOutputStream(outPath);
|
OutputStream out = new FileOutputStream(outPath);
|
||||||
byte[] buf1 = new byte[1024];
|
byte[] buf1 = new byte[1024];
|
||||||
@ -103,7 +103,7 @@ public class SDKTools {
|
|||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
zip.close();
|
zip.close();
|
||||||
System.out.println("******************解压完毕********************");
|
System.out.println("******************解压完毕********************");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -117,11 +117,11 @@ public class SDKTools {
|
|||||||
Tools.deleteFiles(sdkPath.getAbsolutePath());
|
Tools.deleteFiles(sdkPath.getAbsolutePath());
|
||||||
}
|
}
|
||||||
File zipFile = new File(new File(dataFolder).getAbsolutePath() + "/sdk.zip");
|
File zipFile = new File(new File(dataFolder).getAbsolutePath() + "/sdk.zip");
|
||||||
System.out.println("解压sdk源码:"+zipFile.getAbsolutePath());
|
System.out.println("解压sdk源码:"+zipFile.getAbsolutePath());
|
||||||
net.lingala.zip4j.core.ZipFile zip=new net.lingala.zip4j.core.ZipFile(zipFile);
|
net.lingala.zip4j.core.ZipFile zip=new net.lingala.zip4j.core.ZipFile(zipFile);
|
||||||
zip.setFileNameCharset("GBK");
|
zip.setFileNameCharset("GBK");
|
||||||
zip.extractAll(new File("").getAbsolutePath());
|
zip.extractAll(new File("").getAbsolutePath());
|
||||||
System.out.println("******************解压完毕********************");
|
System.out.println("******************解压完毕********************");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -131,14 +131,14 @@ public class SDKTools {
|
|||||||
public void resdk() {
|
public void resdk() {
|
||||||
File sdkPath = new File(new File("").getAbsolutePath() + "/smsdk/");
|
File sdkPath = new File(new File("").getAbsolutePath() + "/smsdk/");
|
||||||
if (!sdkPath.exists()) {
|
if (!sdkPath.exists()) {
|
||||||
System.out.println("SDK目录不存在 " + sdkPath.getAbsolutePath());
|
System.out.println("SDK目录不存在 " + sdkPath.getAbsolutePath());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a = Tools.getRandomString(3);
|
a = Tools.getRandomString(3);
|
||||||
b = Tools.getRandomString(4);
|
b = Tools.getRandomString(4);
|
||||||
c = Tools.getRandomString(4);
|
c = Tools.getRandomString(4);
|
||||||
packName = a + "." + b + "." + c;
|
packName = a + "." + b + "." + c;
|
||||||
System.out.println("SDK包名:" + packName);
|
System.out.println("SDK包名:" + packName);
|
||||||
rename(sdkPath);
|
rename(sdkPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ public class SDKTools {
|
|||||||
private void reGameSDKManage() {
|
private void reGameSDKManage() {
|
||||||
File java = new File(sdkDatapath + "/GameSDKManage.java");
|
File java = new File(sdkDatapath + "/GameSDKManage.java");
|
||||||
if (!java.exists()) {
|
if (!java.exists()) {
|
||||||
System.out.println("GameSDKManage.java不存在");
|
System.out.println("GameSDKManage.java不存在");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GameSDKManageName = Tools.getRandomString(Tools.getRandomInt(4, 8));
|
GameSDKManageName = Tools.getRandomString(Tools.getRandomInt(4, 8));
|
||||||
@ -290,7 +290,7 @@ public class SDKTools {
|
|||||||
File ft = new File(f.getAbsolutePath().replace(".java", ".class"));
|
File ft = new File(f.getAbsolutePath().replace(".java", ".class"));
|
||||||
if (ft.exists()) {
|
if (ft.exists()) {
|
||||||
f.delete();
|
f.delete();
|
||||||
// System.out.println("删除java:"+f.getAbsolutePath()+" "+t);
|
// System.out.println("删除java:"+f.getAbsolutePath()+" "+t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,18 +318,18 @@ public class SDKTools {
|
|||||||
List<ZipEntry> zips = new ArrayList<>();
|
List<ZipEntry> zips = new ArrayList<>();
|
||||||
Map<String, File> fileNames = new HashMap<>();
|
Map<String, File> fileNames = new HashMap<>();
|
||||||
if (sdkzip == null)
|
if (sdkzip == null)
|
||||||
sdkzip = new File("计费sdk" + version + ".zip");
|
sdkzip = new File("计费sdk" + version + ".zip");
|
||||||
if (sdkzip.exists())
|
if (sdkzip.exists())
|
||||||
sdkzip.delete();
|
sdkzip.delete();
|
||||||
ZipOutputStream output = new ZipOutputStream(new FileOutputStream(sdkzip));
|
ZipOutputStream output = new ZipOutputStream(new FileOutputStream(sdkzip));
|
||||||
output.setLevel(Deflater.DEFLATED);
|
output.setLevel(Deflater.DEFLATED);
|
||||||
|
|
||||||
File sdk = new File("sdk.jar");
|
File sdk = new File("sdk.jar");
|
||||||
File word = new File("文档.txt");
|
File word = new File("文档.txt");
|
||||||
File rx = new File("data/rx.lt");
|
File rx = new File("data/rx.lt");
|
||||||
File v4 = new File("data/androidv4.jar");
|
File v4 = new File("data/androidv4.jar");
|
||||||
File manifest = new File("data/manifest清单.txt");
|
File manifest = new File("data/manifest清单.txt");
|
||||||
File permission = new File("data/权限列表.txt");
|
File permission = new File("data/权限列表.txt");
|
||||||
|
|
||||||
files.add(sdk);
|
files.add(sdk);
|
||||||
files.add(word);
|
files.add(word);
|
||||||
@ -359,7 +359,7 @@ public class SDKTools {
|
|||||||
output.closeEntry();
|
output.closeEntry();
|
||||||
output.close();
|
output.close();
|
||||||
|
|
||||||
sdk.delete();
|
sdk.delete();
|
||||||
word.delete();
|
word.delete();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
@ -396,7 +396,7 @@ public class SDKTools {
|
|||||||
private void jar(net.lingala.zip4j.core.ZipFile zipFile, File file,ZipParameters par) throws Exception {
|
private void jar(net.lingala.zip4j.core.ZipFile zipFile, File file,ZipParameters par) throws Exception {
|
||||||
toJar();
|
toJar();
|
||||||
for (File f : file.listFiles()) {
|
for (File f : file.listFiles()) {
|
||||||
System.out.println("压缩文件:"+f.getAbsolutePath());
|
System.out.println("压缩文件:"+f.getAbsolutePath());
|
||||||
if(f.isDirectory()) {
|
if(f.isDirectory()) {
|
||||||
par.setCompressionMethod(Zip4jConstants.COMP_STORE);
|
par.setCompressionMethod(Zip4jConstants.COMP_STORE);
|
||||||
File t=new File(f.getName());
|
File t=new File(f.getName());
|
||||||
|
@ -61,89 +61,6 @@ public class AppMain extends JFrame {
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
new AppMain();
|
new AppMain();
|
||||||
} else {
|
|
||||||
String packageName = null;
|
|
||||||
String version = null;
|
|
||||||
String apkPath = null;
|
|
||||||
String csjPath = null;
|
|
||||||
String model = "csj";
|
|
||||||
String jarPath = null;
|
|
||||||
String jarType = null;
|
|
||||||
String config = null;
|
|
||||||
|
|
||||||
int index = -1;
|
|
||||||
|
|
||||||
for (String arg : args) {
|
|
||||||
if (arg.startsWith("-package")) {
|
|
||||||
packageName = arg.replace("-package=", "");
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-version")) {
|
|
||||||
version = arg.replace("-version=", "");
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-apk")) {
|
|
||||||
apkPath = arg.replace("-apk=", "");
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-csj")) {
|
|
||||||
csjPath = arg.replace("-csj=", "");
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-csc")) {
|
|
||||||
cscPath = arg.replace("-csc=", "");
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-model")) {
|
|
||||||
model = arg.replace("-model=", "");
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-jar")) {
|
|
||||||
jarPath = arg.replace("-jar=", "");
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-type")) {
|
|
||||||
jarType = arg.replace("-type=", "");
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-index")) {
|
|
||||||
index = Integer.parseInt(arg.replace("-index=", "").trim());
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-save")) {
|
|
||||||
savePath = arg.replace("-save=", "");
|
|
||||||
}
|
|
||||||
if (arg.startsWith("-config")) {
|
|
||||||
config = arg.replace("-config=", "");
|
|
||||||
}
|
|
||||||
if (arg.trim().equals("-h")) {
|
|
||||||
outHelp();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (model.equals("csj")) {
|
|
||||||
if (packageName != null && version != null && apkPath != null && csjPath != null) {
|
|
||||||
new CsjTools(apkPath, csjPath, packageName, version, config, new SmaliApkToolsPath() {
|
|
||||||
@Override
|
|
||||||
public void smaliPath(String path) {
|
|
||||||
if (cscPath != null) {
|
|
||||||
File file = new File(path);
|
|
||||||
file.renameTo(new File(cscPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
outHelp();
|
|
||||||
}
|
|
||||||
} else if (model.equals("jar")) {
|
|
||||||
System.out.println(jarPath);
|
|
||||||
System.out.println(version);
|
|
||||||
System.out.println(jarType);
|
|
||||||
System.out.println(index);
|
|
||||||
System.out.println(savePath);
|
|
||||||
if (jarPath != null)
|
|
||||||
new AutoRandomAdSDK(new File(jarPath), version, jarType, index, new SmaliApkToolsPath() {
|
|
||||||
@Override
|
|
||||||
public void smaliPath(String path) {
|
|
||||||
new File(path).renameTo(new File(savePath));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (model.equals("sdk")) {
|
|
||||||
new AutoPackageSDK(path -> new File(path).renameTo(new File(savePath)), version, packageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,8 +166,8 @@ public class AppMain extends JFrame {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
json.put("switch", configList.getSelectedIndex() + 1 + "");
|
json.put("switch", configList.getSelectedIndex() + 1 + "");
|
||||||
path = json.getString("out");
|
path = json.optString("out","");
|
||||||
name = json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) - 1) + ".jar";
|
name = json.getJSONArray("array").getString(Integer.parseInt(json.optString("switch","1")) - 1) + ".jar";
|
||||||
file = new File(path + name);
|
file = new File(path + name);
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
file.delete();
|
file.delete();
|
||||||
@ -301,11 +218,11 @@ public class AppMain extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public void smaliPath(String path) {
|
public void smaliPath(String path) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
File input = new File(json.getString("out")
|
File input = new File(json.optString("out","")
|
||||||
+ json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) - 1) + ".jar");
|
+ json.getJSONArray("array").getString(Integer.parseInt(json.optString("switch","1")) - 1) + ".jar");
|
||||||
Tools.toAJar(json.getString("dx"), input.getAbsolutePath(), input.getAbsolutePath().replace(input.getName(), "dexTmp.jar"));
|
Tools.toAJar(json.optString("dx","dx.jar"), input.getAbsolutePath(), input.getAbsolutePath().replace(input.getName(), "dexTmp.jar"));
|
||||||
File outFile = new EncryptJar().encrypt(new File(input.getAbsolutePath().replace(input.getName(), "dexTmp.jar")), json.getString("out")
|
File outFile = new EncryptJar().encrypt(new File(input.getAbsolutePath().replace(input.getName(), "dexTmp.jar")), json.optString("out","")
|
||||||
+ json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) - 1) + "_encrypt.jar", Integer.parseInt(path)
|
+ json.getJSONArray("array").getString(Integer.parseInt(json.optString("switch","1")) - 1) + "_encrypt.jar", Integer.parseInt(path)
|
||||||
, Integer.parseInt(version));
|
, Integer.parseInt(version));
|
||||||
log.setText("data路径为:" + outFile.getAbsolutePath());
|
log.setText("data路径为:" + outFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
@ -403,8 +320,8 @@ public class AppMain extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public void smaliPath(String path) {
|
public void smaliPath(String path) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
Tools.toAJar(json.getString("dx"), file.getAbsolutePath(), file.getAbsolutePath().replace(file.getName(), "dexTmp.jar"));
|
Tools.toAJar(json.optString("dx","dx.jar"), file.getAbsolutePath(), file.getAbsolutePath().replace(file.getName(), "dexTmp.jar"));
|
||||||
File fileOut = new EncryptJar().encrypt(new File(file.getAbsolutePath().replace(file.getName(), "dexTmp.jar")), file.getAbsolutePath() + "_encrypt.jar", Integer.valueOf(path)
|
File fileOut = new EncryptJar().encrypt(new File(file.getAbsolutePath().replace(file.getName(), "dexTmp.jar")), file.getAbsolutePath() + "_encrypt.jar", Integer.parseInt(path)
|
||||||
, Integer.parseInt(version));
|
, Integer.parseInt(version));
|
||||||
System.out.println("data路径为:" + fileOut.getAbsolutePath());
|
System.out.println("data路径为:" + fileOut.getAbsolutePath());
|
||||||
if (log != null)
|
if (log != null)
|
||||||
@ -497,7 +414,7 @@ public class AppMain extends JFrame {
|
|||||||
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath()));
|
JFileChooser chooser = new JFileChooser(new File(new File("").getAbsolutePath()));
|
||||||
chooser.showOpenDialog(null);
|
chooser.showOpenDialog(null);
|
||||||
File java = chooser.getSelectedFile();
|
File java = chooser.getSelectedFile();
|
||||||
Tools.toAJar(json.getString("dx"), java.getAbsolutePath(),
|
Tools.toAJar(json.optString("dx","dx.jar"), java.getAbsolutePath(),
|
||||||
new File("").getAbsolutePath() + File.separator + java.getName() + "_jar.jar");
|
new File("").getAbsolutePath() + File.separator + java.getName() + "_jar.jar");
|
||||||
if (AppMain.isOpenWindows) {
|
if (AppMain.isOpenWindows) {
|
||||||
try {
|
try {
|
||||||
@ -649,7 +566,7 @@ public class AppMain extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void autoPackageSdk() {
|
public void autoPackageSdk() {
|
||||||
new AutoPackageSDK(path -> new TextToDialog("提示", String.format("打包完成%s", path)), version, packageName);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(autoSDK);
|
menu.add(autoSDK);
|
||||||
@ -690,6 +607,17 @@ public class AppMain extends JFrame {
|
|||||||
});
|
});
|
||||||
mnBasetools.add(mntmBase);
|
mnBasetools.add(mntmBase);
|
||||||
|
|
||||||
|
/*JMenu config=new JMenu("设置");
|
||||||
|
JMenuItem systemConfig=new JMenuItem("主设置");
|
||||||
|
systemConfig.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
config.add(systemConfig);
|
||||||
|
menuBar.add(config);
|
||||||
|
*/
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ import javax.swing.*;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.KeyListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -80,6 +82,25 @@ public class AutoOutAPKAddChannelUi {
|
|||||||
textField.setText(data);
|
textField.setText(data);
|
||||||
textField.setToolTipText(data);
|
textField.setToolTipText(data);
|
||||||
textField.setSize(100,20);
|
textField.setSize(100,20);
|
||||||
|
textField.addKeyListener(new KeyListener() {
|
||||||
|
int oldKey=0;
|
||||||
|
@Override
|
||||||
|
public void keyTyped(KeyEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
if(oldKey==17&&e.getKeyCode()==86){
|
||||||
|
textField.setText(textField.getText().replace("=","{=}"));
|
||||||
|
}else{
|
||||||
|
oldKey=e.getKeyCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
list.add(textField);
|
list.add(textField);
|
||||||
inputPanel.add(textField);
|
inputPanel.add(textField);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children>
|
<children>
|
||||||
<grid id="81cbe" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="81cbe" layout-manager="GridLayoutManager" row-count="7" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints border-constraint="Center"/>
|
<constraints border-constraint="Center"/>
|
||||||
<properties/>
|
<properties/>
|
||||||
@ -63,7 +63,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="bcc75" class="javax.swing.JLabel">
|
<component id="bcc75" class="javax.swing.JLabel">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="渠道参数"/>
|
<text value="渠道参数"/>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
<grid id="21c9" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="21c9" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="3" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="4" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
@ -105,7 +105,7 @@
|
|||||||
</grid>
|
</grid>
|
||||||
<component id="8617" class="javax.swing.JButton" binding="start">
|
<component id="8617" class="javax.swing.JButton" binding="start">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="5" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="6" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="提交"/>
|
<text value="提交"/>
|
||||||
@ -113,17 +113,18 @@
|
|||||||
</component>
|
</component>
|
||||||
<component id="77e44" class="javax.swing.JLabel" binding="appPath">
|
<component id="77e44" class="javax.swing.JLabel" binding="appPath">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
<minimum-size width="200" height="-1"/>
|
<minimum-size width="200" height="-1"/>
|
||||||
</grid>
|
</grid>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
|
<autoscrolls value="true"/>
|
||||||
<text value="选择游戏母包"/>
|
<text value="选择游戏母包"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="4b896" class="javax.swing.JButton" binding="selectAppPath" default-binding="true">
|
<component id="4b896" class="javax.swing.JButton" binding="selectAppPath" default-binding="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||||
<maximum-size width="100" height="-1"/>
|
<maximum-size width="100" height="-1"/>
|
||||||
</grid>
|
</grid>
|
||||||
</constraints>
|
</constraints>
|
||||||
@ -131,6 +132,20 @@
|
|||||||
<text value="选择"/>
|
<text value="选择"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
<component id="310fd" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="快速选择"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="b5535" class="javax.swing.JComboBox" binding="selectAppid">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
|
@ -2,16 +2,16 @@ package com.qy.ui;
|
|||||||
|
|
||||||
import com.qy.Interfaces.DialogInterface;
|
import com.qy.Interfaces.DialogInterface;
|
||||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||||
import com.qy.utils.ApkSignTools;
|
import com.qy.utils.*;
|
||||||
import com.qy.utils.AutoOutAPKTools;
|
import org.json.JSONArray;
|
||||||
import com.qy.utils.StringUtils;
|
|
||||||
import com.qy.utils.Tools;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -30,10 +30,12 @@ public class AutoOutAPKUi {
|
|||||||
private JButton start;
|
private JButton start;
|
||||||
private JButton selectAppPath;
|
private JButton selectAppPath;
|
||||||
private JLabel appPath;
|
private JLabel appPath;
|
||||||
|
private JComboBox<Object> selectAppid;
|
||||||
|
|
||||||
private LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
private LinkedHashMap<String, String> map = new LinkedHashMap<>();
|
||||||
private LinkedHashMap<String, Object> channel = new LinkedHashMap<>();
|
private LinkedHashMap<String, Object> channel = new LinkedHashMap<>();
|
||||||
private Vector<String> vector = new Vector<String>();
|
private Vector<String> vector = new Vector<String>();
|
||||||
|
private JSONObject changeImage=null;
|
||||||
|
|
||||||
|
|
||||||
public AutoOutAPKUi() {
|
public AutoOutAPKUi() {
|
||||||
@ -43,7 +45,7 @@ public class AutoOutAPKUi {
|
|||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
JFrame frame = new JFrame("马甲包出包工具1.0");
|
JFrame frame = new JFrame("马甲包出包工具2.0");
|
||||||
frame.setContentPane(panel1);
|
frame.setContentPane(panel1);
|
||||||
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
@ -102,49 +104,52 @@ public class AutoOutAPKUi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AutoOutAPKTools tools = new AutoOutAPKTools(gid, cmap);
|
AutoOutAPKTools tools = new AutoOutAPKTools(gid, cmap);
|
||||||
JSONObject json=new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
JSONObject pa=new JSONObject();
|
JSONObject pa = new JSONObject();
|
||||||
JSONObject ji=new JSONObject();
|
JSONObject ji = new JSONObject();
|
||||||
pa.put("key","${packagename}");
|
pa.put("key", "${packagename}");
|
||||||
pa.put("value",pid);
|
pa.put("value", pid);
|
||||||
ji.put("key","${JPUSH_KEY}");
|
ji.put("key", "${JPUSH_KEY}");
|
||||||
ji.put("value",jid);
|
ji.put("value", jid);
|
||||||
json.put("${packagename}",pa);
|
json.put("${packagename}", pa);
|
||||||
json.put("JPUSH_APPKEY",ji);
|
json.put("JPUSH_APPKEY", ji);
|
||||||
tools.setAppPath(path);
|
tools.setAppPath(path);
|
||||||
tools.setManifestMap(json);
|
tools.setManifestMap(json);
|
||||||
|
if(changeImage!=null){
|
||||||
|
tools.setChangeFile(changeImage);
|
||||||
|
}
|
||||||
tools.start(new SmaliApkToolsPath() {
|
tools.start(new SmaliApkToolsPath() {
|
||||||
@Override
|
@Override
|
||||||
public void smaliPath(String path) {
|
public void smaliPath(String path) {
|
||||||
LinkedHashMap<String,String> keyMap=ApkSignUi.loadKeys();
|
LinkedHashMap<String, String> keyMap = ApkSignUi.loadKeys();
|
||||||
Vector<String> adbList = new Vector<String>(keyMap.keySet());
|
Vector<String> adbList = new Vector<String>(keyMap.keySet());
|
||||||
JComboBox<String> keysList=new JComboBox<String>(adbList);
|
JComboBox<String> keysList = new JComboBox<String>(adbList);
|
||||||
keysList.setBounds(157, 50, 200, 27);
|
keysList.setBounds(157, 50, 200, 27);
|
||||||
new TextToDialog("选择签名", keysList, new DialogInterface() {
|
new TextToDialog("选择签名", keysList, new DialogInterface() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
String key=adbList.get(keysList.getSelectedIndex());
|
String key = adbList.get(keysList.getSelectedIndex());
|
||||||
String tmp=keyMap.get(key);
|
String tmp = keyMap.get(key);
|
||||||
if(!StringUtils.isEmpty(tmp)){
|
if (!StringUtils.isEmpty(tmp)) {
|
||||||
JSONObject json=new JSONObject(tmp);
|
JSONObject json = new JSONObject(tmp);
|
||||||
ApkSignTools signTools=new ApkSignTools();
|
ApkSignTools signTools = new ApkSignTools();
|
||||||
signTools.setSignFile(new File(json.getString("file")));
|
signTools.setSignFile(new File(json.getString("file")));
|
||||||
signTools.setApkFile(new File(path));
|
signTools.setApkFile(new File(path));
|
||||||
signTools.setKeyStorePassword(json.getString("alias_password"));
|
signTools.setKeyStorePassword(json.getString("alias_password"));
|
||||||
signTools.setName(json.getString("alias"));
|
signTools.setName(json.getString("alias"));
|
||||||
signTools.setSignKey(json.getString("password"));
|
signTools.setSignKey(json.getString("password"));
|
||||||
if(signTools.sign()){
|
if (signTools.sign()) {
|
||||||
try {
|
try {
|
||||||
String apkName="./apk_out/game_"+System.currentTimeMillis()+".apk";
|
String apkName = "./apk_out/game_" + System.currentTimeMillis() + ".apk";
|
||||||
Tools.copyFile(signTools.getApkFile().getAbsolutePath()+"_sign.apk",apkName,true);
|
Tools.copyFile(signTools.getApkFile().getAbsolutePath() + "_sign.apk", apkName, true);
|
||||||
Desktop.getDesktop().open(new File(apkName).getParentFile());
|
Desktop.getDesktop().open(new File(apkName).getParentFile());
|
||||||
System.out.println("签名完成");
|
System.out.println("签名完成");
|
||||||
} catch (IOException ioException) {
|
} catch (IOException ioException) {
|
||||||
ioException.printStackTrace();
|
ioException.printStackTrace();
|
||||||
}
|
}
|
||||||
tools.clear();
|
//tools.clear();
|
||||||
}else {
|
} else {
|
||||||
new TextToDialog("警告","签名失败");
|
new TextToDialog("警告", "签名失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -164,6 +169,75 @@ public class AutoOutAPKUi {
|
|||||||
appPath.setText(path.getAbsolutePath());
|
appPath.setText(path.getAbsolutePath());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
selectAppid.addItem("无");
|
||||||
|
for (String appid : ExcelTools.getAllAppId()) {
|
||||||
|
selectAppid.addItem(appid);
|
||||||
|
}
|
||||||
|
selectAppid.addItemListener(new ItemListener() {
|
||||||
|
@Override
|
||||||
|
public void itemStateChanged(ItemEvent e) {
|
||||||
|
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||||
|
if (e.getItem().toString().equals("无")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JSONObject json = ExcelTools.queryParamByAppId(Integer.parseInt(e.getItem().toString()));
|
||||||
|
if (json != null) {
|
||||||
|
channel.clear();
|
||||||
|
vector.clear();
|
||||||
|
list1.updateUI();
|
||||||
|
setData(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addChannel(JSONObject json) {
|
||||||
|
JSONObject config = Tools.loadConfig(new File("gameConfig.json"));
|
||||||
|
for (String key : config.keySet()) {
|
||||||
|
JSONArray array = config.getJSONArray(key);
|
||||||
|
Map<String, String> map = null;
|
||||||
|
for (Object o : array) {
|
||||||
|
if (!json.isNull(o.toString())) {
|
||||||
|
if (map == null)
|
||||||
|
map = new HashMap<>();
|
||||||
|
map.put(o.toString(), json.getString((o.toString())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (map != null) {
|
||||||
|
channel.put(key,map);
|
||||||
|
vector.add(key);
|
||||||
|
list1.setListData(vector);
|
||||||
|
list1.updateUI();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setData(JSONObject json) {
|
||||||
|
System.out.println(json);
|
||||||
|
gameId.setText(json.getInt("appId") + "");
|
||||||
|
packageName.setText(json.getString("packageName"));
|
||||||
|
jiguang.setText(json.getString("jiguang"));
|
||||||
|
addChannel(json);
|
||||||
|
if(json.optString("isChageImage","否").equals("是")){
|
||||||
|
changeImage=new JSONObject();
|
||||||
|
changeImage.put("srcPath",json.getString("srcimagePath"));
|
||||||
|
changeImage.put("oldPath",json.getString("oldImagePath"));
|
||||||
|
changeImage.put("filePath",json.getString("filePath"));
|
||||||
|
}else{
|
||||||
|
changeImage=null;
|
||||||
|
}
|
||||||
|
/* AutoOutAPKAddChannelUi.newInstance(new DialogInterface() {
|
||||||
|
@Override
|
||||||
|
public void onOut(Object data) {
|
||||||
|
super.onOut(data);
|
||||||
|
Map<?, ?> map = (Map<?, ?>) data;
|
||||||
|
for (Object o : map.keySet()) {
|
||||||
|
System.out.println(o.toString() + " > " + map.get(o));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createUIComponents() {
|
private void createUIComponents() {
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package com.qy.utils;
|
package com.qy.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.*;
|
||||||
import javax.crypto.Cipher;
|
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
|
||||||
import javax.crypto.NoSuchPaddingException;
|
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ public class AutoOutAPKTools {
|
|||||||
private JSONObject manifestMap;
|
private JSONObject manifestMap;
|
||||||
private String appPath;
|
private String appPath;
|
||||||
private SmaliApkToolsPath inter;
|
private SmaliApkToolsPath inter;
|
||||||
|
private JSONObject copyJson;
|
||||||
|
|
||||||
public AutoOutAPKTools(String gameId, Map<String, String> channel) {
|
public AutoOutAPKTools(String gameId, Map<String, String> channel) {
|
||||||
this.gameId = gameId;
|
this.gameId = gameId;
|
||||||
@ -49,10 +50,20 @@ public class AutoOutAPKTools {
|
|||||||
@Override
|
@Override
|
||||||
public void smaliPath(String path) {
|
public void smaliPath(String path) {
|
||||||
inter.smaliPath(appPath + File.separator + new File(oldPath).getName() + gameId);
|
inter.smaliPath(appPath + File.separator + new File(oldPath).getName() + gameId);
|
||||||
|
if (copyJson != null) {
|
||||||
|
File copyPath = new File(copyJson.getString("oldPath"));
|
||||||
|
for (File file : Objects.requireNonNull(copyPath.listFiles())) {
|
||||||
|
Tools.copyFile(file.getAbsolutePath(), appPath + File.separator + copyJson.getString("filePath"), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setChangeFile(JSONObject json) {
|
||||||
|
copyJson = json;
|
||||||
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
Tools.deleteFiles(appPath);
|
Tools.deleteFiles(appPath);
|
||||||
}
|
}
|
||||||
@ -63,7 +74,7 @@ public class AutoOutAPKTools {
|
|||||||
try {
|
try {
|
||||||
List<String> keys = new ArrayList<>(manifestMap.keySet());
|
List<String> keys = new ArrayList<>(manifestMap.keySet());
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(manifest), StandardCharsets.UTF_8));
|
BufferedReader reader = new BufferedReader(new FileReader(manifest));
|
||||||
while ((tmp = reader.readLine()) != null) {
|
while ((tmp = reader.readLine()) != null) {
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
if (tmp.contains(key)) {
|
if (tmp.contains(key)) {
|
||||||
@ -91,6 +102,12 @@ public class AutoOutAPKTools {
|
|||||||
}
|
}
|
||||||
Tools.saveConfig(new File(appPath + File.separator + "assets" + File.separator + "kusdkconf.ini"),
|
Tools.saveConfig(new File(appPath + File.separator + "assets" + File.separator + "kusdkconf.ini"),
|
||||||
builder.toString());
|
builder.toString());
|
||||||
|
if (copyJson != null) {
|
||||||
|
File path = new File(copyJson.getString("srcPath"));
|
||||||
|
for (File file : Objects.requireNonNull(path.listFiles())) {
|
||||||
|
Tools.copyFile(file.getAbsolutePath(), appPath + File.separator + copyJson.getString("filePath"), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void outLog(String log) {
|
private void outLog(String log) {
|
||||||
|
@ -1,311 +1,66 @@
|
|||||||
package com.qy.utils;
|
package com.qy.utils;
|
||||||
|
|
||||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import sun.applet.Main;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
public class AutoPackageSDK {
|
public class AutoPackageSDK {
|
||||||
private AutoRandomAdSDK randomAdSDK;
|
/*
|
||||||
private String version;
|
1、在SDK目录调用.\gradlew assembleKusdk 生成SDK
|
||||||
private String packageName;
|
2、在EmptyDemo项目同步gradle
|
||||||
private SmaliApkToolsPath inter;
|
3、生成Demo.apk
|
||||||
File gdtsdk, uniplaysdk, qysdk,baiduSdk;
|
public void init() {
|
||||||
|
|
||||||
private AutoPackageSDK() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void encryptSDK() {
|
4、复制apk到临时目录并反编译
|
||||||
AutoPackageSDKMust.start(Tools.getRandomString(16), new SmaliApkToolsPath() {
|
5、复制反编译目录到sdk目录 ←到这一步已经完成SDK的处理
|
||||||
@Override
|
生成母包的方案:
|
||||||
public void smaliPath(String path) {
|
1、反编译CP包
|
||||||
if (path != null) {
|
2、拷贝sdk目录的assets、smali到CP包
|
||||||
Tools.copyFile(path, new File("input" + File.separator + "qySDK").getAbsolutePath(), true);
|
3、根据CP包已有的lib库拷贝对应的sdk lib
|
||||||
}
|
4、合并sdk和cp的res,输出到cp目录
|
||||||
init();
|
5、重新打包cp包
|
||||||
}
|
*/
|
||||||
});
|
|
||||||
|
public AutoPackageSDK() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
public void packageSdk() {
|
||||||
System.out.println("准备打包");
|
String sdkPath = Tools.loadConfig(new File("config.cfg")).getString("sdkPath");
|
||||||
File gdtPath = new File("input" + File.separator + "gdtSDK" + File.separator);
|
|
||||||
File unplayPath = new File("input" + File.separator + "uniplaySDK" + File.separator);
|
|
||||||
File qysdkPath = new File("input" + File.separator + "qySDK" + File.separator);
|
|
||||||
File baiduPath = new File("input" + File.separator + "baiduSDK" + File.separator);
|
|
||||||
if (!gdtPath.exists() || Objects.requireNonNull(gdtPath.listFiles()).length == 0) {
|
|
||||||
inter.smaliPath("广点通SDK不存在,请放置到input" + File.separator + "gdtSDK文件夹中");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gdtsdk = Objects.requireNonNull(gdtPath.listFiles())[0];
|
|
||||||
if (!unplayPath.exists() || Objects.requireNonNull(unplayPath.listFiles()).length == 0) {
|
|
||||||
inter.smaliPath("聚量SDK不存在,请放置到input" + File.separator + "gdtSDK文件夹中");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uniplaysdk = Objects.requireNonNull(unplayPath.listFiles())[0];
|
|
||||||
if (!qysdkPath.exists() || Objects.requireNonNull(qysdkPath.listFiles()).length == 0) {
|
|
||||||
inter.smaliPath("趣赢SDK不存在,请放置到input" + File.separator + "gdtSDK文件夹中");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
qysdk = Objects.requireNonNull(qysdkPath.listFiles())[0];
|
|
||||||
|
|
||||||
if (!baiduPath.exists() || Objects.requireNonNull(baiduPath.listFiles()).length == 0) {
|
|
||||||
inter.smaliPath("百青藤SDK不存在,请放置到input" + File.separator + "baiduSDK文件夹中");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
baiduSdk= Objects.requireNonNull(baiduPath.listFiles())[0];
|
|
||||||
|
|
||||||
JSONArray array = new JSONArray();
|
|
||||||
|
|
||||||
JSONObject gdt = new JSONObject();
|
|
||||||
gdt.put("file", gdtsdk.getAbsolutePath());
|
|
||||||
gdt.put("version", version);
|
|
||||||
gdt.put("type", "1");
|
|
||||||
gdt.put("index", 0);
|
|
||||||
gdt.put("packageName", packageName + ".tgd");
|
|
||||||
array.put(gdt);
|
|
||||||
|
|
||||||
JSONObject unplay = new JSONObject();
|
|
||||||
unplay.put("file", uniplaysdk.getAbsolutePath());
|
|
||||||
unplay.put("version", version);
|
|
||||||
unplay.put("type", "5");
|
|
||||||
unplay.put("index", 1);
|
|
||||||
unplay.put("packageName", packageName + ".up");
|
|
||||||
array.put(unplay);
|
|
||||||
|
|
||||||
JSONObject baidu = new JSONObject();
|
|
||||||
baidu.put("file", baiduSdk.getAbsolutePath());
|
|
||||||
baidu.put("version", version);
|
|
||||||
baidu.put("type", "2");
|
|
||||||
baidu.put("packageName", packageName + ".bsb");
|
|
||||||
baidu.put("index", 5);
|
|
||||||
array.put(baidu);
|
|
||||||
|
|
||||||
JSONObject qy = new JSONObject();
|
|
||||||
qy.put("file", qysdk.getAbsolutePath());
|
|
||||||
qy.put("version", version);
|
|
||||||
qy.put("type", "0");
|
|
||||||
qy.put("packageName", packageName + ".ww");
|
|
||||||
qy.put("index", 3);
|
|
||||||
array.put(qy);
|
|
||||||
|
|
||||||
File sdk = new File("packageSDK");
|
|
||||||
|
|
||||||
Tools.deleteFiles(sdk.getAbsolutePath());
|
|
||||||
if (!sdk.exists()) {
|
|
||||||
sdk.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("复制资源文件");
|
|
||||||
outAssetsQY(0, "0");
|
|
||||||
outAssetsQY(1, "4");
|
|
||||||
outRes();
|
|
||||||
System.out.println("开始打包");
|
|
||||||
new AutoRandomAdSDK(array, new SmaliApkToolsPath() {
|
|
||||||
@Override
|
|
||||||
public void smaliPath(String path) {
|
|
||||||
System.out.println("打包完成:" + path);
|
|
||||||
delete(gdtPath, gdtsdk);
|
|
||||||
delete(unplayPath, uniplaysdk);
|
|
||||||
delete(qysdkPath, qysdk);
|
|
||||||
outAssetsADS(path);
|
|
||||||
copy();
|
|
||||||
File sdk = zip();
|
|
||||||
System.out.println("制作SDK完成:");
|
|
||||||
inter.smaliPath(sdk == null ? "sdk打包失败" : sdk.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void delete(File path, File sdk) {
|
|
||||||
for (File file : path.listFiles()) {
|
|
||||||
if (!file.getName().equals(sdk.getName())) {
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public AutoPackageSDK(SmaliApkToolsPath inter, String version, String packageName) {
|
|
||||||
this.version = version;
|
|
||||||
this.packageName = packageName;
|
|
||||||
this.inter=inter;
|
|
||||||
encryptSDK();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void outAssetsQY(int index, String type) {
|
|
||||||
JSONObject json = Tools.loadConfig(new File("config.cfg"));
|
|
||||||
|
|
||||||
json.put("switch", index + 1 + "");
|
|
||||||
String path = json.getString("out");
|
|
||||||
String name = json.getJSONArray("array").getString(Integer.parseInt(json.getString("switch")) - 1) + ".jar";
|
|
||||||
File file = new File(path + name);
|
|
||||||
if (file.exists())
|
|
||||||
file.delete();
|
|
||||||
|
|
||||||
JarToAJar.start(json);
|
|
||||||
|
|
||||||
Timer timer = new Timer();
|
|
||||||
timer.schedule(new TimerTask() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
if (file.exists()) {
|
|
||||||
File input = new File(json.getString("out")
|
|
||||||
+ json.getJSONArray("array").getString(index) + ".jar");
|
|
||||||
Tools.toAJar(json.getString("dx"), input.getAbsolutePath(), input.getAbsolutePath().replace(input.getName(), "dexTmp.jar"));
|
|
||||||
File outFile = new EncryptJar().encrypt(new File(input.getAbsolutePath().replace(input.getName(), "dexTmp.jar")), json.getString("out")
|
|
||||||
+ json.getJSONArray("array").getString(index), Integer.parseInt(type)
|
|
||||||
, Integer.parseInt(version));
|
|
||||||
System.out.println(outFile.getAbsolutePath());
|
|
||||||
File assets = new File("packageSDK" + File.separator + "assets");
|
|
||||||
Tools.copyFile(outFile.getAbsolutePath(), assets.getAbsolutePath(), true);
|
|
||||||
outFile.delete();
|
|
||||||
input.delete();
|
|
||||||
timer.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 100);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void outAssetsADS(String path) {
|
|
||||||
JSONArray array = new JSONArray(path);
|
|
||||||
File assets = new File("packageSDK" + File.separator + "assets");
|
|
||||||
File libs = new File("packageSDK" + File.separator);
|
|
||||||
assets.mkdirs();
|
|
||||||
libs.mkdirs();
|
|
||||||
for (int i = 0; i < array.length(); i++) {
|
|
||||||
JSONObject item = array.getJSONObject(i);
|
|
||||||
System.out.println(">>" + item.toString());
|
|
||||||
if (item.getString("type").equals("0")) {
|
|
||||||
Tools.copyFileToName(item.getString("path"), libs.getAbsolutePath(), "classes.jar", true);
|
|
||||||
} else {
|
|
||||||
Tools.copyFile(item.getString("path"), assets.getAbsolutePath(), true);
|
|
||||||
}
|
|
||||||
File file = new File(item.getString("path"));
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void outRes() {
|
|
||||||
//new File("packageSDK" + File.separator + "jni").mkdirs();
|
|
||||||
File xmlFolder = new File("packageSDK" + File.separator + "res" + File.separator + "xml");
|
|
||||||
xmlFolder.mkdirs();
|
|
||||||
File manifest = new File("packageSDK" + File.separator + "AndroidManifest.xml");
|
|
||||||
File srcManifest = new File("input" + File.separator + "Documents" + File.separator + "AndroidManifest.xml");
|
|
||||||
Tools.copyFile("input" + File.separator + "Documents" + File.separator + "file_paths_5.xml",
|
|
||||||
xmlFolder.getAbsolutePath(), true);
|
|
||||||
Tools.copyFile("input" + File.separator + "Documents" + File.separator + "network_security_config.xml",
|
|
||||||
xmlFolder.getAbsolutePath(), true);
|
|
||||||
try {
|
try {
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(srcManifest));
|
Process process = Runtime.getRuntime().exec(new String[]{"cmd"});
|
||||||
String tmp;
|
OutputStream outputStream = process.getOutputStream();
|
||||||
StringBuilder str = new StringBuilder();
|
outputStream.write(("cd '" + sdkPath + "'").getBytes(StandardCharsets.UTF_8));
|
||||||
while ((tmp = reader.readLine()) != null) {
|
outputStream.flush();
|
||||||
str.append(tmp.replace("{packagename}", packageName)).append("\n");
|
outputStream.write(("gradlew assembleKusdk").getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
byte[] uft8bom = {(byte) 0xef, (byte) 0xbb, (byte) 0xbf};
|
|
||||||
OutputStream os = new FileOutputStream(manifest);
|
|
||||||
|
|
||||||
OutputStreamWriter outputStream = new OutputStreamWriter(os, StandardCharsets.UTF_8);
|
|
||||||
outputStream.write(new String(str.toString().getBytes(), StandardCharsets.UTF_8));
|
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
os.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private File zip(File file) throws Exception {
|
|
||||||
String cd = "cd " + new File("packageSDK").getAbsolutePath();
|
|
||||||
File sdk = new File("packageSDK" + File.separator + "sdk.aar");
|
|
||||||
File files = new File("packageSDK");
|
|
||||||
String aapt = new File("aapt.exe").exists() ? new File("aapt.exe").getAbsolutePath() : "aapt";
|
|
||||||
for (File listFile : file.listFiles()) {
|
|
||||||
if (listFile.isDirectory()) {
|
|
||||||
zip(listFile);
|
|
||||||
} else if (!listFile.getName().equals("sdk.aar")) {
|
|
||||||
String path = listFile.getAbsolutePath().replace(files.getAbsolutePath(), "");
|
|
||||||
String exec = aapt + " r " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n";
|
|
||||||
Runtime.getRuntime().exec("cmd /c " + cd + " && " + exec);
|
|
||||||
Thread.sleep(100);
|
|
||||||
exec = aapt + " a " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n";
|
|
||||||
Runtime.getRuntime().exec("cmd /c " + cd + " && " + exec);
|
|
||||||
Thread.sleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return sdk;
|
|
||||||
}
|
|
||||||
|
|
||||||
private File zip() {
|
|
||||||
File sdk = null;
|
|
||||||
try {
|
|
||||||
Tools.copyFile(new File("input" + File.separator + "Documents" + File.separator + "sdk.aar").getAbsolutePath(),
|
|
||||||
new File("packageSDK").getAbsolutePath(), true);
|
|
||||||
String cd = "cd " + new File("packageSDK").getAbsolutePath() + "\n\r";
|
|
||||||
Process process = Runtime.getRuntime().exec(new String[]{"cmd"});
|
|
||||||
OutputStream stream = process.getOutputStream();
|
|
||||||
stream.write(cd.getBytes());
|
|
||||||
stream.flush();
|
|
||||||
stream.close();
|
|
||||||
process.destroy();
|
|
||||||
sdk = zip(new File("packageSDK"));
|
|
||||||
File copy = new File("packageSDK" + File.separator + "copy");
|
|
||||||
if (copy.exists()) {
|
|
||||||
zip(copy);
|
|
||||||
}
|
|
||||||
stream.close();
|
|
||||||
process.destroy();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
}
|
|
||||||
return sdk;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void copy() {
|
|
||||||
try {
|
|
||||||
File copyPath = new File("input" + File.separator + "Documents" + File.separator + "copy");
|
|
||||||
if (copyPath.exists()) {
|
|
||||||
Tools.copyFile(copyPath.getAbsolutePath(), new File("packageSDK").getAbsolutePath(), true);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void printOut(InputStream inputStream) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
|
String str = "", tmp;
|
||||||
|
while ((tmp = reader.readLine()) != null) {
|
||||||
|
str += tmp;
|
||||||
|
System.out.println(tmp);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int[] nums = new int[]{-1, -1, -1, 1, -1, -1};
|
new AutoPackageSDK().packageSdk();
|
||||||
for (int j = 1; j < nums.length; j++) {
|
|
||||||
int index = j;
|
|
||||||
int tmp = 0;
|
|
||||||
int tmp2 = 0;
|
|
||||||
for (int i = 0; i < index; i++) {
|
|
||||||
tmp += nums[i];
|
|
||||||
}
|
|
||||||
for (int i = index + 1; i < nums.length; i++) {
|
|
||||||
tmp2 += nums[i];
|
|
||||||
}
|
|
||||||
System.out.println(tmp);
|
|
||||||
System.out.println(tmp2);
|
|
||||||
if (tmp == tmp2) {
|
|
||||||
System.out.println("return:" + index);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
System.out.println("return:" + -1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
96
src/com/qy/utils/ExcelTools.java
Normal file
96
src/com/qy/utils/ExcelTools.java
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
package com.qy.utils;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ExcelTools {
|
||||||
|
|
||||||
|
private ExcelTools() {
|
||||||
|
|
||||||
|
}
|
||||||
|
private static Workbook getWorkbook(){
|
||||||
|
try {
|
||||||
|
return new XSSFWorkbook(new File("产品参数.xlsx"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private static void close(Workbook workbook){
|
||||||
|
try {
|
||||||
|
workbook.close();
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static JSONObject queryParamByAppId(int appId) {
|
||||||
|
Workbook workbook=getWorkbook();
|
||||||
|
if (workbook == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
Row param = null;
|
||||||
|
for (Row row : sheet) {
|
||||||
|
if (row.getCell(0).getCellType() == CellType.NUMERIC && row.getCell(0).getNumericCellValue() == appId) {
|
||||||
|
param = row;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (param == null) {
|
||||||
|
close(workbook);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
json.put("appId", param.getCell(0).getNumericCellValue());
|
||||||
|
json.put("packageName", param.getCell(1).getStringCellValue());
|
||||||
|
json.put("jiguang", param.getCell(2).getStringCellValue());
|
||||||
|
json.put("TOUTIAO_APP_ID", getValue(param.getCell(3)));
|
||||||
|
for (Cell cell : sheet.getRow(0)) {
|
||||||
|
String title = getValue(cell);
|
||||||
|
if (!StringUtils.isEmpty(title) && title.contains("|")) {
|
||||||
|
String value = getValue(param.getCell(cell.getColumnIndex()));
|
||||||
|
if (value != null)
|
||||||
|
json.put(title.split("\\|")[1],value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(workbook);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
public static List<String> getAllAppId(){
|
||||||
|
List<String> list=new ArrayList<>();
|
||||||
|
Workbook workbook=getWorkbook();
|
||||||
|
if (workbook == null) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
for (Row row : sheet) {
|
||||||
|
Cell cell=row.getCell(0);
|
||||||
|
String value=getValue(cell);
|
||||||
|
if(value!=null&&!value.equals("appid")){
|
||||||
|
list.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(workbook);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getValue(Cell cell) {
|
||||||
|
switch (cell.getCellType()) {
|
||||||
|
case NUMERIC:
|
||||||
|
return ((int) cell.getNumericCellValue()) + "";
|
||||||
|
case STRING:
|
||||||
|
return cell.getStringCellValue();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
182
src/com/qy/utils/HeiHeiTools.java
Normal file
182
src/com/qy/utils/HeiHeiTools.java
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
package com.qy.utils;
|
||||||
|
|
||||||
|
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||||
|
import com.qy.ui.ApkSignUi;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
public class HeiHeiTools {
|
||||||
|
private File apk;
|
||||||
|
private File pluginPath;
|
||||||
|
|
||||||
|
public HeiHeiTools() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSdkPlugin(File pluginPath) {
|
||||||
|
this.pluginPath = pluginPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApk(File apk) {
|
||||||
|
this.apk = apk;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
SmaliUtils utils = new SmaliUtils();
|
||||||
|
utils.unPack(apk.getAbsolutePath(), new SmaliApkToolsPath() {
|
||||||
|
@Override
|
||||||
|
public void smaliPath(String path) {
|
||||||
|
copyLibs(new File(path));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private SmaliApkToolsPath packaInter;
|
||||||
|
|
||||||
|
private void copyLibs(File smaliPath) {
|
||||||
|
if (!new File(pluginPath.getAbsolutePath() + File.separator + "libs").exists()) {
|
||||||
|
copyAssets(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "assets"));
|
||||||
|
}
|
||||||
|
unpackLibs(new File(pluginPath.getAbsolutePath() + File.separator + "libs"), new SmaliApkToolsPath() {
|
||||||
|
@Override
|
||||||
|
public void smaliPath(String path) {
|
||||||
|
File libs = new File(path);
|
||||||
|
for (File file : libs.listFiles()) {
|
||||||
|
if (file.isDirectory() && !"original".equals(file.getName())&& !"unknown".equals(file.getName())) {
|
||||||
|
Tools.copy_dir(file.getAbsolutePath(), smaliPath.getAbsolutePath() + File.separator + "smali");
|
||||||
|
}
|
||||||
|
if(file.isDirectory()&& "assets".equals(file.getName())){
|
||||||
|
Tools.copy_dir(file.getAbsolutePath(), smaliPath.getAbsolutePath() + File.separator + "assets");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
packaInter = new SmaliApkToolsPath() {
|
||||||
|
@Override
|
||||||
|
public void smaliPath(String path) {
|
||||||
|
XMLTools.mergeManifestXML(new File(smaliPath.getAbsolutePath() + File.separator + "AndroidManifest.xml"),
|
||||||
|
new File(pluginPath.getAbsolutePath() + File.separator + "AndroidManifest.xml"),
|
||||||
|
new File(smaliPath.getAbsolutePath() + File.separator + "AndroidManifest.xml"));
|
||||||
|
SmaliUtils utils = new SmaliUtils();
|
||||||
|
utils.bale(smaliPath.getAbsolutePath(), smaliPath.getAbsolutePath()+File.separator+"game.apk", new SmaliApkToolsPath() {
|
||||||
|
@Override
|
||||||
|
public void smaliPath(String path) {
|
||||||
|
|
||||||
|
LinkedHashMap<String,String> keyMap= ApkSignUi.loadKeys();
|
||||||
|
Vector<String> adbList = new Vector<String>(keyMap.keySet());
|
||||||
|
String key=adbList.get(1);
|
||||||
|
String tmp=keyMap.get(key);
|
||||||
|
System.out.println("选择签名:"+key);
|
||||||
|
JSONObject json=new JSONObject(tmp);
|
||||||
|
ApkSignTools tools=new ApkSignTools();
|
||||||
|
tools.setSignFile(new File(json.getString("file")));
|
||||||
|
tools.setApkFile(new File(path));
|
||||||
|
tools.setKeyStorePassword(json.getString("alias_password"));
|
||||||
|
tools.setName(json.getString("alias"));
|
||||||
|
tools.setSignKey(json.getString("password"));
|
||||||
|
System.out.println("开始签名");
|
||||||
|
tools.sign();
|
||||||
|
System.out.println("打包完成:" + path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
copyAssets(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "assets"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copyAssets(File smaliPath, File assets) {
|
||||||
|
Tools.copy_dir(assets.getAbsolutePath(), smaliPath.getAbsolutePath() + File.separator + "assets");
|
||||||
|
copyJniLibs(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "JniLibs"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copyJniLibs(File smaliPath, File jniLibs) {
|
||||||
|
File libs = new File(smaliPath.getAbsolutePath() + File.separator + "lib");
|
||||||
|
if(libs.exists()) {
|
||||||
|
for (File file : libs.listFiles()) {
|
||||||
|
Tools.copy_dir(jniLibs.getAbsolutePath() + File.separator + file.getName(), file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
copyRes(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "res"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copyRes(File smaliPath, File res) {
|
||||||
|
Tools.copy_dir(res.getAbsolutePath(), smaliPath.getAbsolutePath() + File.separator + "res");
|
||||||
|
copyCode(smaliPath, new File(pluginPath.getAbsolutePath() + File.separator + "code"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copyCode(File smaliPath, File code) {
|
||||||
|
File sboran = null;
|
||||||
|
for (File file : smaliPath.listFiles()) {
|
||||||
|
if (file.getName().startsWith("smali")) {
|
||||||
|
if (new File(file.getAbsolutePath() + File.separator
|
||||||
|
+ "com" + File.separator
|
||||||
|
+ "sboran" + File.separator
|
||||||
|
+ "game" + File.separator
|
||||||
|
+ "sdk").exists()) {
|
||||||
|
sboran = new File(file.getAbsolutePath() + File.separator
|
||||||
|
+ "com" + File.separator
|
||||||
|
+ "sboran" + File.separator
|
||||||
|
+ "game" + File.separator
|
||||||
|
+ "sdk");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sboran != null) {
|
||||||
|
Tools.copyFile(code.listFiles()[0].getAbsolutePath() + File.separator + "SboRanApplication.smali"
|
||||||
|
, sboran.getAbsolutePath(), true);
|
||||||
|
Tools.copy_dir(code.getAbsolutePath(), sboran.getAbsolutePath() + File.separator + "platform");
|
||||||
|
Tools.deleteFile(sboran.getAbsolutePath() + File.separator + "platform" + File.separator + code.listFiles()[0].getName() + File.separator + "SboRanApplication.smali");
|
||||||
|
}
|
||||||
|
packaInter.smaliPath("ok");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void unpackLibs(File libs, SmaliApkToolsPath smaliApkToolsPath) {
|
||||||
|
String dx = Tools.loadConfig(new File("config.cfg")).getString("dx");
|
||||||
|
if (new File("tmp" + File.separator + "dex").exists()) {
|
||||||
|
Tools.deleteFiles(new File("tmp" + File.separator + "dex").getAbsolutePath());
|
||||||
|
}
|
||||||
|
if (new File("tmp" + File.separator + "dx_smali").exists()) {
|
||||||
|
Tools.deleteFiles(new File("tmp" + File.separator + "dx_smali").getAbsolutePath());
|
||||||
|
}
|
||||||
|
new File("tmp" + File.separator + "dxs").mkdirs();
|
||||||
|
System.out.println(libs.getAbsolutePath());
|
||||||
|
for (File file : libs.listFiles()) {
|
||||||
|
Tools.toAJar(dx, file.getAbsolutePath(), "tmp" + File.separator + "dxs" + File.separator + file.getName());
|
||||||
|
}
|
||||||
|
libs = new File("tmp" + File.separator + "dxs");
|
||||||
|
unpackLibsDx(libs.listFiles(), 0);
|
||||||
|
smaliApkToolsPath.smaliPath(new File("tmp" + File.separator + "dx_smali").getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unpackLibsDx(File[] files, int index) {
|
||||||
|
if (index < files.length) {
|
||||||
|
new SmaliUtils().unPack(files[index].getAbsolutePath(), new SmaliApkToolsPath() {
|
||||||
|
@Override
|
||||||
|
public void smaliPath(String path) {
|
||||||
|
Tools.copy_dir(path, "tmp" + File.separator + "dx_smali");
|
||||||
|
unpackLibsDx(files, index + 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
/* HeiHeiTools tools = new HeiHeiTools();
|
||||||
|
tools.setApk(new File("D:\\ieda\\android_sdk_tools\\天命传说(嘿嘿游戏专服)_嘿嘿游戏_8.1.4_202106070951.apk"));
|
||||||
|
tools.setSdkPlugin(new File("D:\\ieda\\android_sdk_tools\\sdk_plugin\\zssdk"));
|
||||||
|
tools.start();*/
|
||||||
|
unpackLibs(new File("D:\\ieda\\android_sdk_tools\\sdk_plugin\\69you\\libs"), new SmaliApkToolsPath() {
|
||||||
|
@Override
|
||||||
|
public void smaliPath(String path) {
|
||||||
|
System.out.println("over = "+path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,6 @@ package com.qy.utils;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.security.Permission;
|
import java.security.Permission;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -14,7 +13,7 @@ import java.util.Set;
|
|||||||
import com.qy.Interfaces.SmaliApkToolsPath;
|
import com.qy.Interfaces.SmaliApkToolsPath;
|
||||||
|
|
||||||
import com.qy.ui.TextToDialog;
|
import com.qy.ui.TextToDialog;
|
||||||
import com.sun.javaws.exceptions.ExitException;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public class SmaliUtils {
|
public class SmaliUtils {
|
||||||
//private String str = "";
|
//private String str = "";
|
||||||
@ -23,8 +22,8 @@ public class SmaliUtils {
|
|||||||
// private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali";
|
// private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali";
|
||||||
private Map<String, String> clazzList;
|
private Map<String, String> clazzList;
|
||||||
private List<File> files = new ArrayList<>();
|
private List<File> files = new ArrayList<>();
|
||||||
private static ClassLoader apktool_234;
|
private ClassLoader package_apktool;
|
||||||
private static ClassLoader apktool_241;
|
private ClassLoader un_apktool;
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -34,11 +33,21 @@ public class SmaliUtils {
|
|||||||
public SmaliUtils() {
|
public SmaliUtils() {
|
||||||
clazzList = new HashMap<>();
|
clazzList = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
if(apktool_234==null){
|
JSONObject json =Tools.loadConfig(new File("config.cfg"));
|
||||||
apktool_234=new URLClassLoader(new URL[]{new URL("file:libs/apktool_2.3.4.jar")});
|
if(package_apktool ==null){
|
||||||
|
String path="libs/apktool_2.4.1.jar";
|
||||||
|
if(json!=null){
|
||||||
|
path=json.optString("packageApkTool","libs/apktool_2.4.1.jar");
|
||||||
|
}
|
||||||
|
System.out.println(path);
|
||||||
|
package_apktool =new URLClassLoader(new URL[]{new URL("file:"+path)});
|
||||||
}
|
}
|
||||||
if(apktool_241==null){
|
if(un_apktool ==null){
|
||||||
apktool_241=new URLClassLoader(new URL[]{new URL("file:libs/apktool_2.4.1.jar")});
|
String path="libs/apktool_2.4.1.jar";
|
||||||
|
if(json!=null){
|
||||||
|
path=json.optString("unPackageApkTool","libs/apktool_2.4.1.jar");
|
||||||
|
}
|
||||||
|
un_apktool =new URLClassLoader(new URL[]{new URL("file:"+path)});
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -222,6 +231,10 @@ public class SmaliUtils {
|
|||||||
Tools.deleteFiles(path.getAbsolutePath());
|
Tools.deleteFiles(path.getAbsolutePath());
|
||||||
}
|
}
|
||||||
String[] args = new String[]{"d", "-f", jarPath};
|
String[] args = new String[]{"d", "-f", jarPath};
|
||||||
|
JSONObject json=Tools.loadConfig(new File("config.cfg"));
|
||||||
|
if(json!=null){
|
||||||
|
isEncryption=json.optBoolean("encryption",false);
|
||||||
|
}
|
||||||
if (isEncryption) {
|
if (isEncryption) {
|
||||||
args = new String[]{"d", "-f", jarPath, "--only-main-classes"};
|
args = new String[]{"d", "-f", jarPath, "--only-main-classes"};
|
||||||
}
|
}
|
||||||
@ -231,7 +244,7 @@ public class SmaliUtils {
|
|||||||
}
|
}
|
||||||
System.out.println("\n");
|
System.out.println("\n");
|
||||||
//Main.main(args);
|
//Main.main(args);
|
||||||
apktool_241.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args});
|
un_apktool.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args});
|
||||||
File jarFile = new File(jarPath);
|
File jarFile = new File(jarPath);
|
||||||
String name;
|
String name;
|
||||||
if (jarFile.getName().contains(".jar")) {
|
if (jarFile.getName().contains(".jar")) {
|
||||||
@ -260,7 +273,7 @@ public class SmaliUtils {
|
|||||||
public void bale(String smaliPath, String path, SmaliApkToolsPath inter) {
|
public void bale(String smaliPath, String path, SmaliApkToolsPath inter) {
|
||||||
String[] args = new String[]{"-r","b", "-f", smaliPath, "-o", path};
|
String[] args = new String[]{"-r","b", "-f", smaliPath, "-o", path};
|
||||||
for (String string : args) {
|
for (String string : args) {
|
||||||
System.out.print(string + " ");
|
System.err.print(string + " ");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
run = true;
|
run = true;
|
||||||
@ -291,7 +304,7 @@ public class SmaliUtils {
|
|||||||
System.setSecurityManager(new NoExitSecurityManager());
|
System.setSecurityManager(new NoExitSecurityManager());
|
||||||
|
|
||||||
//Main.main(args);
|
//Main.main(args);
|
||||||
apktool_241.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args});
|
package_apktool.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args});
|
||||||
if (inter != null) {
|
if (inter != null) {
|
||||||
inter.smaliPath(path);
|
inter.smaliPath(path);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,11 @@ public class Tools {
|
|||||||
}
|
}
|
||||||
public static void copy_dir(String src,String desc){
|
public static void copy_dir(String src,String desc){
|
||||||
try {
|
try {
|
||||||
|
//System.out.println("拷贝文件:"+src+" -> "+desc);
|
||||||
File dirSrc=new File(src);
|
File dirSrc=new File(src);
|
||||||
|
if(!dirSrc.exists()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (File file : dirSrc.listFiles()) {
|
for (File file : dirSrc.listFiles()) {
|
||||||
if(file.isDirectory()){
|
if(file.isDirectory()){
|
||||||
new File(desc+File.separator+file.getName()).mkdirs();
|
new File(desc+File.separator+file.getName()).mkdirs();
|
||||||
@ -413,4 +417,9 @@ public class Tools {
|
|||||||
}
|
}
|
||||||
System.out.println("[域名]" + url + " = [body]" + body.toString() + " -> [接收] " + str);
|
System.out.println("[域名]" + url + " = [body]" + body.toString() + " -> [接收] " + str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void deleteFile(String s) {
|
||||||
|
System.out.println("删除文件:"+s);
|
||||||
|
new File(s).delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
216
src/com/qy/utils/XMLTools.java
Normal file
216
src/com/qy/utils/XMLTools.java
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
package com.qy.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import org.dom4j.*;
|
||||||
|
import org.dom4j.io.OutputFormat;
|
||||||
|
import org.dom4j.io.SAXReader;
|
||||||
|
import org.dom4j.io.XMLWriter;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class XMLTools {
|
||||||
|
private XMLTools() {
|
||||||
|
}
|
||||||
|
public static void mergeManifestXML(File src,File src2,File outFile){
|
||||||
|
try {
|
||||||
|
SAXReader reader = new SAXReader();
|
||||||
|
Document manifestDocument = reader.read(src);
|
||||||
|
Document manifestDocument2 = reader.read(src2);
|
||||||
|
Element manifestElement = manifestDocument.getRootElement();
|
||||||
|
Element manifestElement2 = manifestDocument2.getRootElement();
|
||||||
|
for (Element element : manifestElement2.elements("uses-permission")) {
|
||||||
|
if(manifestElement.asXML().contains((CharSequence) element.attribute("name").getData())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
manifestElement.add((Element) element.clone());
|
||||||
|
}
|
||||||
|
Element application=manifestElement.element("application");
|
||||||
|
Element application2=manifestElement2.element("application");
|
||||||
|
for (Element element : application2.elements()) {
|
||||||
|
if(application.asXML().contains((CharSequence) element.attribute("name").getData())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
application.add((Element) element.clone());
|
||||||
|
}
|
||||||
|
manifestElement.remove(application);
|
||||||
|
manifestElement.add((Element) application.clone());
|
||||||
|
manifestDocument.remove(manifestElement);
|
||||||
|
manifestDocument.add((Element) manifestElement.clone());
|
||||||
|
writeFile4Pretty(outFile,manifestDocument);
|
||||||
|
System.out.println("AndroidManifest处理完成");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private static void writeFile4Pretty(File file, Document document) throws IOException {
|
||||||
|
OutputFormat format = OutputFormat.createPrettyPrint();
|
||||||
|
format.setEncoding(document.getXMLEncoding());
|
||||||
|
XMLWriter writer = new XMLWriter(new FileWriter(file), format);
|
||||||
|
writer.write(document);
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 合并不同xml文件,该方法不能用于合并public.xml
|
||||||
|
* @param file1 文件1
|
||||||
|
* @param file2 被合并的文件2
|
||||||
|
* @param outFile 输出文件
|
||||||
|
*/
|
||||||
|
public static void mergeResXML(File file1, File file2, File outFile) {
|
||||||
|
try {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
List<String> list1 = readXML(file1);
|
||||||
|
List<String> list2 = readXML(file2);
|
||||||
|
list.add("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||||
|
list.add("<resources>");
|
||||||
|
list.addAll(list1);
|
||||||
|
for (String element : list2) {
|
||||||
|
if (!list.contains(element)) {
|
||||||
|
list.add(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
list.add("</resources>");
|
||||||
|
FileWriter writer = new FileWriter(outFile);
|
||||||
|
for (String s : list) {
|
||||||
|
writer.append(s).append("\n");
|
||||||
|
}
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合并public.xml
|
||||||
|
*
|
||||||
|
* @param file1 被合并文件,以该文件id为主
|
||||||
|
* @param file2 合并素材
|
||||||
|
* @param outFile 输出文件
|
||||||
|
*/
|
||||||
|
public static void mergePublicXML(File file1, File file2, File outFile) {
|
||||||
|
try {
|
||||||
|
//file1中的参数,在遍历file2时用来判断是否重复
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
//最后输出的xml文件,不直接asXML是因为asXML不格式化文件,不好看
|
||||||
|
List<String> main = new ArrayList<>();
|
||||||
|
SAXReader reader = new SAXReader();
|
||||||
|
Document document = reader.read(file1);
|
||||||
|
Document document2 = reader.read(file2);
|
||||||
|
Element element = document.getRootElement();
|
||||||
|
Element element2 = document2.getRootElement();
|
||||||
|
//遍历file1,并记录元素
|
||||||
|
for (Element el : element.elements()) {
|
||||||
|
list.add(el.attributeValue("type") + "|" + el.attributeValue("name"));
|
||||||
|
}
|
||||||
|
//合并file2,去重
|
||||||
|
for (Element el : element2.elements()) {
|
||||||
|
String tmp = el.attributeValue("type") + "|" + el.attributeValue("name");
|
||||||
|
if (!list.contains(tmp)) {
|
||||||
|
element.add((Element) el.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//分门别类,保存不同type下的元素到map
|
||||||
|
Map<String,List<Element>> map=new HashMap<>();
|
||||||
|
for (Element el : element.elements()) {
|
||||||
|
List<Element> elements;
|
||||||
|
if(map.containsKey(el.attributeValue("type"))){
|
||||||
|
elements=map.get(el.attributeValue("type"));
|
||||||
|
}else{
|
||||||
|
elements=new ArrayList<>();
|
||||||
|
}
|
||||||
|
if(!elements.contains(el)){
|
||||||
|
elements.add(el);
|
||||||
|
map.put(el.attributeValue("type"),elements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
main.add("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||||
|
main.add("<resources>");
|
||||||
|
int index=0x7f00;//不同type的值
|
||||||
|
int nowIndex=Integer.parseInt( Integer.toHexString(index)+"0000",16);//单个元素的值,例:0x7f000000
|
||||||
|
String nowKey="";
|
||||||
|
//重新设置id
|
||||||
|
for (String key : map.keySet()) {
|
||||||
|
if(!key.equals(nowKey)){
|
||||||
|
nowKey=key;
|
||||||
|
index++;
|
||||||
|
nowIndex=Integer.parseInt( Integer.toHexString(index)+"0000",16);
|
||||||
|
}
|
||||||
|
for (Element el : map.get(key)) {
|
||||||
|
main.add(el.addAttribute("id","0x"+Integer.toHexString(nowIndex++)).asXML());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
main.add("</resources>");
|
||||||
|
FileWriter writer = new FileWriter(outFile);
|
||||||
|
for (String s : main) {
|
||||||
|
writer.append(s).append("\n");
|
||||||
|
}
|
||||||
|
//writer.append(element.asXML());
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> readXML(File file) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
SAXReader reader = new SAXReader();
|
||||||
|
Document document = reader.read(file);
|
||||||
|
Element element = document.getRootElement();
|
||||||
|
for (Element el : element.elements()) {
|
||||||
|
list.add(el.asXML());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println(file.exists());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void out() {
|
||||||
|
try {
|
||||||
|
SAXReader reader = new SAXReader();
|
||||||
|
Document document = reader.read(new File("input\\xml\\tmp.xml"));
|
||||||
|
Element element = document.getRootElement();
|
||||||
|
int i = 0x7f0b0026;
|
||||||
|
for (Element el : element.elements()) {
|
||||||
|
i++;
|
||||||
|
String value = "0x" + Integer.toHexString(i);
|
||||||
|
el = el.addAttribute("id", value);
|
||||||
|
System.out.println(el.asXML());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
boolean isPublic=true;
|
||||||
|
if(isPublic) {
|
||||||
|
mergePublicXML(new File("D:\\ieda\\android_sdk_tools\\EmptyDemo\\res\\values\\public.xml")
|
||||||
|
, new File("D:\\ieda\\android_sdk_tools\\app-game_op2-release\\res\\values\\public.xml")
|
||||||
|
, new File("D:\\ieda\\android_sdk_tools\\app-game_op2-release\\res\\values\\public.xml"));
|
||||||
|
}else {
|
||||||
|
String fileName = "styles.xml";
|
||||||
|
mergeResXML(new File("D:\\ieda\\android_sdk_tools\\qztx_agent_115847_baoliang_11027_1003.0.0_20210128_48301\\res\\values\\" + fileName),
|
||||||
|
new File("D:\\ieda\\android_sdk_tools\\EmptyDemo\\res\\values\\" + fileName),
|
||||||
|
new File("D:\\ieda\\android_sdk_tools\\qztx_agent_115847_baoliang_11027_1003.0.0_20210128_48301\\res\\values\\" + fileName));
|
||||||
|
}
|
||||||
|
/*mergeManifestXML(new File("D:\\ieda\\android_sdk_tools\\三生诀\\AndroidManifest.xml"),
|
||||||
|
new File("D:\\ieda\\android_sdk_tools\\sdk_plugin\\binghu\\AndroidManifest.xml"),
|
||||||
|
new File("D:\\ieda\\android_sdk_tools\\三生诀\\Manifest.xml"));*/
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user