修复穿山甲demo存在时不获取路径的BUG

自动打包程序新增批量打包广告源SDK
配置文件manual字段新增data和end字段,data为添加的内容,end为检测到结束的表示,意思是从find到end这一段由data替换
This commit is contained in:
Yutousama 2020-03-10 17:24:19 +08:00
parent 4e2efcc143
commit 561177d0f4
4 changed files with 134 additions and 52 deletions

View File

@ -2,7 +2,7 @@
"array": [ "array": [
{ {
"title": "广点通", "title": "广点通",
"ltName": "GDTUnionSDK_QY.lt", "ltName": "tgd",
"manifest": [ "manifest": [
"<service android:name=\"com.qq.e.comm.DownloadService\" android:exported=\"false\" />", "<service android:name=\"com.qq.e.comm.DownloadService\" android:exported=\"false\" />",
"<activity android:name=\"com.qq.e.ads.ADActivity\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" />", "<activity android:name=\"com.qq.e.ads.ADActivity\" android:configChanges=\"keyboard|keyboardHidden|orientation|screenSize\" />",
@ -76,7 +76,9 @@
{ {
"class": "com.uniplay.adsdk.basic.RuleManage", "class": "com.uniplay.adsdk.basic.RuleManage",
"find": ".method public configRight", "find": ".method public configRight",
"msg": "仅保留const-string v0, \"\" return-object v0" "msg": "仅保留const-string v0, \"\" return-object v0",
"data":".method public configRight(Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;\n.locals 3\n.prologue\nconst-string v0, \"\" \nreturn-object v0\n",
"end":".end method"
} }
] ]
}, },

View File

@ -1,21 +1,13 @@
{ {
"1": "/home/yutou/AndroidStudioProjects/ADSDK_v5/sdk_rx/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/", "1": "D:\\AndroidStudio_Data\\ADSDK_v5\\sdk_rx\\build\\intermediates\\javac\\debug\\classes\\com",
"2": "/home/yutou/AndroidStudioProjects/ADSDK_v5/qyadsdk/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/", "2": "D:\\AndroidStudio_Data\\ADSDK_v5\\qyadsdk\\build\\intermediates\\javac\\debug\\classes\\com",
"3": "F:/AndroidStudio_Data/GameSDK/sdk_rx/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/",
"4": "/home/yutou/AndroidStudioProjects/ADSDK_v5/sdk_rx/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/",
"5": "/home/yutou/AndroidStudioProjects/ADSDK_v5/qyadsdk/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/",
"6": "/home/yutou/AndroidStudioProjects/ADSDK_v5/Test/build/intermediates/javac/debug/classes/com/",
"switch": "1", "switch": "1",
"input": "/media/yutou/_dde_data/AndroidStudio_Data/buildTools/com.zip", "input": "com.zip",
"out": "/media/yutou/_dde_data/AndroidStudio_Data/buildTools/", "out": "",
"dx": "dx.jar", "dx": "dx.jar",
"array": [ "array": [
"rd_rx", "aa",
"qy_rx", "tl"
"rx",
"rd_rx",
"qy_rx",
"atest"
], ],
"csjConfig": { "csjConfig": {
"xml": { "xml": {

View File

@ -1,12 +1,7 @@
package com.qy.utils; package com.qy.utils;
import java.awt.Desktop; import java.awt.Desktop;
import java.io.BufferedReader; import java.io.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLOutput; import java.sql.SQLOutput;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -69,16 +64,67 @@ public class AutoRandomAdSDK {
public static void main(String[] args) { public static void main(String[] args) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
new AutoRandomAdSDK(new File("JooMobAdSDK_6.1.8.jar"), "5600", "5", 1, null); // new AutoRandomAdSDK(new File("JooMobAdSDK_6.1.8.jar"), "5600", "5", 1, null);
// new AutoRandomAdSDK(new File("GDTSDK.unionNormal.4.100.970.jar"), 0, null); // new AutoRandomAdSDK(new File("GDTSDK.unionNormal.4.100.970.jar"), 0, null);
JSONArray array = new JSONArray();
JSONObject gdt = new JSONObject();
gdt.put("file", "D:\\IDEA\\android_sdk_tools\\GDTSDK.unionNormal.4.170.1040.jar");
gdt.put("version", "5700");
gdt.put("type", "1");
gdt.put("index", 0);
gdt.put("packageName", "com.gzlt.tgttaxc.lmd1.tgd");
array.put(gdt);
JSONObject unplay = new JSONObject();
unplay.put("file", "D:\\IDEA\\android_sdk_tools\\JooMobAdSDK_6.1.8.jar");
unplay.put("version", "5700");
unplay.put("type", "5");
unplay.put("index", 1);
unplay.put("packageName", "com.gzlt.tgttaxc.lmd1.up");
array.put(unplay);
JSONObject qy = new JSONObject();
qy.put("file", "D:\\IDEA\\android_sdk_tools\\classes.jar");
qy.put("version", "5700");
qy.put("type", "0");
qy.put("packageName", "com.gzlt.tgttaxc.lmd1.ww");
qy.put("index", 3);
array.put(qy);
new AutoRandomAdSDK(array, new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
System.out.println("完成:"+path);
}
});
} }
public AutoRandomAdSDK() { public AutoRandomAdSDK() {
} }
public AutoRandomAdSDK(File sdk, String version, String type, int cfgIndex, SmaliApkToolsPath inster) { public AutoRandomAdSDK(JSONArray batch, SmaliApkToolsPath inter) {
final JSONArray array = new JSONArray();
for (Object o : batch) {
final JSONObject item = (JSONObject) o;
autoRandomAdSDK(new File(item.getString("file")), item.getString("version"), item
.getString("type"), item.getString("packageName"), item.getInt("index"), new SmaliApkToolsPath() {
public void smaliPath(String path) {
item.put("path", path);
array.put(item);
}
});
}
inter.smaliPath(array.toString());
}
public void autoRandomAdSDK(File sdk, String version, String type, String packageName, int cfgIndex, SmaliApkToolsPath inster) {
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
if (inster == null) {
inster = path -> {
};
}
this.inter = inster; this.inter = inster;
this.version = version; this.version = version;
this.sdktype = type; this.sdktype = type;
@ -88,9 +134,21 @@ public class AutoRandomAdSDK {
} }
this.sdk = sdk; this.sdk = sdk;
config = cfg.getJSONArray("array").getJSONObject(cfgIndex); config = cfg.getJSONArray("array").getJSONObject(cfgIndex);
if (packageName != null) {
String[] pname = packageName.split("\\.");
JSONArray random = new JSONArray();
for (String pn : pname) {
random.put(pn);
}
this.config.put("random", random);
}
start(); start();
} }
public AutoRandomAdSDK(File sdk, String version, String type, int cfgIndex, SmaliApkToolsPath inster) {
autoRandomAdSDK(sdk, version, type, null, cfgIndex, inster);
}
public void start() { public void start() {
adClass = new HashMap<String, File>(); adClass = new HashMap<String, File>();
nowAdClass = new HashMap<String, File>(); nowAdClass = new HashMap<String, File>();
@ -253,20 +311,46 @@ public class AutoRandomAdSDK {
BufferedReader reader = new BufferedReader(new FileReader(file)); BufferedReader reader = new BufferedReader(new FileReader(file));
String tmp; String tmp;
int index = 1; int index = 1;
boolean find = false;
boolean end = false;
boolean write = false;
StringBuilder buffer = new StringBuilder();
while ((tmp = reader.readLine()) != null) { while ((tmp = reader.readLine()) != null) {
if (tmp.contains(json.getString("find"))) { if (tmp.contains(json.getString("find"))) {
list.add(index); list.add(index);
find = true;
}
if (find && !write) {
buffer.append(json.getString("data"));
write = true;
}
if (find && tmp.contains(json.getString("end"))) {
end = true;
find = false;
}
if (!find) {
buffer.append(tmp).append("\n");
if (end) {
end = false;
write = false;
}
} }
index++; index++;
} }
reader.close(); reader.close();
Desktop.getDesktop().open(file); FileWriter writer = new FileWriter(file);
writer.write(buffer.toString());
writer.flush();
writer.close();
out();
reader.close();
// Desktop.getDesktop().open(file);
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
System.out.println("请手动打开:" + file.getAbsolutePath() + " 文件"); System.out.println("请手动打开:" + file.getAbsolutePath() + " 文件");
} }
String index = ""; /* String index = "";
for (Integer integer : list) { for (Integer integer : list) {
System.out.println("请修改第:" + integer + " 行附近的代码"); System.out.println("请修改第:" + integer + " 行附近的代码");
index += integer + ","; index += integer + ",";
@ -278,11 +362,12 @@ public class AutoRandomAdSDK {
// TODO Auto-generated method stub // TODO Auto-generated method stub
out(); out();
} }
}); });*/
} }
} }
} }
private void show(File file) { private void show(File file) {
for (File listFile : file.listFiles()) { for (File listFile : file.listFiles()) {
if (listFile.isDirectory()) { if (listFile.isDirectory()) {
@ -293,6 +378,7 @@ public class AutoRandomAdSDK {
} }
} }
private void out() { private void out() {
if (!isPackage) { if (!isPackage) {
if (inter != null) { if (inter != null) {
@ -387,10 +473,10 @@ public class AutoRandomAdSDK {
if (fs.getName().startsWith(fileName + "$")) { if (fs.getName().startsWith(fileName + "$")) {
if (getNewName(fs.getName()).endsWith("[notmover]")) { if (getNewName(fs.getName()).endsWith("[notmover]")) {
Tools.copyFileToName(fs.getAbsolutePath(), fs.getAbsolutePath(), Tools.copyFileToName(fs.getAbsolutePath(), fs.getAbsolutePath(), fs
nName + "$" + fs.getName().split("\\$")[1], true); .getName().replace(fs.getName().split("\\$")[0], nName), true);
} else { } else {
moveFile(fs, key, nName + "$" + fs.getName().split("\\$")[1],false); moveFile(fs, key, fs.getName().replace(fs.getName().split("\\$")[0], nName), false);
} }
fs.delete(); fs.delete();
} }

View File

@ -231,6 +231,8 @@ public class CsjTools {
if (new File(csjFile.getName().replace(".apk", "")).exists()) { if (new File(csjFile.getName().replace(".apk", "")).exists()) {
System.out.println(">?>>"+new File(csjFile.getName().replace(".apk", "")).getAbsolutePath()); System.out.println(">?>>"+new File(csjFile.getName().replace(".apk", "")).getAbsolutePath());
unPackageCSJ = true; unPackageCSJ = true;
csj_Path = new File(csjFile.getName().replace(".apk", "")).getAbsolutePath();
csj_res = csj_Path + File.separator + "res" + File.separator + "values";
} }
SmaliUtils utils = new SmaliUtils(); SmaliUtils utils = new SmaliUtils();
// Tools.deleteFiles(new File("").getAbsolutePath() + File.separator + new File(csjPath).getName().replace(".apk", File.separator)); // Tools.deleteFiles(new File("").getAbsolutePath() + File.separator + new File(csjPath).getName().replace(".apk", File.separator));