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

Fix for 2123 Missing FLAG_IMMUTABLE and support for Android 12 - API 31 #2169

Closed

Conversation

ghost
Copy link

@ghost ghost commented Sep 14, 2021

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.

@CLAassistant
Copy link

CLAassistant commented Sep 14, 2021

CLA assistant check
All committers have signed the CLA.

…lable for SDK 23 and MUTABLE is just when targeting 31 and when device is 31+.
@ghost ghost changed the title Fix for 2123 Missing FLAG_IMMUTABLE and upgrade to API 31 Fix for 2123 Missing FLAG_IMMUTABLE and support for Android 12 - API 31 Sep 14, 2021
@ghost ghost mentioned this pull request Sep 16, 2021
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)
Copy link
Member

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?

Copy link
Member

@Armaxis Armaxis Sep 17, 2021

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
Copy link
Member

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.

Copy link
Author

@ghost ghost Sep 17, 2021

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.

@ghost
Copy link
Author

ghost commented Sep 21, 2021

Hi @pyricau
Please let me know if this PR require or more changes.
Thank you.

@ghost
Copy link
Author

ghost commented Oct 13, 2021

@pyricau @Armaxis
I just added one more commit to fix a merge conflict.

Please, is there any planning date to release support for API 31 (Android 12)?

@tethridge
Copy link

@pyricau @Armaxis Any chance these updates can get reviewed and merged? This is effecting our application now as well now that Android 12 has been released and we want to customize the SplashScreen that is being forced on our app.

@pyricau
Copy link
Member

pyricau commented Dec 15, 2021

Closing as I cannot reproduce the crash on the latest master on Android 12. I believe this is already fixed.

@pyricau pyricau closed this Dec 15, 2021
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.

None yet

4 participants