mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
Replace AssertionErrors with snackbar notifications, fix style issues.
This commit is contained in:
parent
14226461c1
commit
cda8b63bb4
@ -122,63 +122,61 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
// Otherwise, all status codes are fixed values.
|
||||
switch (status) {
|
||||
// These errors should not occur in everyday use; if they are returned, it means we
|
||||
// made a mistake sending data to the card.
|
||||
case 0x6A80:
|
||||
throw new AssertionError("Card returned 'Wrong Data' status; this is a programming error!");
|
||||
case 0x6883:
|
||||
throw new AssertionError("Card expected last command in a chain; this is a programming error!");
|
||||
case 0x6B00:
|
||||
throw new AssertionError("Card reported invalid P1/P2 parameter; this is a programming error!");
|
||||
case 0x6D00:
|
||||
throw new AssertionError("Instruction (INS) not supported by smart card; this is a programming error!");
|
||||
case 0x6E00:
|
||||
throw new AssertionError("Class (CLA) not supported by smart card; this is a programming error!");
|
||||
|
||||
// These errors might be encountered in everyday use, and should display a localized
|
||||
// error message to the user.
|
||||
case 0x6285:
|
||||
{
|
||||
Notify.create(this, getString(R.string.error_nfc,
|
||||
getString(R.string.error_nfc_terminated)), Style.WARN).show();
|
||||
// made a mistake sending data to the card, or the card is misbehaving.
|
||||
case 0x6A80: {
|
||||
Notify.create(this, getString(R.string.error_nfc_bad_data), Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
case 0x6700:
|
||||
{
|
||||
Notify.create(this, getString(R.string.error_nfc,
|
||||
getString(R.string.error_nfc_wrong_length)), Style.WARN).show();
|
||||
case 0x6883: {
|
||||
Notify.create(this, getString(R.string.error_nfc_chaining_error), Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
case 0x6982:
|
||||
{
|
||||
Notify.create(this, getString(R.string.error_nfc,
|
||||
getString(R.string.error_nfc_security_not_satisfied)), Style.WARN).show();
|
||||
case 0x6B00: {
|
||||
Notify.create(this, getString(R.string.error_nfc_header, "P1/P2"), Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
case 0x6983:
|
||||
{
|
||||
Notify.create(this, getString(R.string.error_nfc,
|
||||
getString(R.string.error_nfc_authentication_blocked)), Style.WARN).show();
|
||||
case 0x6D00: {
|
||||
Notify.create(this, getString(R.string.error_nfc_header, "INS"), Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
case 0x6985:
|
||||
{
|
||||
Notify.create(this, getString(R.string.error_nfc,
|
||||
getString(R.string.error_nfc_conditions_not_satisfied)), Style.WARN).show();
|
||||
case 0x6E00: {
|
||||
Notify.create(this, getString(R.string.error_nfc_header, "CLA"), Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
// These error conditions are more likely to be experienced by an end user.
|
||||
case 0x6285: {
|
||||
Notify.create(this, getString(R.string.error_nfc_terminated), Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
case 0x6700: {
|
||||
Notify.create(this, getString(R.string.error_nfc_wrong_length), Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
case 0x6982: {
|
||||
Notify.create(this, getString(R.string.error_nfc_security_not_satisfied),
|
||||
Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
case 0x6983: {
|
||||
Notify.create(this, getString(R.string.error_nfc_authentication_blocked),
|
||||
Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
case 0x6985: {
|
||||
Notify.create(this, getString(R.string.error_nfc_conditions_not_satisfied),
|
||||
Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
// 6A88 is "Not Found" in the spec, but Yubikey also returns 6A83 for this in some cases.
|
||||
case 0x6A88:
|
||||
case 0x6A83:
|
||||
{
|
||||
Notify.create(this, getString(R.string.error_nfc,
|
||||
getString(R.string.error_nfc_data_not_found)), Style.WARN).show();
|
||||
case 0x6A83: {
|
||||
Notify.create(this, getString(R.string.error_nfc_data_not_found), Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
// 6F00 is a JavaCard proprietary status code, SW_UNKNOWN, and usually represents an
|
||||
// unhandled exception on the smart card.
|
||||
case 0x6F00:
|
||||
{
|
||||
Notify.create(this, getString(R.string.error_nfc,
|
||||
getString(R.string.error_nfc_unknown)), Style.WARN).show();
|
||||
case 0x6F00: {
|
||||
Notify.create(this, getString(R.string.error_nfc_unknown), Style.WARN).show();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1309,14 +1309,17 @@
|
||||
<string name="btn_import">"Import"</string>
|
||||
<string name="snack_yubi_other">Different key stored on YubiKey!</string>
|
||||
<string name="error_nfc">"NFC Error: %s"</string>
|
||||
<string name="error_pin">"Incorrect PIN; %d tries remaining."</string>
|
||||
<string name="error_nfc_terminated">"Smart card in termination state"</string>
|
||||
<string name="error_nfc_wrong_length">"Wrong length for sent / received data"</string>
|
||||
<string name="error_nfc_conditions_not_satisfied">"Conditions of use not satisfied"</string>
|
||||
<string name="error_nfc_security_not_satisfied">"Security status not satisfied"</string>
|
||||
<string name="error_nfc_authentication_blocked">"PIN blocked after too many attempts"</string>
|
||||
<string name="error_nfc_data_not_found">"Key or object not found"</string>
|
||||
<string name="error_nfc_unknown">"Unknown Error"</string>
|
||||
<string name="error_pin">"NFC: Incorrect PIN; %d tries remaining."</string>
|
||||
<string name="error_nfc_terminated">"NFC: Smart card in termination state"</string>
|
||||
<string name="error_nfc_wrong_length">"NFC: Wrong length for sent / received data"</string>
|
||||
<string name="error_nfc_conditions_not_satisfied">"NFC: Conditions of use not satisfied"</string>
|
||||
<string name="error_nfc_security_not_satisfied">"NFC: Security status not satisfied"</string>
|
||||
<string name="error_nfc_authentication_blocked">"NFC: PIN blocked after too many attempts"</string>
|
||||
<string name="error_nfc_data_not_found">"NFC: Key or object not found"</string>
|
||||
<string name="error_nfc_unknown">"NFC: Unknown Error"</string>
|
||||
<string name="error_nfc_bad_data">"NFC: Card reported invalid data"</string>
|
||||
<string name="error_nfc_chaining_error">"NFC: Card expected last command in a chain"</string>
|
||||
<string name="error_nfc_header">"NFC: Card reported invalid %s byte"</string>
|
||||
<string name="error_pin_nodefault">Default PIN was rejected!</string>
|
||||
<string name="error_bluetooth_file">Error creating temporary file. Bluetooth sharing will fail.</string>
|
||||
<string name="snack_encrypt_filenames_on">"Filenames <b>are</b> encrypted."</string>
|
||||
|
Loading…
Reference in New Issue
Block a user