fix some crashes
This commit is contained in:
parent
4aa24e84c4
commit
be82ac5633
19 changed files with 182 additions and 70 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
try (Cursor cursor = db.query(Account.TABLENAME, null, null, null, null,
|
||||
null, null)) {
|
||||
while (cursor.moveToNext()) {
|
||||
list.add(Account.fromCursor(cursor));
|
||||
}
|
||||
cursor.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4582,6 +4582,7 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
|
||||
public void clearConversationHistory(final Conversation conversation) {
|
||||
try {
|
||||
final long clearDate;
|
||||
final String reference;
|
||||
if (conversation.countMessages() > 0) {
|
||||
|
@ -4600,6 +4601,9 @@ public class XmppConnectionService extends Service {
|
|||
databaseBackend.updateConversation(conversation);
|
||||
};
|
||||
mDatabaseWriterExecutor.execute(runnable);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sendBlockRequest(final Blockable blockable, boolean reportSpam) {
|
||||
|
@ -4845,6 +4849,7 @@ 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) {
|
||||
try {
|
||||
Calendar now = Calendar.getInstance();
|
||||
now.setTimeInMillis(System.currentTimeMillis());
|
||||
Calendar timetoexport = Calendar.getInstance();
|
||||
|
@ -4861,6 +4866,9 @@ public class XmppConnectionService extends Service {
|
|||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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…
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Reference in a new issue