From a9c73f1e517d6e308ff78784daf1a88f74d55cce Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sun, 22 Nov 2020 11:47:39 +0530 Subject: Automatically dismiss decryption screen after 60 seconds (#1216) * Automatically dismiss decryption screen after 60 seconds Fixes #1215 Signed-off-by: Harsh Shandilya * Update changelog Signed-off-by: Harsh Shandilya --- .../main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/src/main/java/com/zeapo') diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt index cb43534d..cfcecc22 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/DecryptActivity.kt @@ -113,6 +113,18 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound { e(e) } + /** + * Automatically finishes the activity 60 seconds after decryption succeeded to prevent + * information leaks from stale activities. + */ + @OptIn(ExperimentalTime::class) + private fun startAutoDismissTimer() { + lifecycleScope.launch { + delay(60.seconds) + finish() + } + } + /** * Edit the current password and hide all the fields populated by encrypted data so that when * the result triggers they can be repopulated with new data. @@ -155,6 +167,7 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound { api?.executeApiAsync(data, inputStream, outputStream) { result -> when (result?.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { OpenPgpApi.RESULT_CODE_SUCCESS -> { + startAutoDismissTimer() runCatching { val showPassword = settings.getBoolean(PreferenceKeys.SHOW_PASSWORD, true) val showExtraContent = settings.getBoolean(PreferenceKeys.SHOW_EXTRA_CONTENT, true) -- cgit v1.2.3