Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optimize getCipherStorageForCurrentAPILevel method #457

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -738,20 +738,21 @@ protected DecryptionResultHandler getInteractiveHandler(@NonNull final CipherSto
for (CipherStorage variant : cipherStorageMap.values()) {
Log.d(KEYCHAIN_MODULE, "Probe cipher storage: " + variant.getClass().getSimpleName());

// if biometric supported but not configured properly than skip
if (variant.isBiometrySupported() && !isBiometry) continue;

// Is the cipherStorage supported on the current API level?
final int minApiLevel = variant.getMinSupportedApiLevel();
final int capabilityLevel = variant.getCapabilityLevel();
final boolean isSupportedApi = (minApiLevel <= currentApiLevel);

// API not supported
if (!isSupportedApi) continue;

final int capabilityLevel = variant.getCapabilityLevel();

// Is the API level better than the one we previously selected (if any)?
if (foundCipher != null && capabilityLevel < foundCipher.getCapabilityLevel()) continue;

// if biometric supported but not configured properly than skip
if (variant.isBiometrySupported() && !isBiometry) continue;

// remember storage with the best capabilities
foundCipher = variant;
}
Expand Down