Fix quality issues

This commit is contained in:
Benoit Marty 2024-06-05 18:52:57 +02:00 committed by Benoit Marty
parent 050dbdfa7c
commit 0ede5d6626
3 changed files with 4 additions and 5 deletions

View file

@ -102,18 +102,17 @@ class DefaultShareIntentHandler @Inject constructor(
}
val resInfoList: List<ResolveInfo> = context.packageManager.queryIntentActivitiesCompat(data, PackageManager.MATCH_DEFAULT_ONLY)
uriList.forEach {
for (resolveInfo in resInfoList) {
resInfoList.forEach resolve@{ resolveInfo ->
val packageName: String = resolveInfo.activityInfo.packageName
// Replace implicit intent by an explicit to fix crash on some devices like Xiaomi.
// see https://juejin.cn/post/7031736325422186510
try {
context.grantUriPermission(packageName, it, Intent.FLAG_GRANT_READ_URI_PERMISSION)
} catch (e: Exception) {
continue
return@resolve
}
data.action = null
data.component = ComponentName(packageName, resolveInfo.activityInfo.name)
break
}
}
return uriList.map { uri ->

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 20244 New Vector Ltd
* Copyright (c) 2024 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View file

@ -104,7 +104,7 @@ class SharePresenter @AssistedInject constructor(
}
)
if (!result) {
throw Exception("Failed to handle incoming share intent")
error("Failed to handle incoming share intent")
}
roomIds
}.runCatchingUpdatingState(shareActionState)