From 3b389c5a3f8e95d5d91fd3807050aebf3d748b5d Mon Sep 17 00:00:00 2001 From: Tom Levy Date: Mon, 15 Jul 2024 13:42:36 +0000 Subject: [PATCH] Fix missing messages after import on Android 14 due to subscriptionId On Android 14, imported messages are not visible if their subscriptionId[1] does not correspond to one of the SIMs in the device. As a workaround, we set subscriptionId to -1 ("unknown") on all messages during import. This does mean that when exporting then importing on the same device, the SIM associations will be lost. But that doesn't seem noticeable. Credit: SMS Import / Export app, https://www.github.com/tmo1/sms-ie/issues/128 Fixes #191. [1] https://developer.android.com/identity/user-data-ids#mobile-subscription-status --- .../org/fossify/messages/helpers/MessagesImporter.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/org/fossify/messages/helpers/MessagesImporter.kt b/app/src/main/kotlin/org/fossify/messages/helpers/MessagesImporter.kt index 9faa06a63..2a664928a 100644 --- a/app/src/main/kotlin/org/fossify/messages/helpers/MessagesImporter.kt +++ b/app/src/main/kotlin/org/fossify/messages/helpers/MessagesImporter.kt @@ -48,7 +48,14 @@ class MessagesImporter(private val activity: SimpleActivity) { activity.toast(org.fossify.commons.R.string.no_entries_for_importing) return } - ImportMessagesDialog(activity, deserializedList) + val messages = deserializedList.map { message -> + // workaround for messages not being imported on Android 14 when the device has a different subscriptionId (see #191) + when (message) { + is SmsBackup -> message.copy(subscriptionId = -1) + is MmsBackup -> message.copy(subscriptionId = -1) + } + } + ImportMessagesDialog(activity, messages) } catch (e: SerializationException) { activity.toast(org.fossify.commons.R.string.invalid_file_format) } catch (e: IllegalArgumentException) {