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

Update PdService.java #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rafaelgustavo123
Copy link

PendingIntent bug on android 12. Please, add this changes.

PendingIntent bug on android 12. Please, add this changes.
Copy link
Member

@tkirshboim tkirshboim left a 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.

Comment on lines 247 to 250
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
else {
pi = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Copy link
Member

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?

Suggested change
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);

Copy link
Author

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

Copy link
Member

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.

Copy link
Contributor

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)

@joebowbeer
Copy link
Contributor

Fixes #121 ?

@joebowbeer
Copy link
Contributor

See SO for background and link to article: https://stackoverflow.com/q/67045607/901597

@joebowbeer
Copy link
Contributor

joebowbeer commented May 17, 2022

@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.

libpd/libpd@df45c75

Still working on fixing the build. Now stuck on some recently added double precision support...

@rafaelgustavo123
Copy link
Author

Fixes #121 ?

yes!

@cerupcat
Copy link

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.

@tkirshboim
Copy link
Member

@cerupcat This still needs to be done.

@FunkyMuse
Copy link

@cerupcat This still needs to be done.

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.

Copy link
Contributor

@residuum residuum left a 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.

@FunkyMuse
Copy link

hey guys, any chance on getting this merged?

@cerupcat
Copy link

@joebowbeer @tkirshboim Any chance we can get this merged? We're like to integrate this change.

@joebowbeer
Copy link
Contributor

joebowbeer commented Jun 14, 2023

@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?

@FunkyMuse
Copy link

@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

@tkirshboim
Copy link
Member

This also still needs to be done. @rafaelgustavo123 Could you take a look?

@joebowbeer
Copy link
Contributor

@FunkyMuse writes

This is only a flag to prevent crashes when it comes to the service

Until the build is fixed, I guess the other option would be to make a point release based on an older tag.

@FunkyMuse
Copy link

@FunkyMuse writes

This is only a flag to prevent crashes when it comes to the service

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

@FunkyMuse
Copy link

FunkyMuse commented Jun 21, 2023

@FunkyMuse writes

This is only a flag to prevent crashes when it comes to the service

Until the build is fixed, I guess the other option would be to make a point release based on an older tag.

can we get a release, I can see the PR is merged for #126

@joebowbeer
Copy link
Contributor

joebowbeer commented Jun 22, 2023

@FunkyMuse writes

This is only a flag to prevent crashes when it comes to the service

Until the build is fixed, I guess the other option would be to make a point release based on an older tag.

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

https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/libpd/android/pd-core/1.2.1-SNAPSHOT/

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?

@cerupcat
Copy link

cerupcat commented Jul 5, 2023

It appears that snapshot also has the crash issue.

@joebowbeer
Copy link
Contributor

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?

@FunkyMuse
Copy link

FunkyMuse commented Jul 7, 2023

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/

@joebowbeer
Copy link
Contributor

@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?

@joebowbeer joebowbeer requested a review from residuum July 7, 2023 10:11
@cerupcat
Copy link

@FunkyMuse can you help provide more information on the crash you're seeing?

@FunkyMuse
Copy link

@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?

It's the FLAG_IMMUTABLE crash

@rafaelgustavo123
Copy link
Author

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);
Copy link
Contributor

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);
Copy link
Contributor

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().

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.

Copy link
Contributor

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.

@joebowbeer
Copy link
Contributor

joebowbeer commented Jul 14, 2023

The immutable flag is in the main branch:

https://github.com/libpd/pd-for-android/blob/master/PdCore/src/main/java/org/puredata/android/service/PdService.java#L244

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants