Playback: remove special handling for Huawei (#7152)

This was introduced in 5105cdd7 to prevent crashes on Huawei phones[1].
However, it seems this has already regressed in 376ffed5, where the setActive
call was moved outside of the try-catch block.

Additionally, the problem is now 9 years old, and hopefully fixed for the users
already.

[1] https://stackoverflow.com/questions/31556679/android-huawei-mediassessioncompat
This commit is contained in:
hades 2024-05-01 11:36:15 +02:00 committed by GitHub
parent a8dfe6f123
commit 292a21f8f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 13 deletions

View File

@ -275,19 +275,8 @@ public class PlaybackService extends MediaBrowserServiceCompat {
mediaSession = new MediaSessionCompat(getApplicationContext(), TAG, eventReceiver, buttonReceiverIntent);
setSessionToken(mediaSession.getSessionToken());
try {
mediaSession.setCallback(sessionCallback);
mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
} catch (NullPointerException npe) {
// on some devices (Huawei) setting active can cause a NullPointerException
// even with correct use of the api.
// See http://stackoverflow.com/questions/31556679/android-huawei-mediassessioncompat
// and https://plus.google.com/+IanLake/posts/YgdTkKFxz7d
Log.e(TAG, "NullPointerException while setting up MediaSession");
npe.printStackTrace();
}
mediaSession.setCallback(sessionCallback);
mediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
recreateMediaPlayer();
mediaSession.setActive(true);
}