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

Commit d7e497e0 authored by William Escande's avatar William Escande
Browse files

ErrorProne: Partial fix SynchronizeOnNonFinalField

See https://errorprone.info/bugpattern/SynchronizeOnNonFinalField

Bug: 344658662
Test: m BluetoothInstrumentationTests
Flag: Exempt Build and test only
Change-Id: I435ce1d6d0fdbc3064b2767ec7cbebe6e37cc23f
parent dc784cdd
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -43,8 +43,9 @@ public class PeriodicScanManager {

    private final BluetoothAdapter mAdapter;
    private final PeriodicScanNativeInterface mNativeInterface;
    Map<IBinder, SyncInfo> mSyncs = new ConcurrentHashMap<>();
    Map<IBinder, SyncTransferInfo> mSyncTransfers = Collections.synchronizedMap(new HashMap<>());
    private final Map<IBinder, SyncInfo> mSyncs = new ConcurrentHashMap<>();
    private final Map<IBinder, SyncTransferInfo> mSyncTransfers =
            Collections.synchronizedMap(new HashMap<>());
    static int sTempRegistrationId = -1;

    /** Constructor of {@link PeriodicScanManager}. */
+7 −2
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import com.android.bluetooth.btservice.MetricsLogger;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.flags.Flags;
import com.android.bluetooth.map.BluetoothMapbMessageMime;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -148,6 +149,10 @@ class MceStateMachine extends StateMachine {
    private HashMap<Bmessage, PendingIntent> mSentReceiptRequested = new HashMap<>(MAX_MESSAGES);
    private HashMap<Bmessage, PendingIntent> mDeliveryReceiptRequested =
            new HashMap<>(MAX_MESSAGES);

    private final Object mLock = new Object();

    @GuardedBy("mLock")
    private Bmessage.Type mDefaultMessageType = Bmessage.Type.SMS_CDMA;

    // The amount of time for MCE to search for remote device's own phone number before:
@@ -472,7 +477,7 @@ class MceStateMachine extends StateMachine {
    }

    Bmessage.Type getDefaultMessageType() {
        synchronized (mDefaultMessageType) {
        synchronized (mLock) {
            if (Utils.isPtsTestMode()) {
                int messageType = SystemProperties.getInt(SEND_MESSAGE_TYPE, -1);
                if (messageType > 0 && messageType < Bmessage.Type.values().length) {
@@ -485,7 +490,7 @@ class MceStateMachine extends StateMachine {

    void setDefaultMessageType(SdpMasRecord sdpMasRecord) {
        int supportedMessageTypes = sdpMasRecord.getSupportedMessageTypes();
        synchronized (mDefaultMessageType) {
        synchronized (mLock) {
            if ((supportedMessageTypes & SdpMasRecord.MessageType.MMS) > 0) {
                mDefaultMessageType = Bmessage.Type.MMS;
            } else if ((supportedMessageTypes & SdpMasRecord.MessageType.SMS_CDMA) > 0) {
+6 −5
Original line number Diff line number Diff line
@@ -139,16 +139,17 @@ public class MediaControlGattService implements MediaControlGattServiceInterface
                    | Request.SupportedOpcodes.PREVIOUS_TRACK;

    private final int mCcid;
    private Map<String, Map<UUID, Short>> mCccDescriptorValues = new HashMap<>();
    private final Map<String, Map<UUID, Short>> mCccDescriptorValues = new HashMap<>();
    private long mFeatures;
    private Context mContext;
    private MediaControlServiceCallbacks mCallbacks;
    private BluetoothGattServerProxy mBluetoothGattServer;
    private BluetoothGattService mGattService = null;
    private Handler mHandler = new Handler(Looper.getMainLooper());
    private Map<Integer, BluetoothGattCharacteristic> mCharacteristics = new HashMap<>();
    private final Handler mHandler = new Handler(Looper.getMainLooper());
    private final Map<Integer, BluetoothGattCharacteristic> mCharacteristics = new HashMap<>();
    private MediaState mCurrentMediaState = MediaState.INACTIVE;
    private Map<BluetoothDevice, List<GattOpContext>> mPendingGattOperations = new HashMap<>();
    private final Map<BluetoothDevice, List<GattOpContext>> mPendingGattOperations =
            new HashMap<>();
    private McpService mMcpService;
    private LeAudioService mLeAudioService;
    private AdapterService mAdapterService;
@@ -1584,7 +1585,7 @@ public class MediaControlGattService implements MediaControlGattServiceInterface
            SearchRequest request, SearchRequest.Results resultStatus, long resultObjectId) {
        Log.d(TAG, "setSearchRequestResult");

        // TODO: There is no Object Trasfer Service implementation.
        // TODO: There is no Object Transfer Service implementation.
        BluetoothGattCharacteristic characteristic =
                mCharacteristics.get(CharId.SEARCH_CONTROL_POINT);
        characteristic.setValue(new byte[] {SEARCH_CONTROL_POINT_RESULT_FAILURE});
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class PbapClientService extends ProfileService {
    private static final int MAXIMUM_DEVICES = 10;

    @VisibleForTesting
    Map<BluetoothDevice, PbapClientStateMachine> mPbapClientStateMachineMap =
    final Map<BluetoothDevice, PbapClientStateMachine> mPbapClientStateMachineMap =
            new ConcurrentHashMap<>();

    private static PbapClientService sPbapClientService;