Simplify PassphraseCacheService
This commit is contained in:
@@ -355,25 +355,21 @@ public class PassphraseCacheService extends Service {
|
|||||||
+ masterKeyId + ", subKeyId: " + subKeyId + ", ttl: " + ttl + ", usrId: " + primaryUserID
|
+ masterKeyId + ", subKeyId: " + subKeyId + ", ttl: " + ttl + ", usrId: " + primaryUserID
|
||||||
);
|
);
|
||||||
|
|
||||||
// if we don't cache by specific subkey id, or the requested subkey is the master key,
|
long referenceKeyId;
|
||||||
// just add master key id to the cache
|
|
||||||
if (subKeyId == masterKeyId || !Preferences.getPreferences(mContext).getPassphraseCacheSubs()) {
|
if (subKeyId == masterKeyId || !Preferences.getPreferences(mContext).getPassphraseCacheSubs()) {
|
||||||
mPassphraseCache.put(masterKeyId, new CachedPassphrase(passphrase, primaryUserID));
|
// if we don't cache by specific subkey id, or the requested subkey is the master key,
|
||||||
if (ttl > 0) {
|
// just add master key id to the cache
|
||||||
// register new alarm with keyId for this passphrase
|
referenceKeyId = masterKeyId;
|
||||||
long triggerTime = new Date().getTime() + (ttl * 1000);
|
|
||||||
AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
|
|
||||||
am.set(AlarmManager.RTC_WAKEUP, triggerTime, buildIntent(this, masterKeyId));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// otherwise, add this specific subkey to the cache
|
// otherwise, add this specific subkey to the cache
|
||||||
mPassphraseCache.put(subKeyId, new CachedPassphrase(passphrase, primaryUserID));
|
referenceKeyId = subKeyId;
|
||||||
if (ttl > 0) {
|
}
|
||||||
// register new alarm with keyId for this passphrase
|
mPassphraseCache.put(referenceKeyId, new CachedPassphrase(passphrase, primaryUserID));
|
||||||
long triggerTime = new Date().getTime() + (ttl * 1000);
|
if (ttl > 0) {
|
||||||
AlarmManager am = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
|
// register new alarm with keyId for this passphrase
|
||||||
am.set(AlarmManager.RTC_WAKEUP, triggerTime, buildIntent(this, subKeyId));
|
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();
|
updateService();
|
||||||
|
|||||||
Reference in New Issue
Block a user