Fixed OpenKeychain loop with hardware key

Closes open-keychain/open-keychain#2507
pull/168/head
M66B 5 years ago
parent f66af79bda
commit 8ec3e01a5e

@ -51,7 +51,7 @@ Related questions:
* A bug in Nova Launcher on Android 5.x lets FairEmail crash with a *java.lang.StackOverflowError* when Nova Launcher has access to the accessibility service. * A bug in Nova Launcher on Android 5.x lets FairEmail crash with a *java.lang.StackOverflowError* when Nova Launcher has access to the accessibility service.
* The folder selector sometimes shows no folders for yet unknown reasons. * The folder selector sometimes shows no folders for yet unknown reasons.
* A [bug in AndroidX](https://issuetracker.google.com/issues/64729576) makes it hard to grap the fast scroller. * A [bug in AndroidX](https://issuetracker.google.com/issues/64729576) makes it hard to grap the fast scroller.
* Encryption with YubiKey results into an infinite loop. This seems to be caused by a [bug in OpenKeychain](https://github.com/open-keychain/open-keychain/issues/2507). * ~~Encryption with YubiKey results into an infinite loop. This seems to be caused by a [bug in OpenKeychain](https://github.com/open-keychain/open-keychain/issues/2507).~~
* Scrolling to an internal linked location in original messages does not work. This can't be fixed because the original message view is contained in a scrolling view. * Scrolling to an internal linked location in original messages does not work. This can't be fixed because the original message view is contained in a scrolling view.
* A preview of the message text doesn't (always) appear on a Samsung watch because [setLocalOnly](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder.html#setLocalOnly(boolean)) seem to be ignored. However, message preview texts are known to appear correctly on a Pebble 2, a Fitbit Charge 3 and a Mi band 3. See also [this FAQ](#user-content-faq126). * A preview of the message text doesn't (always) appear on a Samsung watch because [setLocalOnly](https://developer.android.com/reference/androidx/core/app/NotificationCompat.Builder.html#setLocalOnly(boolean)) seem to be ignored. However, message preview texts are known to appear correctly on a Pebble 2, a Fitbit Charge 3 and a Mi band 3. See also [this FAQ](#user-content-faq126).

@ -1557,9 +1557,11 @@ public class FragmentCompose extends FragmentBase {
} }
// Create temporary files // Create temporary files
File plain = File.createTempFile("plain", "." + id, context.getCacheDir()); File plain = new File(context.getCacheDir(), "plain." + id);
File encrypted = File.createTempFile("encrypted", "." + id, context.getCacheDir()); File encrypted = new File(context.getCacheDir(), "encrypted." + id);
// Serializing messages is NOT reproducible
if (OpenPgpApi.ACTION_GET_KEY_IDS.equals(data.getAction())) {
// Build message // Build message
Properties props = MessageHelper.getSessionProperties(); Properties props = MessageHelper.getSessionProperties();
Session isession = Session.getInstance(props, null); Session isession = Session.getInstance(props, null);
@ -1570,17 +1572,13 @@ public class FragmentCompose extends FragmentBase {
try (OutputStream out = new FileOutputStream(plain)) { try (OutputStream out = new FileOutputStream(plain)) {
imessage.writeTo(out); imessage.writeTo(out);
} }
}
// Call OpenPGP // Call OpenPGP
Intent result;
try {
Log.i("Executing " + data.getAction()); Log.i("Executing " + data.getAction());
Log.logExtras(data); Log.logExtras(data);
OpenPgpApi api = new OpenPgpApi(context, pgpService.getService()); OpenPgpApi api = new OpenPgpApi(context, pgpService.getService());
result = api.executeApi(data, new FileInputStream(plain), new FileOutputStream(encrypted)); Intent result = api.executeApi(data, new FileInputStream(plain), new FileOutputStream(encrypted));
} finally {
plain.delete();
}
// Process result // Process result
try { try {
@ -1686,6 +1684,8 @@ public class FragmentCompose extends FragmentBase {
intent.putExtra(BuildConfig.APPLICATION_ID, id); intent.putExtra(BuildConfig.APPLICATION_ID, id);
return intent; return intent;
} else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) { } else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(data.getAction())) {
plain.delete();
// Get signature // Get signature
Intent intent = new Intent(OpenPgpApi.ACTION_DETACHED_SIGN); Intent intent = new Intent(OpenPgpApi.ACTION_DETACHED_SIGN);
intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, pgpSignKeyId); intent.putExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, pgpSignKeyId);
@ -1700,6 +1700,7 @@ public class FragmentCompose extends FragmentBase {
return (PendingIntent) result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); return (PendingIntent) result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
case OpenPgpApi.RESULT_CODE_ERROR: case OpenPgpApi.RESULT_CODE_ERROR:
plain.delete();
db.identity().setIdentitySignKey(identity.id, null); db.identity().setIdentitySignKey(identity.id, null);
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
throw new IllegalArgumentException( throw new IllegalArgumentException(

Loading…
Cancel
Save