mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Fallback back to Telephony create thread in MMS export on failure.
This commit is contained in:
committed by
Greyson Parrelli
parent
055f4b09ee
commit
07c32e2a35
@@ -1,8 +1,12 @@
|
||||
package org.signal.smsexporter.internal.mms
|
||||
|
||||
import android.content.Context
|
||||
import android.database.sqlite.SQLiteException
|
||||
import android.os.Build
|
||||
import android.provider.Telephony
|
||||
import com.klinker.android.send_message.Utils
|
||||
import org.signal.core.util.Try
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.signal.smsexporter.ExportableMessage
|
||||
|
||||
/**
|
||||
@@ -12,6 +16,9 @@ import org.signal.smsexporter.ExportableMessage
|
||||
* This method will also filter out messages that do not have addresses.
|
||||
*/
|
||||
internal object GetOrCreateMmsThreadIdsUseCase {
|
||||
|
||||
private val TAG = Log.tag(GetOrCreateMmsThreadIdsUseCase::class.java)
|
||||
|
||||
fun execute(
|
||||
context: Context,
|
||||
mms: ExportableMessage.Mms<*>,
|
||||
@@ -31,7 +38,16 @@ internal object GetOrCreateMmsThreadIdsUseCase {
|
||||
return if (cache.containsKey(recipients)) {
|
||||
cache[recipients]!!
|
||||
} else {
|
||||
val threadId = Utils.getOrCreateThreadId(context, recipients)
|
||||
val threadId = try {
|
||||
Utils.getOrCreateThreadId(context, recipients)
|
||||
} catch (e: SQLiteException) {
|
||||
Log.w(TAG, "Unable to create thread using Klinker, falling back to system if possible")
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
Telephony.Threads.getOrCreateThreadId(context, recipients)
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
cache[recipients] = threadId
|
||||
threadId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user