Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b9caa21 authored by linus_lee's avatar linus_lee
Browse files

Eleven: Fix exception when leaving Eleven with nothing in the queue

It is possible for things to post to a handler even after the service has been destroyed
Fix is to shutdown the handlerthread in the onDestroy
Also set the subtitle text to alpha of 0 to not show on first launch

Change-Id: I76b5f4c4bc8a114660ced042ab02089bf279accb
parent 757f2860
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -64,7 +64,8 @@
            android:paddingBottom="6dp"
            android:background="@color/lyrics_background_color"
            android:textColor="@color/white"
            android:textSize="@dimen/text_size_small"/>
            android:textSize="@dimen/text_size_small"
            android:alpha="0.0"/>
    </com.cyanogenmod.eleven.widgets.SquareFrame>

    <RelativeLayout
+9 −6
Original line number Diff line number Diff line
@@ -474,6 +474,7 @@ public class MusicPlaybackService extends Service {
    private long[] mAutoShuffleList = null;

    private MusicPlayerHandler mPlayerHandler;
    private HandlerThread mHandlerThread;

    private BroadcastReceiver mUnmountReceiver = null;

@@ -574,12 +575,12 @@ public class MusicPlaybackService extends Service {
        // separate thread because the service normally runs in the process's
        // main thread, which we don't want to block. We also make it
        // background priority so CPU-intensive work will not disrupt the UI.
        final HandlerThread thread = new HandlerThread("MusicPlayerHandler",
        mHandlerThread = new HandlerThread("MusicPlayerHandler",
                android.os.Process.THREAD_PRIORITY_BACKGROUND);
        thread.start();
        mHandlerThread.start();

        // Initialize the handler
        mPlayerHandler = new MusicPlayerHandler(this, thread.getLooper());
        mPlayerHandler = new MusicPlayerHandler(this, mHandlerThread.getLooper());

        // Initialize the audio manager and register any headset controls for
        // playback
@@ -696,6 +697,11 @@ public class MusicPlaybackService extends Service {
        // remove any pending alarms
        mAlarmManager.cancel(mShutdownIntent);

        // Remove any callbacks from the handler
        mPlayerHandler.removeCallbacksAndMessages(null);
        // quit the thread so that anything that gets posted won't run
        mHandlerThread.quitSafely();

        // Release the player
        mPlayer.release();
        mPlayer = null;
@@ -707,9 +713,6 @@ public class MusicPlaybackService extends Service {
        // remove the media store observer
        getContentResolver().unregisterContentObserver(mMediaStoreObserver);

        // Remove any callbacks from the handler
        mPlayerHandler.removeCallbacksAndMessages(null);

        // Close the cursor
        closeCursor();