Commit 5ff2d24f by olly Committed by Oliver Woodman

Update PlayerNotficationManager to set PendingIntent.FLAG_IMMUTABLE on its Broadcast intent.

In Android 12 mutability flags have to be set on PendingIntents. If they are not, and the app targets Android 12, then the app will be crashed by the system.

PiperOrigin-RevId: 373427591
parent 6596cd1d
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
* HLS * HLS
* Use the PRECISE attribute in EXT-X-START to select the default start * Use the PRECISE attribute in EXT-X-START to select the default start
position. position.
* PlayerNotificationManager:
* Add `PendingIntent.FLAG_IMMUTABLE` flag to BroadcastReceiver to support Android 12.
### 2.14.0 (2021-05-13) ### 2.14.0 (2021-05-13)
......
...@@ -1380,8 +1380,15 @@ public class PlayerNotificationManager { ...@@ -1380,8 +1380,15 @@ public class PlayerNotificationManager {
String action, Context context, int instanceId) { String action, Context context, int instanceId) {
Intent intent = new Intent(action).setPackage(context.getPackageName()); Intent intent = new Intent(action).setPackage(context.getPackageName());
intent.putExtra(EXTRA_INSTANCE_ID, instanceId); intent.putExtra(EXTRA_INSTANCE_ID, instanceId);
return PendingIntent.getBroadcast(
context, instanceId, intent, PendingIntent.FLAG_UPDATE_CURRENT); int pendingFlags;
if (Util.SDK_INT >= 23) {
pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE;
} else {
pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT;
}
return PendingIntent.getBroadcast(context, instanceId, intent, pendingFlags);
} }
@SuppressWarnings("nullness:argument.type.incompatible") @SuppressWarnings("nullness:argument.type.incompatible")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment