Unregister sharedpreferences listener on destroy.

If the playback service is stopped before the main activity gets killed, this would have caused the old class to still get updates.

Sending preference updates to such an orphaned PlaybackService would trigger crashes in some cases (especially when MediaLibrary detects suspicious unregisters).
This commit is contained in:
Adrian Ulrich 2018-10-14 19:43:26 +02:00
parent e2598806ac
commit ce9ccd9bd4

View File

@ -624,6 +624,10 @@ public final class PlaybackService extends Service
// defer wakelock and close audioFX
enterSleepState();
// stop getting preference changes.
getSettings(this).unregisterOnSharedPreferenceChangeListener(this);
// shutdown all observers.
MediaLibrary.unregisterLibraryObserver(mObserver);
mPlaylistObserver.unregister();