From 64addd58d406aa810c02312233cc02567632d7bc Mon Sep 17 00:00:00 2001 From: "M. Dietrich" Date: Wed, 22 Jan 2014 16:38:54 +0100 Subject: [PATCH] add "never" for ttl for passphrase cache --- OpenPGP-Keychain/res/values/arrays.xml | 4 +++- OpenPGP-Keychain/res/values/strings.xml | 3 ++- .../keychain/service/PassphraseCacheService.java | 12 +++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/OpenPGP-Keychain/res/values/arrays.xml b/OpenPGP-Keychain/res/values/arrays.xml index 0c1684919..974239110 100644 --- a/OpenPGP-Keychain/res/values/arrays.xml +++ b/OpenPGP-Keychain/res/values/arrays.xml @@ -13,6 +13,7 @@ @string/choice_2hours @string/choice_4hours @string/choice_8hours + @string/choice_forever 15 @@ -26,6 +27,7 @@ 7200 14400 28800 + -1 @string/key_size_512 @@ -41,4 +43,4 @@ @string/menu_import_from_nfc - \ No newline at end of file + diff --git a/OpenPGP-Keychain/res/values/strings.xml b/OpenPGP-Keychain/res/values/strings.xml index 43c1384f8..4bbf4620b 100644 --- a/OpenPGP-Keychain/res/values/strings.xml +++ b/OpenPGP-Keychain/res/values/strings.xml @@ -166,6 +166,7 @@ 2 hours 4 hours 8 hours + forever DSA ElGamal RSA @@ -410,4 +411,4 @@ Open navigation drawer Close navigation drawer - \ No newline at end of file + diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index f447b6d4f..08b9c26e6 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -291,10 +291,12 @@ public class PassphraseCacheService extends Service { // add keyId and passphrase to memory mPassphraseCache.put(keyId, passphrase); - // 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, keyId)); + 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, keyId)); + } } else if (ACTION_PASSPHRASE_CACHE_GET.equals(intent.getAction())) { long keyId = intent.getLongExtra(EXTRA_KEY_ID, -1); Messenger messenger = intent.getParcelableExtra(EXTRA_MESSENGER); @@ -365,4 +367,4 @@ public class PassphraseCacheService extends Service { private final IBinder mBinder = new PassphraseCacheBinder(); -} \ No newline at end of file +}