Fix crash on incoming share throwing SecurityException

Tested with org.mozilla.fennec_fdroid Version 103.1.0 (1031020) when
sharing to quick contacts.

Change-Id: Ie66e5945aa85fe309b1cfc42d7bad61675a1b4b8
This commit is contained in:
SpiritCroc 2022-08-13 11:06:57 +02:00
parent 772ac44994
commit bd5f011c0e

View file

@ -40,6 +40,7 @@ import im.vector.app.features.attachments.ShareIntentHandler
import im.vector.app.features.attachments.preview.AttachmentsPreviewActivity
import im.vector.app.features.attachments.preview.AttachmentsPreviewArgs
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import timber.log.Timber
import javax.inject.Inject
/**
@ -106,17 +107,24 @@ class IncomingShareFragment @Inject constructor(
}
}
private fun handleIncomingShareIntent(intent: Intent) = shareIntentHandler.handleIncomingShareIntent(
intent,
onFile = {
val sharedData = SharedData.Attachments(it)
viewModel.handle(IncomingShareAction.UpdateSharedData(sharedData))
},
onPlainText = {
val sharedData = SharedData.Text(it)
viewModel.handle(IncomingShareAction.UpdateSharedData(sharedData))
}
)
private fun handleIncomingShareIntent(intent: Intent): Boolean {
return try {
shareIntentHandler.handleIncomingShareIntent(
intent,
onFile = {
val sharedData = SharedData.Attachments(it)
viewModel.handle(IncomingShareAction.UpdateSharedData(sharedData))
},
onPlainText = {
val sharedData = SharedData.Text(it)
viewModel.handle(IncomingShareAction.UpdateSharedData(sharedData))
}
)
} catch (e: SecurityException) {
Timber.e(e, "Security exception handling incoming share")
false
}
}
private fun handleMultipleRoomsShareDone(viewEvent: IncomingShareViewEvents.MultipleRoomsShareDone) {
requireActivity().let {