mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
450cba1d47
commit
cced256088
@ -182,8 +182,11 @@ dependencies {
|
||||
|
||||
//网络
|
||||
implementation('com.squareup.okhttp3:okhttp:4.9.1')
|
||||
implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
|
||||
googleImplementation 'com.google.android.gms:play-services-cronet:17.0.0'
|
||||
compileOnly('com.google.android.gms:play-services-cronet:17.0.1'){
|
||||
exclude(group: "org.chromium.net")
|
||||
}
|
||||
googleImplementation('com.google.android.gms:play-services-cronet:17.0.1')
|
||||
appImplementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
|
||||
|
||||
//Glide
|
||||
implementation('com.github.bumptech.glide:glide:4.12.0')
|
||||
|
@ -11,7 +11,6 @@ import io.legado.app.help.coroutine.Coroutine
|
||||
import io.legado.app.utils.getPrefString
|
||||
import io.legado.app.utils.putPrefString
|
||||
import org.chromium.net.CronetEngine
|
||||
import org.chromium.net.impl.ImplVersion
|
||||
import splitties.init.appCtx
|
||||
import java.io.*
|
||||
import java.math.BigInteger
|
||||
@ -24,22 +23,23 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
|
||||
//https://storage.googleapis.com/chromium-cronet/android/92.0.4515.127/Release/cronet/libs/arm64-v8a/libcronet.92.0.4515.127.so
|
||||
//https://cdn.jsdelivr.net/gh/ag2s20150909/cronet-repo@92.0.4515.127/cronet/92.0.4515.127/arm64-v8a/libcronet.92.0.4515.127.so.js
|
||||
private const val TAG = "CronetLoader"
|
||||
private val soName = "libcronet." + ImplVersion.getCronetVersion() + ".so"
|
||||
private const val soVersion = "92.0.4515.159"
|
||||
private const val soName = "libcronet.$soVersion.so"
|
||||
private val soUrl: String
|
||||
private val md5Url: String
|
||||
private val soFile: File
|
||||
private val downloadFile: File
|
||||
private var cpuAbi: String? = null
|
||||
private var md5: String? = appCtx.getPrefString("soMd5")
|
||||
private val version: String? = appCtx.getPrefString("soVersion", ImplVersion.getCronetVersion())
|
||||
private val version: String? = appCtx.getPrefString("soVersion", soVersion)
|
||||
var download = false
|
||||
|
||||
init {
|
||||
soUrl = ("https://storage.googleapis.com/chromium-cronet/android/"
|
||||
+ ImplVersion.getCronetVersion() + "/Release/cronet/libs/"
|
||||
+ soVersion + "/Release/cronet/libs/"
|
||||
+ getCpuAbi(appCtx) + "/" + soName)
|
||||
md5Url = ("https://cdn.jsdelivr.net/gh/ag2s20150909/cronet-repo@" +
|
||||
ImplVersion.getCronetVersion() + "/cronet/" + ImplVersion.getCronetVersion() + "/"
|
||||
soVersion + "/cronet/" + soVersion + "/"
|
||||
+ getCpuAbi(appCtx) + "/" + soName + ".js")
|
||||
val dir = appCtx.getDir("cronet", Context.MODE_PRIVATE)
|
||||
soFile = File(dir.toString() + "/" + getCpuAbi(appCtx), soName)
|
||||
@ -147,9 +147,9 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
|
||||
@Suppress("SameParameterValue")
|
||||
private fun getUrlMd5(url: String): String? {
|
||||
//这样在下载成功后,遇到无网条件下,只要版本未发生变化也能获取md5
|
||||
if (md5 != null && md5!!.length == 32 && version == ImplVersion.getCronetVersion()) {
|
||||
if (md5 != null && md5!!.length == 32 && version == soVersion) {
|
||||
appCtx.putPrefString("soMd5", md5)
|
||||
appCtx.putPrefString("soVersion", ImplVersion.getCronetVersion())
|
||||
appCtx.putPrefString("soVersion", soVersion)
|
||||
return md5
|
||||
}
|
||||
val inputStream: InputStream
|
||||
@ -168,7 +168,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
|
||||
//成功获取到md5后保存md5和版本
|
||||
if (tmd5.length == 32) {
|
||||
appCtx.putPrefString("soMd5", tmd5)
|
||||
appCtx.putPrefString("soVersion", ImplVersion.getCronetVersion())
|
||||
appCtx.putPrefString("soVersion", soVersion)
|
||||
}
|
||||
|
||||
return tmd5
|
||||
|
Loading…
Reference in New Issue
Block a user