diff --git a/file-plugin/src/main/kotlin/com/imf/plugin/so/HandleSoFileInfo.kt b/file-plugin/src/main/kotlin/com/imf/plugin/so/HandleSoFileInfo.kt index 57e591d..46dd8a3 100644 --- a/file-plugin/src/main/kotlin/com/imf/plugin/so/HandleSoFileInfo.kt +++ b/file-plugin/src/main/kotlin/com/imf/plugin/so/HandleSoFileInfo.kt @@ -1,22 +1,14 @@ package com.imf.plugin.so -class HandleSoFileInfo(val saveCompressToAssets: Boolean, val md5: String?, val dependencies: List?, val compressName: String?) { +import com.google.gson.Gson + +data class HandleSoFileInfo( + var saveCompressToAssets: Boolean, + var md5: String?, + var dependencies: List? = null, + var compressName: String? = null, + var url: String? = null +) { //用于生成json - override fun toString(): String { - val s = StringBuilder("{\"saveCompressToAssets\":${saveCompressToAssets}") - if (!dependencies.isNullOrEmpty()) { - s.append(",\"dependencies\":[\"${dependencies[0]}\"") - for (index in 1 until dependencies.size) { - s.append(",\"${dependencies[index]}\"") - } - s.append(']') - } - md5?.let { - s.append(",\"md5\":\"${md5}\"") - } - compressName?.let { - s.append(",\"compressName\":\"${compressName}\"") - } - return s.append('}').toString() - } + override fun toString(): String = Gson().toJson(this) } \ No newline at end of file diff --git a/file-plugin/src/main/kotlin/com/imf/plugin/so/SoFileExtensions.kt b/file-plugin/src/main/kotlin/com/imf/plugin/so/SoFileExtensions.kt index 0d78e05..31a178b 100644 --- a/file-plugin/src/main/kotlin/com/imf/plugin/so/SoFileExtensions.kt +++ b/file-plugin/src/main/kotlin/com/imf/plugin/so/SoFileExtensions.kt @@ -33,7 +33,7 @@ open class SoFileExtensions { */ var backupDeleteSo: Boolean = true - var onDeleteSo: ((File, String) -> Unit)? = null + var onDeleteSo: ((File, String) -> String)? = null /** * 压缩放在 assets 下的 so 库 diff --git a/file-plugin/src/main/kotlin/com/imf/plugin/so/SoHandle.kt b/file-plugin/src/main/kotlin/com/imf/plugin/so/SoHandle.kt index b9e3de7..d2f944a 100644 --- a/file-plugin/src/main/kotlin/com/imf/plugin/so/SoHandle.kt +++ b/file-plugin/src/main/kotlin/com/imf/plugin/so/SoHandle.kt @@ -138,7 +138,9 @@ class SoHandle( FileUtils.copyFile(it, this) } } else it - extension.onDeleteSo?.invoke(soFile, md5) + extension.onDeleteSo?.invoke(soFile, md5)?.let { url -> + recordMap[unmapLibraryName(name)]?.url = url + } it.delete() } } diff --git a/load-assets-7z/build.gradle b/load-assets-7z/build.gradle index 33ec979..54ecce7 100644 --- a/load-assets-7z/build.gradle +++ b/load-assets-7z/build.gradle @@ -19,7 +19,7 @@ android { dependencies { implementation project(":load-hook") implementation project(":android-un7z") - implementation("androidx.annotation:annotation:1.6.0") + implementation("com.android.tools:annotations:30.4.2") } task sourcesJar(type: Jar) { diff --git a/load-assets-7z/src/main/java/com/imf/so/assets/load/NeedDownloadSoListener.java b/load-assets-7z/src/main/java/com/imf/so/assets/load/NeedDownloadSoListener.java index e98604e..0e1af50 100644 --- a/load-assets-7z/src/main/java/com/imf/so/assets/load/NeedDownloadSoListener.java +++ b/load-assets-7z/src/main/java/com/imf/so/assets/load/NeedDownloadSoListener.java @@ -1,7 +1,6 @@ package com.imf.so.assets.load; -import androidx.annotation.Nullable; - +import com.android.annotations.Nullable; import com.imf.so.assets.load.bean.SoFileInfo; import java.io.File; diff --git a/load-assets-7z/src/main/java/com/imf/so/assets/load/bean/SoFileInfo.java b/load-assets-7z/src/main/java/com/imf/so/assets/load/bean/SoFileInfo.java index cb0a026..5576d4f 100644 --- a/load-assets-7z/src/main/java/com/imf/so/assets/load/bean/SoFileInfo.java +++ b/load-assets-7z/src/main/java/com/imf/so/assets/load/bean/SoFileInfo.java @@ -28,14 +28,16 @@ public class SoFileInfo { public String md5; public String compressName; public List dependencies; + public String url; - private SoFileInfo(String libName, String abi, boolean saveCompressToAssets, String md5, String compressName, List dependencies) { + private SoFileInfo(String libName, String abi, boolean saveCompressToAssets, String md5, String compressName, List dependencies, String url) { this.libName = libName; this.abi = abi; this.saveCompressToAssets = saveCompressToAssets; this.md5 = md5; this.compressName = compressName; this.dependencies = dependencies; + this.url = url; } @@ -69,7 +71,8 @@ public static SoFileInfo fromJson(JSONObject json, String abi, String libName) { } } } - return new SoFileInfo(libName, abi, saveCompressToAssets, md5, compressName, dependencies); + String aUrl = targetSoInfo.optString("url"); + return new SoFileInfo(libName, abi, saveCompressToAssets, md5, compressName, dependencies, aUrl); } return null; } diff --git a/so-file-config.gradle b/so-file-config.gradle index 78da2c0..f14ebd0 100644 --- a/so-file-config.gradle +++ b/so-file-config.gradle @@ -39,6 +39,12 @@ SoFileConfig { 'libsource.so', 'libblur-lib.so', ] + /** + * 移除 so 时回调,这里可以做上传云端的逻辑 + */ + onDeleteSo = { File file, String md5 -> + return file.absolutePath.replace(".so", "_${md5}.so") + } // 设置要压缩的库 注意 libun7zip.so 为 7z 解压库不可压缩 compressSo2AssetsLibs = [