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
parent
7e0de29dd7
commit
207dd23c86
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue