Skip to content

Commit

Permalink
Run Google ProviderInstaller on UI thread
Browse files Browse the repository at this point in the history
  • Loading branch information
AbandonedCart committed Oct 22, 2023
1 parent a024af9 commit 72d0638
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ object Debug {
setClipboard(context, subject, logText)
when {
BuildConfig.WEAR_OS -> { }
KeyManager(context).isKeyMissing -> { showGuideBanner(context) }
KeyManager(context).isKeyMissing || !hasDebugging() -> {
showGuideBanner(context)
}
System.currentTimeMillis() < mPrefs.lastBugReport() + 900000 -> {
if (context is Activity) {
IconifiedSnackbar(context).buildSnackbar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,32 @@ class SecurityHandler(activity: Activity?, listener: ProviderInstallListener?) {
listener?.onProviderInstalled()
} else {
activity?.let {
ProviderInstaller.installIfNeededAsync(it,
object : ProviderInstaller.ProviderInstallListener {
override fun onProviderInstalled() {
listener?.onProviderInstalled()
}
it.runOnUiThread {
ProviderInstaller.installIfNeededAsync(it,
object : ProviderInstaller.ProviderInstallListener {
override fun onProviderInstalled() {
listener?.onProviderInstalled()
}

override fun onProviderInstallFailed(errorCode: Int, recoveryIntent: Intent?) {
val availability = GoogleApiAvailability.getInstance()
if (availability.isUserResolvableError(errorCode)) {
try {
availability.showErrorDialogFragment(
it, errorCode, 7000
) { listener?.onProviderInstallFailed() }
} catch (ex: IllegalArgumentException) {
listener?.onProviderInstallException()
override fun onProviderInstallFailed(
errorCode: Int,
recoveryIntent: Intent?
) {
val availability = GoogleApiAvailability.getInstance()
if (availability.isUserResolvableError(errorCode)) {
try {
availability.showErrorDialogFragment(
it, errorCode, 7000
) { listener?.onProviderInstallFailed() }
} catch (ex: IllegalArgumentException) {
listener?.onProviderInstallException()
}
} else {
listener?.onProviderInstallFailed()
}
} else {
listener?.onProviderInstallFailed()
}
}
})
})
}
}
}
}
Expand Down

0 comments on commit 72d0638

Please sign in to comment.