pull/1486/head
gedoor 3 years ago
parent b3c1277567
commit 45e664d4d0
  1. 6
      app/build.gradle
  2. 2
      app/src/main/java/io/legado/app/help/http/HttpHelper.kt
  3. 5
      app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt
  4. 6
      app/src/main/java/io/legado/app/help/http/cronet/CronetLoader.kt

@ -189,11 +189,7 @@ dependencies {
//
implementation('com.squareup.okhttp3:okhttp:4.9.2')
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']))
implementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
//Glide
implementation('com.github.bumptech.glide:glide:4.12.0')

@ -43,7 +43,7 @@ val okHttpClient: OkHttpClient by lazy {
.build()
chain.proceed(request)
})
if (AppConfig.isCronet && CronetLoader.install() && !AppConfig.isGooglePlay) {
if (!AppConfig.isGooglePlay && AppConfig.isCronet && CronetLoader.install()) {
builder.addInterceptor(CronetInterceptor(null))
}
builder.build()

@ -1,6 +1,5 @@
package io.legado.app.help.http.cronet
import com.google.android.gms.net.CronetProviderInstaller
import io.legado.app.constant.AppLog
import io.legado.app.help.AppConfig
import okhttp3.Headers
@ -20,9 +19,7 @@ import java.util.concurrent.Executors
val executor: ExecutorService by lazy { Executors.newCachedThreadPool() }
val cronetEngine: ExperimentalCronetEngine? by lazy {
if (AppConfig.isGooglePlay) {
CronetProviderInstaller.installProvider(appCtx)
} else {
if (!AppConfig.isGooglePlay) {
CronetLoader.preDownload()
}
val builder = ExperimentalCronetEngine.Builder(appCtx).apply {

@ -5,7 +5,6 @@ import android.content.Context
import android.content.pm.ApplicationInfo
import android.os.Build
import android.text.TextUtils
import com.google.android.gms.net.CronetProviderInstaller
import io.legado.app.BuildConfig
import io.legado.app.help.AppConfig
import io.legado.app.help.coroutine.Coroutine
@ -57,9 +56,7 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
return true
}
if (AppConfig.isGooglePlay) {
//检查GMS的Cronet服务是否安装
cacheInstall = CronetProviderInstaller.isInstalled()
return cacheInstall
return false
}
if (md5.length != 32 || !soFile.exists() || md5 != getFileMD5(soFile)) {
cacheInstall = false
@ -75,7 +72,6 @@ object CronetLoader : CronetEngine.Builder.LibraryLoader() {
*/
fun preDownload() {
if (AppConfig.isGooglePlay) {
CronetProviderInstaller.installProvider(appCtx)
return
}
Coroutine.async {

Loading…
Cancel
Save