Skip to content

Commit 545c424

Browse files
committed
Do a check for shortcut host permissions before pinning a shortcut
1 parent 2614be4 commit 545c424

File tree

1 file changed

+8
-6
lines changed
  • app/src/main/kotlin/com/simplemobiletools/launcher/activities

1 file changed

+8
-6
lines changed

app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,14 @@ class MainActivity : SimpleActivity(), FlingListener {
233233
REQUEST_CREATE_SHORTCUT -> {
234234
if (resultCode == Activity.RESULT_OK && resultData != null) {
235235
val launcherApps = applicationContext.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
236-
val item = launcherApps.getPinItemRequest(resultData)
237-
if (item.accept()) {
238-
val shortcutId = item.shortcutInfo?.id!!
239-
val label = item.shortcutInfo.getLabel()
240-
val icon = launcherApps.getShortcutBadgedIconDrawable(item.shortcutInfo!!, resources.displayMetrics.densityDpi)
241-
mActionOnAddShortcut?.invoke(shortcutId, label, icon)
236+
if (launcherApps.hasShortcutHostPermission()) {
237+
val item = launcherApps.getPinItemRequest(resultData)
238+
if (item.accept()) {
239+
val shortcutId = item.shortcutInfo?.id!!
240+
val label = item.shortcutInfo.getLabel()
241+
val icon = launcherApps.getShortcutBadgedIconDrawable(item.shortcutInfo!!, resources.displayMetrics.densityDpi)
242+
mActionOnAddShortcut?.invoke(shortcutId, label, icon)
243+
}
242244
}
243245
}
244246
}

0 commit comments

Comments
 (0)