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

Make PendingIntents immutable for Android 12. #49

Merged
merged 4 commits into from Nov 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build

object HomeWidgetLaunchIntent {

Expand All @@ -15,7 +16,12 @@ object HomeWidgetLaunchIntent {
intent.data = uri
intent.action = HOME_WIDGET_LAUNCH_ACTION

return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
var flags = PendingIntent.FLAG_UPDATE_CURRENT
if (Build.VERSION.SDK_INT >= 23) {
flags = flags or PendingIntent.FLAG_IMMUTABLE
}

return PendingIntent.getActivity(context, 0, intent, flags)
}
}

Expand All @@ -28,6 +34,11 @@ object HomeWidgetBackgroundIntent {
intent.data = uri
intent.action = HOME_WIDGET_BACKGROUND_ACTION

return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
var flags = PendingIntent.FLAG_UPDATE_CURRENT
if (Build.VERSION.SDK_INT >= 23) {
flags = flags or PendingIntent.FLAG_IMMUTABLE
}

return PendingIntent.getBroadcast(context, 0, intent, flags)
}
}