From 207dd23c866f735773e644170c890bbcbe7f4bf6 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Wed, 27 Nov 2019 00:55:58 -0500 Subject: [PATCH] Fix performance issue with large number of notifications. Constructing the notification would call KeyCachingService#isLocked() many times in a loop. This call is slow, because when the device isn't locked, it would construct the master secret each time, which can take 50+ ms. Do that twice in a loop a hundred times, and it adds up. This simplified #isLocked to avoid the unnecessary master secret generation. --- src/org/thoughtcrime/securesms/service/KeyCachingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/service/KeyCachingService.java b/src/org/thoughtcrime/securesms/service/KeyCachingService.java index 7bade8b3de..71308ca67c 100644 --- a/src/org/thoughtcrime/securesms/service/KeyCachingService.java +++ b/src/org/thoughtcrime/securesms/service/KeyCachingService.java @@ -79,7 +79,7 @@ public class KeyCachingService extends Service { public KeyCachingService() {} public static synchronized boolean isLocked(Context context) { - return getMasterSecret(context) == null; + return masterSecret == null && (!TextSecurePreferences.isPasswordDisabled(context) || TextSecurePreferences.isScreenLockEnabled(context)); } public static synchronized @Nullable MasterSecret getMasterSecret(Context context) {