parent
1187f45913
commit
fa7c35503e
|
|
@ -4,10 +4,10 @@
|
|||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2026-03-10T06:53:45.140671700Z">
|
||||
<DropdownSelection timestamp="2026-03-11T06:38:33.168759600Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=d927cac5" />
|
||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=Y5DELZR46DZTCI9D" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ android {
|
|||
applicationId = "com.img.rabbit"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 3
|
||||
versionName = "1.0.3"
|
||||
versionCode = 1
|
||||
versionName = "1.0.0"
|
||||
multiDexEnabled = true
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ class MainActivity : ComponentActivity(), LoadingCallback {
|
|||
UpdateUtils.download(
|
||||
scope = coroutineScope,
|
||||
url = url,
|
||||
filePath = FileUtils.getInstance().cacheDownLoadDir.absolutePath,
|
||||
filePath = FileUtils.instance?.cacheDownLoadDir?.absolutePath?:"",
|
||||
fileName = AppUpdate.getFileNameFromUrl(url),
|
||||
onProgress = {progress->
|
||||
progressState.floatValue = progress.toFloat()/100f
|
||||
|
|
|
|||
|
|
@ -1,337 +1,239 @@
|
|||
package com.img.rabbit.utils;
|
||||
package com.img.rabbit.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Environment
|
||||
import android.os.StatFs
|
||||
import android.util.Log
|
||||
import com.img.rabbit.provider.utils.HeadParamUtils.applicationContext
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.text.DecimalFormat
|
||||
import java.util.Objects
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.img.rabbit.provider.utils.HeadParamUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressWarnings({"ResultOfMethodCallIgnored", "CallToPrintStackTrace"})
|
||||
public class FileUtils {
|
||||
|
||||
private static FileUtils instance;
|
||||
private static String packageName = "dev";
|
||||
|
||||
// 文件缓存路径
|
||||
private String CACHE_DIR;
|
||||
|
||||
// 下载目录
|
||||
private File downloadDir;
|
||||
// 缓存目录
|
||||
private File cacheDir;
|
||||
// 图片缓存目录
|
||||
private File cacheImageDir;
|
||||
|
||||
private File cacheOriginalImageDir;
|
||||
|
||||
private File cacheEditImageDir;
|
||||
|
||||
private File cachePuzzleImageDir;
|
||||
// 下载Uni小程序WGTD文件存放目录
|
||||
private File uniWGTDir;
|
||||
|
||||
public static FileUtils getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (FileUtils.class) {
|
||||
if (instance == null) {
|
||||
instance = new FileUtils(Objects.requireNonNull(HeadParamUtils.INSTANCE.getApplicationContext()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private FileUtils(Context context) {
|
||||
CACHE_DIR = Objects.requireNonNull(context.getExternalFilesDir(null)).getAbsolutePath() + File.separator + packageName + File.separator;
|
||||
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
cacheDir = new File(CACHE_DIR, "/cache");
|
||||
} else {
|
||||
cacheDir = context.getCacheDir();
|
||||
}
|
||||
if (!cacheDir.exists())
|
||||
cacheDir.mkdirs();
|
||||
cacheImageDir = new File(cacheDir, "/image/");
|
||||
if (!cacheImageDir.exists())
|
||||
cacheImageDir.mkdirs();
|
||||
|
||||
cacheOriginalImageDir = new File(cacheDir, "/originalImage/");
|
||||
if (!cacheOriginalImageDir.exists())
|
||||
cacheOriginalImageDir.mkdirs();
|
||||
|
||||
cacheEditImageDir = new File(cacheDir, "/cacheEditImage/");
|
||||
if (!cacheEditImageDir.exists())
|
||||
cacheEditImageDir.mkdirs();
|
||||
|
||||
cachePuzzleImageDir = new File(cacheDir, "/cachePuzzleImage/");
|
||||
if (!cachePuzzleImageDir.exists())
|
||||
cachePuzzleImageDir.mkdirs();
|
||||
|
||||
downloadDir = new File(cacheDir, "/download/");
|
||||
if (!downloadDir.exists())
|
||||
downloadDir.mkdirs();
|
||||
|
||||
uniWGTDir = new File(cacheDir, "/uniApp/");
|
||||
if (!uniWGTDir.exists())
|
||||
uniWGTDir.mkdirs();
|
||||
}
|
||||
|
||||
public String getCACHE_DIR() {
|
||||
return CACHE_DIR;
|
||||
}
|
||||
/**
|
||||
* 文件工具类
|
||||
* 注意:处理路径(android/data/xxx.xxx.xxx/files/cache/)
|
||||
*/
|
||||
class FileUtils private constructor(context: Context) {
|
||||
// 文件缓存路径(android/data/xxx.xxx.xxx/files/)
|
||||
var cacheParentDir: String?
|
||||
private set
|
||||
|
||||
/**
|
||||
* 获取缓存目录
|
||||
* 缓存目录(/cache/)
|
||||
*/
|
||||
public File getCacheDir() {
|
||||
return cacheDir;
|
||||
}
|
||||
private var cacheDir: File? = null
|
||||
|
||||
/**
|
||||
* 获取下载目录
|
||||
* 下载目录(/cache/download/)
|
||||
*/
|
||||
public File getCacheDownLoadDir() {
|
||||
return downloadDir;
|
||||
}
|
||||
var cacheDownLoadDir: File
|
||||
private set
|
||||
|
||||
/**
|
||||
* 缓存图片目录(/cache/image/)
|
||||
*/
|
||||
var cacheImageDir: File
|
||||
private set
|
||||
|
||||
/**
|
||||
* 获取UniApp目录
|
||||
* 下载Uni小程序wgt文件存放目录(/cache/uniApp/)
|
||||
*/
|
||||
public File getCacheUniAppDir() {
|
||||
return uniWGTDir;
|
||||
var cacheUniAppDir: File
|
||||
private set
|
||||
|
||||
init {
|
||||
this.cacheParentDir = context.getExternalFilesDir(null)?.absolutePath + File.separator
|
||||
cacheDir = if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
|
||||
File(this.cacheParentDir, "/cache")
|
||||
} else {
|
||||
context.cacheDir
|
||||
}
|
||||
if (cacheDir?.exists() != true) cacheDir?.mkdirs()
|
||||
|
||||
cacheImageDir = File(cacheDir, "/image/")
|
||||
if (!cacheImageDir.exists()) cacheImageDir.mkdirs()
|
||||
|
||||
this.cacheDownLoadDir = File(cacheDir, "/download/")
|
||||
if (!cacheDownLoadDir.exists()) cacheDownLoadDir.mkdirs()
|
||||
|
||||
this.cacheUniAppDir = File(cacheDir, "/uniApp/")
|
||||
if (!cacheUniAppDir.exists()) cacheUniAppDir.mkdirs()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取缓存图片目录
|
||||
* 获取缓存目录(android/data/xxx.xxx.xxx/files/cache/)
|
||||
*/
|
||||
public File getCacheImageDir() {
|
||||
return cacheImageDir;
|
||||
fun getCacheDir(): File {
|
||||
cacheDir = if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
|
||||
File(this.cacheParentDir, "/cache")
|
||||
} else {
|
||||
applicationContext?.cacheDir
|
||||
}
|
||||
return cacheDir!!
|
||||
}
|
||||
|
||||
/**
|
||||
* 水印照片编辑后的路径
|
||||
* 创建一个临时图片文件((android/data/xxx.xxx.xxx/files/cache/image/系统当前时间.jpg)
|
||||
*/
|
||||
public File getCacheEditImageDir() {
|
||||
return cacheEditImageDir;
|
||||
}
|
||||
|
||||
public File getCacheOriginalImageDir() {
|
||||
return cacheOriginalImageDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼图路径
|
||||
*/
|
||||
public File getCachePuzzleImageDir() {
|
||||
return cachePuzzleImageDir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建一个临时图片文件
|
||||
*/
|
||||
public File newTempImageFile() {
|
||||
return new File(cacheImageDir, System.currentTimeMillis() + ".jpg");
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否安装SD卡
|
||||
*/
|
||||
public static boolean checkSaveLocationExists() {
|
||||
String sDCardStatus = Environment.getExternalStorageState();
|
||||
boolean status;
|
||||
status = sDCardStatus.equals(Environment.MEDIA_MOUNTED);
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定目录下文件及目录
|
||||
*/
|
||||
public static void deleteFolderFile(String filePath) {
|
||||
if (!TextUtils.isEmpty(filePath)) {
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
if (file.isDirectory()) {// 处理目录
|
||||
File[] files = file.listFiles();
|
||||
for (int i = 0; i < Objects.requireNonNull(files).length; i++) {
|
||||
deleteFolderFile(files[i].getAbsolutePath());
|
||||
}
|
||||
}
|
||||
if (!file.isDirectory()) {// 如果是文件,删除
|
||||
file.delete();
|
||||
} else {// 目录
|
||||
if (Objects.requireNonNull(file.listFiles()).length == 0) {// 目录下没有文件或者目录,删除
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("FileUtils", Objects.requireNonNull(e.getMessage()));
|
||||
}
|
||||
}
|
||||
fun newTempImageFile(): File {
|
||||
return File(cacheImageDir, System.currentTimeMillis().toString() + ".jpg")
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
public boolean deleteFile(String path) {
|
||||
boolean status;
|
||||
SecurityManager checker = new SecurityManager();
|
||||
fun deleteFile(path: String): Boolean = File(path).takeIf { it.isFile }?.delete() ?: false
|
||||
|
||||
if (!path.isEmpty()) {
|
||||
File newPath = new File(path);
|
||||
checker.checkDelete(newPath.toString());
|
||||
if (newPath.isFile()) {
|
||||
|
||||
fun fileIsExists(file: File): Boolean = file.exists()
|
||||
|
||||
/**
|
||||
* 打开图库
|
||||
*/
|
||||
fun openGallery(context: Context) {
|
||||
try {
|
||||
|
||||
newPath.delete();
|
||||
status = true;
|
||||
} catch (SecurityException se) {
|
||||
Log.e("FileUtils", Objects.requireNonNull(se.getMessage()));
|
||||
status = false;
|
||||
val intent = Intent(Intent.ACTION_MAIN)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
intent.addCategory(Intent.CATEGORY_APP_GALLERY)
|
||||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
} else
|
||||
status = false;
|
||||
} else
|
||||
status = false;
|
||||
return status;
|
||||
}
|
||||
|
||||
companion object {
|
||||
var instance: FileUtils? = null
|
||||
get() {
|
||||
if (field == null) {
|
||||
synchronized(FileUtils::class.java) {
|
||||
if (field == null) {
|
||||
field = applicationContext?.let { FileUtils(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
return field
|
||||
}
|
||||
private set
|
||||
|
||||
/**
|
||||
* 判断是否安装SD卡
|
||||
*/
|
||||
fun checkSaveLocationExists(): Boolean {
|
||||
val sDCardStatus = Environment.getExternalStorageState()
|
||||
val status = sDCardStatus == Environment.MEDIA_MOUNTED
|
||||
return status
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定目录下文件及目录
|
||||
*/
|
||||
fun deleteFolderFile(filePath: String?) {
|
||||
filePath?.let { File(filePath).deleteRecursively() }
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取目录文件大小
|
||||
*/
|
||||
public static long getDirSize(File dir) {
|
||||
fun getDirSize(dir: File?): Long {
|
||||
if (dir == null) {
|
||||
return 0;
|
||||
return 0
|
||||
}
|
||||
if (!dir.isDirectory()) {
|
||||
return 0;
|
||||
return 0
|
||||
}
|
||||
long dirSize = 0;
|
||||
File[] files = dir.listFiles();
|
||||
for (File file : Objects.requireNonNull(files)) {
|
||||
var dirSize: Long = 0
|
||||
val files = dir.listFiles()
|
||||
for (file in Objects.requireNonNull(files)) {
|
||||
if (file.isFile()) {
|
||||
dirSize += file.length();
|
||||
dirSize += file.length()
|
||||
} else if (file.isDirectory()) {
|
||||
dirSize += file.length();
|
||||
dirSize += getDirSize(file); // 递归调用继续统计
|
||||
dirSize += file.length()
|
||||
dirSize += getDirSize(file) // 递归调用继续统计
|
||||
}
|
||||
}
|
||||
return dirSize;
|
||||
return dirSize
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定文件大小
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public static long getFileSize(File file) throws Exception {
|
||||
long size = 0;
|
||||
@Throws(Exception::class)
|
||||
fun getFileSize(file: File): Long {
|
||||
var size: Long = 0
|
||||
if (file.exists()) {
|
||||
FileInputStream fis = null;
|
||||
fis = new FileInputStream(file);
|
||||
size = fis.available();
|
||||
var fis: FileInputStream? = null
|
||||
fis = FileInputStream(file)
|
||||
size = fis.available().toLong()
|
||||
} else {
|
||||
|
||||
Log.e("获取文件大小", "文件不存在!");
|
||||
Log.e("获取文件大小", "文件不存在!")
|
||||
}
|
||||
return size;
|
||||
return size
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定文件夹
|
||||
*/
|
||||
public static long getFileSizes(File f) throws Exception {
|
||||
long size = 0;
|
||||
File[] flist = f.listFiles();
|
||||
for (int i = 0; i < Objects.requireNonNull(flist).length; i++) {
|
||||
if (flist[i].isDirectory()) {
|
||||
size = size + getFileSizes(flist[i]);
|
||||
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
|
||||
@Throws(Exception::class)
|
||||
fun getFileSizes(f: File): Long {
|
||||
var size: Long = 0
|
||||
val fileList = f.listFiles()
|
||||
for (i in Objects.requireNonNull(fileList).indices) {
|
||||
size += if (fileList[i].isDirectory()) {
|
||||
getFileSizes(fileList[i])
|
||||
} else {
|
||||
size = size + getFileSize(flist[i]);
|
||||
getFileSize(fileList[i])
|
||||
}
|
||||
}
|
||||
return size;
|
||||
return size
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换文件大小
|
||||
*/
|
||||
public static String toFileSize(long fileS) {
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
String fileSizeString;
|
||||
String wrongSize = "0M";
|
||||
if (fileS == 0) {
|
||||
return wrongSize;
|
||||
fun toFileSize(fileS: Long): String {
|
||||
val df = DecimalFormat("#.00")
|
||||
val fileSizeString: String
|
||||
val wrongSize = "0M"
|
||||
if (fileS == 0L) {
|
||||
return wrongSize
|
||||
}
|
||||
if (fileS < 1024) {
|
||||
fileSizeString = df.format((double) fileS) + "B";
|
||||
fileSizeString = df.format(fileS.toDouble()) + "B"
|
||||
} else if (fileS < 1048576) {
|
||||
fileSizeString = df.format((double) fileS / 1024) + "K";
|
||||
fileSizeString = df.format(fileS.toDouble() / 1024) + "K"
|
||||
} else if (fileS < 1073741824) {
|
||||
fileSizeString = df.format((double) fileS / 1048576) + "M";
|
||||
fileSizeString = df.format(fileS.toDouble() / 1048576) + "M"
|
||||
} else {
|
||||
fileSizeString = df.format((double) fileS / 1073741824) + "G";
|
||||
fileSizeString = df.format(fileS.toDouble() / 1073741824) + "G"
|
||||
}
|
||||
return fileSizeString;
|
||||
}
|
||||
|
||||
//判断文件是否存在
|
||||
public boolean fileIsExists(File strFile) {
|
||||
try {
|
||||
if (!strFile.exists()) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//判断文件是否存在
|
||||
public boolean fileIsExists(String strFile) {
|
||||
try {
|
||||
File f = new File(strFile);
|
||||
if (!f.exists()) {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return fileSizeString
|
||||
}
|
||||
|
||||
val externalStorageSpace: Long
|
||||
//外部存储空间
|
||||
public static long getExternalStorageSpace() {
|
||||
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
StatFs externalStatFs = new StatFs(Environment.getExternalStorageDirectory().getAbsolutePath());
|
||||
long externalBlockSize = externalStatFs.getBlockSizeLong();
|
||||
long externalTotalSize = externalStatFs.getBlockCountLong() * externalBlockSize;
|
||||
long externalAvailableSize = externalStatFs.getAvailableBlocksLong() * externalBlockSize;
|
||||
Log.d("FileUtils", "当前外部空间总大小----" + externalTotalSize);
|
||||
Log.d("FileUtils", "当前外部空间可用大小----" + externalAvailableSize);
|
||||
return externalAvailableSize;
|
||||
get() {
|
||||
if (Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED) {
|
||||
val externalStatFs = StatFs(
|
||||
Environment.getExternalStorageDirectory().absolutePath
|
||||
)
|
||||
val externalBlockSize = externalStatFs.blockSizeLong
|
||||
val externalTotalSize =
|
||||
externalStatFs.blockCountLong * externalBlockSize
|
||||
val externalAvailableSize =
|
||||
externalStatFs.availableBlocksLong * externalBlockSize
|
||||
Log.d("FileUtils", "当前外部空间总大小----$externalTotalSize")
|
||||
Log.d(
|
||||
"FileUtils",
|
||||
"当前外部空间可用大小----$externalAvailableSize"
|
||||
)
|
||||
return externalAvailableSize
|
||||
} else {
|
||||
return 0;
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开图库
|
||||
*/
|
||||
public void openGallery(Context context) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addCategory(Intent.CATEGORY_APP_GALLERY);
|
||||
context.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,13 +34,15 @@ import okhttp3.Request
|
|||
import java.io.File
|
||||
import kotlin.jvm.java
|
||||
|
||||
|
||||
/**
|
||||
* UniApp工具类
|
||||
* 小程序运行路径:/data/user/0/com.img.rabbit/files/apps/(一般/data/data/com.img.rabbit/files/apps/)
|
||||
*/
|
||||
object UniAppUtils {
|
||||
private const val TAG = "UniAppUtils"
|
||||
/**
|
||||
* 所有运行的UniMp小程序实体
|
||||
*/
|
||||
// val uniMpPair = mutableMapOf<String?, IUniMP?>()
|
||||
private val _uniMpFlow = MutableStateFlow<Map<String?, IUniMP?>>(emptyMap())
|
||||
val uniMpFlow = _uniMpFlow.asStateFlow()
|
||||
fun updateUniMp(id: String?, mp: IUniMP?) {
|
||||
|
|
@ -60,6 +62,11 @@ object UniAppUtils {
|
|||
return String.format("%s.wgt", uniMpId)
|
||||
//return String.format("%s.zip", uniMpId)
|
||||
}
|
||||
|
||||
private fun getWgtFile(uniMpId: String): File{
|
||||
val wgtName = getWgtName(uniMpId)
|
||||
return File(FileUtils.instance?.cacheUniAppDir?.absolutePath?:"", wgtName)
|
||||
}
|
||||
/**
|
||||
*获取当前前台运行的UniMp小程序实体
|
||||
*/
|
||||
|
|
@ -85,16 +92,14 @@ object UniAppUtils {
|
|||
* 是否需要下载(强制更新或者不存在wgt文件)
|
||||
*/
|
||||
fun isDownloadUniMp(uniVersion: UniVersionEntity): Boolean{
|
||||
val wgtName = getWgtName(uniVersion.unimp_id)
|
||||
val wgtFile = File(FileUtils.getInstance().cacheUniAppDir.absolutePath, wgtName)
|
||||
return isUpdateForce(uniVersion) || !(FileUtils.getInstance().fileIsExists(wgtFile) && FileUtils.getFileSize(wgtFile) > 0)
|
||||
val wgtFile = getWgtFile(uniVersion.unimp_id)
|
||||
return isUpdateForce(uniVersion) || !(FileUtils.instance?.fileIsExists(wgtFile) == true && FileUtils.getFileSize(wgtFile) > 0)
|
||||
}
|
||||
|
||||
fun wgtIsExists(uniMpId: String): Boolean{
|
||||
val wgtName = getWgtName(uniMpId)
|
||||
val wgtFile = File(FileUtils.getInstance().cacheUniAppDir.absolutePath, wgtName)
|
||||
val wgtFile = getWgtFile(uniMpId)
|
||||
//判断wgt是否下载
|
||||
return FileUtils.getInstance().fileIsExists(wgtFile) && FileUtils.getFileSize(wgtFile) > 0
|
||||
return FileUtils.instance?.fileIsExists(wgtFile) == true && FileUtils.getFileSize(wgtFile) > 0
|
||||
}
|
||||
|
||||
private fun isRelease(uniMpId: String): Boolean{
|
||||
|
|
@ -215,8 +220,7 @@ object UniAppUtils {
|
|||
val appBasePath = DCUniMPSDK.getInstance().getAppBasePath(applicationContext)
|
||||
val deleteSuccess = File(appBasePath, uniMpId).deleteRecursively()
|
||||
if(deleteSuccess){
|
||||
val wgtName = getWgtName(uniMpId)
|
||||
val wgtFile = File(FileUtils.getInstance().cacheUniAppDir.absolutePath, wgtName)
|
||||
val wgtFile = getWgtFile(uniMpId)
|
||||
val uniMPReleaseConfiguration = UniMPReleaseConfiguration().apply {
|
||||
wgtPath = wgtFile.path
|
||||
password = PreferenceUtil.getUserConfig()?.config?.wgtPassword//"6462"////没有密码可以不写
|
||||
|
|
@ -251,9 +255,7 @@ object UniAppUtils {
|
|||
* 下载wgt文件
|
||||
*/
|
||||
fun downloadWGT(context: Context,scope: CoroutineScope, uniVersion: UniVersionEntity, reportViewModel: ReportViewModel = ReportViewModel(), onProgress:(state: UniMpUpdate, filePath: String?, progress: Float?) -> Unit) {
|
||||
val uniMpId = uniVersion.unimp_id
|
||||
val wgtName = getWgtName(uniMpId)
|
||||
val wgtFile = File(FileUtils.getInstance().cacheUniAppDir.absolutePath, wgtName)
|
||||
val wgtFile = getWgtFile(uniVersion.unimp_id)
|
||||
onProgress(UniMpUpdate.DOWNLOAD_START, wgtFile.path, 0f)
|
||||
|
||||
downloadUniMp(scope, uniVersion){uniState, filePath, progress ->
|
||||
|
|
@ -304,7 +306,7 @@ object UniAppUtils {
|
|||
|
||||
val uniMpId = uniVersion.unimp_id
|
||||
val wgtName = getWgtName(uniMpId)
|
||||
val path = FileUtils.getInstance().cacheUniAppDir.absolutePath
|
||||
val path = FileUtils.instance?.cacheUniAppDir?.absolutePath?:""
|
||||
//先删除旧文件
|
||||
val oldFile = File(path, wgtName)
|
||||
if(oldFile.exists()){
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ object UpdateUtils {
|
|||
|
||||
fun install(context: Context, apkFilePath: String) {
|
||||
try {
|
||||
val apkFile = File(FileUtils.getInstance().cacheDownLoadDir, AppUpdate.getFileNameFromUrl(apkFilePath))
|
||||
val apkFile = File(FileUtils.instance?.cacheDownLoadDir, AppUpdate.getFileNameFromUrl(apkFilePath))
|
||||
if (!apkFile.exists()) {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public final class ChannelReader {
|
|||
/**
|
||||
* 读取注入的内容
|
||||
*/
|
||||
@SuppressWarnings("CallToPrintStackTrace")
|
||||
public static String get(@NonNull Context context) {
|
||||
String apkPath = getApkPath(context);
|
||||
String raw = TextUtils.isEmpty(apkPath) ? null : getRaw(new File(apkPath));
|
||||
|
|
|
|||
Loading…
Reference in New Issue