Only start the screen lock timeout when the app is backgrounded.

master
Greyson Parrelli 2018-10-18 09:40:32 -07:00
parent 78124ef224
commit a287408a7a
1 changed files with 11 additions and 6 deletions

View File

@ -32,6 +32,8 @@ import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat;
import org.thoughtcrime.securesms.ApplicationContext;
import org.thoughtcrime.securesms.logging.Log;
import android.widget.RemoteViews;
@ -220,13 +222,16 @@ public class KeyCachingService extends Service {
}
private static void startTimeoutIfAppropriate(@NonNull Context context) {
boolean timeoutEnabled = TextSecurePreferences.isPassphraseTimeoutEnabled(context);
long screenTimeout = TextSecurePreferences.getScreenLockTimeout(context);
boolean appVisible = ApplicationContext.getInstance(context).isAppVisible();
boolean secretSet = KeyCachingService.masterSecret != null;
if ((KeyCachingService.masterSecret != null) &&
(timeoutEnabled && !TextSecurePreferences.isPasswordDisabled(context)) ||
(screenTimeout >= 60 && TextSecurePreferences.isScreenLockEnabled(context)))
{
boolean timeoutEnabled = TextSecurePreferences.isPassphraseTimeoutEnabled(context);
boolean passLockActive = timeoutEnabled && !TextSecurePreferences.isPasswordDisabled(context);
long screenTimeout = TextSecurePreferences.getScreenLockTimeout(context);
boolean screenLockActive = screenTimeout >= 60 && TextSecurePreferences.isScreenLockEnabled(context);
if (!appVisible && secretSet && (passLockActive || screenLockActive)) {
long passphraseTimeoutMinutes = TextSecurePreferences.getPassphraseTimeoutInterval(context);
long screenLockTimeoutSeconds = TextSecurePreferences.getScreenLockTimeout(context);