summaryrefslogtreecommitdiff
path: root/framework/java
diff options
context:
space:
mode:
author William Escande <wescande@google.com> 2025-02-20 18:21:32 -0800
committer William Escande <wescande@google.com> 2025-02-24 14:19:48 -0800
commit0f45ca0eec3bfef25bcee3fc2b1555a06fa67849 (patch)
tree50e354cf75092216f6ebd641c0dadc7f2d53b25a /framework/java
parente130ea7295c14fb40cca59c1d99fa8d1e32e2745 (diff)
Errorprone fix & enforce MethodCanBeStatic
Bug: 344658662 Test: m BluetoothInstrumentationTests Test: m . Flag: Exempt refactor Change-Id: Ibde1dabbb1ba64cd278e9607e29dec04e70b1bb9
Diffstat (limited to 'framework/java')
-rw-r--r--framework/java/android/bluetooth/BluetoothA2dp.java3
-rw-r--r--framework/java/android/bluetooth/BluetoothAdapter.java7
-rw-r--r--framework/java/android/bluetooth/BluetoothGattCharacteristic.java16
-rw-r--r--framework/java/android/bluetooth/BluetoothHapClient.java2
-rw-r--r--framework/java/android/bluetooth/BluetoothHearingAid.java4
-rw-r--r--framework/java/android/bluetooth/BluetoothHidDevice.java2
-rw-r--r--framework/java/android/bluetooth/BluetoothLeAudio.java2
-rw-r--r--framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java4
-rw-r--r--framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java2
-rw-r--r--framework/java/android/bluetooth/BluetoothLeBroadcast.java2
-rw-r--r--framework/java/android/bluetooth/BluetoothPbap.java2
-rw-r--r--framework/java/android/bluetooth/BluetoothSocket.java6
-rw-r--r--framework/java/android/bluetooth/OobData.java9
-rw-r--r--framework/java/android/bluetooth/le/BluetoothLeAdvertiser.java4
-rw-r--r--framework/java/android/bluetooth/le/BluetoothLeScanner.java2
-rw-r--r--framework/java/android/bluetooth/le/ScanSettings.java2
16 files changed, 34 insertions, 35 deletions
diff --git a/framework/java/android/bluetooth/BluetoothA2dp.java b/framework/java/android/bluetooth/BluetoothA2dp.java
index da949d94d3..06e98105cd 100644
--- a/framework/java/android/bluetooth/BluetoothA2dp.java
+++ b/framework/java/android/bluetooth/BluetoothA2dp.java
@@ -1125,6 +1125,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
return false;
}
+ @SuppressWarnings("MethodCanBeStatic")
private void verifyDeviceNotNull(BluetoothDevice device, String methodName) {
if (device == null) {
Log.e(TAG, methodName + ": device param is null");
@@ -1132,7 +1133,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
}
}
- private boolean isValidDevice(BluetoothDevice device) {
+ private static boolean isValidDevice(BluetoothDevice device) {
if (device == null) return false;
if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java
index 1d8bc20493..bf5ec5ae21 100644
--- a/framework/java/android/bluetooth/BluetoothAdapter.java
+++ b/framework/java/android/bluetooth/BluetoothAdapter.java
@@ -3337,7 +3337,7 @@ public final class BluetoothAdapter {
@RequiresBluetoothConnectPermission
@RequiresPermission(BLUETOOTH_CONNECT)
- private BluetoothServerSocket createNewRfcommSocketAndRecord(
+ private static BluetoothServerSocket createNewRfcommSocketAndRecord(
String name, UUID uuid, boolean auth, boolean encrypt) throws IOException {
BluetoothServerSocket socket;
socket =
@@ -4048,7 +4048,7 @@ public final class BluetoothAdapter {
}
}
- private Set<BluetoothDevice> toDeviceSet(List<BluetoothDevice> devices) {
+ private static Set<BluetoothDevice> toDeviceSet(List<BluetoothDevice> devices) {
Set<BluetoothDevice> deviceSet = new HashSet<BluetoothDevice>(devices);
return Collections.unmodifiableSet(deviceSet);
}
@@ -5807,7 +5807,8 @@ public final class BluetoothAdapter {
}
@RequiresPermission(BLUETOOTH_PRIVILEGED)
- void unregisterFromService(IBluetooth service, IBluetoothHciVendorSpecificCallback stub) {
+ static void unregisterFromService(
+ IBluetooth service, IBluetoothHciVendorSpecificCallback stub) {
if (service == null) {
return;
}
diff --git a/framework/java/android/bluetooth/BluetoothGattCharacteristic.java b/framework/java/android/bluetooth/BluetoothGattCharacteristic.java
index 9d7a95236b..15aebc083d 100644
--- a/framework/java/android/bluetooth/BluetoothGattCharacteristic.java
+++ b/framework/java/android/bluetooth/BluetoothGattCharacteristic.java
@@ -681,29 +681,29 @@ public class BluetoothGattCharacteristic implements Parcelable {
}
/** Returns the size of a give value type. */
- private int getTypeLen(int formatType) {
+ private static int getTypeLen(int formatType) {
return formatType & 0xF;
}
/** Convert a signed byte to an unsigned int. */
- private int unsignedByteToInt(byte b) {
+ private static int unsignedByteToInt(byte b) {
return b & 0xFF;
}
/** Convert signed bytes to a 16-bit unsigned int. */
- private int unsignedBytesToInt(byte b0, byte b1) {
+ private static int unsignedBytesToInt(byte b0, byte b1) {
return (unsignedByteToInt(b0) + (unsignedByteToInt(b1) << 8));
}
/** Convert signed bytes to a 32-bit unsigned int. */
- private int unsignedBytesToInt(byte b0, byte b1, byte b2, byte b3) {
+ private static int unsignedBytesToInt(byte b0, byte b1, byte b2, byte b3) {
return (unsignedByteToInt(b0) + (unsignedByteToInt(b1) << 8))
+ (unsignedByteToInt(b2) << 16)
+ (unsignedByteToInt(b3) << 24);
}
/** Convert signed bytes to a 16-bit short float value. */
- private float bytesToFloat(byte b0, byte b1) {
+ private static float bytesToFloat(byte b0, byte b1) {
int mantissa =
unsignedToSigned(unsignedByteToInt(b0) + ((unsignedByteToInt(b1) & 0x0F) << 8), 12);
int exponent = unsignedToSigned(unsignedByteToInt(b1) >> 4, 4);
@@ -711,7 +711,7 @@ public class BluetoothGattCharacteristic implements Parcelable {
}
/** Convert signed bytes to a 32-bit short float value. */
- private float bytesToFloat(byte b0, byte b1, byte b2, byte b3) {
+ private static float bytesToFloat(byte b0, byte b1, byte b2, byte b3) {
int mantissa =
unsignedToSigned(
unsignedByteToInt(b0)
@@ -722,7 +722,7 @@ public class BluetoothGattCharacteristic implements Parcelable {
}
/** Convert an unsigned integer value to a two's-complement encoded signed value. */
- private int unsignedToSigned(int unsigned, int size) {
+ private static int unsignedToSigned(int unsigned, int size) {
if ((unsigned & (1 << (size - 1))) != 0) {
unsigned = -1 * ((1 << (size - 1)) - (unsigned & ((1 << (size - 1)) - 1)));
}
@@ -730,7 +730,7 @@ public class BluetoothGattCharacteristic implements Parcelable {
}
/** Convert an integer into the signed bits of a given length. */
- private int intToSignedBits(int i, int size) {
+ private static int intToSignedBits(int i, int size) {
if (i < 0) {
i = (1 << (size - 1)) + (i & ((1 << (size - 1)) - 1));
}
diff --git a/framework/java/android/bluetooth/BluetoothHapClient.java b/framework/java/android/bluetooth/BluetoothHapClient.java
index c11249bc9e..08642c3800 100644
--- a/framework/java/android/bluetooth/BluetoothHapClient.java
+++ b/framework/java/android/bluetooth/BluetoothHapClient.java
@@ -1085,7 +1085,7 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable
s -> s.setPresetNameForGroup(groupId, presetIndex, name, mAttributionSource));
}
- private boolean isValidDevice(BluetoothDevice device) {
+ private static boolean isValidDevice(BluetoothDevice device) {
if (device == null) return false;
if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
diff --git a/framework/java/android/bluetooth/BluetoothHearingAid.java b/framework/java/android/bluetooth/BluetoothHearingAid.java
index 29b00611d2..0a4e829216 100644
--- a/framework/java/android/bluetooth/BluetoothHearingAid.java
+++ b/framework/java/android/bluetooth/BluetoothHearingAid.java
@@ -775,14 +775,14 @@ public final class BluetoothHearingAid implements BluetoothProfile {
return false;
}
- private void verifyDeviceNotNull(BluetoothDevice device, String methodName) {
+ private static void verifyDeviceNotNull(BluetoothDevice device, String methodName) {
if (device == null) {
Log.e(TAG, methodName + ": device param is null");
throw new IllegalArgumentException("Device cannot be null");
}
}
- private boolean isValidDevice(BluetoothDevice device) {
+ private static boolean isValidDevice(BluetoothDevice device) {
if (device == null) return false;
if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
diff --git a/framework/java/android/bluetooth/BluetoothHidDevice.java b/framework/java/android/bluetooth/BluetoothHidDevice.java
index 230b5dfaaa..8fd7dee6f7 100644
--- a/framework/java/android/bluetooth/BluetoothHidDevice.java
+++ b/framework/java/android/bluetooth/BluetoothHidDevice.java
@@ -786,7 +786,7 @@ public final class BluetoothHidDevice implements BluetoothProfile {
return false;
}
- private boolean isValidDevice(BluetoothDevice device) {
+ private static boolean isValidDevice(BluetoothDevice device) {
if (device == null) return false;
if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
diff --git a/framework/java/android/bluetooth/BluetoothLeAudio.java b/framework/java/android/bluetooth/BluetoothLeAudio.java
index d71068308f..09683a912a 100644
--- a/framework/java/android/bluetooth/BluetoothLeAudio.java
+++ b/framework/java/android/bluetooth/BluetoothLeAudio.java
@@ -1353,7 +1353,7 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
}
}
- private boolean isValidDevice(@Nullable BluetoothDevice device) {
+ private static boolean isValidDevice(@Nullable BluetoothDevice device) {
if (device == null) return false;
if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
diff --git a/framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java b/framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java
index 0541d4898c..22453839cd 100644
--- a/framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java
+++ b/framework/java/android/bluetooth/BluetoothLeAudioCodecConfig.java
@@ -304,7 +304,7 @@ public final class BluetoothLeAudioCodecConfig implements Parcelable {
out.writeInt(mMaxOctetsPerFrame);
}
- private String sampleRateToString(@SampleRate int sampleRateBit) {
+ private static String sampleRateToString(@SampleRate int sampleRateBit) {
switch (sampleRateBit) {
case SAMPLE_RATE_NONE:
return "None";
@@ -339,7 +339,7 @@ public final class BluetoothLeAudioCodecConfig implements Parcelable {
}
}
- private String frameDurationToString(@FrameDuration int frameDurationBit) {
+ private static String frameDurationToString(@FrameDuration int frameDurationBit) {
switch (frameDurationBit) {
case FRAME_DURATION_NONE:
return "None";
diff --git a/framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java b/framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java
index 2997cba518..7089529638 100644
--- a/framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java
+++ b/framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java
@@ -128,7 +128,7 @@ public final class BluetoothLeAudioCodecStatus implements Parcelable {
return c1.containsAll(c2);
}
- private boolean isCodecConfigSelectable(
+ private static boolean isCodecConfigSelectable(
BluetoothLeAudioCodecConfig codecConfig, BluetoothLeAudioCodecConfig selectableConfig) {
if (codecConfig.getCodecType() != selectableConfig.getCodecType()) {
return false;
diff --git a/framework/java/android/bluetooth/BluetoothLeBroadcast.java b/framework/java/android/bluetooth/BluetoothLeBroadcast.java
index eb65dd0841..4023184fee 100644
--- a/framework/java/android/bluetooth/BluetoothLeBroadcast.java
+++ b/framework/java/android/bluetooth/BluetoothLeBroadcast.java
@@ -778,7 +778,7 @@ public final class BluetoothLeBroadcast implements AutoCloseable, BluetoothProfi
mAdapter.closeProfileProxy(this);
}
- private BluetoothLeBroadcastSettings buildBroadcastSettingsFromMetadata(
+ private static BluetoothLeBroadcastSettings buildBroadcastSettingsFromMetadata(
BluetoothLeAudioContentMetadata contentMetadata, @Nullable byte[] broadcastCode) {
BluetoothLeBroadcastSubgroupSettings.Builder subgroupBuilder =
new BluetoothLeBroadcastSubgroupSettings.Builder()
diff --git a/framework/java/android/bluetooth/BluetoothPbap.java b/framework/java/android/bluetooth/BluetoothPbap.java
index d4c1dfcc7a..afa796b85e 100644
--- a/framework/java/android/bluetooth/BluetoothPbap.java
+++ b/framework/java/android/bluetooth/BluetoothPbap.java
@@ -297,7 +297,7 @@ public class BluetoothPbap implements BluetoothProfile {
return false;
}
- private boolean isValidDevice(BluetoothDevice device) {
+ private static boolean isValidDevice(BluetoothDevice device) {
if (device == null) return false;
if (BluetoothAdapter.checkBluetoothAddress(device.getAddress())) return true;
diff --git a/framework/java/android/bluetooth/BluetoothSocket.java b/framework/java/android/bluetooth/BluetoothSocket.java
index c151a483ef..7c2f524fa0 100644
--- a/framework/java/android/bluetooth/BluetoothSocket.java
+++ b/framework/java/android/bluetooth/BluetoothSocket.java
@@ -1283,7 +1283,7 @@ public final class BluetoothSocket implements Closeable {
return mPfd;
}
- private String convertAddr(final byte[] addr) {
+ private static String convertAddr(final byte[] addr) {
return String.format(
Locale.US,
"%02X:%02X:%02X:%02X:%02X:%02X",
@@ -1394,7 +1394,7 @@ public final class BluetoothSocket implements Closeable {
}
}
- private int readAll(InputStream is, byte[] b) throws IOException {
+ private static int readAll(InputStream is, byte[] b) throws IOException {
int left = b.length;
while (left > 0) {
int ret = is.read(b, b.length - left, left);
@@ -1415,7 +1415,7 @@ public final class BluetoothSocket implements Closeable {
return b.length;
}
- private int readInt(InputStream is) throws IOException {
+ private static int readInt(InputStream is) throws IOException {
byte[] ibytes = new byte[4];
int ret = readAll(is, ibytes);
if (VDBG) Log.d(TAG, "inputStream.read ret: " + ret);
diff --git a/framework/java/android/bluetooth/OobData.java b/framework/java/android/bluetooth/OobData.java
index e699ec541c..48b107c7c0 100644
--- a/framework/java/android/bluetooth/OobData.java
+++ b/framework/java/android/bluetooth/OobData.java
@@ -862,8 +862,7 @@ public final class OobData implements Parcelable {
* @hide
*/
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "OobData: \n\t"
// Both
+ "Device Address With Type: "
@@ -900,13 +899,11 @@ public final class OobData implements Parcelable {
+ "\n\t";
}
- @NonNull
- private String toHexString(int b) {
+ private static @NonNull String toHexString(int b) {
return toHexString(new byte[] {(byte) b});
}
- @NonNull
- private String toHexString(byte[] array) {
+ private static @NonNull String toHexString(byte[] array) {
if (array == null) return "null";
StringBuilder builder = new StringBuilder(array.length * 2);
for (byte b : array) {
diff --git a/framework/java/android/bluetooth/le/BluetoothLeAdvertiser.java b/framework/java/android/bluetooth/le/BluetoothLeAdvertiser.java
index d5c5f64df3..f4fee92e69 100644
--- a/framework/java/android/bluetooth/le/BluetoothLeAdvertiser.java
+++ b/framework/java/android/bluetooth/le/BluetoothLeAdvertiser.java
@@ -780,7 +780,7 @@ public final class BluetoothLeAdvertiser {
return size;
}
- private int byteLength(byte[] array) {
+ private static int byteLength(byte[] array) {
return array == null ? 0 : array.length;
}
@@ -896,7 +896,7 @@ public final class BluetoothLeAdvertiser {
}
@SuppressLint("AndroidFrameworkBluetoothPermission")
- private void postStartSetFailure(
+ private static void postStartSetFailure(
Handler handler, final AdvertisingSetCallback callback, final int error) {
handler.post(
new Runnable() {
diff --git a/framework/java/android/bluetooth/le/BluetoothLeScanner.java b/framework/java/android/bluetooth/le/BluetoothLeScanner.java
index 02f48fb8d8..cd94688f2b 100644
--- a/framework/java/android/bluetooth/le/BluetoothLeScanner.java
+++ b/framework/java/android/bluetooth/le/BluetoothLeScanner.java
@@ -636,7 +636,7 @@ public final class BluetoothLeScanner {
return false;
}
- private boolean isSettingsAndFilterComboAllowed(
+ private static boolean isSettingsAndFilterComboAllowed(
ScanSettings settings, List<ScanFilter> filterList) {
final int callbackType = settings.getCallbackType();
// If onlost/onfound is requested, a non-empty filter is expected
diff --git a/framework/java/android/bluetooth/le/ScanSettings.java b/framework/java/android/bluetooth/le/ScanSettings.java
index 014df2f4f0..e78f46c8d4 100644
--- a/framework/java/android/bluetooth/le/ScanSettings.java
+++ b/framework/java/android/bluetooth/le/ScanSettings.java
@@ -357,7 +357,7 @@ public final class ScanSettings implements Parcelable {
}
// Returns true if the callbackType is valid.
- private boolean isValidCallbackType(int callbackType) {
+ private static boolean isValidCallbackType(int callbackType) {
if (callbackType == CALLBACK_TYPE_ALL_MATCHES
|| callbackType == CALLBACK_TYPE_ALL_MATCHES_AUTO_BATCH
|| callbackType == CALLBACK_TYPE_FIRST_MATCH