完善自动打包程序(基本正常),缺少UI界面

穿山甲打包程序新增选择是否用应用包名选项
穿山甲配置同步
This commit is contained in:
Yutousama 2020-03-18 17:10:43 +08:00
parent 19e7e49fe7
commit 6637bfe422
7 changed files with 125 additions and 54 deletions

View File

@ -160,8 +160,18 @@
"<activity android:name=\"com.bytedance.sdk.openadsdk.activity.TTFullScreenExpressVideoActivity\" android:configChanges=\"keyboardHidden|orientation|screenSize\" android:launchMode=\"standard\" /> ",
"<activity android:name=\"com.bytedance.sdk.openadsdk.activity.TTDelegateActivity\" android:launchMode=\"singleTask\" android:theme=\"@android:style/Theme.Translucent.NoTitleBar\" /> ",
"<service android:name=\"com.bytedance.sdk.openadsdk.multipro.aidl.BinderPoolService\" /> ",
"<receiver android:name=\"com.bytedance.embedapplog.collector.Collector\" android:enabled=\"true\" android:exported=\"true\" /> ",
"<service android:name=\"com.bytedance.tea.crash.upload.CrashUploadService\" android:process=\":npth\" />"
"<receiver android:name=\"com.ss.android.downloadlib.core.download.DownloadReceiver\" android:enabled=\"true\" android:exported=\"true\" /> ",
"<service android:name=\"com.bytedance.tea.crash.upload.CrashUploadService\" android:process=\":npth\" />",
"<service android:name=\"com.ss.android.socialbase.downloader.notification.DownloadNotificationService\" />",
"<service android:name=\"com.ss.android.socialbase.downloader.downloader.DownloadService\" />",
"<service android:name=\"com.ss.android.socialbase.downloader.downloader.IndependentProcessDownloadService\" android:process=\":downloader\"> <intent-filter> <action android:name=\"com.ss.android.socialbase.downloader.remote\" /> </intent-filter> </service>",
"<service android:name=\"com.ss.android.socialbase.downloader.impls.DownloadHandleService\" />",
"<service android:name=\"com.ss.android.socialbase.appdownloader.DownloadHandlerService\" />",
"<activity android:name=\"com.ss.android.socialbase.appdownloader.view.DownloadSizeLimitActivity\" android:launchMode=\"singleTask\" android:theme=\"@android:style/Theme.Dialog\" />",
"<activity android:name=\"com.ss.android.socialbase.appdownloader.view.DownloadTaskDeleteActivity\" android:launchMode=\"singleTask\" android:theme=\"@android:style/Theme.Dialog\" />",
"<activity android:name=\"com.ss.android.downloadlib.activity.TTDelegateActivity\" android:launchMode=\"singleTask\" android:theme=\"@android:style/Theme.Translucent.NoTitleBar\" />",
],
"class":[
"com.bytedance.sdk.openadsdk.activity.TTLandingPageActivity",
@ -175,13 +185,20 @@
"com.bytedance.sdk.openadsdk.multipro.aidl.BinderPoolService",
"com.bytedance.embedapplog.collector.Collector",
"com.bytedance.tea.crash.upload.CrashUploadService",
"com.bytedance.sdk.openadsdk.activity.TTBaseVideoActivity"
"com.bytedance.sdk.openadsdk.activity.TTBaseVideoActivity",
"com.ss.android.socialbase.downloader.notification.DownloadNotificationService",
"com.ss.android.socialbase.downloader.downloader.DownloadService",
"com.ss.android.socialbase.downloader.downloader.IndependentProcessDownloadService",
"com.ss.android.socialbase.downloader.impls.DownloadHandleService",
"com.ss.android.socialbase.appdownloader.DownloadHandlerService",
"com.ss.android.socialbase.appdownloader.view.DownloadSizeLimitActivity",
"com.ss.android.socialbase.appdownloader.view.DownloadTaskDeleteActivity",
"com.ss.android.downloadlib.activity.TTDelegateActivity"
],
"random":[
"com",
"ww",
"za",
"csc"
],
"isAllPackage":false,
"isReName":true,
@ -196,6 +213,21 @@
"data":" const-string v1, \".fileprovider\"\n",
"end":" invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;",
"msg":"把TTFileProvider改成fileprovider"
},{
"class":"com.bytedance.embedapplog.util.TTEncryptUtils",
"find":"const-string v0, \"tobEmbedEncrypt\"",
"data":"const-string v0, \"tob\"\n",
"end":"invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V"
},{
"class":"com.pgl.sys.ces.a",
"find":"const-string v0, \"nms\"",
"data":"const-string v0, \"hms\"\n",
"end":"invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V"
},{
"class":"com.pgl.sys.ces.b",
"find":"const-string p1, \"nms\"",
"data":"const-string p1, \"hms\"\n",
"end":"invoke-static {p0, p1}, Lcom/pgl/a/b/e;->a(Landroid/content/Context;Ljava/lang/String;)Z"
}
],
"rename":{
@ -208,9 +240,19 @@
"TTFullScreenExpressVideoActivity":"{>+/activity}TTFullScreenExpressVideoActivity",
"TTDelegateActivity":"{>+/activity}TTDelegateActivity",
"TTBaseVideoActivity":"{>+/activity}TTBaseVideoActivity",
"BinderPoolService":"BinderPoolService",
"Collector":"Collector",
"CrashUploadService":"CrashUploadService"
"BinderPoolService":"{>+/multipro/aidl}BinderPoolService",
"Collector":"{>+/cc/collector}Collector",
"CrashUploadService":"{>+/cc/crash/upload}CrashUploadService",
"com.ss.android.downloadlib.activity.TTDelegateActivity":"{>+/dl/activity}TTDelegateActivity",
"DownloadNotificationService":"{>+/sb/downloader/notification}DownloadNotificationService",
"DownloadService":"{>+/sb/downloader/downloader}DownloadService",
"IndependentProcessDownloadService":"{>+/sb/downloader/downloader}IndependentProcessDownloadService",
"DownloadHandleService":"{>+/sb/downloader/impls}DownloadHandleService",
"DownloadHandlerService":"{>+/sb/appdownloader}DownloadHandlerService",
"DownloadSizeLimitActivity":"{>+/sb/appdownloader/view}DownloadSizeLimitActivity",
"DownloadTaskDeleteActivity":"{>+/sb/appdownloader/view}DownloadTaskDeleteActivity",
"DownloadReceiver":"{>+/dl/core/download}DownloadReceiver",
},
"filter":[
"com.android",

View File

@ -103,6 +103,15 @@
<text value="选择"/>
</properties>
</component>
<component id="faddb" class="javax.swing.JCheckBox" binding="useAppPackageName">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<gridbag weightx="0.0" weighty="0.0"/>
</constraints>
<properties>
<text value="使用APP的包名"/>
</properties>
</component>
</children>
</grid>
</children>

View File

@ -14,6 +14,7 @@ public class ChuanShanJiaUi {
private JPanel mainPanel;
private JButton selectButton;
private JTextArea log;
private JCheckBox useAppPackageName;
public ChuanShanJiaUi() {
selectButton.addActionListener(new ActionListener() {
@ -38,6 +39,7 @@ public class ChuanShanJiaUi {
@Override
public void run() {
CsjTools tools=new CsjTools();
tools.setUserPackageName(useAppPackageName.isSelected());
tools.build(csjDemo.getAbsolutePath(), apkFile.getAbsolutePath(), new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {

View File

@ -72,6 +72,9 @@ public class AutoPackageSDK {
}
outAssetsQY(0, "0");
outAssetsQY(1, "4");
outRes();
new AutoRandomAdSDK(array, new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
@ -79,11 +82,7 @@ public class AutoPackageSDK {
delete(gdtPath,gdtsdk);
delete(unplayPath,uniplaysdk);
delete(qysdkPath,qysdk);
outAssetsADS(path);
outAssetsQY(0, "0");
outAssetsQY(1, "4");
outRes();
copy();
zip();
System.out.println("制作SDK完成");
@ -97,6 +96,7 @@ public class AutoPackageSDK {
}
});
}
private void outAssetsQY(int index, String type) {
@ -183,21 +183,22 @@ public class AutoPackageSDK {
e.printStackTrace();
}
}
private void zip(File file,OutputStream stream) throws Exception {
private void 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,stream);
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";
stream.write(exec.getBytes());
stream.flush();
Runtime.getRuntime().exec("cmd /c "+cd+" && "+exec);
Thread.sleep(100);
exec =aapt+ " a " + sdk.getAbsolutePath() + " " + path.substring(1) + "\n";
stream.write(exec.getBytes());
stream.flush();
Runtime.getRuntime().exec("cmd /c "+cd+" && "+exec);
Thread.sleep(100);
}
}
@ -206,17 +207,20 @@ public class AutoPackageSDK {
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";
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();
zip(new File("packageSDK"),stream);
stream.close();
process.destroy();
zip(new File("packageSDK"));
File copy=new File("packageSDK"+File.separator+"copy");
if(copy.exists()){
zip(copy,stream);
zip(copy);
}
stream.close();
process.destroy();
} catch (Exception e) {
e.printStackTrace();
}
@ -238,6 +242,6 @@ public class AutoPackageSDK {
public void smaliPath(String path) {
//com.tanggttaxc.langtt.mi
}
}, "5700", a==0?"com.luckyboy.mmxing":"danxian.popstar");
}, "5700", a==0?"com.luckyboy.mmxing":"com.prujwk.jdyphn");
}
}

View File

@ -212,7 +212,6 @@ public class AutoRandomAdSDK {
for (String str : packagename.split("\\.")) {
array.put(str);
}
array.put("csc");
config.put("random", array);
rootPath = path;
sdktype = "13";
@ -255,7 +254,6 @@ public class AutoRandomAdSDK {
array.put(manifest.getString(i).replace(key, newManifest.replace(".smali", "")));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
//System.out.println("-------->" + adClass.size());
for (String keys : adClass.keySet()) {
//System.out.println(keys + " " + adClass.get(keys));
@ -276,7 +274,7 @@ public class AutoRandomAdSDK {
writer.flush();
}
writer.close();
} catch (FileNotFoundException e) {
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
@ -380,7 +378,7 @@ public class AutoRandomAdSDK {
writer.write(buffer.toString());
writer.flush();
writer.close();
out();
reader.close();
// Desktop.getDesktop().open(file);
} catch (IOException e) {
@ -404,6 +402,7 @@ public class AutoRandomAdSDK {
}
}
out();
}
private void show(File file) {
@ -503,9 +502,9 @@ public class AutoRandomAdSDK {
}
for (String key : nowAdClass.keySet()) {
/* for (String key : nowAdClass.keySet()) {
System.out.println("key=" + key + " file=" + nowAdClass.get(key) + " oldFile=" + adClass.get(key));
}
}*/
for (String key : adClass.keySet()) {
File file = new File(adClass.get(key).getAbsolutePath());
String fileName = file.getName().replace(".smali", "");
@ -513,8 +512,8 @@ public class AutoRandomAdSDK {
if (!config.getBoolean("isAllPackage")) {
filePath = new File(file.getAbsolutePath().replace(file.getName(), ""));
}
System.out.println(nowAdClass.get(key)+" "+file.getName()+" "+filePath.getAbsolutePath());
// System.out.println(key + " | " + file.getAbsolutePath() + " | " + fileName + " | " + filePath.getAbsolutePath());
//System.out.println(nowAdClass.get(key)+" "+file.getName()+" "+filePath.getAbsolutePath());
//System.out.println(key + " | " + file.getAbsolutePath() + " | " + fileName + " | " + filePath.getAbsolutePath());
if (filePath.listFiles() == null) {
//System.out.println("filePath为空" + filePath.getAbsolutePath());
//System.out.println(file.getAbsolutePath());
@ -529,10 +528,10 @@ public class AutoRandomAdSDK {
continue;
}
String nName = getNewName(fs.getName());
if (fs.getName().startsWith(fileName + "$")) {
if (getNewName(fs.getName()).endsWith("[notmover]")) {
Tools.copyFileToName(fs.getAbsolutePath(), fs.getAbsolutePath(), fs
String nName = getNewName(fs.getAbsolutePath());
if (fs.getName().startsWith(fileName.split("\\$")[0] + "$")) {
if (getNewName(fs.getAbsolutePath()).endsWith("[notmover]")) {
Tools.copyFileToName(fs.getAbsolutePath(), fs.getAbsolutePath(), fs
.getName().replace(fs.getName().split("\\$")[0], nName), true);
} else {
moveFile(fs, key, fs.getName().replace(fs.getName().split("\\$")[0], nName), false);
@ -543,9 +542,9 @@ public class AutoRandomAdSDK {
if (getNewNameForSrc(file.getName()).endsWith("[notmover]")) {
nowAdFile.put(key, file.getAbsolutePath());
Tools.copyFileToName(file.getAbsolutePath(), file.getAbsolutePath().replace(file.getName(), ""),
getNewName(file.getName()) + ".smali", true);
getNewName(file.getAbsolutePath()) + ".smali", true);
} else {
moveFile(file, key, getNewName(file.getName()) + ".smali", true);
moveFile(file, key, getNewName(file.getAbsolutePath()) + ".smali", true);
}
file.delete();
@ -561,10 +560,10 @@ public class AutoRandomAdSDK {
moveFile(file, key);
} else {
if (file.getName().startsWith("TMProvider")) {
//System.out.println("移动文件:" + file.getName() + " -> " + getNewName(file.getName()) + " | " + fileName);
//System.out.println("移动文件:" + file.getName() + " -> " + getNewName(file.getAbsolutePath()) + " | " + fileName);
}
// //System.out.println("移动文件:"+path.getName()+" -> "+getNewName(path.getName()));
moveFile(file, key, getNewName(path.getName()) + ".smali", false);
moveFile(file, key, getNewName(path.getAbsolutePath()) + ".smali", false);
}
}
}
@ -597,7 +596,7 @@ public class AutoRandomAdSDK {
boolean t = Tools.copyFileToName(file.getAbsolutePath(), path,
nName, true);
file.delete();
////System.out.println("移动文件:" + file.getAbsolutePath() + "" + path + " 重命名为:" + nName + " 结果" + t);
//System.err.println("移动文件:" + file.getAbsolutePath() + "" + path + " 重命名为:" + nName + " 结果" + t);
}
private void allpackage(File file, String packge) {
@ -612,7 +611,7 @@ public class AutoRandomAdSDK {
}
}
//穿山甲视频会闪退
private void movesdk(File path, String toPath) {
for (File file : path.listFiles()) {
if (file.getName().equals("BuildConfig.smali")) {
@ -670,10 +669,16 @@ public class AutoRandomAdSDK {
}
private String getNewName(String name) {
String nName = getNewNameForSrc(name);
File file=new File(name);
String packageName=file.getAbsolutePath().replace(rootPath + File.separator + "smali" + File.separator,"").replace(file.getName(),"");
String nName = getNewNameForSrc(packageName.replace(File.separator,".")+file.getName());
if(nName.equals(packageName.replace(File.separator,".")+file.getName().replace(".smali",""))){
nName=getNewNameForSrc(file.getName());
}
if (nName.endsWith("[notmover]")) {
nName = nName.replace("[notmover]", "");
}
return nName;
}
@ -685,6 +690,7 @@ public class AutoRandomAdSDK {
String tmpName;
String wName = null;
name = name.replace(".smali", "");
if (name.contains("$")) {
tmpName = name.split("$")[0];
for (String t : name.split("$")) {

View File

@ -66,14 +66,21 @@ public class CsjTools {
}
return null;
}
private boolean isAppPackageName =false;
public void setUserPackageName(boolean isAppPackageName){
this.isAppPackageName=isAppPackageName;
}
private String getPackageName() {
try {
File apkManifest = new File(apk_Path + File.separator + "AndroidManifest.xml");
BufferedReader reader = new BufferedReader(new FileReader(apkManifest));
String tmp = reader.readLine();
reader.close();
return getXMLValue("package", tmp);
if(isAppPackageName) {
File apkManifest = new File(apk_Path + File.separator + "AndroidManifest.xml");
BufferedReader reader = new BufferedReader(new FileReader(apkManifest));
String tmp = reader.readLine();
reader.close();
return getXMLValue("package", tmp);
}else{
return "com.prujwk.jdyphn";
}
} catch (Exception e) {
e.printStackTrace();
}
@ -240,15 +247,18 @@ public class CsjTools {
_log = log;
unPackageCSJ = false;
File csjFile = new File(csjPath);
if (new File(csjFile.getName().replace(".apk", "")).exists()) {
//由于改成动态SDK所以每个应用都要单独打包
/*if (new File(csjFile.getName().replace(".apk", "")).exists()) {
System.out.println(">?>>" + new File(csjFile.getName().replace(".apk", "")).getAbsolutePath());
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();
// 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));
Tools.deleteFiles(new File("").getAbsolutePath() + File.separator + new File(apkPath).getName().replace(".apk", File.separator));
new Thread(new Runnable() {
@Override
public void run() {

View File

@ -55,9 +55,10 @@ public class Tools {
File srcFile = new File(srcFileName);
// 判断源文件是否存在
if (!srcFile.exists()) {
System.err.println("源文件不存在:"+srcFile.getAbsolutePath());
return false;
} else if (!srcFile.isFile()) {
System.err.println("源文件是目录:"+srcFile.getAbsolutePath());
return false;
}
@ -66,12 +67,9 @@ public class Tools {
// 如果目标文件所在目录不存在则创建目录
if (!destFile.exists()) {
// 目标文件所在目录不存在
boolean t=destFile.mkdirs();
if(srcFileName.equals("Activity.smali")){
System.out.println("创建文件夹:"+destFileName+" "+t);
}
if (!destFile.mkdirs()) {
// 复制文件失败创建目标文件所在目录失败
System.err.println("创建文件夹失败");
return false;
}