Skip to content

Commit

Permalink
Default to not include sub_ids in message import
Browse files Browse the repository at this point in the history
Previously, sub_ids were included in message import. On Android 14 (API
level 34), this causes messages with certain sub_ids to (silently) fail
to import. Preservation of sub_ids is of limited benefit anyway, since
the sub_ids on the target device may not correspond to those of the
source device. The default behavior has therefore been changed to set
all sub_ids to "-1" upon import, since negative values indicate that
"the sub_id cannot be determined":

https://developer.android.com/reference/android/provider/Telephony.TextBasedSmsColumns#SUBSCRIPTION_ID

The old behavior is still available via a settings toggle.

Addresses: #118, #128
  • Loading branch information
tmo1 committed Oct 24, 2023
1 parent d2e310e commit c56fa0e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ suspend fun importMessages(
val messageMetadata = ContentValues()
val messageJSON = JSONObject(line)
val oldThreadId = messageJSON.optString("thread_id")
// See https://github.com/tmo1/sms-ie/issues/128
if (!prefs.getBoolean("import_sub_ids", false)) {
messageJSON.put("sub_id", "-1")
}
if (oldThreadId in threadIdMap) {
messageMetadata.put(
"thread_id", threadIdMap[oldThreadId]
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
app:defaultValue="false"
app:singleLineTitle="false" />

<SwitchPreferenceCompat
android:key="import_sub_ids"
android:title="Include Subscription IDs in import"
app:defaultValue="false"
app:singleLineTitle="false" />

</PreferenceCategory>

<PreferenceCategory android:title="Debugging options">
Expand Down

0 comments on commit c56fa0e

Please # to comment.