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

Commit eb33cd29 authored by Hongwei Wang's avatar Hongwei Wang Committed by Automerger Merge Worker
Browse files

Merge "Cache the Binder call for PlaybackState" into udc-dev am: 5f716d18 am: ae3054c2

parents c7c795b3 ae3054c2
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -252,13 +252,16 @@ public class PipMediaController {
    // It can be removed when min_sdk of the app is set to 31 or greater.
    // It can be removed when min_sdk of the app is set to 31 or greater.
    @SuppressLint("NewApi")
    @SuppressLint("NewApi")
    private List<RemoteAction> getMediaActions() {
    private List<RemoteAction> getMediaActions() {
        if (mMediaController == null || mMediaController.getPlaybackState() == null) {
        // Cache the PlaybackState since it's a Binder call.
        final PlaybackState playbackState;
        if (mMediaController == null
                || (playbackState = mMediaController.getPlaybackState()) == null) {
            return Collections.emptyList();
            return Collections.emptyList();
        }
        }


        ArrayList<RemoteAction> mediaActions = new ArrayList<>();
        ArrayList<RemoteAction> mediaActions = new ArrayList<>();
        boolean isPlaying = mMediaController.getPlaybackState().isActive();
        boolean isPlaying = playbackState.isActive();
        long actions = mMediaController.getPlaybackState().getActions();
        long actions = playbackState.getActions();


        // Prev action
        // Prev action
        mPrevAction.setEnabled((actions & PlaybackState.ACTION_SKIP_TO_PREVIOUS) != 0);
        mPrevAction.setEnabled((actions & PlaybackState.ACTION_SKIP_TO_PREVIOUS) != 0);