Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using IconCompat.createFromIcon() that doesn't support bitmap icons #7158

Merged
merged 1 commit into from
Jul 18, 2023

Conversation

canyie
Copy link
Collaborator

@canyie canyie commented Jul 13, 2023

This is a regression introduced in e9b76b6:

From the source code of IconCompat.createFromIcon(), bitmap icons will be treated as TYPE_UNKNOWN:
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:core/core/src/main/java/androidx/core/graphics/drawable/IconCompat.java;l=1110
image

And IconCompat.addToShortcutIntent() does not support TYPE_UNKNOWN:
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:core/core/src/main/java/androidx/core/graphics/drawable/IconCompat.java;l=698
image

So it will crash on Android before 8.0:

 java.lang.IllegalArgumentException: Icon type not supported for intent shortcuts
    at androidx.core.graphics.drawable.IconCompat.addToShortcutIntent(IconCompat.java:754)
    at androidx.core.content.pm.ShortcutInfoCompat.addToIntent(ShortcutInfoCompat.java:213)
    at androidx.core.content.pm.ShortcutManagerCompat.requestPinShortcut(ShortcutManagerCompat.java:204)
    at com.topjohnwu.magisk.view.Shortcuts.addHomeIcon(Shortcuts.kt:36)
    at com.topjohnwu.magisk.ui.MainActivity$askForHomeShortcut$1$2$1.invoke(MainActivity.kt:227)
    at com.topjohnwu.magisk.ui.MainActivity$askForHomeShortcut$1$2$1.invoke(MainActivity.kt:226)
    at com.topjohnwu.magisk.view.MagiskDialog$ButtonViewModel.clicked(MagiskDialog.kt:122)
    at com.topjohnwu.magisk.databinding.DialogMagiskBaseBindingImpl._internalCallbackOnClick(DialogMagiskBaseBindingImpl.java:562)
    at com.topjohnwu.magisk.generated.callback.OnClickListener.onClick(OnClickListener.java:11)
    at android.view.View.performClick(View.java:5205)
                                                           

@canyie canyie changed the title Avoid using IconCompat.createFromIcon() that doesn't support bitmap icon Avoid using IconCompat.createFromIcon() that doesn't support bitmap icons Jul 13, 2023
@topjohnwu topjohnwu merged commit d390ca2 into topjohnwu:master Jul 18, 2023
8 checks passed
@canyie canyie deleted the shortcut branch July 18, 2023 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants