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

Issue: #1174 Fix crash after phonecall on Android 12+ #1217

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1048,13 +1048,19 @@ private void processNewState(int oldState, int state)
if (mMediaPlayerInitialized)
mMediaPlayer.pause();

// We are switching into background mode. The notification will be removed
// unless we forcefully show it (or the user selected to always show it)
// In both cases we will update the notification to reflect the
if (Build.VERSION.SDK_INT < 31) {
// We are switching into background mode (however, we only do that for
// versions before Android 12, as starting from 12 (SDK version 31)
// starting a foreground job from an application in the background
// trigger a ForegroundServiceStartNotAllowedException)
// The notification will be removed.
// unless we forcefully show it (or the user selected to always show it)
boolean removeNotification = (mForceNotificationVisible == false && mNotificationVisibility != VISIBILITY_ALWAYS);
stopForeground(removeNotification);
}
// We will update the notification in any case to reflect the
// actual playback state (or to hit cancel() as this is required to
// get rid of it if it was created via notify())
boolean removeNotification = (mForceNotificationVisible == false && mNotificationVisibility != VISIBILITY_ALWAYS);
stopForeground(removeNotification);
updateNotification();

// Delay entering deep sleep. This allows the headset
Expand Down