Catch security exception
This commit is contained in:
parent
ac29dd512c
commit
b65ef71c3c
@ -47,5 +47,6 @@ dependencies {
|
|||||||
implementation(project(":core:permissions"))
|
implementation(project(":core:permissions"))
|
||||||
implementation(project(":core:base"))
|
implementation(project(":core:base"))
|
||||||
implementation(project(":core:ktx"))
|
implementation(project(":core:ktx"))
|
||||||
|
implementation(project(":core:crashreporter"))
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -12,6 +12,7 @@ import android.os.Process
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import de.mm20.launcher2.appshortcuts.R
|
import de.mm20.launcher2.appshortcuts.R
|
||||||
|
import de.mm20.launcher2.crashreporter.CrashReporter
|
||||||
import de.mm20.launcher2.icons.*
|
import de.mm20.launcher2.icons.*
|
||||||
import de.mm20.launcher2.ktx.getSerialNumber
|
import de.mm20.launcher2.ktx.getSerialNumber
|
||||||
import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
import de.mm20.launcher2.ktx.isAtLeastApiLevel
|
||||||
@ -93,10 +94,15 @@ data class LauncherShortcut(
|
|||||||
): LauncherIcon? {
|
): LauncherIcon? {
|
||||||
val launcherApps = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
val launcherApps = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
|
||||||
val icon = withContext(Dispatchers.IO) {
|
val icon = withContext(Dispatchers.IO) {
|
||||||
launcherApps.getShortcutIconDrawable(
|
try {
|
||||||
launcherShortcut,
|
launcherApps.getShortcutIconDrawable(
|
||||||
context.resources.displayMetrics.densityDpi
|
launcherShortcut,
|
||||||
)
|
context.resources.displayMetrics.densityDpi
|
||||||
|
)
|
||||||
|
} catch (e: SecurityException) {
|
||||||
|
CrashReporter.logException(e)
|
||||||
|
null
|
||||||
|
}
|
||||||
} ?: return null
|
} ?: return null
|
||||||
if (icon is AdaptiveIconDrawable) {
|
if (icon is AdaptiveIconDrawable) {
|
||||||
if (themed && isAtLeastApiLevel(33) && icon.monochrome != null) {
|
if (themed && isAtLeastApiLevel(33) && icon.monochrome != null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user