From 64a6e0f4e916122fdd00df2e2b48d96ea7d49c1c Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 25 Jul 2020 14:37:16 +0530 Subject: Properly handle files without passwords (#969) * Properly handle files without passwords Fixes #967 Signed-off-by: Harsh Shandilya * Fix tests Signed-off-by: Harsh Shandilya * Only look for TOTP URI Signed-off-by: Harsh Shandilya (cherry picked from commit 62dbc183d52d93860228316b209ec5aa15f16a08) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index b186d093..93b247b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Fixed + +- Properly handle cases where files contain only TOTP secrets and no password + ## [1.10.1] - 2020-07-23 ### Fixed -- cgit v1.2.3 From c132cc98e632036731b118d886709d783a55cc71 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Wed, 29 Jul 2020 13:06:22 +0530 Subject: Fix TOTP import button check semantics (#982) * Improve TOTP checking semantics Signed-off-by: Harsh Shandilya * Fix return label Signed-off-by: Harsh Shandilya * update CHANGELOG Signed-off-by: Harsh Shandilya * Move updateViewState() call outside with(binding) scope Signed-off-by: Harsh Shandilya (cherry picked from commit ecf96aa0668a758b2408284facda41ac70fe10aa) --- CHANGELOG.md | 1 + .../java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b247b4..2c79702e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. ### Fixed - Properly handle cases where files contain only TOTP secrets and no password +- Correctly hide TOTP import button when TOTP secret/OTPAUTH URL is already present in extra content ## [1.10.1] - 2020-07-23 diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt index 3c1757f1..615b695e 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt @@ -177,13 +177,11 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB extraContent.setText(entry.extraContentWithoutAuthData) } } - updateViewState() } } listOf(filename, extraContent).forEach { it.doOnTextChanged { _, _, _, _ -> updateViewState() } } - updateViewState() } suggestedPass?.let { password.setText(it) @@ -195,6 +193,7 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB password.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD } } + updateViewState() } override fun onCreateOptionsMenu(menu: Menu?): Boolean { @@ -235,7 +234,7 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB val entry = PasswordEntry("PLACEHOLDER\n${extraContent.text}") encryptUsername.apply { if (visibility != View.VISIBLE) - return@with + return@apply val hasUsernameInFileName = filename.text.toString().isNotBlank() val hasUsernameInExtras = entry.hasUsername() isEnabled = hasUsernameInFileName xor hasUsernameInExtras @@ -420,8 +419,7 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB AutofillPreferences.directoryStructure(applicationContext) val entry = PasswordEntry(content) returnIntent.putExtra(RETURN_EXTRA_PASSWORD, entry.password) - val username = PasswordEntry(content).username - ?: directoryStructure.getUsernameFor(file) + val username = entry.username ?: directoryStructure.getUsernameFor(file) returnIntent.putExtra(RETURN_EXTRA_USERNAME, username) } -- cgit v1.2.3 From 23158ce6da8332bdb1f75a589b31ebcd1d819e00 Mon Sep 17 00:00:00 2001 From: Fabian Henneke Date: Thu, 30 Jul 2020 10:29:01 +0200 Subject: Fix two SMS Autofill crashes (#985) SMS OTP Autofill currently crashes for two reasons: 1. Tasks.await has a precondition of not running on the UI thread. 2. Exceptions thrown from Tasks are always wrapped into ExecutionExceptions and need to be unwrapped before they can be identified as ResolvableApiException. This commit addresses both issues by making waitForSms a proper coroutine using withContext and a custom wrapper around Task that relies on suspendCoroutine and automatically unwraps exceptions. (cherry picked from commit 3afeff45d8bd5fff66e1d0fa2c15fa2527487af1) --- CHANGELOG.md | 1 + .../autofill/oreo/ui/AutofillSmsActivity.kt | 33 ++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c79702e..38eb7eb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Properly handle cases where files contain only TOTP secrets and no password - Correctly hide TOTP import button when TOTP secret/OTPAUTH URL is already present in extra content +- SMS OTP Autofill no longer crashes when invoked and correctly asks for the required permission on first use ## [1.10.1] - 2020-07-23 diff --git a/app/src/nonFree/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSmsActivity.kt b/app/src/nonFree/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSmsActivity.kt index 02394867..4413ea10 100644 --- a/app/src/nonFree/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSmsActivity.kt +++ b/app/src/nonFree/java/com/zeapo/pwdstore/autofill/oreo/ui/AutofillSmsActivity.kt @@ -24,13 +24,30 @@ import com.google.android.gms.auth.api.phone.SmsRetriever import com.google.android.gms.common.ConnectionResult import com.google.android.gms.common.GoogleApiAvailability import com.google.android.gms.common.api.ResolvableApiException -import com.google.android.gms.tasks.Tasks +import com.google.android.gms.tasks.Task import com.zeapo.pwdstore.autofill.oreo.AutofillAction import com.zeapo.pwdstore.autofill.oreo.Credentials import com.zeapo.pwdstore.autofill.oreo.FillableForm import com.zeapo.pwdstore.databinding.ActivityOreoAutofillSmsBinding import com.zeapo.pwdstore.utils.viewBinding +import java.util.concurrent.ExecutionException +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlin.coroutines.suspendCoroutine +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext + +suspend fun Task.suspendableAwait() = suspendCoroutine { cont -> + addOnSuccessListener { result: T -> + cont.resume(result) + } + addOnFailureListener { e -> + // Unwrap specific exceptions (e.g. ResolvableApiException) from ExecutionException. + val cause = (e as? ExecutionException)?.cause ?: e + cont.resumeWithException(cause) + } +} @RequiresApi(Build.VERSION_CODES.O) class AutofillSmsActivity : AppCompatActivity() { @@ -105,15 +122,21 @@ class AutofillSmsActivity : AppCompatActivity() { } } - private fun waitForSms() { + private suspend fun waitForSms() { val smsClient = SmsCodeRetriever.getAutofillClient(this@AutofillSmsActivity) try { - Tasks.await(smsClient.startSmsCodeRetriever()) + withContext(Dispatchers.IO) { + smsClient.startSmsCodeRetriever().suspendableAwait() + } } catch (e: ResolvableApiException) { - e.startResolutionForResult(this, 1) + withContext(Dispatchers.Main) { + e.startResolutionForResult(this@AutofillSmsActivity, 1) + } } catch (e: Exception) { e(e) - finish() + withContext(Dispatchers.Main) { + finish() + } } } -- cgit v1.2.3 From cccf3e39ec77518fd6c8abe5197963c8e89bcdc5 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 30 Jul 2020 08:58:45 +0000 Subject: Prepare release 1.10.2 --- CHANGELOG.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 38eb7eb0..204704be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,13 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +## [1.10.2] - 2020-07-30 + ### Fixed -- Properly handle cases where files contain only TOTP secrets and no password -- Correctly hide TOTP import button when TOTP secret/OTPAUTH URL is already present in extra content -- SMS OTP Autofill no longer crashes when invoked and correctly asks for the required permission on first use +- Properly handle cases where files contain only TOTP secrets and no password +- Correctly hide TOTP import button when TOTP secret/OTPAUTH URL is already present in extra content +- SMS OTP Autofill no longer crashes when invoked and correctly asks for the required permission on first use ## [1.10.1] - 2020-07-23 @@ -265,7 +267,9 @@ All notable changes to this project will be documented in this file. - Fix elements overlapping. -[Unreleased]: https://github.com/android-password-store/Android-Password-Store/compare/1.10.1...HEAD +[Unreleased]: https://github.com/android-password-store/Android-Password-Store/compare/1.10.2...HEAD + +[1.10.2]: https://github.com/android-password-store/Android-Password-Store/compare/1.10.1...1.10.2 [1.10.1]: https://github.com/android-password-store/Android-Password-Store/compare/1.10.0...1.10.1 -- cgit v1.2.3