aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/providers/contacts/CallLogDatabaseHelper.java82
-rw-r--r--tests/src/com/android/providers/contacts/CallLogMigrationTest.java45
2 files changed, 0 insertions, 127 deletions
diff --git a/src/com/android/providers/contacts/CallLogDatabaseHelper.java b/src/com/android/providers/contacts/CallLogDatabaseHelper.java
index c5052d70..73480994 100644
--- a/src/com/android/providers/contacts/CallLogDatabaseHelper.java
+++ b/src/com/android/providers/contacts/CallLogDatabaseHelper.java
@@ -203,7 +203,6 @@ public class CallLogDatabaseHelper {
VoicemailContract.Status.SOURCE_TYPE + " TEXT" +
");");
- migrateFromLegacyTables(db);
}
@Override
@@ -532,87 +531,6 @@ public class CallLogDatabaseHelper {
mPhoneAccountHandleMigrationUtils.migrateIccIdToSubId(db);
}
- /**
- * Perform the migration from the contacts2.db (of the latest version) to the current calllog/
- * voicemail status tables.
- */
- private void migrateFromLegacyTables(SQLiteDatabase calllog) {
- final SQLiteDatabase contacts = getContactsWritableDatabaseForMigration();
-
- if (contacts == null) {
- Log.w(TAG, "Contacts DB == null, skipping migration. (running tests?)");
- return;
- }
- if (DEBUG) {
- Log.d(TAG, "migrateFromLegacyTables");
- }
-
- if ("1".equals(PropertyUtils.getProperty(calllog, DbProperties.DATA_MIGRATED, ""))) {
- return;
- }
-
- Log.i(TAG, "Migrating from old tables...");
-
- contacts.beginTransaction();
- try {
- if (!tableExists(contacts, LegacyConstants.CALLS_LEGACY)
- || !tableExists(contacts, LegacyConstants.VOICEMAIL_STATUS_LEGACY)) {
- // This is fine on new devices. (or after a "clear data".)
- Log.i(TAG, "Source tables don't exist.");
- return;
- }
- calllog.beginTransaction();
- try {
-
- final ContentValues cv = new ContentValues();
-
- try (Cursor source = contacts.rawQuery(
- "SELECT * FROM " + LegacyConstants.CALLS_LEGACY, null)) {
- while (source.moveToNext()) {
- cv.clear();
-
- DatabaseUtils.cursorRowToContentValues(source, cv);
-
- calllog.insertOrThrow(Tables.CALLS, null, cv);
- }
- }
-
- try (Cursor source = contacts.rawQuery("SELECT * FROM " +
- LegacyConstants.VOICEMAIL_STATUS_LEGACY, null)) {
- while (source.moveToNext()) {
- cv.clear();
-
- DatabaseUtils.cursorRowToContentValues(source, cv);
-
- calllog.insertOrThrow(Tables.VOICEMAIL_STATUS, null, cv);
- }
- }
-
- contacts.execSQL("DROP TABLE " + LegacyConstants.CALLS_LEGACY + ";");
- contacts.execSQL("DROP TABLE " + LegacyConstants.VOICEMAIL_STATUS_LEGACY + ";");
-
- // Also copy the last sync time.
- PropertyUtils.setProperty(calllog, DbProperties.CALL_LOG_LAST_SYNCED,
- PropertyUtils.getProperty(contacts,
- LegacyConstants.CALL_LOG_LAST_SYNCED_LEGACY, null));
-
- Log.i(TAG, "Migration completed.");
-
- calllog.setTransactionSuccessful();
- } finally {
- calllog.endTransaction();
- }
-
- contacts.setTransactionSuccessful();
- } catch (RuntimeException e) {
- // We don't want to be stuck here, so we just swallow exceptions...
- Log.w(TAG, "Exception caught during migration", e);
- } finally {
- contacts.endTransaction();
- }
- PropertyUtils.setProperty(calllog, DbProperties.DATA_MIGRATED, "1");
- }
-
@VisibleForTesting
static boolean tableExists(SQLiteDatabase db, String table) {
return DatabaseUtils.longForQuery(db,
diff --git a/tests/src/com/android/providers/contacts/CallLogMigrationTest.java b/tests/src/com/android/providers/contacts/CallLogMigrationTest.java
index d1e80035..74e5d0a5 100644
--- a/tests/src/com/android/providers/contacts/CallLogMigrationTest.java
+++ b/tests/src/com/android/providers/contacts/CallLogMigrationTest.java
@@ -93,51 +93,6 @@ public class CallLogMigrationTest extends FixedAndroidTestCase {
+ " = 1", null));
}
- public void testMigration() throws IOException {
- final File sourceDbFile = new File(getTestContext().getCacheDir(), "contacts2src.db");
- writeAssetFileToDisk("calllogmigration/contacts2.db", sourceDbFile);
-
- try (final SQLiteDatabase sourceDb = SQLiteDatabase.openDatabase(
- sourceDbFile.getAbsolutePath(), /* cursorFactory=*/ null,
- SQLiteDatabase.OPEN_READWRITE)) {
-
- // Make sure the source tables exist initially.
- assertTrue(CallLogDatabaseHelper.tableExists(sourceDb, "calls"));
- assertTrue(CallLogDatabaseHelper.tableExists(sourceDb, "voicemail_status"));
- // Create the calllog DB to perform the migration.
- final CallLogDatabaseHelperTestable dbh =
- new CallLogDatabaseHelperTestable(getTestContext(), sourceDb);
-
- final SQLiteDatabase db = dbh.getReadableDatabase();
-
- // Check the content:
- // Note what we worry here is basically insertion error due to additional constraints,
- // renames, etc. So here, we just check the number of rows and don't check the content.
- assertEquals(3, DatabaseUtils.longForQuery(db, "select count(*) from " +
- CallLogDatabaseHelper.Tables.CALLS, null));
-
- assertEquals(2, DatabaseUtils.longForQuery(db, "select count(*) from " +
- CallLogDatabaseHelper.Tables.VOICEMAIL_STATUS, null));
-
- assertEquals("123456",
- dbh.getProperty(CallLogDatabaseHelper.DbProperties.CALL_LOG_LAST_SYNCED, ""));
-
- // Test onCreate() step, check each entry with TelephonyComponent in the CALLS has
- // a new coloumn of Calls.IS_PHONE_ACCOUNT_MIGRATION_PENDING.
- assertEquals(3,
- DatabaseUtils.longForQuery(db, "select count(*) from "
- + CallLogDatabaseHelper.Tables.CALLS + " where "
- + Calls.IS_PHONE_ACCOUNT_MIGRATION_PENDING + " = 0", null));
-
- // Also, the source table should have been removed.
- assertFalse(CallLogDatabaseHelper.tableExists(sourceDb, "calls"));
- assertFalse(CallLogDatabaseHelper.tableExists(sourceDb, "voicemail_status"));
-
- assertEquals("1",
- dbh.getProperty(CallLogDatabaseHelper.DbProperties.DATA_MIGRATED, ""));
- }
- }
-
public static final class InMemoryCallLogProviderDbHelperV1 extends SQLiteOpenHelper {
public InMemoryCallLogProviderDbHelperV1(Context context, int databaseVersion) {
super(context,