use of net.zetetic.database.sqlcipher.SQLiteStatement in project Signal-Android by WhisperSystems.
the class SmsMigrator method migrateConversation.
private static void migrateConversation(Context context, SmsMigrationProgressListener listener, ProgressDescription progress, long theirThreadId, long ourThreadId) {
MessageDatabase ourSmsDatabase = SignalDatabase.sms();
Cursor cursor = null;
SQLiteStatement statement = null;
try {
Uri uri = Uri.parse("content://sms/conversations/" + theirThreadId);
try {
cursor = context.getContentResolver().query(uri, null, null, null, null);
} catch (SQLiteException e) {
// / Work around for weird sony-specific (?) bug: #4309
Log.w(TAG, e);
return;
}
SQLiteDatabase transaction = ourSmsDatabase.beginTransaction();
statement = ourSmsDatabase.createInsertStatement(transaction);
while (cursor != null && cursor.moveToNext()) {
int addressColumn = cursor.getColumnIndexOrThrow(SystemColumns.ADDRESS);
int typeColumn = cursor.getColumnIndex(SmsDatabase.TYPE);
if (!cursor.isNull(addressColumn) && (cursor.isNull(typeColumn) || isAppropriateTypeForMigration(cursor, typeColumn))) {
getContentValuesForRow(context, cursor, ourThreadId, statement);
statement.execute();
}
listener.progressUpdate(new ProgressDescription(progress, cursor.getCount(), cursor.getPosition()));
}
ourSmsDatabase.endTransaction(transaction);
SignalDatabase.threads().update(ourThreadId, true);
SignalDatabase.threads().setLastScrolled(ourThreadId, 0);
SignalDatabase.threads().notifyConversationListeners(ourThreadId);
} finally {
if (statement != null)
statement.close();
if (cursor != null)
cursor.close();
}
}
Aggregations