Apply proper selection for MMS sender
See https://github.com/FossifyOrg/Messages/issues/344 More info: https://android.googlesource.com/platform/packages/apps/Messaging/+/master/src/com/android/messaging/sms/MmsUtils.java#1673
This commit is contained in:
parent
2a9b5b6d85
commit
a7c598e47e
1 changed files with 9 additions and 4 deletions
|
|
@ -21,9 +21,11 @@ import android.provider.Telephony.Threads
|
||||||
import android.provider.Telephony.ThreadsColumns
|
import android.provider.Telephony.ThreadsColumns
|
||||||
import android.telephony.SubscriptionManager
|
import android.telephony.SubscriptionManager
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
|
import androidx.core.net.toUri
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import com.bumptech.glide.request.RequestOptions
|
import com.bumptech.glide.request.RequestOptions
|
||||||
|
import com.google.android.mms.pdu_alt.PduHeaders
|
||||||
import me.leolin.shortcutbadger.ShortcutBadger
|
import me.leolin.shortcutbadger.ShortcutBadger
|
||||||
import org.fossify.commons.extensions.areDigitsOnly
|
import org.fossify.commons.extensions.areDigitsOnly
|
||||||
import org.fossify.commons.extensions.getBlockedNumbers
|
import org.fossify.commons.extensions.getBlockedNumbers
|
||||||
|
|
@ -297,16 +299,19 @@ fun Context.getMMS(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.getMMSSender(msgId: Long): String {
|
fun Context.getMMSSender(msgId: Long): String {
|
||||||
val uri = Uri.parse("${Mms.CONTENT_URI}/$msgId/addr")
|
val uri = "${Mms.CONTENT_URI}/$msgId/addr".toUri()
|
||||||
val projection = arrayOf(
|
val projection = arrayOf(
|
||||||
Mms.Addr.ADDRESS
|
Mms.Addr.ADDRESS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val selection = "${Mms.Addr.TYPE} = ?"
|
||||||
|
val selectionArgs = arrayOf(PduHeaders.FROM.toString())
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val cursor = contentResolver.query(uri, projection, null, null, null)
|
val cursor = contentResolver.query(uri, projection, selection, selectionArgs, null)
|
||||||
cursor?.use {
|
cursor?.use {
|
||||||
if (cursor.moveToFirst()) {
|
if (it.moveToFirst()) {
|
||||||
return cursor.getStringValue(Mms.Addr.ADDRESS)
|
return it.getStringValue(Mms.Addr.ADDRESS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue