diff --git a/src/org/thialfihar/android/apg/Apg.java b/src/org/thialfihar/android/apg/Apg.java index 201f33550..c20a6f42f 100644 --- a/src/org/thialfihar/android/apg/Apg.java +++ b/src/org/thialfihar/android/apg/Apg.java @@ -1017,7 +1017,10 @@ public class Apg { keyIds.add(c.getInt(0)); } while (c.moveToNext()); } - c.close(); + + if (c != null) { + c.close(); + } return keyIds; } diff --git a/src/org/thialfihar/android/apg/CachedPassPhrase.java b/src/org/thialfihar/android/apg/CachedPassPhrase.java index e7566220e..74248aee3 100644 --- a/src/org/thialfihar/android/apg/CachedPassPhrase.java +++ b/src/org/thialfihar/android/apg/CachedPassPhrase.java @@ -10,6 +10,12 @@ public class CachedPassPhrase { this.passPhrase = passPhrase; } + public int hashCode() { + int hc1 = (int)(this.timestamp & 0xffffffff); + int hc2 = (this.passPhrase == null ? 0 : this.passPhrase.hashCode()); + return (hc1 + hc2) * hc2 + hc1; + } + public boolean equals(Object other) { if (!(other instanceof CachedPassPhrase)) { return false; diff --git a/src/org/thialfihar/android/apg/EncryptActivity.java b/src/org/thialfihar/android/apg/EncryptActivity.java index b31ba3468..3c6e3ccb8 100644 --- a/src/org/thialfihar/android/apg/EncryptActivity.java +++ b/src/org/thialfihar/android/apg/EncryptActivity.java @@ -755,6 +755,7 @@ public class EncryptActivity extends BaseActivity { EncryptActivity.this. startActivity(Intent.createChooser(emailIntent, getString(R.string.title_sendEmail))); + break; } case Id.target.file: { diff --git a/src/org/thialfihar/android/apg/provider/Database.java b/src/org/thialfihar/android/apg/provider/Database.java index 55736e8b4..6fee3888b 100644 --- a/src/org/thialfihar/android/apg/provider/Database.java +++ b/src/org/thialfihar/android/apg/provider/Database.java @@ -200,7 +200,10 @@ public class Database extends SQLiteOpenHelper { } } while (cursor.moveToNext()); } - cursor.close(); + + if (cursor != null) { + cursor.close(); + } break; } @@ -427,7 +430,10 @@ public class Database extends SQLiteOpenHelper { rowId = mDb.insert(KeyRings.TABLE_NAME, KeyRings.WHO_ID, values); mStatus = Id.return_value.ok; } - c.close(); + + if (c != null) { + c.close(); + } return rowId; } @@ -465,11 +471,14 @@ public class Database extends SQLiteOpenHelper { if (c != null && c.moveToFirst()) { rowId = c.getLong(0); mDb.update(UserIds.TABLE_NAME, values, - UserIds._ID + " = ?", new String[] { "" + rowId }); + UserIds._ID + " = ?", new String[] { "" + rowId }); } else { rowId = mDb.insert(UserIds.TABLE_NAME, UserIds.USER_ID, values); } - c.close(); + + if (c != null) { + c.close(); + } return rowId; } @@ -500,7 +509,10 @@ public class Database extends SQLiteOpenHelper { } } } - c.close(); + + if (c != null) { + c.close(); + } return keyRing; } @@ -522,7 +534,10 @@ public class Database extends SQLiteOpenHelper { if (c != null && c.moveToFirst()) { data = c.getBlob(0); } - c.close(); + + if (c != null) { + c.close(); + } return data; } @@ -539,7 +554,10 @@ public class Database extends SQLiteOpenHelper { if (c != null && c.moveToFirst()) { data = c.getBlob(0); } - c.close(); + + if (c != null) { + c.close(); + } return data; } @@ -561,7 +579,10 @@ public class Database extends SQLiteOpenHelper { deleteKey(keyId); } while (c.moveToNext()); } - c.close(); + + if (c != null) { + c.close(); + } mDb.setTransactionSuccessful(); mDb.endTransaction();