Skip to content

Commit

Permalink
Default to not include MMS address sub_ids in import
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tmo1 committed Sep 20, 2024
1 parent 6aa7e70 commit 1a6ec44
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/src/main/java/com/github/tmo1/sms_ie/ImportExportMessages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,8 @@ suspend fun importMessages(
)
)
}
addresses.add(address)
}
addresses.add(address)
}
}/* If we don't yet have a thread_id (i.e., the message has a new
thread_id that we haven't yet encountered and so isn't yet in
Expand Down Expand Up @@ -568,9 +568,18 @@ suspend fun importMessages(
val messageId = insertUri.lastPathSegment
val addressUri = Uri.parse("content://mms/$messageId/addr")
addresses.forEach { address ->
// Some MMS address metadata contain sub_ids, and attempting to import them can cause the address import to fail:
// See: https://github.com/tmo1/sms-ie/issues/213
if (!prefs.getBoolean(
"import_sub_ids", false
) && address.containsKey("sub_id")
) {
address.put("sub_id", "-1")
}
address.put(
Telephony.Mms.Addr.MSG_ID, messageId
)/*Log.v(
)
/*Log.v(
LOG_TAG,
"Trying to insert MMS address - metadata:" + address.toString()
)*/
Expand Down

0 comments on commit 1a6ec44

Please sign in to comment.