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

Commit 2b97e346 authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Android (Google) Code Review
Browse files

Merge "Fixing stray NPEs" into rvc-dev

parents d507d09c a51c3140
Loading
Loading
Loading
Loading
+26 −19
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.media.MediaMetadata;
import android.media.session.MediaController;
import android.media.session.MediaSession;
import android.media.session.PlaybackState;
import android.os.Handler;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -64,6 +63,7 @@ import java.util.concurrent.Executor;
public class MediaControlPanel implements NotificationMediaManager.MediaListener {
    private static final String TAG = "MediaControlPanel";
    private final NotificationMediaManager mMediaManager;
    private final Executor mForegroundExecutor;
    private final Executor mBackgroundExecutor;

    private Context mContext;
@@ -102,15 +102,18 @@ public class MediaControlPanel implements NotificationMediaManager.MediaListener
     * @param manager
     * @param layoutId layout resource to use for this control panel
     * @param actionIds resource IDs for action buttons in the layout
     * @param foregroundExecutor foreground executor
     * @param backgroundExecutor background executor, used for processing artwork
     */
    public MediaControlPanel(Context context, ViewGroup parent, NotificationMediaManager manager,
            @LayoutRes int layoutId, int[] actionIds, Executor backgroundExecutor) {
            @LayoutRes int layoutId, int[] actionIds, Executor foregroundExecutor,
            Executor backgroundExecutor) {
        mContext = context;
        LayoutInflater inflater = LayoutInflater.from(mContext);
        mMediaNotifView = (LinearLayout) inflater.inflate(layoutId, parent, false);
        mMediaManager = manager;
        mActionIds = actionIds;
        mForegroundExecutor = foregroundExecutor;
        mBackgroundExecutor = backgroundExecutor;
    }

@@ -176,6 +179,7 @@ public class MediaControlPanel implements NotificationMediaManager.MediaListener
        mMediaNotifView.setBackgroundTintList(ColorStateList.valueOf(mBackgroundColor));

        // Click action
        if (contentIntent != null) {
            mMediaNotifView.setOnClickListener(v -> {
                try {
                    contentIntent.send();
@@ -185,6 +189,7 @@ public class MediaControlPanel implements NotificationMediaManager.MediaListener
                    Log.e(TAG, "Pending intent was canceled", e);
                }
            });
        }

        // App icon
        ImageView appIcon = mMediaNotifView.findViewById(R.id.icon);
@@ -316,7 +321,7 @@ public class MediaControlPanel implements NotificationMediaManager.MediaListener

        // Now that it's resized, update the UI
        final RoundedBitmapDrawable result = roundedDrawable;
        albumView.getHandler().post(() -> {
        mForegroundExecutor.execute(() -> {
            if (result != null) {
                albumView.setImageDrawable(result);
                albumView.setVisibility(View.VISIBLE);
@@ -335,8 +340,7 @@ public class MediaControlPanel implements NotificationMediaManager.MediaListener
        if (mSeamless == null) {
            return;
        }
        Handler handler = mSeamless.getHandler();
        handler.post(() -> {
        mForegroundExecutor.execute(() -> {
            updateChipInternal(device);
        });
    }
@@ -401,13 +405,16 @@ public class MediaControlPanel implements NotificationMediaManager.MediaListener
                        new KeyEvent(KeyEvent.ACTION_DOWN, keyCode));
                mContext.sendBroadcast(intent);
            } else {
                Log.d(TAG, "No receiver to restart");
                // If we don't have a receiver, try relaunching the activity instead
                if (mController.getSessionActivity() != null) {
                    try {
                        mController.getSessionActivity().send();
                    } catch (PendingIntent.CanceledException e) {
                        Log.e(TAG, "Pending intent was canceled", e);
                    }
                } else {
                    Log.e(TAG, "No receiver or activity to restart");
                }
            }
        });
        btn.setImageDrawable(mContext.getResources().getDrawable(R.drawable.lb_ic_play));
+4 −2
Original line number Diff line number Diff line
@@ -55,11 +55,13 @@ public class QSMediaPlayer extends MediaControlPanel {
     * @param context
     * @param parent
     * @param manager
     * @param foregroundExecutor
     * @param backgroundExecutor
     */
    public QSMediaPlayer(Context context, ViewGroup parent, NotificationMediaManager manager,
            Executor backgroundExecutor) {
        super(context, parent, manager, R.layout.qs_media_panel, QS_ACTION_IDS, backgroundExecutor);
            Executor foregroundExecutor, Executor backgroundExecutor) {
        super(context, parent, manager, R.layout.qs_media_panel, QS_ACTION_IDS, foregroundExecutor,
                backgroundExecutor);
    }

    /**
+5 −1
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.plugins.qs.DetailAdapter;
import com.android.systemui.plugins.qs.QSTile;
@@ -101,6 +102,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
    private final ArrayList<QSMediaPlayer> mMediaPlayers = new ArrayList<>();
    private final NotificationMediaManager mNotificationMediaManager;
    private final LocalBluetoothManager mLocalBluetoothManager;
    private final Executor mForegroundExecutor;
    private final Executor mBackgroundExecutor;
    private LocalMediaManager mLocalMediaManager;
    private MediaDevice mDevice;
@@ -160,6 +162,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
            BroadcastDispatcher broadcastDispatcher,
            QSLogger qsLogger,
            NotificationMediaManager notificationMediaManager,
            @Main Executor foregroundExecutor,
            @Background Executor backgroundExecutor,
            @Nullable LocalBluetoothManager localBluetoothManager
    ) {
@@ -168,6 +171,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
        mQSLogger = qsLogger;
        mDumpManager = dumpManager;
        mNotificationMediaManager = notificationMediaManager;
        mForegroundExecutor = foregroundExecutor;
        mBackgroundExecutor = backgroundExecutor;
        mLocalBluetoothManager = localBluetoothManager;

@@ -270,7 +274,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
        if (player == null) {
            Log.d(TAG, "creating new player");
            player = new QSMediaPlayer(mContext, this, mNotificationMediaManager,
                    mBackgroundExecutor);
                    mForegroundExecutor, mBackgroundExecutor);

            if (player.isPlaying()) {
                mMediaCarousel.addView(player.getView(), 0, lp); // add in front
+3 −2
Original line number Diff line number Diff line
@@ -48,12 +48,13 @@ public class QuickQSMediaPlayer extends MediaControlPanel {
     * @param context
     * @param parent
     * @param manager
     * @param foregroundExecutor
     * @param backgroundExecutor
     */
    public QuickQSMediaPlayer(Context context, ViewGroup parent, NotificationMediaManager manager,
            Executor backgroundExecutor) {
            Executor foregroundExecutor, Executor backgroundExecutor) {
        super(context, parent, manager, R.layout.qqs_media_panel, QQS_ACTION_IDS,
                backgroundExecutor);
                foregroundExecutor, backgroundExecutor);
    }

    /**
+4 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.plugins.qs.QSTile.SignalState;
@@ -79,11 +80,12 @@ public class QuickQSPanel extends QSPanel {
            BroadcastDispatcher broadcastDispatcher,
            QSLogger qsLogger,
            NotificationMediaManager notificationMediaManager,
            @Main Executor foregroundExecutor,
            @Background Executor backgroundExecutor,
            @Nullable LocalBluetoothManager localBluetoothManager
    ) {
        super(context, attrs, dumpManager, broadcastDispatcher, qsLogger, notificationMediaManager,
                backgroundExecutor, localBluetoothManager);
                foregroundExecutor, backgroundExecutor, localBluetoothManager);
        if (mFooter != null) {
            removeView(mFooter.getView());
        }
@@ -103,7 +105,7 @@ public class QuickQSPanel extends QSPanel {

            int marginSize = (int) mContext.getResources().getDimension(R.dimen.qqs_media_spacing);
            mMediaPlayer = new QuickQSMediaPlayer(mContext, mHorizontalLinearLayout,
                    notificationMediaManager, backgroundExecutor);
                    notificationMediaManager, foregroundExecutor, backgroundExecutor);
            LayoutParams lp2 = new LayoutParams(0, LayoutParams.MATCH_PARENT, 1);
            lp2.setMarginEnd(marginSize);
            lp2.setMarginStart(0);
Loading