diff options
author | Allan Wang <me@allanwang.ca> | 2019-09-09 00:41:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-09 00:41:19 -0700 |
commit | 35a2e236e394abc17f2238c296b6fbead4ce6a49 (patch) | |
tree | 66d81d42186f4a60911332983542f392efe7eb42 /app/src/main/kotlin/com | |
parent | f8b477b976cf858e1fff5dbb8f9de26ef3de1cd4 (diff) | |
parent | 5f397d2b8f699dd1bf8c08c3951e864d3ac14304 (diff) | |
download | frost-35a2e236e394abc17f2238c296b6fbead4ce6a49.tar.gz frost-35a2e236e394abc17f2238c296b6fbead4ce6a49.tar.bz2 frost-35a2e236e394abc17f2238c296b6fbead4ce6a49.zip |
Merge pull request #1535 from AllanWang/fix-biometrics
Move biometric init out of coroutine launch
Diffstat (limited to 'app/src/main/kotlin/com')
3 files changed, 7 insertions, 2 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt index e5b6d49a..d03a7ea4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/StartActivity.kt @@ -70,8 +70,8 @@ class StartActivity : KauBaseActivity() { showInvalidWebView() } + val authDefer = BiometricUtils.authenticate(this@StartActivity) launch { - val authDefer = BiometricUtils.authenticate(this@StartActivity) try { FbCookie.switchBackUser() val cookies = ArrayList(cookieDao.selectAll()) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt index d82084d5..0322a4bb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt @@ -209,8 +209,8 @@ abstract class WebOverlayActivityBase : BaseActivity(), with(web) { Prefs.prevId = Prefs.userId + val authDefer = BiometricUtils.authenticate(this@WebOverlayActivityBase) launch { - val authDefer = BiometricUtils.authenticate(this@WebOverlayActivityBase) if (userId != Prefs.userId) FbCookie.switchUser(userId) authDefer.await() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt index 4ececc8b..136fe28f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/BiometricUtils.kt @@ -65,6 +65,11 @@ object BiometricUtils { return Prefs.biometricsEnabled && System.currentTimeMillis() - lastUnlockTime > UNLOCK_TIME_INTERVAL } + /** + * Generates a prompt dialog and attempt to return an auth object. + * Note that the underlying request will call [androidx.fragment.app.FragmentTransaction.commit], + * so this cannot happen after onSaveInstanceState. + */ fun authenticate(activity: FragmentActivity, force: Boolean = false): BiometricDeferred { val deferred: BiometricDeferred = CompletableDeferred() if (!force && !shouldPrompt(activity)) { |