Playback: remove special handling for Huawei (#7152)
This was introduced in5105cdd7
to prevent crashes on Huawei phones[1]. However, it seems this has already regressed in376ffed5
, 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:
parent
a8dfe6f123
commit
292a21f8f8
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue