diff --git a/app/src/androidTest/java/org/thoughtcrime/securesms/backup/v2/ImportExportTest.kt b/app/src/androidTest/java/org/thoughtcrime/securesms/backup/v2/ImportExportTest.kt index 88e0c531e1..c56c04f2fb 100644 --- a/app/src/androidTest/java/org/thoughtcrime/securesms/backup/v2/ImportExportTest.kt +++ b/app/src/androidTest/java/org/thoughtcrime/securesms/backup/v2/ImportExportTest.kt @@ -333,6 +333,99 @@ class ImportExportTest { ) } + @Test + fun calls() { + val individualCalls = ArrayList() + val groupCalls = ArrayList() + val states = arrayOf(Call.State.MISSED, Call.State.COMPLETED, Call.State.DECLINED_BY_USER, Call.State.DECLINED_BY_NOTIFICATION_PROFILE) + val types = arrayOf(Call.Type.VIDEO_CALL, Call.Type.AD_HOC_CALL, Call.Type.AUDIO_CALL) + var id = 1L + var timestamp = 12345L + + for (state in states) { + for (type in types) { + individualCalls.add( + Call( + callId = id++, + conversationRecipientId = 3, + type = type, + state = state, + timestamp = timestamp++, + ringerRecipientId = 3, + outgoing = true + ) + ) + individualCalls.add( + Call( + callId = id++, + conversationRecipientId = 3, + type = type, + state = state, + timestamp = timestamp++, + ringerRecipientId = selfRecipient.id, + outgoing = false + ) + ) + } + groupCalls.add( + Call( + callId = id++, + conversationRecipientId = 4, + type = Call.Type.GROUP_CALL, + state = state, + timestamp = timestamp++, + ringerRecipientId = 3, + outgoing = true + ) + ) + groupCalls.add( + Call( + callId = id++, + conversationRecipientId = 4, + type = Call.Type.GROUP_CALL, + state = state, + timestamp = timestamp++, + ringerRecipientId = selfRecipient.id, + outgoing = false + ) + ) + } + + importExport( + *standardFrames, + Recipient( + id = 3, + contact = Contact( + aci = TestRecipientUtils.nextAci().toByteString(), + pni = TestRecipientUtils.nextPni().toByteString(), + username = "coolusername", + e164 = 141255501234, + blocked = false, + hidden = false, + registered = Contact.Registered.REGISTERED, + unregisteredTimestamp = 0L, + profileKey = TestRecipientUtils.generateProfileKey().toByteString(), + profileSharing = true, + profileGivenName = "Alexa", + profileFamilyName = "Kim", + hideStory = true + ) + ), + Recipient( + id = 4, + group = Group( + masterKey = TestRecipientUtils.generateGroupMasterKey().toByteString(), + whitelisted = true, + hideStory = true, + storySendMode = Group.StorySendMode.DEFAULT, + name = "Cool test group" + ) + ), + *individualCalls.toArray(), + *groupCalls.toArray() + ) + } + /** * Export passed in frames as a backup. Does not automatically include * any standard frames (e.g. backup header). diff --git a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/database/CallTableBackupExtensions.kt b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/database/CallTableBackupExtensions.kt index e2348c2357..5f3116b0d5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/backup/v2/database/CallTableBackupExtensions.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/backup/v2/database/CallTableBackupExtensions.kt @@ -57,7 +57,8 @@ fun CallTable.restoreCallLogFromBackup(call: BackupCall, backupState: BackupStat CallTable.TYPE to CallTable.Type.serialize(type), CallTable.DIRECTION to CallTable.Direction.serialize(direction), CallTable.EVENT to CallTable.Event.serialize(event), - CallTable.TIMESTAMP to call.timestamp + CallTable.TIMESTAMP to call.timestamp, + CallTable.RINGER to if (call.ringerRecipientId != null) backupState.backupToLocalRecipientId[call.ringerRecipientId]?.toLong() else null ) writableDatabase.insert(CallTable.TABLE_NAME, SQLiteDatabase.CONFLICT_IGNORE, values)