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

Commit bc7fd494 authored by Jaewan Kim's avatar Jaewan Kim Committed by Android (Google) Code Review
Browse files

Merge "MediaSession2 API set for audio focus handling"

parents ce07298e 5fdfa211
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.media.AudioAttributes;
import android.media.IMediaSession2Callback;
import android.media.MediaItem2;
import android.media.MediaPlayerInterface;
@@ -181,20 +180,18 @@ public class MediaSession2Impl implements MediaSession2Provider {
        return mSessionStub.getControllers();
    }

    @Override
    public void setAudioAttributes_impl(AudioAttributes attributes) {
        // implement
    }

    @Override
    public void setAudioFocusRequest_impl(int focusGain) {
        // implement
        mAudioFocusType = focusGain;
    }

    @Override
    public void play_impl() {
        ensureCallingThread();
        ensurePlayer();
        if (!gainAudioFocus()) {
           // TODO: implement
        }
        mPlayer.play();
    }

@@ -369,6 +366,13 @@ public class MediaSession2Impl implements MediaSession2Provider {
        mSessionStub.notifyPlaybackStateChangedNotLocked(state);
    }

    private boolean gainAudioFocus() {
        // implement
        // int res = mAudioManager.requestAudioFocus(mFocusRequest.build());
        // return res == AUDIOFOCUS_REQUEST_GRANTED;
        return false;
    }

    Context getContext() {
        return mContext;
    }