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

Commit 8675483c authored by Cole Faust's avatar Cole Faust
Browse files

Fix errorprone warnings that should be errors

This commit is part of a large scale change to fix errorprone
errors that have been downgraded to warnings in the android
source tree, so that they can be promoted to errors again.
The full list of changes include the following, but not all
will be present in any one individual commit:

BadAnnotationImplementation
BadShiftAmount
BanJNDI
BoxedPrimitiveEquality
ComparableType
ComplexBooleanConstant
CollectionToArraySafeParameter
ConditionalExpressionNumericPromotion
DangerousLiteralNull
DoubleBraceInitialization
DurationFrom
DurationTemporalUnit
EmptyTopLevelDeclaration
EqualsNull
EqualsReference
FormatString
FromTemporalAccessor
GetClassOnAnnotation
GetClassOnClass
HashtableContains
IdentityBinaryExpression
IdentityHashMapBoxing
InstantTemporalUnit
InvalidTimeZoneID
InvalidZoneId
IsInstanceIncompatibleType
JUnitParameterMethodNotFound
LockOnBoxedPrimitive
MathRoundIntLong
MislabeledAndroidString
MisusedDayOfYear
MissingSuperCall
MisusedWeekYear
ModifyingCollectionWithItself
NoCanIgnoreReturnValueOnClasses
NonRuntimeAnnotation
NullableOnContainingClass
NullTernary
OverridesJavaxInjectableMethod
ParcelableCreator
PeriodFrom
PreconditionsInvalidPlaceholder
ProtoBuilderReturnValueIgnored
ProtoFieldNullComparison
RandomModInteger
RectIntersectReturnValueIgnored
ReturnValueIgnored
SelfAssignment
SelfComparison
SelfEquals
SizeGreaterThanOrEqualsZero
StringBuilderInitWithChar
TreeToString
TryFailThrowable
UnnecessaryCheckNotNull
UnusedCollectionModifiedInPlace
XorPower

See https://errorprone.info/bugpatterns for more
information on the checks.

Bug: 253827323
Test: m RUN_ERROR_PRONE=true javac-check
Change-Id: I9408872c39c30cd2c9c1038b4a56d0d412344bde
parent eb367ceb
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -457,11 +457,11 @@ public class BassClientStateMachine extends StateMachine {
                subGroup.addChannel(channel.build());
            }
            byte[] arrayCodecId = baseLevel2.codecId;
            long codeId = (long) ((arrayCodecId[4] & 0xff) << 32
            long codeId = ((long) (arrayCodecId[4] & 0xff)) << 32
                    | (arrayCodecId[3] & 0xff) << 24
                    | (arrayCodecId[2] & 0xff) << 16
                    | (arrayCodecId[1] & 0xff) << 8
                    | (arrayCodecId[0] & 0xff));
                    | (arrayCodecId[0] & 0xff);
            subGroup.setCodecId(codeId);
            subGroup.setCodecSpecificConfig(BluetoothLeAudioCodecConfigMetadata.
                    fromRawBytes(baseLevel2.codecConfigInfo));
+8 −4
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.view.Display;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.BluetoothAdapterProxy;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayDeque;
@@ -110,7 +111,9 @@ public class ScanManager {
    // Scan parameters for batch scan.
    private BatchScanParams mBatchScanParms;

    private Integer mCurUsedTrackableAdvertisements;
    private final Object mCurUsedTrackableAdvertisementsLock = new Object();
    @GuardedBy("mCurUsedTrackableAdvertisementsLock")
    private int mCurUsedTrackableAdvertisements = 0;
    private final GattService mService;
    private final AdapterService mAdapterService;
    private BroadcastReceiver mBatchAlarmReceiver;
@@ -157,7 +160,6 @@ public class ScanManager {
                Collections.newSetFromMap(new ConcurrentHashMap<ScanClient, Boolean>());
        mService = service;
        mScanNative = new ScanNative();
        mCurUsedTrackableAdvertisements = 0;
        mDm = mService.getSystemService(DisplayManager.class);
        mActivityManager = mService.getSystemService(ActivityManager.class);
        mLocationManager = mService.getSystemService(LocationManager.class);
@@ -716,8 +718,10 @@ public class ScanManager {
    }

    public int getCurrentUsedTrackingAdvertisement() {
        synchronized (mCurUsedTrackableAdvertisementsLock) {
            return mCurUsedTrackableAdvertisements;
        }
    }

    private class ScanNative {

@@ -1508,7 +1512,7 @@ public class ScanManager {
                boolean allocate) {
            int maxTotalTrackableAdvertisements =
                    AdapterService.getAdapterService().getTotalNumOfTrackableAdvertisements();
            synchronized (mCurUsedTrackableAdvertisements) {
            synchronized (mCurUsedTrackableAdvertisementsLock) {
                int availableEntries =
                        maxTotalTrackableAdvertisements - mCurUsedTrackableAdvertisements;
                if (allocate) {
+2 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.bluetooth.Utils;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

class VendorCommandResponseProcessor {

@@ -106,7 +107,7 @@ class VendorCommandResponseProcessor {
        // replace all white spaces
        commandWord = commandWord.replaceAll("\\s+", "");

        if (SUPPORTED_VENDOR_AT_COMMANDS.get(commandWord) != (Integer) (vendorId)) {
        if (!Objects.equals(SUPPORTED_VENDOR_AT_COMMANDS.get(commandWord), vendorId)) {
            Log.e(TAG, "Invalid command " + atCommand + ", " + vendorId + ". Cand="
                    + commandWord);
            return false;
+1 −1
Original line number Diff line number Diff line
@@ -746,7 +746,7 @@ public class LeAudioService extends ProfileService {
        }
        synchronized (mGroupLock) {
            for (Map.Entry<BluetoothDevice, Integer> entry : mDeviceGroupIdMap.entrySet()) {
                if (entry.getValue() != groupId) {
                if (!Objects.equals(entry.getValue(), groupId)) {
                    continue;
                }
                LeAudioStateMachine sm = mStateMachines.get(entry.getKey());
+1 −1
Original line number Diff line number Diff line
@@ -673,7 +673,7 @@ class MceStateMachine extends StateMachine {
                        case NEW_MESSAGE:
                            // Infer the timestamp for this message as 'now' and read status false
                            // instead of getting the message listing data for it
                            if (!mMessages.contains(ev.getHandle())) {
                            if (!mMessages.containsKey(ev.getHandle())) {
                                Calendar calendar = Calendar.getInstance();
                                MessageMetadata metadata = new MessageMetadata(ev.getHandle(),
                                        calendar.getTime().getTime(), false);
Loading