Skip to content

Commit

Permalink
Playback: remove special handling for Huawei (#7152)
Browse files Browse the repository at this point in the history
This was introduced in 5105cdd to prevent crashes on Huawei phones[1].
However, it seems this has already regressed in 376ffed, 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
  • Loading branch information
hades committed May 1, 2024
1 parent a8dfe6f commit 292a21f
Showing 1 changed file with 2 additions and 13 deletions.
Expand Up @@ -275,19 +275,8 @@ void recreateMediaSessionIfNeeded() {

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);
}
Expand Down

0 comments on commit 292a21f

Please sign in to comment.