From 386c0f11ee2db0d0b53e288abe7bf33b8b490735 Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Thu, 9 May 2024 11:45:56 +0300 Subject: [PATCH 1/2] wip --- .../main/java/com/flowcrypt/email/FlowCryptApplication.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/FlowCryptApplication.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/FlowCryptApplication.kt index 774968d53..c6db5493a 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/FlowCryptApplication.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/FlowCryptApplication.kt @@ -117,7 +117,10 @@ class FlowCryptApplication : Application(), Configuration.Provider { val hasTemporaryPassPhrases = keysStorage.getRawKeys().any { it.passphraseType == KeyEntity.PassphraseType.RAM } if (hasTemporaryPassPhrases) { - PassPhrasesInRAMService.start(this) + if (GeneralUtil.isAppForegrounded()) { + //we can run a foreground service only if the app is visible for a user + PassPhrasesInRAMService.start(this) + } } else { PassPhrasesInRAMService.stop(this) } From 7c9b46ff2dc40da20a99b9ba4ada016b3a30274e Mon Sep 17 00:00:00 2001 From: DenBond7 Date: Thu, 9 May 2024 15:13:25 +0300 Subject: [PATCH 2/2] wip --- .../PrivateKeyDetailsFragmentPassInRamFlexibleTimeFlowTest.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/PrivateKeyDetailsFragmentPassInRamFlexibleTimeFlowTest.kt b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/PrivateKeyDetailsFragmentPassInRamFlexibleTimeFlowTest.kt index 5382f1027..94f5bd478 100644 --- a/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/PrivateKeyDetailsFragmentPassInRamFlexibleTimeFlowTest.kt +++ b/FlowCrypt/src/androidTest/java/com/flowcrypt/email/ui/PrivateKeyDetailsFragmentPassInRamFlexibleTimeFlowTest.kt @@ -96,6 +96,9 @@ class PrivateKeyDetailsFragmentPassInRamFlexibleTimeFlowTest : BaseTest() { @Test fun testInMemoryPassPhraseSessionLengthParameter() { + //as tests run a bit differently need to run PassPhrasesInRAMService manually at this stage + PassPhrasesInRAMService.start(getTargetContext()) + onView(withId(R.id.tVPassPhraseVerification)) .check(matches(withText(getResString(R.string.pass_phrase_not_provided)))) .check(matches(hasTextColor(R.color.red)))