OSDN Git Service

Eleven: Fix potential NPE when media server crashes
authorGabriele M <moto.falcon.git@gmail.com>
Sun, 1 Oct 2017 16:37:38 +0000 (18:37 +0200)
committerGabriele M <moto.falcon.git@gmail.com>
Sun, 15 Oct 2017 14:01:28 +0000 (14:01 +0000)
If the service doesn't exist when the media server crashes, Eleven
will crash when creating the TrackErrorInfo object. The SERVER_DIED
message is processed only when the service is not null, so just
ignore the MEDIA_ERROR_SERVER_DIED message if service is null.

BUGBASH-1045

Change-Id: Idaf3e238eefd412ebb85244b48ad7b20bc049ff0

src/com/cyanogenmod/eleven/MusicPlaybackService.java

index 869ee6e..eedf555 100644 (file)
@@ -3442,6 +3442,9 @@ public class MusicPlaybackService extends Service {
             switch (what) {
                 case MediaPlayer.MEDIA_ERROR_SERVER_DIED:
                     final MusicPlaybackService service = mService.get();
+                    if (service == null) {
+                        return false;
+                    }
                     final TrackErrorInfo errorInfo = new TrackErrorInfo(service.getAudioId(),
                             service.getTrackName());