From 1e40c861d17a3d2bbe9d8b8ac92137ce1fc17f27 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Tue, 20 Apr 2021 17:02:14 +1000 Subject: [PATCH 1/3] make screenlock work within 60s --- .../securesms/preferences/AppProtectionPreferenceFragment.java | 3 ++- .../org/thoughtcrime/securesms/service/KeyCachingService.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java b/app/src/main/java/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java index db9484f9b0..e516916de4 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/AppProtectionPreferenceFragment.java @@ -102,7 +102,8 @@ public class AppProtectionPreferenceFragment extends CorrectedPreferenceFragment if (duration == 0) { TextSecurePreferences.setScreenLockTimeout(getContext(), 0); } else { - long timeoutSeconds = Math.max(TimeUnit.MILLISECONDS.toSeconds(duration), 60); + long timeoutSeconds = TimeUnit.MILLISECONDS.toSeconds(duration); +// long timeoutSeconds = Math.max(TimeUnit.MILLISECONDS.toSeconds(duration), 60); TextSecurePreferences.setScreenLockTimeout(getContext(), timeoutSeconds); } diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java b/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java index e1c2350ef1..cde706c6e0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java @@ -210,7 +210,7 @@ public class KeyCachingService extends Service { boolean passLockActive = timeoutEnabled && !TextSecurePreferences.isPasswordDisabled(context); long screenTimeout = TextSecurePreferences.getScreenLockTimeout(context); - boolean screenLockActive = screenTimeout >= 60 && TextSecurePreferences.isScreenLockEnabled(context); + boolean screenLockActive = screenTimeout >= 0 && TextSecurePreferences.isScreenLockEnabled(context); if (!appVisible && secretSet && (passLockActive || screenLockActive)) { long passphraseTimeoutMinutes = TextSecurePreferences.getPassphraseTimeoutInterval(context); From 01eb7945f66f9e6247bdfa74e73a5dd8819e9b49 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 28 Apr 2021 15:59:30 +1000 Subject: [PATCH 2/3] fix crash --- .../thoughtcrime/securesms/PassphrasePromptActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/PassphrasePromptActivity.java b/app/src/main/java/org/thoughtcrime/securesms/PassphrasePromptActivity.java index b058c99c91..ad75d60330 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/PassphrasePromptActivity.java +++ b/app/src/main/java/org/thoughtcrime/securesms/PassphrasePromptActivity.java @@ -84,6 +84,7 @@ public class PassphrasePromptActivity extends BaseActionBarActivity { } @Override public void onServiceDisconnected(ComponentName name) { + keyCachingService.setMasterSecret(new Object()); keyCachingService = null; } }, Context.BIND_AUTO_CREATE); @@ -133,7 +134,9 @@ public class PassphrasePromptActivity extends BaseActionBarActivity { private void handleAuthenticated() { authenticated = true; //TODO Replace with a proper call. - keyCachingService.setMasterSecret(new Object()); + if (keyCachingService != null) { + keyCachingService.setMasterSecret(new Object()); + } // Finish and proceed with the next intent. Intent nextIntent = getIntent().getParcelableExtra("next_intent"); @@ -188,6 +191,8 @@ public class PassphrasePromptActivity extends BaseActionBarActivity { if (!keyguardManager.isKeyguardSecure()) { Log.w(TAG ,"Keyguard not secure..."); + TextSecurePreferences.setScreenLockEnabled(getApplicationContext(), false); + TextSecurePreferences.setScreenLockTimeout(getApplicationContext(), 0); handleAuthenticated(); return; } From 4508510958439b044b442b3f2b66fe3f7d2bd0aa Mon Sep 17 00:00:00 2001 From: Ryan ZHAO Date: Thu, 29 Apr 2021 13:23:02 +1000 Subject: [PATCH 3/3] fix for API 21 --- .../org/thoughtcrime/securesms/service/KeyCachingService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java b/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java index cde706c6e0..e204c3f503 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/KeyCachingService.java @@ -119,7 +119,6 @@ public class KeyCachingService extends Service { KeyCachingService.masterSecret = masterSecret; foregroundService(); - startTimeoutIfAppropriate(this); new AsyncTask() { @Override