aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-08 06:51:39 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-08 06:51:39 +0100
commitafa869ddd22ba9913a87da13d2194e069379f910 (patch)
tree07d8e980f3035729c93e52fb0e9d5099a40868d1 /src/main/java/de/pixart
parentb0599b923df86cf4bc9b2657aa2881bb6e70b9bc (diff)
improve openkeychain error reporting
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/PgpEngine.java18
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java2
2 files changed, 15 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/PgpEngine.java b/src/main/java/de/pixart/messenger/crypto/PgpEngine.java
index 3be5ceb23..7fb474429 100644
--- a/src/main/java/de/pixart/messenger/crypto/PgpEngine.java
+++ b/src/main/java/de/pixart/messenger/crypto/PgpEngine.java
@@ -2,6 +2,7 @@ package de.pixart.messenger.crypto;
import android.app.PendingIntent;
import android.content.Intent;
+import android.support.annotation.StringRes;
import android.util.Log;
import org.openintents.openpgp.OpenPgpError;
@@ -39,7 +40,8 @@ public class PgpEngine {
private static void logError(Account account, OpenPgpError error) {
if (error != null) {
- Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": OpenKeychain error '" + error.getMessage() + "' code=" + error.getErrorId());
+ error.describeContents();
+ Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": OpenKeychain error '" + error.getMessage() + "' code=" + error.getErrorId() + " class=" + error.getClass().getName());
} else {
Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": OpenKeychain error with no message");
}
@@ -93,8 +95,16 @@ public class PgpEngine {
callback.userInputRequried(result.getParcelableExtra(OpenPgpApi.RESULT_INTENT), message);
break;
case OpenPgpApi.RESULT_CODE_ERROR:
- logError(conversation.getAccount(), result.getParcelableExtra(OpenPgpApi.RESULT_ERROR));
- callback.error(R.string.openpgp_error, message);
+ OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
+ String errorMessage = error != null ? error.getMessage() : null;
+ @StringRes final int res;
+ if (errorMessage != null && errorMessage.startsWith("Bad key for encryption")) {
+ res = R.string.bad_key_for_encryption;
+ } else {
+ res = R.string.openpgp_error;
+ }
+ logError(conversation.getAccount(), error);
+ callback.error(res, message);
break;
}
});
@@ -173,7 +183,7 @@ public class PgpEngine {
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
return 0;
case OpenPgpApi.RESULT_CODE_ERROR:
- logError(account, (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ logError(account, result.getParcelableExtra(OpenPgpApi.RESULT_ERROR));
return 0;
}
return 0;
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 7edc309c9..be4ca8af4 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -2802,7 +2802,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
public void error(final int error, Message message) {
getActivity().runOnUiThread(() -> {
doneSendingPgpMessage();
- Toast.makeText(getActivity(), R.string.unable_to_connect_to_keychain, Toast.LENGTH_SHORT).show();
+ Toast.makeText(getActivity(), error == 0 ? R.string.unable_to_connect_to_keychain : error, Toast.LENGTH_SHORT).show();
});
}