pull/2457/head
kunfei 2 years ago
parent b7ffeb930b
commit 830ecde32f
  1. 38
      app/src/main/java/io/legado/app/App.kt

@ -28,10 +28,9 @@ import io.legado.app.help.http.cronet.CronetLoader
import io.legado.app.model.BookCover import io.legado.app.model.BookCover
import io.legado.app.utils.defaultSharedPreferences import io.legado.app.utils.defaultSharedPreferences
import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.getPrefBoolean
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.delay
import splitties.init.appCtx
import splitties.systemservices.notificationManager import splitties.systemservices.notificationManager
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -53,7 +52,7 @@ class App : MultiDexApplication() {
registerActivityLifecycleCallbacks(LifecycleHelp) registerActivityLifecycleCallbacks(LifecycleHelp)
defaultSharedPreferences.registerOnSharedPreferenceChangeListener(AppConfig) defaultSharedPreferences.registerOnSharedPreferenceChangeListener(AppConfig)
Coroutine.async { Coroutine.async {
installGmsTlsProviderAsync(this@App).start() async { installGmsTlsProvider(appCtx) }.start()
//初始化封面 //初始化封面
BookCover.toString() BookCover.toString()
//清除过期数据 //清除过期数据
@ -99,24 +98,19 @@ class App : MultiDexApplication() {
* @param context * @param context
* @return * @return
*/ */
private suspend fun installGmsTlsProviderAsync(context: Context): Deferred<Boolean> { private suspend fun installGmsTlsProvider(context: Context) {
return coroutineScope { try {
async(IO) { val gms = context.createPackageContext(
try { "com.google.android.gms",
val gms = context.createPackageContext( CONTEXT_INCLUDE_CODE or CONTEXT_IGNORE_SECURITY
"com.google.android.gms", )
CONTEXT_INCLUDE_CODE or CONTEXT_IGNORE_SECURITY gms.classLoader
) .loadClass("com.google.android.gms.common.security.ProviderInstallerImpl")
gms.classLoader .getMethod("insertProvider", Context::class.java)
.loadClass("com.google.android.gms.common.security.ProviderInstallerImpl") .invoke(null, gms)
.getMethod("insertProvider", Context::class.java) delay(1000)
.invoke(null, gms) } catch (e: java.lang.Exception) {
true e.printStackTrace()
} catch (e: java.lang.Exception) {
e.printStackTrace()
false
}
}
} }
} }

Loading…
Cancel
Save