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

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

ErrorProne: Enforce & fix StringCaseLocaleUsage

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

Bug: 344658662
Test: m BluetoothInstrumentationTests
Flag: Exempt Build and test only
Change-Id: I802f6d0cbce11796e9e857cfb05701ec7d36aced
parent fa6fb000
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -332,6 +332,7 @@ android_app {
            "-Xep:NonApiType:ERROR",
            "-Xep:NonCanonicalType:ERROR",
            "-Xep:ReturnAtTheEndOfVoidFunction:ERROR",
            "-Xep:StringCaseLocaleUsage:ERROR",
            "-Xep:StringCharset:ERROR",
            "-Xep:UnusedMethod:ERROR",
            "-Xep:UnusedVariable:ERROR",
+3 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.bluetooth;

import com.google.common.base.Ascii;

public final class DeviceWorkArounds {
    public static final String PCM_CARKIT = "9C:DF:03";
    public static final String FORD_SYNC_CARKIT = "00:1E:AE";
@@ -25,6 +27,6 @@ public final class DeviceWorkArounds {
    public static final String MERCEDES_BENZ_CARKIT = "00:26:e8";

    public static boolean addressStartsWith(String bdAddr, String carkitAddr) {
        return bdAddr.toLowerCase().startsWith(carkitAddr.toLowerCase());
        return Ascii.toLowerCase(bdAddr).startsWith(Ascii.toLowerCase(carkitAddr));
    }
}
+7 −5
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.bluetooth.avrcpcontroller;

import android.util.SparseArray;

import com.google.common.base.Ascii;

import java.util.HashMap;

/**
@@ -83,12 +85,12 @@ public class BipEncoding {
        if (encoding == null) {
            throw new ParseException("Encoding input invalid");
        }
        encoding = encoding.trim();
        mType = determineEncoding(encoding.toUpperCase());
        encoding = Ascii.toUpperCase(encoding.trim());
        mType = determineEncoding(encoding);

        String proprietaryEncodingId = null;
        if (mType == USR_XXX) {
            proprietaryEncodingId = encoding.substring(4).toUpperCase();
            proprietaryEncodingId = encoding.substring(4);
        }
        mProprietaryEncodingId = proprietaryEncodingId;

@@ -102,7 +104,7 @@ public class BipEncoding {
     * Create an encoding object based on one of the constants for the available formats
     *
     * @param encoding A constant representing an available encoding
     * @param proprietaryId A string representing the Id of a propreitary encoding. Only used if the
     * @param proprietaryId A string representing the Id of a proprietary encoding. Only used if the
     *     encoding type is BipEncoding.USR_XXX
     */
    public BipEncoding(int encoding, String proprietaryId) {
@@ -117,7 +119,7 @@ public class BipEncoding {
                throw new IllegalArgumentException(
                        "Received invalid user defined encoding id '" + proprietaryId + "'");
            }
            proprietaryEncodingId = proprietaryId.toUpperCase();
            proprietaryEncodingId = Ascii.toUpperCase(proprietaryId);
        }
        mProprietaryEncodingId = proprietaryEncodingId;
    }
+3 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.bluetooth.avrcpcontroller;

import android.util.Log;

import com.google.common.base.Ascii;

import java.util.HashSet;

/**
@@ -51,7 +53,7 @@ public class BipTransformation {
    public BipTransformation(String transformations) {
        if (transformations == null) return;

        transformations = transformations.trim().toLowerCase();
        transformations = Ascii.toLowerCase(transformations.trim());
        String[] tokens = transformations.split(" ");
        for (String token : tokens) {
            switch (token) {
+2 −1
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ import com.android.modules.utils.BytesMatcher;

import libcore.util.SneakyThrow;

import com.google.common.base.Ascii;
import com.google.protobuf.InvalidProtocolBufferException;

import java.io.FileDescriptor;
@@ -4794,7 +4795,7 @@ public class AdapterService extends Service {

    public String getIdentityAddress(String address) {
        BluetoothDevice device =
                BluetoothAdapter.getDefaultAdapter().getRemoteDevice(address.toUpperCase());
                BluetoothAdapter.getDefaultAdapter().getRemoteDevice(Ascii.toUpperCase(address));
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);
        if (deviceProp != null && deviceProp.getIdentityAddress() != null) {
            return deviceProp.getIdentityAddress();
Loading