-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Fix for 2123 Missing FLAG_IMMUTABLE and support for Android 12 - API 31 #2169
Fix for 2123 Missing FLAG_IMMUTABLE and support for Android 12 - API 31 #2169
Conversation
…lable for SDK 23 and MUTABLE is just when targeting 31 and when device is 31+.
leakcanary-android-core/src/main/java/leakcanary/internal/AndroidHeapDumper.kt
Outdated
Show resolved
Hide resolved
leakcanary-android-core/src/main/java/leakcanary/internal/HeapAnalyzerService.kt
Outdated
Show resolved
Hide resolved
leakcanary-android-core/src/main/java/leakcanary/internal/NotificationReceiver.kt
Show resolved
Hide resolved
val textView = toast.view.findViewById<TextView>(android.R.id.message) | ||
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.leak_canary_icon, 0, 0, 0) | ||
textView.compoundDrawablePadding = | ||
val textView = toast.view?.findViewById<TextView>(android.R.id.message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting with API 30 Toast.getView() returns null when the toast is constructed via Toast.makeText()
. So we should likely switch to a full blown custom toast like in default LeakCanary?
@Armaxis thoughts on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, what an amazing API change, thanks, Google! /s
Yea, we should go with custom Toast then
val flags = if (Build.VERSION.SDK_INT >= 23) { | ||
FLAG_UPDATE_CURRENT or FLAG_IMMUTABLE | ||
val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
FLAG_MUTABLE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, what's this change supposed to do?
Did you confirm that the crash still happens on the latest master? This crash is supposed to be already fixed by #2124, and we haven't made a new release since.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @pyricau,
I did a test on the latest snapshot I can find, and I am afraid yes still happen.
With FLAG_IMMTABLE you will be not able to update the current PendingIntent.
Basically, You can Still use FLAG_UPDATE_CURRENT even if from 23 you have IMMUTABLE, but from 31 you must use IMMUTABLE or MUTABLE, in this case, if you want to still update the PendingIntent from 31, on my understanding FLAG_MUTABLE is mutable like FLAG_UPDATE_CURRENT. Otherwise, you can use FLAG_IMMUTABLE from SDK 23 and above or 0
until SDK 22.
Please correct me if I am wrong.
Hi @pyricau |
Closing as I cannot reproduce the crash on the latest master on Android 12. I believe this is already fixed. |
Fix the issue for: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
issue: #2123
This branch also includes some small code changes where toast API has deprecated custom toast.