Merge remote-tracking branch 'origin/master'

pull/2457/head
kunfei 2 years ago
commit fdf71cc48e
  1. 28
      app/src/main/java/io/legado/app/App.kt
  2. 2
      app/src/main/java/io/legado/app/ui/book/manage/ComposeView.kt

@ -49,6 +49,7 @@ class App : MultiDexApplication() {
registerActivityLifecycleCallbacks(LifecycleHelp) registerActivityLifecycleCallbacks(LifecycleHelp)
defaultSharedPreferences.registerOnSharedPreferenceChangeListener(AppConfig) defaultSharedPreferences.registerOnSharedPreferenceChangeListener(AppConfig)
Coroutine.async { Coroutine.async {
installGmsTlsProvider(this@App)
//初始化封面 //初始化封面
BookCover.toString() BookCover.toString()
//清除过期数据 //清除过期数据
@ -84,6 +85,33 @@ class App : MultiDexApplication() {
oldConfig = Configuration(newConfig) oldConfig = Configuration(newConfig)
} }
/**
* 尝试在安装了GMS的设备上(GMS或者MicroG)使用GMS内置的Conscrypt
* 作为首选JCE提供程序而使Okhttp在低版本Android上
* 能够启用TLSv1.3
* https://f-droid.org/zh_Hans/2020/05/29/android-updates-and-tls-connections.html
* https://developer.android.google.cn/reference/javax/net/ssl/SSLSocket
*
* @param context
* @return
*/
private suspend fun installGmsTlsProvider(context: Context): Boolean {
return try {
val gms = context.createPackageContext(
"com.google.android.gms",
CONTEXT_INCLUDE_CODE or CONTEXT_IGNORE_SECURITY
)
gms.classLoader
.loadClass("com.google.android.gms.common.security.ProviderInstallerImpl")
.getMethod("insertProvider", Context::class.java)
.invoke(null, gms)
true
} catch (e: java.lang.Exception) {
e.printStackTrace()
false
}
}
/** /**
* 创建通知ID * 创建通知ID
*/ */

@ -26,7 +26,7 @@ fun BatchChangeSourceDialog(
cancel.invoke() cancel.invoke()
state.value = false state.value = false
}, content = { }, content = {
Text(text = "取消") Text(text = appCtx.getString(R.string.cancel))
}) })
}, },
title = { title = {

Loading…
Cancel
Save