passphrasecache: update defaults, add "forever" setting
This commit is contained in:
@@ -365,6 +365,8 @@ public class PassphraseCacheService extends Service {
|
||||
CachedPassphrase cachedPassphrase;
|
||||
if (timeoutTtl == 0L) {
|
||||
cachedPassphrase = CachedPassphrase.getPassphraseLock(passphrase, primaryUserID);
|
||||
} else if (timeoutTtl >= Integer.MAX_VALUE) {
|
||||
cachedPassphrase = CachedPassphrase.getPassphraseNoTimeout(passphrase, primaryUserID);
|
||||
} else {
|
||||
cachedPassphrase = CachedPassphrase.getPassphraseTtlTimeout(passphrase, primaryUserID, timeoutTtl);
|
||||
|
||||
@@ -427,7 +429,10 @@ public class PassphraseCacheService extends Service {
|
||||
|
||||
// Stop all ttl alarms
|
||||
for (int i = 0; i < mPassphraseCache.size(); i++) {
|
||||
am.cancel(buildIntent(this, mPassphraseCache.keyAt(i)));
|
||||
CachedPassphrase cachedPassphrase = mPassphraseCache.valueAt(i);
|
||||
if (cachedPassphrase.mTimeoutMode == TimeoutMode.TTL) {
|
||||
am.cancel(buildIntent(this, mPassphraseCache.keyAt(i)));
|
||||
}
|
||||
}
|
||||
mPassphraseCache.clear();
|
||||
|
||||
|
||||
@@ -77,7 +77,6 @@ public class SettingsCacheTTLFragment extends Fragment {
|
||||
recyclerView.setAdapter(mAdapter);
|
||||
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void savePreference() {
|
||||
|
||||
@@ -322,11 +322,13 @@ public class Preferences {
|
||||
static {
|
||||
HashMap<Integer,Integer> cacheTtlNames = new HashMap<>();
|
||||
cacheTtlNames.put(0, R.string.cache_ttl_lock_screen);
|
||||
cacheTtlNames.put(60 * 5, R.string.cache_ttl_five_minutes);
|
||||
cacheTtlNames.put(60 * 10, R.string.cache_ttl_ten_minutes);
|
||||
cacheTtlNames.put(60 * 30, R.string.cache_ttl_thirty_minutes);
|
||||
cacheTtlNames.put(60 * 60, R.string.cache_ttl_one_hour);
|
||||
cacheTtlNames.put(60 * 60 * 3, R.string.cache_ttl_three_hours);
|
||||
cacheTtlNames.put(60 * 60 * 24, R.string.cache_ttl_one_day);
|
||||
cacheTtlNames.put(60 * 60 * 24 * 3, R.string.cache_ttl_three_days);
|
||||
cacheTtlNames.put(Integer.MAX_VALUE, R.string.cache_ttl_forever);
|
||||
CACHE_TTL_NAMES = Collections.unmodifiableMap(cacheTtlNames);
|
||||
|
||||
CACHE_TTLS = new ArrayList<>(CacheTTLPrefs.CACHE_TTL_NAMES.keySet());
|
||||
@@ -352,7 +354,7 @@ public class Preferences {
|
||||
|
||||
public static CacheTTLPrefs getDefault() {
|
||||
ArrayList<String> ttlStrings = new ArrayList<>();
|
||||
ttlStrings.add(Integer.toString(60 * 5));
|
||||
ttlStrings.add(Integer.toString(0));
|
||||
ttlStrings.add(Integer.toString(60 * 60));
|
||||
ttlStrings.add(Integer.toString(60 * 60 * 24));
|
||||
return new CacheTTLPrefs(ttlStrings);
|
||||
|
||||
Reference in New Issue
Block a user