Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Conversation

@rguntha
Copy link
Contributor

@rguntha rguntha commented Oct 31, 2021

  1. Added PendingIntent.FLAG_IMMUTABLE for all the pending requests in AudiofilePlayerService.java and AudiofilePlayerPlugin.java
  2. Modified the MediaSessionCompat in the AudiofilePlayerService.onCreate method to send the FLAG_IMMUTABLE
  3. Added new MediaButtonReceiver12 class, modifying the static methods that create the PendingIntent and passing the FLAG_IMMUTABLE flag

java.lang.RuntimeException: Unable to create service com.google.flutter.plugins.audiofileplayer.AudiofileplayerService: java.lang.IllegalArgumentException: com.layamritam.app: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
import android.support.v4.media.session.PlaybackStateCompat;
import android.util.Log;
import android.view.KeyEvent;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line

);

mediaSession = new MediaSessionCompat(this, TAG);
mediaSession = new MediaSessionCompat(this, TAG,null,pendingItent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add spaces after commas

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this intent is only used up to KitKat:
https://developer.android.com/reference/android/support/v4/media/session/MediaSessionCompat#MediaSessionCompat(android.content.Context,%20java.lang.String,%20android.content.ComponentName,%20android.app.PendingIntent)

  1. Does this library support KitKat or farther back?
  2. If so, add a comment highlighting that, so that if this library ever drops support for KitKat and previous, to remove this pendingIntent

pendingIntent = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_IMMUTABLE);
}
else
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use same style as elsewhere:

} else {

}
else
{
pendingIntent = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to just pass
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
in all cases? Or will that break on older OS versions?


import java.util.List;

public class MediaButtonReceiver12{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space before open brace

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a doc string to describe what this class does, and why it is needed beyond MediaButtonReceiver

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this use case is already handled by a more recent version of AndroidX libraries:
https://developer.android.com/jetpack/androidx/releases/media#version_130_3

Seems like you can just change that dependency version and remove this file.


public class MediaButtonReceiver12{

public static ComponentName getMediaButtonReceiverComponent(Context context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

import java.util.List;

public class MediaButtonReceiver12{
public class MediaButtonReceiver12 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete this file if unused

This file is not needed as the updated media library 1.3.0 is sufficient
@rguntha
Copy link
Contributor Author

rguntha commented Nov 1, 2021 via email

@monkeyswarm monkeyswarm merged commit cad20a9 into google:master Nov 1, 2021
arodriguezgb added a commit to arodriguezgb/flutter.plugins that referenced this pull request Nov 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants