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

Commit 6b481688 authored by William Escande's avatar William Escande
Browse files

MediaControlProfile: Move variable to final

Since some variable are final, we can remove the impossible null check

Bug: 311772251
Test: None
Flag: EXEMPT refactor
Change-Id: Ief02d1dd1f85ab4ddb635929fbecc22db51d8e05
parent 2788d288
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.bluetooth.mcp;

import static java.util.Map.entry;
import static java.util.Objects.requireNonNull;

import android.annotation.NonNull;
import android.bluetooth.BluetoothAvrcp;
@@ -63,17 +64,20 @@ import java.util.stream.Stream;
 * Implemented according to Media Control Service v1.0 specification.
 */
public class MediaControlProfile implements MediaControlServiceCallbacks {
    private static final String TAG = "MediaControlProfile";
    private final Context mContext;
    private static final String TAG = MediaControlProfile.class.getSimpleName();

    private static final int LOG_NB_EVENTS = 100;
    private final BluetoothEventLogger mEventLogger;

    private final BluetoothEventLogger mEventLogger =
            new BluetoothEventLogger(LOG_NB_EVENTS, TAG + " event log");
    private final Context mContext;
    private final McpService mMcpService;
    private final Map<String, MediaControlGattServiceInterface> mServiceMap = new HashMap<>();

    // Media players data
    private MediaPlayerList mMediaPlayerList;
    private final MediaPlayerList mMediaPlayerList;
    private MediaData mCurrentData;

    private McpService mMcpService;
    // MCP service instance
    private MediaControlGattServiceInterface mGMcsService;

@@ -278,9 +282,8 @@ public class MediaControlProfile implements MediaControlServiceCallbacks {
    public MediaControlProfile(@NonNull McpService mcpService) {
        Log.v(TAG, "Creating Generic Media Control Service");

        mMcpService = requireNonNull(mcpService);
        mContext = mcpService;
        mMcpService = mcpService;
        mServiceMap = new HashMap<>();

        if (sMediaPlayerListForTesting != null) {
            mMediaPlayerList = sMediaPlayerListForTesting;
@@ -288,7 +291,6 @@ public class MediaControlProfile implements MediaControlServiceCallbacks {
            mMediaPlayerList = new MediaPlayerList(Looper.myLooper(), mContext);
        }

        mEventLogger = new BluetoothEventLogger(LOG_NB_EVENTS, TAG + " event log");
    }

    @Override
@@ -806,10 +808,7 @@ public class MediaControlProfile implements MediaControlServiceCallbacks {
    }

    public void cleanup() {
        if (mMediaPlayerList != null) {
        mMediaPlayerList.cleanup();
        }
        mMediaPlayerList = null;

        unregisterServiceInstance(mContext.getPackageName());

@@ -869,8 +868,6 @@ public class MediaControlProfile implements MediaControlServiceCallbacks {
                    | ServiceFeature.MEDIA_CONTROL_POINT_OPCODES_SUPPORTED_NOTIFY
                    | ServiceFeature.CONTENT_CONTROL_ID;

    private final Map<String, MediaControlGattServiceInterface> mServiceMap;

    public void unregisterServiceInstance(String appToken) {
        mEventLogger.logd(TAG, "unregisterServiceInstance");