version:2.0.1.9
update:2020.08.1 fix:修复强制安装应用重复下载,禁止升级应用卸载后无法安装 add:增加测试图标,多版本打包
This commit is contained in:
@@ -42,6 +42,7 @@ import android.widget.Toast;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.blankj.utilcode.util.EncryptUtils;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.blankj.utilcode.util.PathUtils;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
@@ -53,6 +54,7 @@ import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.MyApplication;
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
@@ -937,6 +939,12 @@ public class Utils {
|
||||
if (ApkUtils.isAvailable(context, s)) {
|
||||
allList.remove(s);
|
||||
//去掉已经安装的
|
||||
} else {
|
||||
if (allList.indexOf(s) == -1) {
|
||||
allList.add(s);
|
||||
}
|
||||
//没有安装就加入进去
|
||||
//没有加入会导致安装后卸载不能再安装的情况
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -978,21 +986,44 @@ public class Utils {
|
||||
return url.substring(position + 1);
|
||||
}
|
||||
|
||||
private String getMD5fromFileName(String fileName) {
|
||||
private static String getMD5fromFileName(String fileName) {
|
||||
int position = fileName.lastIndexOf("/");
|
||||
return fileName.substring(position + 9);
|
||||
|
||||
return fileName.substring(position + 9, fileName.length() - 4);
|
||||
|
||||
}
|
||||
|
||||
public static void ariaDownload(Context context, String url, JSONObject jsonObject) {
|
||||
String fileName = getFileNamefromURL(url);
|
||||
Aria.download(context)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName, true)
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
String urlMD5 = jsonObject.getString("MD5");
|
||||
Log.e("ariaDownload", "urlMD5=" + urlMD5);
|
||||
File file = new File(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName);
|
||||
if (file.exists() && !file.isDirectory()) {
|
||||
String filenameMD5 = getMD5fromFileName(url);
|
||||
|
||||
String fileMD5 = FileUtils.getFileMD5ToString(file);
|
||||
Log.e("ariaDownload", "filenameMD5=" + filenameMD5);
|
||||
Log.e("ariaDownload", "fileMD5=" + fileMD5);
|
||||
//后端还没有完成json字段的MD5,暂时用文件名获取
|
||||
if (fileMD5.equalsIgnoreCase(filenameMD5)) {
|
||||
ApkUtils.installApp(context, file.getAbsolutePath());
|
||||
} else {
|
||||
Aria.download(context)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName, true)
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
// SaveListUtils.addDownLoadList(app_package);
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
Aria.download(context)
|
||||
.load(url) //读取下载地址
|
||||
.setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + fileName, true)
|
||||
.setExtendField(jsonObject.toJSONString())
|
||||
.create(); //启动下载}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user