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

Commit ba9e2b9c authored by Roman Birg's avatar Roman Birg Committed by Nir Bruderman
Browse files

Eleven: properly send open/close session events



These were being fired off at device boot and there was a session being
held for the entire duration. Only request the session when playing.

Change-Id: I37ebc5a6898453dd090cc68ee2126e9c5d08d892
Signed-off-by: default avatarRoman Birg <roman@cyngn.com>
(cherry picked from commit 914b9d7a)
parent dafca0d2
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -2396,6 +2396,11 @@ public class MusicPlaybackService extends Service {
            return;
        }

        final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
        intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
        intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
        sendBroadcast(intent);

        mAudioManager.registerMediaButtonEventReceiver(new ComponentName(getPackageName(),
                MediaButtonIntentReceiver.class.getName()));
        mSession.setActive(true);
@@ -2434,6 +2439,12 @@ public class MusicPlaybackService extends Service {
        synchronized (this) {
            mPlayerHandler.removeMessages(FADEUP);
            if (mIsSupposedToBePlaying) {
                final Intent intent = new Intent(
                        AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION);
                intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
                intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
                sendBroadcast(intent);

                mPlayer.pause();
                setIsSupposedToBePlaying(false, true);
                stopShakeDetector(false);
@@ -3154,10 +3165,6 @@ public class MusicPlaybackService extends Service {
            }
            player.setOnCompletionListener(this);
            player.setOnErrorListener(this);
            final Intent intent = new Intent(AudioEffect.ACTION_OPEN_AUDIO_EFFECT_CONTROL_SESSION);
            intent.putExtra(AudioEffect.EXTRA_AUDIO_SESSION, getAudioSessionId());
            intent.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, mService.get().getPackageName());
            mService.get().sendBroadcast(intent);
            return true;
        }