使用Gradle下载Cronet,自动计算md5

pull/1276/head
ag2s20150909 3 years ago
parent 79978db56c
commit ecdfc0941e
  1. 9
      app/src/main/java/io/legado/app/help/http/cronet/CronetHelper.kt
  2. 2
      app/src/main/java/io/legado/app/help/http/cronet/CronetInterceptor.kt

@ -27,19 +27,16 @@ val cronetEngine: ExperimentalCronetEngine by lazy {
val builder = ExperimentalCronetEngine.Builder(appCtx).apply { val builder = ExperimentalCronetEngine.Builder(appCtx).apply {
if (!AppConfig.isGooglePlay) { if (!AppConfig.isGooglePlay&&CronetLoader.install()) {
setLibraryLoader(CronetLoader)//设置自定义so库加载 setLibraryLoader(CronetLoader)//设置自定义so库加载
} }
setStoragePath(appCtx.externalCacheDir?.absolutePath)//设置缓存路径 setStoragePath(appCtx.externalCacheDir?.absolutePath)//设置缓存路径
enableHttpCache(HTTP_CACHE_DISK, (1024 * 1024 * 50))//设置缓存模式 enableHttpCache(HTTP_CACHE_DISK, (1024 * 1024 * 50).toLong())//设置缓存模式
enableQuic(true)//设置支持http/3 enableQuic(true)//设置支持http/3
enableHttp2(true) //设置支持http/2 enableHttp2(true) //设置支持http/2
enablePublicKeyPinningBypassForLocalTrustAnchors(true) enablePublicKeyPinningBypassForLocalTrustAnchors(true)
//enableNetworkQualityEstimator(true)
//Brotli压缩 enableBrotli(true)//Brotli压缩
enableBrotli(true)
//setExperimentalOptions("{\"quic_version\": \"h3-29\"}")
} }
val engine = builder.build() val engine = builder.build()
Log.d("Cronet", "Cronet Version:" + engine.versionString) Log.d("Cronet", "Cronet Version:" + engine.versionString)

@ -45,7 +45,7 @@ class CronetInterceptor(private val cookieJar: CookieJar?) : Interceptor {
val callback = CronetUrlRequestCallback(request, call) val callback = CronetUrlRequestCallback(request, call)
val urlRequest = buildRequest(request, callback) val urlRequest = buildRequest(request, callback)
urlRequest.start() urlRequest.start()
return callback.waitForDone(urlRequest) return callback.waitForDone(urlRequest)
} }
private fun getCookie(url: HttpUrl): String { private fun getCookie(url: HttpUrl): String {

Loading…
Cancel
Save