Add Android 7 broken SSL workaround

This commit is contained in:
NerdNumber9 2019-08-07 15:47:43 -04:00
parent 333dfbc642
commit c4c988f7a4
2 changed files with 30 additions and 1 deletions

View File

@ -176,6 +176,9 @@ dependencies {
// DO NOT UPGRADE TO 17.0, IT REQUIRES ANDROIDX
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
// [EXH] Android 7 SSL Workaround
implementation 'com.google.android.gms:play-services-safetynet:15.0.1'
// Changelog
implementation 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0'

View File

@ -4,6 +4,7 @@ import android.app.Application
import android.content.Context
import android.content.res.Configuration
import android.graphics.Color
import android.os.Build
import android.os.Environment
import android.support.multidex.MultiDex
import com.elvishew.xlog.LogConfiguration
@ -17,6 +18,9 @@ import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
import com.evernote.android.job.JobManager
import com.github.ajalt.reprint.core.Reprint
import com.google.android.gms.common.GooglePlayServicesNotAvailableException
import com.google.android.gms.common.GooglePlayServicesRepairableException
import com.google.android.gms.security.ProviderInstaller
import com.kizitonwose.time.days
import com.ms_square.debugoverlay.DebugOverlay
import com.ms_square.debugoverlay.modules.FpsModule
@ -38,15 +42,18 @@ import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.InjektScope
import uy.kohesive.injekt.registry.default.DefaultRegistrar
import java.io.File
import java.security.NoSuchAlgorithmException
import javax.net.ssl.SSLContext
import kotlin.concurrent.thread
open class App : Application() {
override fun onCreate() {
super.onCreate()
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
setupExhLogging() // EXH logging
workaroundAndroid7BrokenSSL()
Injekt = InjektScope(DefaultRegistrar())
Injekt.importModule(AppModule(this))
@ -71,6 +78,25 @@ open class App : Application() {
LocaleHelper.updateConfiguration(this, newConfig, true)
}
private fun workaroundAndroid7BrokenSSL() {
if(Build.VERSION.SDK_INT == Build.VERSION_CODES.N
|| Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1) {
try {
SSLContext.getInstance("TLSv1.2")
} catch (e: NoSuchAlgorithmException) {
XLog.e("Could not install Android 7 broken SSL workaround!", e)
}
try {
ProviderInstaller.installIfNeeded(applicationContext)
} catch (e: GooglePlayServicesRepairableException) {
XLog.e("Could not install Android 7 broken SSL workaround!", e)
} catch (e: GooglePlayServicesNotAvailableException) {
XLog.e("Could not install Android 7 broken SSL workaround!", e)
}
}
}
protected open fun setupJobManager() {
try {
JobManager.create(this).addJobCreator { tag ->