更新layer版本:2.5.6→2.5.7

This commit is contained in:
yutou
2020-12-07 11:32:40 +08:00
parent 7ec461ff29
commit e5a7f5a878
29 changed files with 37 additions and 169 deletions

View File

@@ -1,132 +0,0 @@
package com.yutou.tools.home.nas;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.interfaces.DownloadInterface;
import com.yutou.tools.utils.OSSTools;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
import redis.clients.jedis.Jedis;
import java.io.*;
import java.util.*;
public class BotTools {
private static Thread runThread = null;
protected static String download(JSONObject json) {
String url = json.getString("url");
if (url.endsWith(".apk")) {
Tools.download(url, new DownloadInterface() {
@Override
public void onDownload(String file) {
super.onDownload(file);
if (file.endsWith(".apk")) {
csjAssets(file, json.getString("package"), json.getString("version"));
}
}
@Override
public void onError(Exception e) {
super.onError(e);
}
});
}
return "ok";
}
private static Map<Long, JSONObject> map = new HashMap<>();
private static boolean isRun = false;
static void csjAssets(String path, String packagename, String version) {
System.out.println("data=" + path + " packagename=" + packagename + " version=" + version);
File file = new File(path);
JSONObject json = new JSONObject();
json.put("file", file);
json.put("version", version);
json.put("packagename", packagename);
map.put(System.currentTimeMillis(), json);
if (isRun) {
RedisTools.set(1, "msg_" + System.currentTimeMillis(), file.getName() + "\n已加入到队列");
return;
}
if (runThread == null) {
runThread = new MyThread();
}
}
private static void csj(JSONObject jsonObject) {
long startTime = System.currentTimeMillis();
isRun = true;
File apk = new File(jsonObject.getString("file"));
RedisTools.set(1, "msg_" + System.currentTimeMillis(), "开始处理:" + apk.getName());
try {
File csc = new File("out" + File.separator + apk.getName().replace(".", "") + File.separator + "csc");
csc.mkdirs();
if (csc.exists()) {
csc.delete();
}
System.out.println(">>" + csc.getAbsolutePath());
Process process = Runtime.getRuntime().exec(String.format("java -jar android_sdk_tools.jar -package=%s -version=%s -apk=%s -csj=%s -csc=%s"
, jsonObject.getString("packagename"), jsonObject.getString("version"), apk.getAbsoluteFile()
, new File("csj" + File.separator + "demo.apk"), csc.getAbsoluteFile()));
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String tmp;
while ((tmp = reader.readLine()) != null) {
System.out.println(tmp);
}
reader.close();
process.destroy();
if (csc.exists())
OSSTools.uploadFile(csc, new DownloadInterface() {
String path;
@Override
public void onDownload(String file) {
super.onDownload(file);
long nowTime = System.currentTimeMillis() - startTime;
RedisTools.set(1, "msg_" + System.currentTimeMillis(), apk.getName()
+ "已处理完成,下载地址" +
"\n" + file +
"\n耗时" + nowTime + "ms");
path = file.replace("https://yutou-oss-test.oss-cn-hangzhou.aliyuncs.com/", "");
isRun = false;
System.gc();
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
private static class MyThread extends Thread {
public MyThread() {
System.out.println("启动线程");
start();
}
@Override
public void run() {
super.run();
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (map.size() > 0) {
isRun = true;
for (Long key : map.keySet()) {
JSONObject json = map.get(key);
map.remove(key);
csj(json);
}
isRun = false;
}
}
}
}
}

View File

@@ -1,4 +1,4 @@
package com.yutou.tools.web;
package com.yutou.tools.home.nas;
import com.yutou.tools.nas.UpdateIp;
import com.yutou.tools.utils.RedisTools;