diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-09-03 20:31:32 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-09-03 20:31:32 +0200 |
commit | be82ac563323ed83427b3ad692650c8283ce5338 (patch) | |
tree | 53dfcd82ec65e0b523c3790c3b57539a2aa0442b | |
parent | 4aa24e84c49348f8d96c273f77a636557dbb40a2 (diff) |
fix some crashes
19 files changed, 183 insertions, 71 deletions
diff --git a/src/main/java/de/pixart/messenger/android/JabberIdContact.java b/src/main/java/de/pixart/messenger/android/JabberIdContact.java index bfafb54c9..322fc2ea4 100644 --- a/src/main/java/de/pixart/messenger/android/JabberIdContact.java +++ b/src/main/java/de/pixart/messenger/android/JabberIdContact.java @@ -23,7 +23,9 @@ public class JabberIdContact extends AbstractPhoneContact { super(cursor); try { this.jid = Jid.of(cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Im.DATA))); - } catch (IllegalArgumentException | NullPointerException e) { + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException(e); + } catch (NullPointerException e) { throw new IllegalArgumentException(e); } } diff --git a/src/main/java/de/pixart/messenger/crypto/OtrService.java b/src/main/java/de/pixart/messenger/crypto/OtrService.java index f355ac348..cf41ec26f 100644 --- a/src/main/java/de/pixart/messenger/crypto/OtrService.java +++ b/src/main/java/de/pixart/messenger/crypto/OtrService.java @@ -95,7 +95,9 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost { this.account.setKey("otr_p", privateKeySpec.getP().toString(16)); this.account.setKey("otr_q", privateKeySpec.getQ().toString(16)); this.account.setKey("otr_y", publicKeySpec.getY().toString(16)); - } catch (final NoSuchAlgorithmException | InvalidKeySpecException e) { + } catch (final NoSuchAlgorithmException e) { + e.printStackTrace(); + } catch (final InvalidKeySpecException e) { e.printStackTrace(); } diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java index 3b3fda228..f45668c49 100644 --- a/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java +++ b/src/main/java/de/pixart/messenger/crypto/axolotl/AxolotlService.java @@ -1115,7 +1115,18 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { callback.onSessionBuildSuccessful(); } } - } catch (UntrustedIdentityException | InvalidKeyException e) { + } catch (UntrustedIdentityException e) { + Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Error building session for " + address + ": " + + e.getClass().getName() + ", " + e.getMessage()); + fetchStatusMap.put(address, FetchStatus.ERROR); + finishBuildingSessionsFromPEP(address); + if (oneOfOurs && cleanedOwnDeviceIds.add(address.getDeviceId())) { + removeFromDeviceAnnouncement(address.getDeviceId()); + } + if (callback != null) { + callback.onSessionBuildFailed(); + } + } catch (InvalidKeyException e) { Log.e(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Error building session for " + address + ": " + e.getClass().getName() + ", " + e.getMessage()); fetchStatusMap.put(address, FetchStatus.ERROR); diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java index 60aa1e357..c89ad2172 100644 --- a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java +++ b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlMessage.java @@ -189,9 +189,19 @@ public class XmppAxolotlMessage { System.arraycopy(this.innerKey, 0, authtagPlusInnerKey, 0, this.innerKey.length); this.ciphertext = ciphertext; } - } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException - | IllegalBlockSizeException | BadPaddingException | NoSuchProviderException - | InvalidAlgorithmParameterException e) { + } catch (NoSuchAlgorithmException e) { + throw new CryptoFailedException(e); + } catch (NoSuchPaddingException e) { + throw new CryptoFailedException(e); + } catch (InvalidKeyException e) { + throw new CryptoFailedException(e); + } catch (IllegalBlockSizeException e) { + throw new CryptoFailedException(e); + } catch (BadPaddingException e) { + throw new CryptoFailedException(e); + } catch (NoSuchProviderException e) { + throw new CryptoFailedException(e); + } catch (InvalidAlgorithmParameterException e) { throw new CryptoFailedException(e); } } @@ -308,9 +318,19 @@ public class XmppAxolotlMessage { String plaintext = new String(cipher.doFinal(ciphertext)); plaintextMessage = new XmppAxolotlPlaintextMessage(Config.OMEMO_PADDING ? plaintext.trim() : plaintext, session.getFingerprint()); - } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException - | InvalidAlgorithmParameterException | IllegalBlockSizeException - | BadPaddingException | NoSuchProviderException e) { + } catch (NoSuchAlgorithmException e) { + throw new CryptoFailedException(e); + } catch (NoSuchPaddingException e) { + throw new CryptoFailedException(e); + } catch (InvalidKeyException e) { + throw new CryptoFailedException(e); + } catch (InvalidAlgorithmParameterException e) { + throw new CryptoFailedException(e); + } catch (IllegalBlockSizeException e) { + throw new CryptoFailedException(e); + } catch (BadPaddingException e) { + throw new CryptoFailedException(e); + } catch (NoSuchProviderException e) { throw new CryptoFailedException(e); } } diff --git a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java index 71e20676e..f7a9c0a6f 100644 --- a/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java +++ b/src/main/java/de/pixart/messenger/crypto/axolotl/XmppAxolotlSession.java @@ -115,7 +115,13 @@ public class XmppAxolotlSession implements Comparable<XmppAxolotlSession> { SignalMessage signalMessage = new SignalMessage(encryptedKey.key); try { plaintext = cipher.decrypt(signalMessage); - } catch (InvalidMessageException | NoSessionException e) { + } catch (InvalidMessageException e) { + if (iterator.hasNext()) { + Log.w(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring crypto exception because possible keys left to try", e); + continue; + } + throw new BrokenSessionException(this.remoteAddress, e); + } catch (NoSessionException e) { if (iterator.hasNext()) { Log.w(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring crypto exception because possible keys left to try", e); continue; diff --git a/src/main/java/de/pixart/messenger/crypto/sasl/ScramMechanism.java b/src/main/java/de/pixart/messenger/crypto/sasl/ScramMechanism.java index e1a153ef6..4a6fa42e5 100644 --- a/src/main/java/de/pixart/messenger/crypto/sasl/ScramMechanism.java +++ b/src/main/java/de/pixart/messenger/crypto/sasl/ScramMechanism.java @@ -43,7 +43,9 @@ abstract class ScramMechanism extends SaslMechanism { clientKey = hmac(saltedPassword, CLIENT_KEY_BYTES); return new KeyPair(clientKey, serverKey); - } catch (final InvalidKeyException | NumberFormatException e) { + } catch (final InvalidKeyException e) { + return null; + } catch (final NumberFormatException e) { return null; } } diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index 943d7f45e..a43899663 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -737,7 +737,9 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } DSAPublicKey remotePubKey = (DSAPublicKey) getOtrSession().getRemotePublicKey(); this.otrFingerprint = getAccount().getOtrService().getFingerprint(remotePubKey).toLowerCase(Locale.US); - } catch (final OtrCryptoException | UnsupportedOperationException ignored) { + } catch (final OtrCryptoException ignored) { + return null; + } catch (final UnsupportedOperationException ignored) { return null; } } diff --git a/src/main/java/de/pixart/messenger/entities/ReadByMarker.java b/src/main/java/de/pixart/messenger/entities/ReadByMarker.java index 86057c680..113c418ba 100644 --- a/src/main/java/de/pixart/messenger/entities/ReadByMarker.java +++ b/src/main/java/de/pixart/messenger/entities/ReadByMarker.java @@ -111,12 +111,16 @@ public class ReadByMarker { ReadByMarker marker = new ReadByMarker(); try { marker.fullJid = Jid.of(jsonObject.getString("fullJid")); - } catch (JSONException | IllegalArgumentException e) { + } catch (JSONException e) { + marker.fullJid = null; + } catch (IllegalArgumentException e) { marker.fullJid = null; } try { marker.realJid = Jid.of(jsonObject.getString("realJid")); - } catch (JSONException | IllegalArgumentException e) { + } catch (JSONException e) { + marker.realJid = null; + } catch (IllegalArgumentException e) { marker.realJid = null; } return marker; @@ -125,7 +129,9 @@ public class ReadByMarker { public static Set<ReadByMarker> fromJsonString(String json) { try { return fromJson(new JSONArray(json)); - } catch (JSONException | NullPointerException e) { + } catch (JSONException e) { + return new HashSet<>(); + } catch (NullPointerException e) { return new HashSet<>(); } } diff --git a/src/main/java/de/pixart/messenger/http/HttpConnectionManager.java b/src/main/java/de/pixart/messenger/http/HttpConnectionManager.java index e6e1a3df5..5d8a342d7 100644 --- a/src/main/java/de/pixart/messenger/http/HttpConnectionManager.java +++ b/src/main/java/de/pixart/messenger/http/HttpConnectionManager.java @@ -104,7 +104,8 @@ public class HttpConnectionManager extends AbstractConnectionManager { final SSLSocketFactory sf = new TLSSocketFactory(new X509TrustManager[]{trustManager}, mXmppConnectionService.getRNG()); connection.setSSLSocketFactory(sf); connection.setHostnameVerifier(hostnameVerifier); - } catch (final KeyManagementException | NoSuchAlgorithmException ignored) { + } catch (final KeyManagementException ignored) { + } catch (final NoSuchAlgorithmException ignored) { } } }
\ No newline at end of file diff --git a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java index 39249c655..7d58cde07 100644 --- a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java +++ b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java @@ -406,7 +406,9 @@ public class HttpDownloadConnection implements Transferable { long reportedContentLengthOnGet; try { reportedContentLengthOnGet = Long.parseLong(connection.getHeaderField("Content-Length")); - } catch (NumberFormatException | NullPointerException e) { + } catch (NumberFormatException e) { + reportedContentLengthOnGet = 0; + } catch (NullPointerException e) { reportedContentLengthOnGet = 0; } if (expected != reportedContentLengthOnGet) { @@ -437,7 +439,10 @@ public class HttpDownloadConnection implements Transferable { } catch (IOException e) { throw new FileWriterException(); } - } catch (CancellationException | IOException e) { + } catch (CancellationException e) { + Log.d(Config.LOGTAG, "http download failed " + e.getMessage()); + throw e; + } catch (IOException e) { Log.d(Config.LOGTAG, "http download failed " + e.getMessage()); throw e; } finally { diff --git a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java index afffa388f..e9f7c0576 100644 --- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java @@ -1009,12 +1009,14 @@ public class DatabaseBackend extends SQLiteOpenHelper { private List<Account> getAccounts(SQLiteDatabase db) { List<Account> list = new ArrayList<>(); - Cursor cursor = db.query(Account.TABLENAME, null, null, null, null, - null, null); - while (cursor.moveToNext()) { - list.add(Account.fromCursor(cursor)); + try (Cursor cursor = db.query(Account.TABLENAME, null, null, null, null, + null, null)) { + while (cursor.moveToNext()) { + list.add(Account.fromCursor(cursor)); + } + } catch (Exception e) { + e.printStackTrace(); } - cursor.close(); return list; } diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index 962496dcb..235547c1d 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -719,7 +719,10 @@ public class FileBackend { frame = metadataRetriever.getFrameAtTime(0); metadataRetriever.release(); frame = resize(frame, size); - } catch (IOException | RuntimeException e) { + } catch (IOException e) { + frame = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); + frame.eraseColor(0xff000000); + } catch (RuntimeException e) { frame = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); frame.eraseColor(0xff000000); } @@ -880,7 +883,9 @@ public class FileBackend { avatar.width = options.outWidth; avatar.type = options.outMimeType; return avatar; - } catch (NoSuchAlgorithmException | IOException e) { + } catch (NoSuchAlgorithmException e) { + return null; + } catch (IOException e) { return null; } finally { close(is); @@ -934,7 +939,11 @@ public class FileBackend { return false; } avatar.size = bytes.length; - } catch (IllegalArgumentException | IOException | NoSuchAlgorithmException e) { + } catch (IllegalArgumentException e) { + return false; + } catch (IOException e) { + return false; + } catch (NoSuchAlgorithmException e) { return false; } finally { close(os); @@ -970,7 +979,10 @@ public class FileBackend { input = rotate(input, getRotation(image)); return cropCenterSquare(input, size); } - } catch (FileNotFoundException | SecurityException e) { + } catch (FileNotFoundException e) { + Log.d(Config.LOGTAG, "unable to open file " + image.toString(), e); + return null; + } catch (SecurityException e) { Log.d(Config.LOGTAG, "unable to open file " + image.toString(), e); return null; } finally { diff --git a/src/main/java/de/pixart/messenger/services/ExportBackupService.java b/src/main/java/de/pixart/messenger/services/ExportBackupService.java index 7640c6ea0..64595a961 100644 --- a/src/main/java/de/pixart/messenger/services/ExportBackupService.java +++ b/src/main/java/de/pixart/messenger/services/ExportBackupService.java @@ -160,7 +160,9 @@ public class ExportBackupService extends Service { try { SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1"); return factory.generateSecret(new PBEKeySpec(password.toCharArray(), salt, 1024, 128)).getEncoded(); - } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { + } catch (NoSuchAlgorithmException e) { + throw new AssertionError(e); + } catch (InvalidKeySpecException e) { throw new AssertionError(e); } } diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 8fc39b97b..6f67d7bc0 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -4582,24 +4582,28 @@ public class XmppConnectionService extends Service { } public void clearConversationHistory(final Conversation conversation) { - final long clearDate; - final String reference; - if (conversation.countMessages() > 0) { - Message latestMessage = conversation.getLatestMessage(); - clearDate = latestMessage.getTimeSent() + 1000; - reference = latestMessage.getServerMsgId(); - } else { - clearDate = System.currentTimeMillis(); - reference = null; + try { + final long clearDate; + final String reference; + if (conversation.countMessages() > 0) { + Message latestMessage = conversation.getLatestMessage(); + clearDate = latestMessage.getTimeSent() + 1000; + reference = latestMessage.getServerMsgId(); + } else { + clearDate = System.currentTimeMillis(); + reference = null; + } + conversation.clearMessages(); + conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam + conversation.setLastClearHistory(clearDate, reference); + Runnable runnable = () -> { + databaseBackend.deleteMessagesInConversation(conversation); + databaseBackend.updateConversation(conversation); + }; + mDatabaseWriterExecutor.execute(runnable); + } catch (Exception e) { + e.printStackTrace(); } - conversation.clearMessages(); - conversation.setHasMessagesLeftOnServer(false); //avoid messages getting loaded through mam - conversation.setLastClearHistory(clearDate, reference); - Runnable runnable = () -> { - databaseBackend.deleteMessagesInConversation(conversation); - databaseBackend.updateConversation(conversation); - }; - mDatabaseWriterExecutor.execute(runnable); } public boolean sendBlockRequest(final Blockable blockable, boolean reportSpam) { @@ -4845,22 +4849,26 @@ public class XmppConnectionService extends Service { //start export log service every day at given time if (Config.ExportLogs) { if (Config.ExportLogs_Hour >= 0 && Config.ExportLogs_Hour <= 23 && Config.ExportLogs_Minute >= 0 && Config.ExportLogs_Minute <= 59) { - Calendar now = Calendar.getInstance(); - now.setTimeInMillis(System.currentTimeMillis()); - Calendar timetoexport = Calendar.getInstance(); - timetoexport.setTimeInMillis(System.currentTimeMillis()); - Intent intent = new Intent(this, AlarmReceiver.class); - intent.setAction("exportlogs"); - Log.d(Config.LOGTAG, "Schedule automatic export logs at " + Config.ExportLogs_Hour + ":" + Config.ExportLogs_Minute); - timetoexport.set(Calendar.HOUR_OF_DAY, Config.ExportLogs_Hour); - timetoexport.set(Calendar.MINUTE, Config.ExportLogs_Minute); - if (timetoexport.before(now)) { - SimpleDateFormat newDate = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US); - timetoexport.add(Calendar.DAY_OF_YEAR, 1); //DATE or DAY_OF_MONTH - Log.d(Config.LOGTAG, "Schedule automatic export logs, for today, the export time is in the past, scheduling first export run for the next day (" + newDate.format(timetoexport.getTimeInMillis()) + ")."); - } - final PendingIntent ScheduleExportIntent = PendingIntent.getBroadcast(this, AlarmReceiver.SCHEDULE_ALARM_REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT); - ((AlarmManager) getSystemService(ALARM_SERVICE)).setInexactRepeating(AlarmManager.RTC_WAKEUP, timetoexport.getTimeInMillis(), AlarmManager.INTERVAL_DAY, ScheduleExportIntent); + try { + Calendar now = Calendar.getInstance(); + now.setTimeInMillis(System.currentTimeMillis()); + Calendar timetoexport = Calendar.getInstance(); + timetoexport.setTimeInMillis(System.currentTimeMillis()); + Intent intent = new Intent(this, AlarmReceiver.class); + intent.setAction("exportlogs"); + Log.d(Config.LOGTAG, "Schedule automatic export logs at " + Config.ExportLogs_Hour + ":" + Config.ExportLogs_Minute); + timetoexport.set(Calendar.HOUR_OF_DAY, Config.ExportLogs_Hour); + timetoexport.set(Calendar.MINUTE, Config.ExportLogs_Minute); + if (timetoexport.before(now)) { + SimpleDateFormat newDate = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US); + timetoexport.add(Calendar.DAY_OF_YEAR, 1); //DATE or DAY_OF_MONTH + Log.d(Config.LOGTAG, "Schedule automatic export logs, for today, the export time is in the past, scheduling first export run for the next day (" + newDate.format(timetoexport.getTimeInMillis()) + ")."); + } + final PendingIntent ScheduleExportIntent = PendingIntent.getBroadcast(this, AlarmReceiver.SCHEDULE_ALARM_REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT); + ((AlarmManager) getSystemService(ALARM_SERVICE)).setInexactRepeating(AlarmManager.RTC_WAKEUP, timetoexport.getTimeInMillis(), AlarmManager.INTERVAL_DAY, ScheduleExportIntent); + } catch (Exception e) { + e.printStackTrace(); + } } } } diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java index 980ce5bce..7447ac96e 100644 --- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java +++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java @@ -179,7 +179,16 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } else { jid = Jid.of(binding.accountJid.getText().toString()); } - } catch (final NullPointerException | IllegalArgumentException e) { + } catch (final NullPointerException e) { + if (mUsernameMode) { + binding.accountJidLayout.setError(getString(R.string.invalid_username)); + } else { + binding.accountJidLayout.setError(getString(R.string.invalid_jid)); + } + binding.accountJid.requestFocus(); + removeErrorsOnAllBut(binding.accountJidLayout); + return; + } catch (final IllegalArgumentException e) { if (mUsernameMode) { binding.accountJidLayout.setError(getString(R.string.invalid_username)); } else { @@ -724,7 +733,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat } else if (intent != null) { try { this.jidToEdit = Jid.of(intent.getStringExtra("jid")); - } catch (final IllegalArgumentException | NullPointerException ignored) { + } catch (final IllegalArgumentException ignored) { + this.jidToEdit = null; + } catch (final NullPointerException ignored) { this.jidToEdit = null; } if (jidToEdit != null && intent.getData() != null && intent.getBooleanExtra("scanned", false)) { diff --git a/src/main/java/de/pixart/messenger/utils/Compatibility.java b/src/main/java/de/pixart/messenger/utils/Compatibility.java index 728c6298a..a57835101 100644 --- a/src/main/java/de/pixart/messenger/utils/Compatibility.java +++ b/src/main/java/de/pixart/messenger/utils/Compatibility.java @@ -75,7 +75,9 @@ public class Compatibility { final PackageManager packageManager = context.getPackageManager(); final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); return applicationInfo == null || applicationInfo.targetSdkVersion >= 24; - } catch (PackageManager.NameNotFoundException | RuntimeException e) { + } catch (PackageManager.NameNotFoundException e) { + return true; //when in doubt… + } catch (RuntimeException e) { return true; //when in doubt… } } diff --git a/src/main/java/de/pixart/messenger/utils/PhoneHelper.java b/src/main/java/de/pixart/messenger/utils/PhoneHelper.java index 86a9bed1a..a9468cfbe 100644 --- a/src/main/java/de/pixart/messenger/utils/PhoneHelper.java +++ b/src/main/java/de/pixart/messenger/utils/PhoneHelper.java @@ -42,7 +42,9 @@ public class PhoneHelper { if (packageName != null) { try { return context.getPackageManager().getPackageInfo(packageName, 0).versionName; - } catch (final PackageManager.NameNotFoundException | RuntimeException e) { + } catch (final PackageManager.NameNotFoundException e) { + return "unknown"; + } catch (final RuntimeException e) { return "unknown"; } } else { diff --git a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java index 9ff9e8bce..9f0d9a0fe 100644 --- a/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java +++ b/src/main/java/de/pixart/messenger/xmpp/XmppConnection.java @@ -408,11 +408,17 @@ public class XmppConnection implements Runnable { this.changeStatus(Account.State.MISSING_INTERNET_PERMISSION); } catch (final StateChangingException e) { this.changeStatus(e.state); - } catch (final UnknownHostException | ConnectException e) { + } catch (final UnknownHostException e) { + this.changeStatus(Account.State.SERVER_NOT_FOUND); + } catch (final ConnectException e) { this.changeStatus(Account.State.SERVER_NOT_FOUND); } catch (final SocksSocketFactory.SocksProxyNotFoundException e) { this.changeStatus(Account.State.TOR_NOT_AVAILABLE); - } catch (final IOException | XmlPullParserException e) { + } catch (final IOException e) { + Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": " + e.getMessage()); + this.changeStatus(Account.State.OFFLINE); + this.attempt = Math.max(0, this.attempt - 1); + } catch (final XmlPullParserException e) { Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": " + e.getMessage()); this.changeStatus(Account.State.OFFLINE); this.attempt = Math.max(0, this.attempt - 1); @@ -640,7 +646,9 @@ public class XmppConnection implements Runnable { if (acknowledgedMessages) { mXmppConnectionService.updateConversationUi(); } - } catch (NumberFormatException | NullPointerException e) { + } catch (NumberFormatException e) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": server send ack without sequence number"); + } catch (NullPointerException e) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": server send ack without sequence number"); } } else if (nextTag.isStart("failed")) { @@ -655,7 +663,9 @@ public class XmppConnection implements Runnable { if (acknowledgedMessages) { mXmppConnectionService.updateConversationUi(); } - } catch (NumberFormatException | NullPointerException e) { + } catch (NumberFormatException e) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": resumption failed"); + } catch (NullPointerException e) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": resumption failed"); } resetStreamId(); @@ -859,7 +869,10 @@ public class XmppConnection implements Runnable { throw new StateChangingException(Account.State.STREAM_OPENING_ERROR); } sslSocket.close(); - } catch (final NoSuchAlgorithmException | KeyManagementException e1) { + } catch (final NoSuchAlgorithmException e1) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": TLS certificate verification failed"); + throw new StateChangingException(Account.State.TLS_ERROR); + } catch (final KeyManagementException e1) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": TLS certificate verification failed"); throw new StateChangingException(Account.State.TLS_ERROR); } diff --git a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java index 72a9142ec..8b8a16ac9 100644 --- a/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java +++ b/src/main/java/de/pixart/messenger/xmpp/jingle/JingleInbandTransport.java @@ -108,7 +108,10 @@ public class JingleInbandTransport extends JingleTransport { return; } this.remainingSize = this.fileSize = file.getExpectedSize(); - } catch (final NoSuchAlgorithmException | IOException e) { + } catch (final NoSuchAlgorithmException e) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + " " + e.getMessage()); + callback.onFileTransferAborted(); + } catch (final IOException e) { Log.d(Config.LOGTAG, account.getJid().asBareJid() + " " + e.getMessage()); callback.onFileTransferAborted(); } |