Skip to content

Commit 1a6ec44

Browse files
committed
Default to not include MMS address sub_ids in import
Some MMS address metadata apparently contain a sub_id field (despite the absence of any mention of this in the API documentation at https://developer.android.com/reference/android/provider/Telephony.Mms.Addr), and attempting to import these sub_ids can cause address import failure. This is probably related to #128. In any event, this commit fixes the problem by extending the solution to that issue (c56fa0e) to MMS address metadata sub_ids. This commit also corrects a coding error that caused MMS addresses to be inserted multiple times. Closes: #213 Related: #128, #142
1 parent 6aa7e70 commit 1a6ec44

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

app/src/main/java/com/github/tmo1/sms_ie/ImportExportMessages.kt

+11-2
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,8 @@ suspend fun importMessages(
522522
)
523523
)
524524
}
525-
addresses.add(address)
526525
}
526+
addresses.add(address)
527527
}
528528
}/* If we don't yet have a thread_id (i.e., the message has a new
529529
thread_id that we haven't yet encountered and so isn't yet in
@@ -568,9 +568,18 @@ suspend fun importMessages(
568568
val messageId = insertUri.lastPathSegment
569569
val addressUri = Uri.parse("content://mms/$messageId/addr")
570570
addresses.forEach { address ->
571+
// Some MMS address metadata contain sub_ids, and attempting to import them can cause the address import to fail:
572+
// See: https://github.com/tmo1/sms-ie/issues/213
573+
if (!prefs.getBoolean(
574+
"import_sub_ids", false
575+
) && address.containsKey("sub_id")
576+
) {
577+
address.put("sub_id", "-1")
578+
}
571579
address.put(
572580
Telephony.Mms.Addr.MSG_ID, messageId
573-
)/*Log.v(
581+
)
582+
/*Log.v(
574583
LOG_TAG,
575584
"Trying to insert MMS address - metadata:" + address.toString()
576585
)*/

0 commit comments

Comments
 (0)