-
Notifications
You must be signed in to change notification settings - Fork 91
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
Update PdService.java #120
base: master
Are you sure you want to change the base?
Conversation
PendingIntent bug on android 12. Please, add this changes.
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.
Thanks for the contribution!
I assume that this PR addresses this issue that was raised on stackoverflow.
In the future, please provide more information on why you wish to implement a certain change.
I'd like to get @joebowbeer approval before merging this PR.
PdCore/src/main/java/org/puredata/android/service/PdService.java
Outdated
Show resolved
Hide resolved
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); | ||
} | ||
else { | ||
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); |
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.
What is the reason for changing the value that was previously used (0
) to PendingIntent.FLAG_UPDATE_CURRENT
?
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); | |
} | |
else { | |
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); | |
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_IMMUTABLE); | |
} | |
else { | |
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, 0); |
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.
In my experience it doesn't change much, but we can keep 0 to be more like the original code.
https://stackoverflow.com/questions/50128188/what-are-different-between-pendingintent-flag-update-current-and-0-in-android
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.
Let's keep 0
then for 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.
This might be clearer with a helper to compose the flag(s)
Fixes #121 ? |
See SO for background and link to article: https://stackoverflow.com/q/67045607/901597 |
@tkirshboim our git submodules are not syncing due to deprecated protocol as reported #118 Deprecation: https://github.blog/2021-09-01-improving-git-protocol-security-github/ I created a test PR #122 but it is failing further along; we also need to update our link to libpd in order to pickup the .gitmodules changes there. Still working on fixing the build. Now stuck on some recently added double precision support... |
Co-authored-by: Tal Kirshboim <[email protected]>
yes! |
Is there any additional work to be done here? I'm aiming to get this up and running on 31+ so would like to help get this merged in if it's ready. |
As I can see that the question is whether to keep the zero or not, in this case it's smarter to keep the zero because you do not have any custom request code meaning zero is no request codes at all, unless the service does something specific and obtains it through that request code then and only then it makes sense to have it custom one. |
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.
Works for me here with latest Android Studio and Android 32.
hey guys, any chance on getting this merged? |
@joebowbeer @tkirshboim Any chance we can get this merged? We're like to integrate this change. |
@cerupcat This PR looks good to me, but the build fails. @tkirshboim I think we're still stuck on nettoyeurny/opensl_stream#5 via libpd/libpd#357 Ideas? |
I'm not sure how they're related 🤔 This is only a flag to prevent crashes when it comes to the service |
This also still needs to be done. @rafaelgustavo123 Could you take a look? |
@FunkyMuse writes
Until the build is fixed, I guess the other option would be to make a point release based on an older tag. |
It'll be of a great help, since targeting newer SDKs is a requirement from Google nowadays |
can we get a release, I can see the PR is merged for #126 |
It may be a while before we release to maven central, but there is a recent snapshot build And the aar artifact can be downloaded from the GitHub Action: https://github.com/libpd/pd-for-android/actions/runs/5283412584 Perhaps one of these will work in the interim? |
It appears that snapshot also has the crash issue. |
What crash issue? The current code now provides FLAG_IMMUTABLE, right? Is the error message still the same? |
yeap, tried with every version from https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/libpd/android/pd-core/1.2.1-SNAPSHOT/ |
@rafaelgustavo123 can you confirm this PR is no longer needed and close it? @cerupcat @FunkyMuse can you open an issue for your crash? Is it one of these crashes? |
@FunkyMuse can you help provide more information on the crash you're seeing? |
It's the FLAG_IMMUTABLE crash |
Should I close it? |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); | ||
} else { | ||
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); |
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.
I am against FLAG_UPDATE_CURRENT
here. This may change the behaviour on older Android versions, and the existing code with using 0
was working in many apps.
|
||
PendingIntent pi = null; | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | 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.
I am not sure about setting FLAG_UPDATE_CURRENT
here. On the one hand, this will just replace an existing notification so it will not show multiple notifications, if startAudio()
is called multiple times. On the other hand, this should have been prevented in startAudio()
.
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.
What's the solution here? We need to set one or the other per the original discussion on SO.
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.
What's the solution here? We need to set one or the other per the original discussion on SO.
I would pick FLAG_IMMUTABLE
, but I am unsure about the FLAG_UPDATE_CURRENT_PART
.
The immutable flag is in the main branch: I've confirmed that this change is in the source code of the latest snapshot. @rafaelgustavo123 please close this PR or rebase on the main branch @cerupcat @FunkyMuse Please create a new issue with details NOTE: Make sure you update the cache https://stackoverflow.com/questions/13565082/how-can-i-force-gradle-to-redownload-dependencies |
PendingIntent bug on android 12. Please, add this changes.