-
Notifications
You must be signed in to change notification settings - Fork 640
Add mutability flag to pending intent #3513
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
Conversation
Coverage Report 1Affected Products
Test Logs
Notes |
Size Report 1Affected Products
Test Logs
Notes |
@@ -110,6 +110,7 @@ private PendingIntent createAppLaunchIntent() { | |||
LogWrapper.getInstance().w(TAG + "No activity found to launch app"); | |||
return null; | |||
} | |||
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT); | |||
return PendingIntent.getActivity( | |||
context, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE); |
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.
This makes me wonder if we should avoid using FLAG_IMMUTABLE on older SDK versions:
Lines 536 to 540 in 21a9f91
private static int getPendingIntentFlags(int baseFlags) { | |
// Only add on platform levels that support FLAG_IMMUTABLE. | |
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M | |
? baseFlags | PendingIntent.FLAG_IMMUTABLE | |
: baseFlags; |
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.
Ah, it looks like FLAG_IMMUTABLE was only added in API level 23 (M) https://developer.android.com/reference/android/app/PendingIntent#FLAG_IMMUTABLE
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.
The issue is that your sdk has misSdkVersion = 16, so it could crash at runtime?
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.
But the check against Build.VERSION.SDK_INT
would prevent that crash, right @vkryachko ?
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.
right, but I don't see the check it in the pr, and I thought that in your previous comment you were suggesting that it's safe not to do the check given that this flag is 23+. If we have the check then it shouldn't be a problem.
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.
Ah, no, sorry. I meant we need to add the check. We'll do that now.
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.
Done.
@rachaprince: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
* Add mutability flag to pending intent * Fix styles * Only add FLAG_IMMUTABLE on SDK level 23+ Co-authored-by: Lee Kellogg <lkellogg@google.com>
Add a mutability flag to the pending intent to support apps targeting android 12.
See https://developer.android.com/guide/components/intents-filters#DeclareMutabilityPendingIntent
We use a pending intent because this is sent to the Notifications Manager. See https://developer.android.com/guide/components/intents-filters#PendingIntent