Apply SdkSuppress to Nearby Tests.
This is to limit Nearby Tests on Android T only.
Bug: 216634361
Test: CTS and Unit tests
Change-Id: I90573215d58883bd5cdbe09e85cfe24ea3490bbd
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java
index bfe71cd..f1b8c7d 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java
@@ -50,6 +50,7 @@
import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import com.google.common.collect.ImmutableList;
@@ -220,6 +221,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathLoadFastPairAntispoofkeyDeviceMetadata() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().loadFastPairAntispoofkeyDeviceMetadata(
@@ -246,6 +248,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathLoadFastPairAccountDevicesMetadata() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().loadFastPairAccountDevicesMetadata(
@@ -270,6 +273,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathLoadFastPairEligibleAccounts() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().loadFastPairEligibleAccounts(
@@ -293,6 +297,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathManageFastPairAccount() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().manageFastPairAccount(
@@ -314,6 +319,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathManageFastPairAccountDevice() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().manageFastPairAccountDevice(
@@ -335,6 +341,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testErrorPathLoadFastPairAntispoofkeyDeviceMetadata() throws Exception {
mErrorPathFastPairDataProvider.asProvider().loadFastPairAntispoofkeyDeviceMetadata(
FAST_PAIR_ANTI_SPOOF_KEY_DEVICE_METADATA_REQUEST_PARCEL,
@@ -347,6 +354,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testErrorPathLoadFastPairAccountDevicesMetadata() throws Exception {
mErrorPathFastPairDataProvider.asProvider().loadFastPairAccountDevicesMetadata(
FAST_PAIR_ACCOUNT_DEVICES_METADATA_REQUEST_PARCEL,
@@ -359,6 +367,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testErrorPathLoadFastPairEligibleAccounts() throws Exception {
mErrorPathFastPairDataProvider.asProvider().loadFastPairEligibleAccounts(
FAST_PAIR_ELIGIBLE_ACCOUNTS_REQUEST_PARCEL,
@@ -371,6 +380,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testErrorPathManageFastPairAccount() throws Exception {
mErrorPathFastPairDataProvider.asProvider().manageFastPairAccount(
FAST_PAIR_MANAGE_ACCOUNT_REQUEST_PARCEL,
@@ -382,6 +392,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testErrorPathManageFastPairAccountDevice() throws Exception {
mErrorPathFastPairDataProvider.asProvider().manageFastPairAccountDevice(
FAST_PAIR_MANAGE_ACCOUNT_DEVICE_REQUEST_PARCEL,
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceParcelableTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceParcelableTest.java
index 84e1263..081626b 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceParcelableTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceParcelableTest.java
@@ -24,6 +24,7 @@
import androidx.annotation.RequiresApi;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -36,6 +37,7 @@
/** Verify toString returns expected string. */
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testToString() {
NearbyDeviceParcelable nearbyDeviceParcelable = new NearbyDeviceParcelable.Builder()
.setName("testDevice")
@@ -53,6 +55,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_defaultNullFields() {
NearbyDeviceParcelable nearbyDeviceParcelable = new NearbyDeviceParcelable.Builder()
.setMedium(NearbyDevice.Medium.BLE)
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceTest.java
index 53d1b0c..aad3fca 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyDeviceTest.java
@@ -25,6 +25,7 @@
import androidx.annotation.RequiresApi;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,6 +36,7 @@
public class NearbyDeviceTest {
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_isValidMedium() {
assertThat(NearbyDevice.isValidMedium(1)).isTrue();
assertThat(NearbyDevice.isValidMedium(2)).isTrue();
@@ -44,6 +46,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getMedium_fromChild() {
FastPairDevice fastPairDevice = new FastPairDevice.Builder()
.setMedium(NearbyDevice.Medium.BLE)
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyFrameworkInitializerTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyFrameworkInitializerTest.java
index b1395a4..370bfe1 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyFrameworkInitializerTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/NearbyFrameworkInitializerTest.java
@@ -21,6 +21,7 @@
import androidx.annotation.RequiresApi;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,6 +43,7 @@
// registerServiceWrappers can only be called during initialization and should throw otherwise
@Test(expected = IllegalStateException.class)
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testThrowsException() {
NearbyFrameworkInitializer.registerServiceWrappers();
}
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java
index 91abf4b..b5939f8 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java
@@ -33,6 +33,7 @@
import androidx.annotation.RequiresApi;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -46,11 +47,13 @@
// Valid scan type must be set to one of ScanRequest#SCAN_TYPE_
@Test(expected = IllegalStateException.class)
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testScanType_notSet_throwsException() {
new ScanRequest.Builder().setScanMode(SCAN_MODE_BALANCED).build();
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testScanMode_defaultLowPower() {
ScanRequest request = new ScanRequest.Builder()
.setScanType(SCAN_TYPE_FAST_PAIR)
@@ -61,6 +64,7 @@
/** Verify setting work source with null value in the scan request is allowed*/
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testSetWorkSource_nullValue() {
ScanRequest request = new ScanRequest.Builder()
.setScanType(SCAN_TYPE_EXPOSURE_NOTIFICATION)
@@ -73,6 +77,7 @@
/** Verify toString returns expected string. */
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testToString() {
WorkSource workSource = getWorkSource();
ScanRequest request = new ScanRequest.Builder()
@@ -89,6 +94,7 @@
/** Verify toString works correctly with null WorkSource. */
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testToString_nullWorkSource() {
ScanRequest request = new ScanRequest.Builder().setScanType(
SCAN_TYPE_FAST_PAIR).setWorkSource(null).build();
@@ -98,6 +104,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testisEnableBle_defaultTrue() {
ScanRequest request = new ScanRequest.Builder()
.setScanType(SCAN_TYPE_FAST_PAIR)
@@ -107,6 +114,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_isValidScanType() {
assertThat(ScanRequest.isValidScanType(SCAN_TYPE_FAST_PAIR)).isTrue();
assertThat(ScanRequest.isValidScanType(SCAN_TYPE_NEARBY_SHARE)).isTrue();
@@ -118,6 +126,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_isValidScanMode() {
assertThat(ScanRequest.isValidScanMode(SCAN_MODE_LOW_LATENCY)).isTrue();
assertThat(ScanRequest.isValidScanMode(SCAN_MODE_BALANCED)).isTrue();
@@ -129,6 +138,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_scanModeToString() {
assertThat(ScanRequest.scanModeToString(2)).isEqualTo("SCAN_MODE_LOW_LATENCY");
assertThat(ScanRequest.scanModeToString(1)).isEqualTo("SCAN_MODE_BALANCED");
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/ble/BleRecordTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/ble/BleRecordTest.java
index 56ac1b8..f4aff1d 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/ble/BleRecordTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/ble/BleRecordTest.java
@@ -18,6 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.filters.SdkSuppress;
+
import org.junit.Test;
/** Test for Bluetooth LE {@link BleRecord}. */
@@ -215,6 +217,7 @@
};
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testEquals() {
BleRecord record = BleRecord.parseFromBytes(BEACON);
BleRecord record2 = BleRecord.parseFromBytes(SAME_BEACON);
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AccountKeyGeneratorTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AccountKeyGeneratorTest.java
index 6b3ed2e..35a45c0 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AccountKeyGeneratorTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AccountKeyGeneratorTest.java
@@ -23,6 +23,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.Test;
@@ -38,6 +39,7 @@
@RunWith(AndroidJUnit4.class)
public class AccountKeyGeneratorTest {
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void createAccountKey() throws NoSuchAlgorithmException {
byte[] accountKey = AccountKeyGenerator.createAccountKey();
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AdditionalDataEncoderTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AdditionalDataEncoderTest.java
index 0273af9..28d2fca 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AdditionalDataEncoderTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AdditionalDataEncoderTest.java
@@ -29,6 +29,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.Test;
@@ -45,6 +46,7 @@
public class AdditionalDataEncoderTest {
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void decodeEncodedAdditionalDataPacket_mustGetSameRawData()
throws GeneralSecurityException {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
@@ -60,6 +62,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectKeySizeToEncode_mustThrowException() {
byte[] secret = new byte[KEY_LENGTH - 1];
byte[] rawData = base16().decode("00112233445566778899AABBCCDDEEFF");
@@ -75,6 +78,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectKeySizeToDecode_mustThrowException() {
byte[] secret = new byte[KEY_LENGTH - 1];
byte[] packet = base16().decode("01234567890123456789");
@@ -90,6 +94,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputTooSmallPacketSize_mustThrowException() {
byte[] secret = new byte[KEY_LENGTH];
byte[] packet = new byte[EXTRACT_HMAC_SIZE - 1];
@@ -103,6 +108,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputTooLargePacketSize_mustThrowException() throws GeneralSecurityException {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
byte[] packet = new byte[MAX_LENGTH_OF_DATA + EXTRACT_HMAC_SIZE + NONCE_SIZE + 1];
@@ -116,6 +122,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectHmacToDecode_mustThrowException() throws GeneralSecurityException {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
byte[] rawData = base16().decode("00112233445566778899AABBCCDDEEFF");
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AesCtrMultipleBlockEncryptionTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AesCtrMultipleBlockEncryptionTest.java
index 50f826d..7d86037 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AesCtrMultipleBlockEncryptionTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AesCtrMultipleBlockEncryptionTest.java
@@ -29,6 +29,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.Test;
@@ -45,6 +46,7 @@
public class AesCtrMultipleBlockEncryptionTest {
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void decryptEncryptedData_nonBlockSizeAligned_mustEqualToPlaintext() throws Exception {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
byte[] plaintext = "Someone's Google Headphone 2019".getBytes(UTF_8); // The length is 31.
@@ -56,6 +58,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void decryptEncryptedData_blockSizeAligned_mustEqualToPlaintext() throws Exception {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
byte[] plaintext =
@@ -69,6 +72,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void generateNonceTwice_mustBeDifferent() {
byte[] nonce1 = AesCtrMultipleBlockEncryption.generateNonce();
byte[] nonce2 = AesCtrMultipleBlockEncryption.generateNonce();
@@ -77,6 +81,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void encryptedSamePlaintext_mustBeDifferentEncryptedResult() throws Exception {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
byte[] plaintext = "Someone's Google Headphone 2019".getBytes(UTF_8);
@@ -88,6 +93,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void encryptData_mustBeDifferentToUnencrypted() throws Exception {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
byte[] plaintext = "Someone's Google Headphone 2019".getBytes(UTF_8);
@@ -98,6 +104,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectKeySizeToEncrypt_mustThrowException() {
byte[] secret = new byte[KEY_LENGTH + 1];
byte[] plaintext = "Someone's Google Headphone 2019".getBytes(UTF_8);
@@ -113,6 +120,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectKeySizeToDecrypt_mustThrowException() {
byte[] secret = new byte[KEY_LENGTH - 1];
byte[] plaintext = "Someone's Google Headphone 2019".getBytes(UTF_8);
@@ -128,6 +136,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectDataSizeToDecrypt_mustThrowException()
throws GeneralSecurityException {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
@@ -147,6 +156,7 @@
// Add some random tests that for a certain amount of random plaintext of random length to prove
// our encryption/decryption is correct. This is suggested by security team.
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void decryptEncryptedRandomDataForCertainAmount_mustEqualToOriginalData()
throws Exception {
SecureRandom random = new SecureRandom();
@@ -166,6 +176,7 @@
// Add some random tests that for a certain amount of random plaintext of random length to prove
// our encryption is correct. This is suggested by security team.
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void twoDistinctEncryptionOnSameRandomData_mustBeDifferentResult() throws Exception {
SecureRandom random = new SecureRandom();
for (int i = 0; i < 1000; i++) {
@@ -184,6 +195,7 @@
// Adds this test example on spec. Also we can easily change the parameters(e.g. secret, data,
// nonce) to clarify test results with partners.
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputTestExampleToEncrypt_getCorrectResult() throws GeneralSecurityException {
byte[] secret = base16().decode("0123456789ABCDEF0123456789ABCDEF");
byte[] nonce = base16().decode("0001020304050607");
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AesEcbSingleBlockEncryptionTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AesEcbSingleBlockEncryptionTest.java
index b1f5148..eccbd01 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AesEcbSingleBlockEncryptionTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/AesEcbSingleBlockEncryptionTest.java
@@ -22,6 +22,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import com.google.common.primitives.Bytes;
@@ -38,6 +39,7 @@
private static final byte[] PLAINTEXT = base16().decode("F30F4E786C59A7BBF3873B5A49BA97EA");
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void encryptDecryptSuccessful() throws Exception {
byte[] secret = AesEcbSingleBlockEncryption.generateKey();
byte[] encrypted = AesEcbSingleBlockEncryption.encrypt(secret, PLAINTEXT);
@@ -47,6 +49,7 @@
}
@Test(expected = IllegalArgumentException.class)
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void encryptionSizeLimitationEnforced() throws Exception {
byte[] secret = AesEcbSingleBlockEncryption.generateKey();
byte[] largePacket = Bytes.concat(PLAINTEXT, PLAINTEXT);
@@ -54,6 +57,7 @@
}
@Test(expected = IllegalArgumentException.class)
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void decryptionSizeLimitationEnforced() throws Exception {
byte[] secret = AesEcbSingleBlockEncryption.generateKey();
byte[] largePacket = Bytes.concat(PLAINTEXT, PLAINTEXT);
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothAddressTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothAddressTest.java
index fa0a890..6c95558 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothAddressTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothAddressTest.java
@@ -22,6 +22,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.Test;
@@ -34,28 +35,33 @@
public class BluetoothAddressTest {
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void maskBluetoothAddress_whenInputIsNull() {
assertThat(BluetoothAddress.maskBluetoothAddress(null)).isEqualTo("");
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void maskBluetoothAddress_whenInputStringNotMatchFormat() {
assertThat(BluetoothAddress.maskBluetoothAddress("AA:BB:CC")).isEqualTo("AA:BB:CC");
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void maskBluetoothAddress_whenInputStringMatchFormat() {
assertThat(BluetoothAddress.maskBluetoothAddress("AA:BB:CC:DD:EE:FF"))
.isEqualTo("XX:XX:XX:XX:EE:FF");
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void maskBluetoothAddress_whenInputStringContainLowerCaseMatchFormat() {
assertThat(BluetoothAddress.maskBluetoothAddress("Aa:Bb:cC:dD:eE:Ff"))
.isEqualTo("XX:XX:XX:XX:EE:FF");
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void maskBluetoothAddress_whenInputBluetoothDevice() {
assertThat(
BluetoothAddress.maskBluetoothAddress(
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothUuidsTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothUuidsTest.java
index dbb01f2..fa977ed 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothUuidsTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/BluetoothUuidsTest.java
@@ -21,6 +21,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.Test;
@@ -47,23 +48,27 @@
UUID.fromString("FE2C9487-8366-4814-8EB0-01DE32100BEA");
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void get16BitUuid() {
assertThat(BluetoothUuids.get16BitUuid(A2DP_SINK_CHARACTERISTICS))
.isEqualTo(A2DP_SINK_SHORT_UUID);
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void is16BitUuid() {
assertThat(BluetoothUuids.is16BitUuid(A2DP_SINK_CHARACTERISTICS)).isTrue();
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void to128BitUuid() {
assertThat(BluetoothUuids.to128BitUuid(A2DP_SINK_SHORT_UUID))
.isEqualTo(A2DP_SINK_CHARACTERISTICS);
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void toFastPair128BitUuid() {
assertThat(BluetoothUuids.toFastPair128BitUuid(CUSTOM_SHORT_UUID))
.isEqualTo(CUSTOM_CHARACTERISTICS);
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/ConstantsTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/ConstantsTest.java
index a0933a9..f7ffa24 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/ConstantsTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/ConstantsTest.java
@@ -27,6 +27,8 @@
import android.bluetooth.BluetoothGattCharacteristic;
+import androidx.test.filters.SdkSuppress;
+
import com.android.server.nearby.common.bluetooth.BluetoothException;
import com.android.server.nearby.common.bluetooth.fastpair.Constants.FastPairService.KeyBasedPairingCharacteristic;
import com.android.server.nearby.common.bluetooth.gatt.BluetoothGattConnection;
@@ -56,6 +58,7 @@
initMocks(this);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getId_whenSupportNewCharacteristics() throws BluetoothException {
when(mMockGattConnection.getCharacteristic(any(UUID.class), any(UUID.class)))
.thenReturn(new BluetoothGattCharacteristic(NEW_KEY_BASE_PAIRING_CHARACTERISTICS, 0,
@@ -65,6 +68,7 @@
.isEqualTo(NEW_KEY_BASE_PAIRING_CHARACTERISTICS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getId_whenNotSupportNewCharacteristics() throws BluetoothException {
// {@link BluetoothGattConnection#getCharacteristic(UUID, UUID)} throws {@link
// BluetoothException} if the characteristic not found .
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/EllipticCurveDiffieHellmanExchangeTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/EllipticCurveDiffieHellmanExchangeTest.java
index 94eba0e..3719783 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/EllipticCurveDiffieHellmanExchangeTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/EllipticCurveDiffieHellmanExchangeTest.java
@@ -23,6 +23,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.Test;
@@ -44,6 +45,7 @@
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void generateCommonKey() throws Exception {
EllipticCurveDiffieHellmanExchange bob = EllipticCurveDiffieHellmanExchange.create();
EllipticCurveDiffieHellmanExchange alice = EllipticCurveDiffieHellmanExchange.create();
@@ -56,6 +58,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void generateCommonKey_withExistingPrivateKey() throws Exception {
EllipticCurveDiffieHellmanExchange bob = EllipticCurveDiffieHellmanExchange.create();
EllipticCurveDiffieHellmanExchange alice =
@@ -66,6 +69,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void generateCommonKey_soundcoreAntiSpoofingKey_generatedTooShort() throws Exception {
// This soundcore device has a public key that was generated which starts with 0x0. This was
// stripped out in our database, but this test confirms that adding that byte back fixes the
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/EventTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/EventTest.java
index d3867f0..28e925f 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/EventTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/EventTest.java
@@ -24,6 +24,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import com.android.server.nearby.intdefs.NearbyEventIntDefs.EventCode;
@@ -47,6 +48,7 @@
private static final Short PROFILE = (short) 1;
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void createAndReadFromParcel() {
Event event =
Event.builder()
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/FastPairHistoryItemTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/FastPairHistoryItemTest.java
index 072fe00..b47fd89 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/FastPairHistoryItemTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/FastPairHistoryItemTest.java
@@ -23,6 +23,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import com.google.common.hash.Hashing;
@@ -40,6 +41,7 @@
public class FastPairHistoryItemTest {
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputMatchedPublicAddress_isMatchedReturnTrue() {
final byte[] accountKey = base16().decode("0123456789ABCDEF");
final byte[] publicAddress = BluetoothAddress.decode("11:22:33:44:55:66");
@@ -54,6 +56,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputNotMatchedPublicAddress_isMatchedReturnFalse() {
final byte[] accountKey = base16().decode("0123456789ABCDEF");
final byte[] publicAddress1 = BluetoothAddress.decode("11:22:33:44:55:66");
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/HeadsetPieceTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/HeadsetPieceTest.java
index ff69a57..670b2ca 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/HeadsetPieceTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/HeadsetPieceTest.java
@@ -23,6 +23,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.Test;
@@ -37,6 +38,7 @@
public class HeadsetPieceTest {
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void parcelAndUnparcel() {
HeadsetPiece headsetPiece = createDefaultHeadset().build();
Parcel expectedParcel = Parcel.obtain();
@@ -49,6 +51,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void parcelAndUnparcel_nullImageContentUri() {
HeadsetPiece headsetPiece = createDefaultHeadset().setImageContentUri(null).build();
Parcel expectedParcel = Parcel.obtain();
@@ -61,6 +64,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void equals() {
HeadsetPiece headsetPiece = createDefaultHeadset().build();
@@ -70,6 +74,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void equals_nullImageContentUri() {
HeadsetPiece headsetPiece = createDefaultHeadset().setImageContentUri(null).build();
@@ -79,6 +84,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void notEquals_differentLowLevelThreshold() {
HeadsetPiece headsetPiece = createDefaultHeadset().build();
@@ -88,6 +94,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void notEquals_differentBatteryLevel() {
HeadsetPiece headsetPiece = createDefaultHeadset().build();
@@ -97,6 +104,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void notEquals_differentImageUrl() {
HeadsetPiece headsetPiece = createDefaultHeadset().build();
@@ -107,6 +115,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void notEquals_differentChargingState() {
HeadsetPiece headsetPiece = createDefaultHeadset().build();
@@ -116,6 +125,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void notEquals_differentImageContentUri() {
HeadsetPiece headsetPiece = createDefaultHeadset().build();
@@ -127,6 +137,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void notEquals_nullImageContentUri() {
HeadsetPiece headsetPiece = createDefaultHeadset().build();
@@ -145,6 +156,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void isLowBattery() {
HeadsetPiece headsetPiece =
HeadsetPiece.builder()
@@ -158,6 +170,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void isNotLowBattery() {
HeadsetPiece headsetPiece =
HeadsetPiece.builder()
@@ -171,6 +184,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void isNotLowBattery_whileCharging() {
HeadsetPiece headsetPiece =
HeadsetPiece.builder()
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/HmacSha256Test.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/HmacSha256Test.java
index f5f2988..8db3b97 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/HmacSha256Test.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/HmacSha256Test.java
@@ -28,6 +28,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import com.google.common.base.Preconditions;
@@ -53,6 +54,7 @@
private static final byte INNER_PADDING_BYTE = 0x36;
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void compareResultWithOurImplementation_mustBeIdentical()
throws GeneralSecurityException {
Random random = new Random(0xFE2C);
@@ -69,6 +71,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectKeySizeToDecrypt_mustThrowException() {
byte[] secret = new byte[KEY_LENGTH - 1];
byte[] data = base16().decode("1234567890ABCDEF1234567890ABCDEF1234567890ABCD");
@@ -82,6 +85,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputTwoIdenticalArrays_compareTwoHmacMustReturnTrue() {
Random random = new Random(0x1237);
byte[] array1 = new byte[EXTRACT_HMAC_SIZE];
@@ -92,6 +96,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputTwoRandomArrays_compareTwoHmacMustReturnFalse() {
Random random = new Random(0xff);
byte[] array1 = new byte[EXTRACT_HMAC_SIZE];
@@ -132,6 +137,7 @@
// Adds this test example on spec. Also we can easily change the parameters(e.g. secret, data)
// to clarify test results with partners.
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputTestExampleToHmacSha256_getCorrectResult() {
byte[] secret = base16().decode("0123456789ABCDEF0123456789ABCDEF");
byte[] data =
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/MessageStreamHmacEncoderTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/MessageStreamHmacEncoderTest.java
index 9a7c430..d4c3342 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/MessageStreamHmacEncoderTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/MessageStreamHmacEncoderTest.java
@@ -16,7 +16,6 @@
package com.android.server.nearby.common.bluetooth.fastpair;
-
import static com.android.server.nearby.common.bluetooth.fastpair.MessageStreamHmacEncoder.EXTRACT_HMAC_SIZE;
import static com.android.server.nearby.common.bluetooth.fastpair.MessageStreamHmacEncoder.SECTION_NONCE_LENGTH;
@@ -26,6 +25,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.Test;
@@ -46,6 +46,7 @@
private static final int ACCOUNT_KEY_LENGTH = 16;
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void encodeMessagePacket() throws GeneralSecurityException {
int messageLength = 2;
SecureRandom secureRandom = new SecureRandom();
@@ -76,6 +77,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void verifyHmac() throws GeneralSecurityException {
int messageLength = 2;
SecureRandom secureRandom = new SecureRandom();
@@ -92,6 +94,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void verifyHmac_failedByAccountKey() throws GeneralSecurityException {
int messageLength = 2;
SecureRandom secureRandom = new SecureRandom();
@@ -109,6 +112,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void verifyHmac_failedBySectionNonce() throws GeneralSecurityException {
int messageLength = 2;
SecureRandom secureRandom = new SecureRandom();
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/NamingEncoderTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/NamingEncoderTest.java
index 9e3f3da..d66d209 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/NamingEncoderTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/NamingEncoderTest.java
@@ -29,6 +29,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.Test;
@@ -45,6 +46,7 @@
public class NamingEncoderTest {
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void decodeEncodedNamingPacket_mustGetSameName() throws GeneralSecurityException {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
String name = "Someone's Google Headphone";
@@ -55,6 +57,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectKeySizeToEncode_mustThrowException() {
byte[] secret = new byte[KEY_LENGTH - 1];
String data = "Someone's Google Headphone";
@@ -69,6 +72,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectKeySizeToDecode_mustThrowException() {
byte[] secret = new byte[KEY_LENGTH - 1];
byte[] data = new byte[50];
@@ -83,6 +87,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputTooSmallPacketSize_mustThrowException() {
byte[] secret = new byte[KEY_LENGTH];
byte[] data = new byte[EXTRACT_HMAC_SIZE - 1];
@@ -96,6 +101,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputTooLargePacketSize_mustThrowException() throws GeneralSecurityException {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
byte[] namingPacket = new byte[MAX_LENGTH_OF_NAME + EXTRACT_HMAC_SIZE + NONCE_SIZE + 1];
@@ -109,6 +115,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void inputIncorrectHmacToDecode_mustThrowException() throws GeneralSecurityException {
byte[] secret = AesCtrMultipleBlockEncryption.generateKey();
String name = "Someone's Google Headphone";
@@ -129,6 +136,7 @@
// Adds this test example on spec. Also we can easily change the parameters(e.g. secret, naming
// packet) to clarify test results with partners.
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void decodeTestNamingPacket_mustGetSameName() throws GeneralSecurityException {
byte[] secret = base16().decode("0123456789ABCDEF0123456789ABCDEF");
byte[] namingPacket = base16().decode(
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/TimingLoggerTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/TimingLoggerTest.java
index ded1fb7..4672905 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/TimingLoggerTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/fastpair/TimingLoggerTest.java
@@ -22,6 +22,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import com.android.server.nearby.common.bluetooth.fastpair.TimingLogger.ScopedTiming;
@@ -30,7 +31,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-
/**
* Unit tests for {@link TimingLogger}.
*/
@@ -42,6 +42,7 @@
private final Preferences mPrefs = Preferences.builder().setEvaluatePerformance(true).build();
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void logPairedTiming() {
String label = "start";
TimingLogger timingLogger = new TimingLogger("paired", mPrefs);
@@ -65,6 +66,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void logScopedTiming() {
String label = "scopedTiming";
TimingLogger timingLogger = new TimingLogger("scoped", mPrefs);
@@ -88,6 +90,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void logOrderedTiming() {
String label1 = "t1";
String label2 = "t2";
@@ -128,6 +131,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void logNestedTiming() {
String labelOuter = "outer";
String labelInner1 = "inner1";
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattConnectionTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattConnectionTest.java
index 13802ee..80bde63 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattConnectionTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattConnectionTest.java
@@ -39,6 +39,8 @@
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
+import androidx.test.filters.SdkSuppress;
+
import com.android.server.nearby.common.bluetooth.BluetoothConsts;
import com.android.server.nearby.common.bluetooth.BluetoothException;
import com.android.server.nearby.common.bluetooth.BluetoothGattException;
@@ -164,12 +166,14 @@
when(mMockBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getDevice() {
BluetoothDevice result = mBluetoothGattConnection.getDevice();
assertThat(result).isEqualTo(mMockBluetoothDevice);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getConnectionOptions() {
BluetoothGattHelper.ConnectionOptions result = mBluetoothGattConnection
.getConnectionOptions();
@@ -177,6 +181,7 @@
assertThat(result).isSameInstanceAs(CONNECTION_OPTIONS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_isConnected_false_beforeConnection() {
mBluetoothGattConnection = new BluetoothGattConnection(
mMockBluetoothGattWrapper,
@@ -188,12 +193,14 @@
assertThat(result).isFalse();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_isConnected_true_afterConnection() {
boolean result = mBluetoothGattConnection.isConnected();
assertThat(result).isTrue();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_isConnected_false_afterDisconnection() {
mBluetoothGattConnection.onClosed();
@@ -202,6 +209,7 @@
assertThat(result).isFalse();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getService_notDiscovered() throws Exception {
BluetoothGattService result = mBluetoothGattConnection.getService(SERVICE_UUID);
verify(mMockBluetoothOperationExecutor).execute(mSynchronousOperationCaptor.capture());
@@ -216,6 +224,7 @@
verify(mMockBluetoothGattWrapper).discoverServices();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getService_alreadyDiscovered() throws Exception {
mBluetoothGattConnection.getService(SERVICE_UUID);
verify(mMockBluetoothOperationExecutor).execute(mSynchronousOperationCaptor.capture());
@@ -229,6 +238,7 @@
verifyNoMoreInteractions(mMockBluetoothOperationExecutor);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getService_notFound() throws Exception {
when(mMockBluetoothGattWrapper.getServices()).thenReturn(
Arrays.<BluetoothGattService>asList());
@@ -240,6 +250,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getService_moreThanOne() throws Exception {
when(mMockBluetoothGattWrapper.getServices())
.thenReturn(Arrays.asList(mMockBluetoothGattService, mMockBluetoothGattService));
@@ -251,6 +262,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getCharacteristic() throws Exception {
BluetoothGattCharacteristic result =
mBluetoothGattConnection.getCharacteristic(SERVICE_UUID, CHARACTERISTIC_UUID);
@@ -258,6 +270,7 @@
assertThat(result).isEqualTo(mMockBluetoothGattCharacteristic);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getCharacteristic_notFound() throws Exception {
when(mMockBluetoothGattService.getCharacteristics())
.thenReturn(Arrays.<BluetoothGattCharacteristic>asList());
@@ -269,6 +282,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getCharacteristic_moreThanOne() throws Exception {
when(mMockBluetoothGattService.getCharacteristics())
.thenReturn(
@@ -282,6 +296,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getCharacteristic_moreThanOneService() throws Exception {
// Add a new service with the same service UUID as our existing one, but add a different
// characteristic inside of it.
@@ -303,6 +318,7 @@
mBluetoothGattConnection.getCharacteristic(SERVICE_UUID, CHARACTERISTIC_UUID);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getDescriptor() throws Exception {
when(mMockBluetoothGattCharacteristic.getDescriptors())
.thenReturn(Arrays.asList(mMockBluetoothGattDescriptor));
@@ -314,6 +330,7 @@
assertThat(result).isEqualTo(mMockBluetoothGattDescriptor);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getDescriptor_notFound() throws Exception {
when(mMockBluetoothGattCharacteristic.getDescriptors())
.thenReturn(Arrays.<BluetoothGattDescriptor>asList());
@@ -326,6 +343,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getDescriptor_moreThanOne() throws Exception {
when(mMockBluetoothGattCharacteristic.getDescriptors())
.thenReturn(
@@ -339,6 +357,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_discoverServices() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new SynchronousOperation<>(
@@ -358,6 +377,7 @@
verify(mMockBluetoothGattWrapper, never()).refresh();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_discoverServices_serviceChange() throws Exception {
when(mMockBluetoothGattWrapper.getService(ReservedUuids.Services.GENERIC_ATTRIBUTE))
.thenReturn(mMockBluetoothGattService);
@@ -376,6 +396,7 @@
verify(mMockBluetoothGattWrapper).refresh();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_discoverServices_SelfDefinedServiceDynamic() throws Exception {
when(mMockBluetoothGattWrapper.getService(BluetoothConsts.SERVICE_DYNAMIC_SERVICE))
.thenReturn(mMockBluetoothGattService);
@@ -394,6 +415,7 @@
verify(mMockBluetoothGattWrapper).refresh();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_discoverServices_refreshWithGattErrorOnMncAbove() throws Exception {
if (VERSION.SDK_INT <= VERSION_CODES.LOLLIPOP_MR1) {
return;
@@ -414,6 +436,7 @@
verify(mMockBluetoothGattWrapper).refresh();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_discoverServices_refreshWithGattInternalErrorOnMncAbove() throws Exception {
if (VERSION.SDK_INT <= VERSION_CODES.LOLLIPOP_MR1) {
return;
@@ -434,6 +457,7 @@
verify(mMockBluetoothGattWrapper).refresh();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_discoverServices_dynamicServices_notBonded() throws Exception {
when(mMockBluetoothGattWrapper.getService(ReservedUuids.Services.GENERIC_ATTRIBUTE))
.thenReturn(mMockBluetoothGattService);
@@ -447,6 +471,7 @@
verify(mMockBluetoothGattWrapper, never()).refresh();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_readCharacteristic() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new Operation<byte[]>(
@@ -466,6 +491,7 @@
verify(mMockBluetoothGattWrapper).readCharacteristic(mMockBluetoothGattCharacteristic);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_readCharacteristic_by_uuid() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new Operation<byte[]>(
@@ -485,6 +511,7 @@
verify(mMockBluetoothGattWrapper).readCharacteristic(mMockBluetoothGattCharacteristic);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_writeCharacteristic() throws Exception {
BluetoothGattCharacteristic characteristic =
new BluetoothGattCharacteristic(
@@ -502,6 +529,7 @@
assertThat(writtenCharacteristic).isEqualTo(characteristic);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_writeCharacteristic_by_uuid() throws Exception {
mBluetoothGattConnection.writeCharacteristic(SERVICE_UUID, CHARACTERISTIC_UUID, DATA);
@@ -515,6 +543,7 @@
assertThat(writtenCharacteristic.getUuid()).isEqualTo(CHARACTERISTIC_UUID);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_readDescriptor() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new Operation<byte[]>(
@@ -532,6 +561,7 @@
verify(mMockBluetoothGattWrapper).readDescriptor(mMockBluetoothGattDescriptor);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_readDescriptor_by_uuid() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new Operation<byte[]>(
@@ -551,6 +581,7 @@
verify(mMockBluetoothGattWrapper).readDescriptor(mMockBluetoothGattDescriptor);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_writeDescriptor() throws Exception {
BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(DESCRIPTOR_UUID, 0);
mBluetoothGattConnection.writeDescriptor(descriptor, DATA);
@@ -565,6 +596,7 @@
assertThat(writtenDescriptor).isEqualTo(descriptor);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_writeDescriptor_by_uuid() throws Exception {
mBluetoothGattConnection.writeDescriptor(
SERVICE_UUID, CHARACTERISTIC_UUID, DESCRIPTOR_UUID, DATA);
@@ -578,6 +610,7 @@
assertThat(writtenDescriptor.getUuid()).isEqualTo(DESCRIPTOR_UUID);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_readRemoteRssi() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new Operation<Integer>(OperationType.READ_RSSI, mMockBluetoothGattWrapper),
@@ -595,12 +628,14 @@
verify(mMockBluetoothGattWrapper).readRemoteRssi();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getMaxDataPacketSize() throws Exception {
int result = mBluetoothGattConnection.getMaxDataPacketSize();
assertThat(result).isEqualTo(mBluetoothGattConnection.getMtu() - 3);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testSetNotificationEnabled_indication_enable() throws Exception {
when(mMockBluetoothGattCharacteristic.getProperties())
.thenReturn(BluetoothGattCharacteristic.PROPERTY_INDICATE);
@@ -618,6 +653,7 @@
.isEqualTo(ReservedUuids.Descriptors.CLIENT_CHARACTERISTIC_CONFIGURATION);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_getNotificationEnabled_notification_enable() throws Exception {
mBluetoothGattConnection.setNotificationEnabled(mMockBluetoothGattCharacteristic, true);
@@ -632,6 +668,7 @@
.isEqualTo(ReservedUuids.Descriptors.CLIENT_CHARACTERISTIC_CONFIGURATION);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_setNotificationEnabled_indication_disable() throws Exception {
when(mMockBluetoothGattCharacteristic.getProperties())
.thenReturn(BluetoothGattCharacteristic.PROPERTY_INDICATE);
@@ -649,6 +686,7 @@
.isEqualTo(ReservedUuids.Descriptors.CLIENT_CHARACTERISTIC_CONFIGURATION);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_setNotificationEnabled_notification_disable() throws Exception {
mBluetoothGattConnection.setNotificationEnabled(mMockBluetoothGattCharacteristic, false);
@@ -663,6 +701,7 @@
.isEqualTo(ReservedUuids.Descriptors.CLIENT_CHARACTERISTIC_CONFIGURATION);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_setNotificationEnabled_failure() throws Exception {
when(mMockBluetoothGattCharacteristic.getProperties())
.thenReturn(BluetoothGattCharacteristic.PROPERTY_READ);
@@ -675,6 +714,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_enableNotification_Uuid() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new SynchronousOperation<>(
@@ -692,6 +732,7 @@
verify(mMockCharChangeListener).onValueChange(DATA);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_enableNotification() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new SynchronousOperation<>(
@@ -711,6 +752,7 @@
verify(mMockCharChangeListener).onValueChange(DATA);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_enableNotification_observe() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new SynchronousOperation<>(
@@ -728,6 +770,7 @@
assertThat(changeObserver.waitForUpdate(TimeUnit.SECONDS.toMillis(1))).isEqualTo(DATA);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_disableNotification_Uuid() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new SynchronousOperation<>(
@@ -743,6 +786,7 @@
verify(mMockCharChangeListener, never()).onValueChange(DATA);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_disableNotification() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new SynchronousOperation<ChangeObserver>(
@@ -763,6 +807,7 @@
verify(mMockCharChangeListener, never()).onValueChange(DATA);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_addCloseListener() throws Exception {
mBluetoothGattConnection.addCloseListener(mMockConnectionCloseListener);
@@ -770,6 +815,7 @@
verify(mMockConnectionCloseListener).onClose();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_removeCloseListener() throws Exception {
mBluetoothGattConnection.addCloseListener(mMockConnectionCloseListener);
@@ -779,6 +825,7 @@
verify(mMockConnectionCloseListener, never()).onClose();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_close() throws Exception {
mBluetoothGattConnection.close();
@@ -790,6 +837,7 @@
verify(mMockBluetoothGattWrapper).close();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_onClosed() throws Exception {
mBluetoothGattConnection.onClosed();
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattHelperTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattHelperTest.java
index 60cac57..7c20be1 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattHelperTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattHelperTest.java
@@ -42,6 +42,8 @@
import android.os.ParcelUuid;
import android.test.mock.MockContext;
+import androidx.test.filters.SdkSuppress;
+
import com.android.server.nearby.common.bluetooth.BluetoothException;
import com.android.server.nearby.common.bluetooth.gatt.BluetoothGattHelper.ConnectionOptions;
import com.android.server.nearby.common.bluetooth.gatt.BluetoothGattHelper.OperationType;
@@ -144,6 +146,7 @@
.thenReturn(ConnectionOptions.builder().build());
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_autoConnect_uuid_success_lowLatency() throws Exception {
BluetoothGattConnection result = mBluetoothGattHelper.autoConnect(SERVICE_UUID);
@@ -163,6 +166,7 @@
verifyNoMoreInteractions(mMockBluetoothLeScanner);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_autoConnect_uuid_success_lowPower() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(SCANNING_OPERATION,
BluetoothGattHelper.LOW_LATENCY_SCAN_MILLIS)).thenThrow(
@@ -182,6 +186,7 @@
verifyNoMoreInteractions(mMockBluetoothLeScanner);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_autoConnect_uuid_success_afterRetry() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new Operation<BluetoothGattConnection>(OperationType.CONNECT, mMockBluetoothDevice),
@@ -194,6 +199,7 @@
assertThat(result).isEqualTo(mMockBluetoothGattConnection);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_autoConnect_uuid_failure_scanning() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(SCANNING_OPERATION,
BluetoothGattHelper.LOW_LATENCY_SCAN_MILLIS)).thenThrow(
@@ -207,6 +213,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_autoConnect_uuid_failure_connecting() throws Exception {
when(mMockBluetoothOperationExecutor.executeNonnull(
new Operation<BluetoothGattConnection>(OperationType.CONNECT, mMockBluetoothDevice),
@@ -226,6 +233,7 @@
CONNECT_TIMEOUT_MILLIS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_autoConnect_uuid_failure_noBle() throws Exception {
when(mMockBluetoothAdapter.getBluetoothLeScanner()).thenReturn(null);
@@ -237,6 +245,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_connect() throws Exception {
BluetoothGattConnection result = mBluetoothGattHelper.connect(mMockBluetoothDevice);
@@ -251,6 +260,7 @@
.isEqualTo(mMockBluetoothDevice);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_connect_withOptionAutoConnect_success() throws Exception {
BluetoothGattConnection result = mBluetoothGattHelper
.connect(
@@ -272,6 +282,7 @@
.build());
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_connect_withOptionAutoConnect_failure_nullResult() throws Exception {
when(mMockBluetoothDevice.connectGatt(eq(mMockApplicationContext), anyBoolean(),
eq(mBluetoothGattHelper.mBluetoothGattCallback),
@@ -291,6 +302,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_connect_withOptionRequestConnectionPriority_success() throws Exception {
// Operation succeeds on the 3rd try.
when(mMockBluetoothGattWrapper
@@ -322,6 +334,7 @@
.requestConnectionPriority(BluetoothGatt.CONNECTION_PRIORITY_HIGH);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_connect_cancel() throws Exception {
mBluetoothGattHelper.connect(mMockBluetoothDevice);
@@ -336,6 +349,7 @@
assertThat(mBluetoothGattHelper.mConnections.get(mMockBluetoothGattWrapper)).isNull();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onConnectionStateChange_connected_success()
throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
@@ -352,6 +366,7 @@
verify(mMockBluetoothGattConnection).onConnected();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onConnectionStateChange_connected_success_withMtuOption()
throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
@@ -371,6 +386,7 @@
verify(mMockBluetoothGattWrapper).requestMtu(MTU);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onConnectionStateChange_connected_success_failMtuOption()
throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
@@ -394,6 +410,7 @@
assertThat(mBluetoothGattHelper.mConnections.get(mMockBluetoothGattWrapper)).isNull();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onConnectionStateChange_connected_unexpectedSuccess()
throws Exception {
mBluetoothGattHelper.mBluetoothGattCallback.onConnectionStateChange(
@@ -403,6 +420,7 @@
verifyZeroInteractions(mMockBluetoothOperationExecutor);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onConnectionStateChange_connected_failure()
throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
@@ -424,6 +442,7 @@
assertThat(mBluetoothGattHelper.mConnections.get(mMockBluetoothGattWrapper)).isNull();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onConnectionStateChange_disconnected_unexpectedSuccess()
throws Exception {
mBluetoothGattHelper.mBluetoothGattCallback
@@ -435,6 +454,7 @@
verifyZeroInteractions(mMockBluetoothOperationExecutor);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onConnectionStateChange_disconnected_notConnected()
throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
@@ -457,6 +477,7 @@
assertThat(mBluetoothGattHelper.mConnections.get(mMockBluetoothGattWrapper)).isNull();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onConnectionStateChange_disconnected_success()
throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
@@ -474,6 +495,7 @@
assertThat(mBluetoothGattHelper.mConnections.get(mMockBluetoothGattWrapper)).isNull();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onConnectionStateChange_disconnected_failure()
throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
@@ -491,6 +513,7 @@
assertThat(mBluetoothGattHelper.mConnections.get(mMockBluetoothGattWrapper)).isNull();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onServicesDiscovered() throws Exception {
mBluetoothGattHelper.mBluetoothGattCallback.onServicesDiscovered(mMockBluetoothGattWrapper,
GATT_STATUS);
@@ -501,6 +524,7 @@
GATT_STATUS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onCharacteristicRead() throws Exception {
mBluetoothGattHelper.mBluetoothGattCallback.onCharacteristicRead(mMockBluetoothGattWrapper,
mMockBluetoothGattCharacteristic, GATT_STATUS);
@@ -511,6 +535,7 @@
GATT_STATUS, CHARACTERISTIC_VALUE);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onCharacteristicWrite() throws Exception {
mBluetoothGattHelper.mBluetoothGattCallback.onCharacteristicWrite(mMockBluetoothGattWrapper,
mMockBluetoothGattCharacteristic, GATT_STATUS);
@@ -521,6 +546,7 @@
GATT_STATUS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onDescriptorRead() throws Exception {
mBluetoothGattHelper.mBluetoothGattCallback.onDescriptorRead(mMockBluetoothGattWrapper,
mMockBluetoothGattDescriptor, GATT_STATUS);
@@ -532,6 +558,7 @@
DESCRIPTOR_VALUE);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onDescriptorWrite() throws Exception {
mBluetoothGattHelper.mBluetoothGattCallback.onDescriptorWrite(mMockBluetoothGattWrapper,
mMockBluetoothGattDescriptor, GATT_STATUS);
@@ -542,6 +569,7 @@
GATT_STATUS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onReadRemoteRssi() throws Exception {
mBluetoothGattHelper.mBluetoothGattCallback.onReadRemoteRssi(mMockBluetoothGattWrapper,
RSSI, GATT_STATUS);
@@ -551,6 +579,7 @@
GATT_STATUS, RSSI);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onReliableWriteCompleted() throws Exception {
mBluetoothGattHelper.mBluetoothGattCallback.onReliableWriteCompleted(
mMockBluetoothGattWrapper,
@@ -561,6 +590,7 @@
GATT_STATUS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onMtuChanged() throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
mMockBluetoothGattConnection);
@@ -574,6 +604,7 @@
MTU);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testBluetoothGattCallback_onMtuChangedDuringConnection_success() throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
mMockBluetoothGattConnection);
@@ -590,6 +621,7 @@
mMockBluetoothGattConnection);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testBluetoothGattCallback_onMtuChangedDuringConnection_fail() throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
mMockBluetoothGattConnection);
@@ -609,6 +641,7 @@
assertThat(mBluetoothGattHelper.mConnections.get(mMockBluetoothGattWrapper)).isNull();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_BluetoothGattCallback_onCharacteristicChanged() throws Exception {
mBluetoothGattHelper.mConnections.put(mMockBluetoothGattWrapper,
mMockBluetoothGattConnection);
@@ -622,6 +655,7 @@
CHARACTERISTIC_VALUE);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_ScanCallback_onScanFailed() throws Exception {
mBluetoothGattHelper.mScanCallback.onScanFailed(ScanCallback.SCAN_FAILED_INTERNAL_ERROR);
@@ -630,6 +664,7 @@
isA(BluetoothException.class));
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_ScanCallback_onScanResult() throws Exception {
mBluetoothGattHelper.mScanCallback.onScanResult(ScanSettings.CALLBACK_TYPE_ALL_MATCHES,
mMockScanResult);
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/util/BluetoothGattUtilsTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/util/BluetoothGattUtilsTest.java
index 4f206c4..47182c3 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/util/BluetoothGattUtilsTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/util/BluetoothGattUtilsTest.java
@@ -24,6 +24,7 @@
import android.platform.test.annotations.Presubmit;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import com.google.common.collect.ImmutableSet;
@@ -45,6 +46,7 @@
"GATT_WRITE_REQUEST_BUSY", "GATT_WRITE_REQUEST_FAIL", "GATT_WRITE_REQUEST_SUCCESS");
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testGetMessageForStatusCode() throws Exception {
Field[] publicFields = BluetoothGatt.class.getFields();
for (Field field : publicFields) {
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/util/BluetoothOperationExecutorTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/util/BluetoothOperationExecutorTest.java
index 6d1450f..7b3ebab 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/util/BluetoothOperationExecutorTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/bluetooth/util/BluetoothOperationExecutorTest.java
@@ -25,6 +25,8 @@
import android.bluetooth.BluetoothGatt;
+import androidx.test.filters.SdkSuppress;
+
import com.android.server.nearby.common.bluetooth.BluetoothException;
import com.android.server.nearby.common.bluetooth.testability.NonnullProvider;
import com.android.server.nearby.common.bluetooth.testability.TimeProvider;
@@ -89,6 +91,7 @@
mMockBlockingQueueProvider);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testExecute() throws Exception {
when(mMockBlockingQueue.take()).thenReturn(OPERATION_RESULT);
@@ -98,6 +101,7 @@
assertThat(result).isEqualTo(OPERATION_RESULT);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testExecuteWithTimeout() throws Exception {
when(mMockBlockingQueue.poll(TIMEOUT, TimeUnit.MILLISECONDS)).thenReturn(OPERATION_RESULT);
@@ -107,6 +111,7 @@
assertThat(result).isEqualTo(OPERATION_RESULT);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testSchedule() throws Exception {
when(mMockBlockingQueue.poll(TIMEOUT, TimeUnit.MILLISECONDS)).thenReturn(OPERATION_RESULT);
@@ -116,6 +121,7 @@
assertThat(result.get(TIMEOUT, TimeUnit.MILLISECONDS)).isEqualTo(OPERATION_RESULT);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testScheduleOtherOperationInProgress() throws Exception {
when(mMockSemaphore.tryAcquire()).thenReturn(false);
when(mMockBlockingQueue.poll(TIMEOUT, TimeUnit.MILLISECONDS)).thenReturn(OPERATION_RESULT);
@@ -130,6 +136,7 @@
verify(mMockStringOperation).execute(mBluetoothOperationExecutor);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testNotifySuccessWithResult() throws Exception {
when(mMockBlockingQueueProvider.get()).thenReturn(new LinkedBlockingDeque<Object>());
Future<String> future = mBluetoothOperationExecutor.schedule(mMockStringOperation);
@@ -139,6 +146,7 @@
assertThat(future.get(1, TimeUnit.MILLISECONDS)).isEqualTo(OPERATION_RESULT);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testNotifySuccessTwice() throws Exception {
BlockingQueue<Object> resultQueue = new LinkedBlockingDeque<Object>();
when(mMockBlockingQueueProvider.get()).thenReturn(resultQueue);
@@ -153,6 +161,7 @@
assertThat(resultQueue).isEmpty();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testNotifySuccessWithNullResult() throws Exception {
when(mMockBlockingQueueProvider.get()).thenReturn(new LinkedBlockingDeque<Object>());
Future<String> future = mBluetoothOperationExecutor.schedule(mMockStringOperation);
@@ -162,6 +171,7 @@
assertThat(future.get(1, TimeUnit.MILLISECONDS)).isNull();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testNotifySuccess() throws Exception {
when(mMockBlockingQueueProvider.get()).thenReturn(new LinkedBlockingDeque<Object>());
Future<Void> future = mBluetoothOperationExecutor.schedule(mMockVoidOperation);
@@ -171,6 +181,7 @@
future.get(1, TimeUnit.MILLISECONDS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testNotifyCompletionSuccess() throws Exception {
when(mMockBlockingQueueProvider.get()).thenReturn(new LinkedBlockingDeque<Object>());
Future<Void> future = mBluetoothOperationExecutor.schedule(mMockVoidOperation);
@@ -181,6 +192,7 @@
future.get(1, TimeUnit.MILLISECONDS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testNotifyCompletionFailure() throws Exception {
when(mMockBlockingQueueProvider.get()).thenReturn(new LinkedBlockingDeque<Object>());
Future<Void> future = mBluetoothOperationExecutor.schedule(mMockVoidOperation);
@@ -196,6 +208,7 @@
}
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testNotifyFailure() throws Exception {
when(mMockBlockingQueueProvider.get()).thenReturn(new LinkedBlockingDeque<Object>());
Future<Void> future = mBluetoothOperationExecutor.schedule(mMockVoidOperation);
@@ -212,6 +225,7 @@
}
@SuppressWarnings("unchecked")
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testWaitFor() throws Exception {
mBluetoothOperationExecutor.waitFor(Arrays.asList(mMockFuture, mMockFuture2));
@@ -220,6 +234,7 @@
}
@SuppressWarnings("unchecked")
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testWaitForWithTimeout() throws Exception {
mBluetoothOperationExecutor.waitFor(
Arrays.asList(mMockFuture, mMockFuture2),
@@ -229,6 +244,7 @@
verify(mMockFuture2).get(TIMEOUT, TimeUnit.MILLISECONDS);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testGetResult() throws Exception {
when(mMockFuture.get()).thenReturn(OPERATION_RESULT);
@@ -237,6 +253,7 @@
assertThat(result).isEqualTo(OPERATION_RESULT);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testGetResultWithTimeout() throws Exception {
when(mMockFuture.get(TIMEOUT, TimeUnit.MILLISECONDS)).thenThrow(new TimeoutException());
@@ -249,6 +266,7 @@
verify(mMockFuture).cancel(true);
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_SynchronousOperation_execute() throws Exception {
when(mMockBlockingQueueProvider.get()).thenReturn(mMockBlockingQueue);
SynchronousOperation<String> synchronousOperation = new SynchronousOperation<String>() {
@@ -265,6 +283,7 @@
verify(mMockSemaphore).release();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_SynchronousOperation_exception() throws Exception {
final BluetoothException exception = new BluetoothException(EXCEPTION_REASON);
when(mMockBlockingQueueProvider.get()).thenReturn(mMockBlockingQueue);
@@ -282,6 +301,7 @@
verify(mMockSemaphore).release();
}
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_AsynchronousOperation_exception() throws Exception {
final BluetoothException exception = new BluetoothException(EXCEPTION_REASON);
when(mMockBlockingQueueProvider.get()).thenReturn(mMockBlockingQueue);
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/eventloop/EventLoopTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/eventloop/EventLoopTest.java
index 1af55b5..70dcec8 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/eventloop/EventLoopTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/eventloop/EventLoopTest.java
@@ -18,6 +18,8 @@
import static com.google.common.truth.Truth.assertThat;
+import androidx.test.filters.SdkSuppress;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -48,6 +50,7 @@
*/
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void isPosted() {
NumberedRunnable runnable = new NumberedRunnable(0);
mEventLoop.postRunnableDelayed(runnable, 10 * 1000L);
@@ -61,6 +64,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void postAndWaitAfterDestroy() throws InterruptedException {
mEventLoop.destroy();
mEventLoop.postAndWait(new NumberedRunnable(0));
diff --git a/nearby/tests/unit/src/com/android/server/nearby/fastpair/FastPairManagerTest.java b/nearby/tests/unit/src/com/android/server/nearby/fastpair/FastPairManagerTest.java
index bbf8cdf..f061115 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/fastpair/FastPairManagerTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/fastpair/FastPairManagerTest.java
@@ -22,6 +22,8 @@
import android.content.Context;
+import androidx.test.filters.SdkSuppress;
+
import com.android.server.nearby.common.locator.LocatorContextWrapper;
import org.junit.Before;
@@ -43,6 +45,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testFastPairInit() {
mFastPairManager.initiate();
@@ -50,6 +53,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testFastPairCleanUp() {
mFastPairManager.cleanUp();
diff --git a/nearby/tests/unit/src/com/android/server/nearby/fastpair/ModuleTest.java b/nearby/tests/unit/src/com/android/server/nearby/fastpair/ModuleTest.java
index fafd3b4..bb4e3d0 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/fastpair/ModuleTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/fastpair/ModuleTest.java
@@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import androidx.test.core.app.ApplicationProvider;
+import androidx.test.filters.SdkSuppress;
import com.android.server.nearby.common.eventloop.EventLoop;
import com.android.server.nearby.common.locator.Locator;
@@ -48,6 +49,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void genericConstructor() {
assertThat(mLocator.get(FastPairCacheManager.class)).isNotNull();
assertThat(mLocator.get(FootprintsDeviceManager.class)).isNotNull();
@@ -58,6 +60,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void genericDestroy() {
mLocator.destroy();
}
diff --git a/nearby/tests/unit/src/com/android/server/nearby/fastpair/cache/FastPairCacheManagerTest.java b/nearby/tests/unit/src/com/android/server/nearby/fastpair/cache/FastPairCacheManagerTest.java
index ff98ecf..b8233ec 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/fastpair/cache/FastPairCacheManagerTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/fastpair/cache/FastPairCacheManagerTest.java
@@ -23,6 +23,7 @@
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
+import androidx.test.filters.SdkSuppress;
import org.junit.Before;
import org.junit.Test;
@@ -52,6 +53,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void notSaveRetrieveInfo() {
Context mContext = ApplicationProvider.getApplicationContext();
when(mDiscoveryItem.getCopyOfStoredItem()).thenReturn(mStoredDiscoveryItem);
@@ -64,6 +66,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void saveRetrieveInfo() {
Context mContext = ApplicationProvider.getApplicationContext();
when(mDiscoveryItem.getCopyOfStoredItem()).thenReturn(mStoredDiscoveryItem);
@@ -76,6 +79,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void getAllInfo() {
Context mContext = ApplicationProvider.getApplicationContext();
when(mDiscoveryItem.getCopyOfStoredItem()).thenReturn(mStoredDiscoveryItem);