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.
master
Greyson Parrelli 2019-11-27 00:55:58 -05:00
parent 7e0de29dd7
commit 207dd23c86
1 changed files with 1 additions and 1 deletions

View File

@ -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) {