diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-04-12 19:55:10 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2015-04-12 19:55:10 +0200 |
commit | c3d6637e6acf595e0f13ce8a3cb7accd6173e5d4 (patch) | |
tree | 00b6a1fcd5671596173d301dab4aadfafb24609a /OpenKeychain/src/main/java/org | |
parent | fd09b9d380a96d92f08b3ee970c350228aa2ef63 (diff) | |
download | open-keychain-c3d6637e6acf595e0f13ce8a3cb7accd6173e5d4.tar.gz open-keychain-c3d6637e6acf595e0f13ce8a3cb7accd6173e5d4.tar.bz2 open-keychain-c3d6637e6acf595e0f13ce8a3cb7accd6173e5d4.zip |
Simplify PassphraseCacheService
Diffstat (limited to 'OpenKeychain/src/main/java/org')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index 8e37a8867..2bea05de8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -355,25 +355,21 @@ public class PassphraseCacheService extends Service { + masterKeyId + ", subKeyId: " + subKeyId + ", ttl: " + ttl + ", usrId: " + primaryUserID ); - // if we don't cache by specific subkey id, or the requested subkey is the master key, - // just add master key id to the cache + long referenceKeyId; if (subKeyId == masterKeyId || !Preferences.getPreferences(mContext).getPassphraseCacheSubs()) { - mPassphraseCache.put(masterKeyId, new CachedPassphrase(passphrase, primaryUserID)); - if (ttl > 0) { - // register new alarm with keyId for this passphrase - long triggerTime = new Date().getTime() + (ttl * 1000); - AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); - am.set(AlarmManager.RTC_WAKEUP, triggerTime, buildIntent(this, masterKeyId)); - } + // if we don't cache by specific subkey id, or the requested subkey is the master key, + // just add master key id to the cache + referenceKeyId = masterKeyId; } else { // otherwise, add this specific subkey to the cache - mPassphraseCache.put(subKeyId, new CachedPassphrase(passphrase, primaryUserID)); - if (ttl > 0) { - // register new alarm with keyId for this passphrase - long triggerTime = new Date().getTime() + (ttl * 1000); - AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); - am.set(AlarmManager.RTC_WAKEUP, triggerTime, buildIntent(this, subKeyId)); - } + referenceKeyId = subKeyId; + } + mPassphraseCache.put(referenceKeyId, new CachedPassphrase(passphrase, primaryUserID)); + if (ttl > 0) { + // register new alarm with keyId for this passphrase + long triggerTime = new Date().getTime() + (ttl * 1000); + AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); + am.set(AlarmManager.RTC_WAKEUP, triggerTime, buildIntent(this, referenceKeyId)); } updateService(); |