From 45e664d4d0a2d6f09a0492b3d5cd9fbd307634fd Mon Sep 17 00:00:00 2001 From: gedoor Date: Sun, 19 Dec 2021 21:13:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 6 +----- app/src/main/java/io/legado/app/help/http/HttpHelper.kt | 2 +- .../java/io/legado/app/help/http/cronet/CronetHelper.kt | 5 +---- .../java/io/legado/app/help/http/cronet/CronetLoader.kt | 6 +----- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 902baadc6..5f525d816 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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') diff --git a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt index ffdb66f9b..7b7d91d08 100644 --- a/app/src/main/java/io/legado/app/help/http/HttpHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/HttpHelper.kt @@ -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() diff --git a/app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt b/app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt index 7c1689306..44d82438e 100644 --- a/app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt +++ b/app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt @@ -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 { diff --git a/app/src/main/java/io/legado/app/help/http/cronet/CronetLoader.kt b/app/src/main/java/io/legado/app/help/http/cronet/CronetLoader.kt index e077166e0..abcecfda2 100644 --- a/app/src/main/java/io/legado/app/help/http/cronet/CronetLoader.kt +++ b/app/src/main/java/io/legado/app/help/http/cronet/CronetLoader.kt @@ -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 {