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

Improve Android Service lifecycle/notification management. #849

Open
wants to merge 4 commits into
base: major
Choose a base branch
from

Conversation

ryanheise
Copy link
Owner

Try to be more reasonable in some edge case state transitions.

@@ -592,6 +596,7 @@ private void deactivateMediaSession() {
}
// Force cancellation of the notification
getNotificationManager().cancel(NOTIFICATION_ID);
notificationCreated = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Because of this change notification won't update when go ready -> idle -> ready, not sure why.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ah, yes I was wondering whether this would break anything, although the logic seemed right. That said, when I planned out this change, I originally wanted to get rid of notificationCreated completely so that it would be possible to display the notification even before entering the foreground state. Maybe with !idle being used to determine whether updateNotification should show the notification rather than notificationCreated.

Comment on lines +548 to +555
private boolean isActuallyPlaying() {
return playing && (processingState == AudioProcessingState.loading
|| processingState == AudioProcessingState.buffering
|| processingState == AudioProcessingState.ready);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This fixes playing=true and idle thing. It's also looks ok to exit foreground state when it's completed or error.

Copy link
Contributor

@nt4f04uNd nt4f04uNd Oct 13, 2021

Choose a reason for hiding this comment

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

But other problem is if you try to stop the idle service - nothing happens, I'll try to think about this...

Copy link
Contributor

Choose a reason for hiding this comment

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

Left a comment in #847

Copy link
Owner Author

Choose a reason for hiding this comment

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

The above is only used when entering foreground. When exiting foreground, it uses a broader condition (simply !playing).

@nt4f04uNd
Copy link
Contributor

Let's have a conversation in #847 before making changes like this, It's hard to design changes while also making them =)
Also, the feature request for making config dynamic is #683.

@ryanheise
Copy link
Owner Author

There's no problem with discussing the specifics of a pull request here, since we now have two concrete pull request to look at and comment on. It's easier that way to review and comment using the GitHub tools..

@nt4f04uNd
Copy link
Contributor

nt4f04uNd commented Oct 14, 2021

I have no problem with discussing the details of this PR here. Just wanted you to take a look at what I proposed in the issue, because this correlates with what you made here, and perhaps is a better solution.

@ryanheise ryanheise changed the base branch from master to major October 17, 2021 09:25
@ryanheise ryanheise force-pushed the feature/service_lifecycle branch from 5a6dd55 to 6e49376 Compare October 18, 2021 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants