Merge "Add MainlineTestModuleController to Nearby CTS."
diff --git a/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java b/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
index 6166052..87045de 100644
--- a/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
+++ b/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
@@ -70,7 +70,8 @@
"On discovery model id" + Hex.bytesToStringLowercase(model));
// Use api to get anti spoofing key from model id.
Rpcs.GetObservedDeviceResponse response =
- FastPairDataProvider.getInstance().loadFastPairDeviceMetadata(model);
+ FastPairDataProvider.getInstance()
+ .loadFastPairAntispoofkeyDeviceMetadata(model);
ByteString publicKey = response.getDevice().getAntiSpoofingKeyPair().getPublicKey();
Locator.get(mContext, FastPairHalfSheetManager.class).showHalfSheet(
Cache.ScanFastPairStoreItem.newBuilder().setAddress(mBleAddress)
diff --git a/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java b/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java
index 9bf2bef..d59e696 100644
--- a/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java
+++ b/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java
@@ -21,6 +21,10 @@
import android.content.Context;
import android.nearby.FastPairDataProviderBase;
import android.nearby.FastPairDevice;
+import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataRequestParcel;
+import android.nearby.aidl.FastPairEligibleAccountsRequestParcel;
+import android.nearby.aidl.FastPairManageAccountDeviceRequestParcel;
+import android.nearby.aidl.FastPairManageAccountRequestParcel;
import android.util.Log;
import androidx.annotation.WorkerThread;
@@ -28,9 +32,13 @@
import com.android.server.nearby.common.bloomfilter.BloomFilter;
import com.android.server.nearby.fastpair.footprint.FastPairUploadInfo;
+import java.util.List;
+
import service.proto.Rpcs;
-/** FastPairDataProvider is a singleton that implements APIs to get FastPair data. */
+/**
+ * FastPairDataProvider is a singleton that implements APIs to get FastPair data.
+ */
public class FastPairDataProvider {
private static final String TAG = "FastPairDataProvider";
@@ -39,7 +47,9 @@
private ProxyFastPairDataProvider mProxyFastPairDataProvider;
- /** Initializes FastPairDataProvider singleton. */
+ /**
+ * Initializes FastPairDataProvider singleton.
+ */
public static synchronized FastPairDataProvider init(Context context) {
if (sInstance == null) {
@@ -68,28 +78,58 @@
}
}
- /** loadFastPairDeviceMetadata. */
+ /**
+ * Loads FastPairAntispoofkeyDeviceMetadata.
+ *
+ * @throws IllegalStateException If ProxyFastPairDataProvider is not available.
+ */
@WorkerThread
@Nullable
- public Rpcs.GetObservedDeviceResponse loadFastPairDeviceMetadata(byte[] modelId) {
+ public Rpcs.GetObservedDeviceResponse loadFastPairAntispoofkeyDeviceMetadata(byte[] modelId) {
if (mProxyFastPairDataProvider != null) {
- return mProxyFastPairDataProvider.loadFastPairDeviceMetadata(modelId);
+ FastPairAntispoofkeyDeviceMetadataRequestParcel requestParcel =
+ new FastPairAntispoofkeyDeviceMetadataRequestParcel();
+ requestParcel.modelId = modelId;
+ return Utils.convertFastPairAntispoofkeyDeviceMetadataToGetObservedDeviceResponse(
+ mProxyFastPairDataProvider
+ .loadFastPairAntispoofkeyDeviceMetadata(requestParcel));
}
throw new IllegalStateException("No ProxyFastPairDataProvider yet constructed");
}
/**
- * opt in default account to fast pair
+ * Enrolls an account to Fast Pair.
+ *
+ * @throws IllegalStateException If ProxyFastPairDataProvider is not available.
*/
public void optIn(Account account) {
-
+ if (mProxyFastPairDataProvider != null) {
+ FastPairManageAccountRequestParcel requestParcel =
+ new FastPairManageAccountRequestParcel();
+ requestParcel.account = account;
+ requestParcel.requestType = FastPairDataProviderBase.MANAGE_REQUEST_ADD;
+ mProxyFastPairDataProvider.manageFastPairAccount(requestParcel);
+ }
+ throw new IllegalStateException("No ProxyFastPairDataProvider yet constructed");
}
/**
- * Upload the device to the footprint
+ * Uploads the device info to Fast Pair account.
+ *
+ * @throws IllegalStateException If ProxyFastPairDataProvider is not available.
*/
public void upload(Account account, FastPairUploadInfo uploadInfo) {
-
+ if (mProxyFastPairDataProvider != null) {
+ FastPairManageAccountDeviceRequestParcel requestParcel =
+ new FastPairManageAccountDeviceRequestParcel();
+ requestParcel.account = account;
+ requestParcel.requestType = FastPairDataProviderBase.MANAGE_REQUEST_ADD;
+ requestParcel.accountKeyDeviceMetadata =
+ Utils.convertFastPairUploadInfoToFastPairAccountKeyDeviceMetadata(
+ uploadInfo);
+ mProxyFastPairDataProvider.manageFastPairAccountDevice(requestParcel);
+ }
+ throw new IllegalStateException("No ProxyFastPairDataProvider yet constructed");
}
/**
@@ -99,4 +139,18 @@
return new FastPairDevice.Builder().build();
}
+ /**
+ * Get FastPair Eligible Accounts.
+ *
+ * @throws IllegalStateException If ProxyFastPairDataProvider is not available.
+ */
+ public List<Account> loadFastPairEligibleAccounts() {
+ if (mProxyFastPairDataProvider != null) {
+ FastPairEligibleAccountsRequestParcel requestParcel =
+ new FastPairEligibleAccountsRequestParcel();
+ return Utils.convertFastPairEligibleAccountsToAccountList(
+ mProxyFastPairDataProvider.loadFastPairEligibleAccounts(requestParcel));
+ }
+ throw new IllegalStateException("No ProxyFastPairDataProvider yet constructed");
+ }
}
diff --git a/nearby/service/java/com/android/server/nearby/provider/ProxyFastPairDataProvider.java b/nearby/service/java/com/android/server/nearby/provider/ProxyFastPairDataProvider.java
index 7bd53f4..36b4478 100644
--- a/nearby/service/java/com/android/server/nearby/provider/ProxyFastPairDataProvider.java
+++ b/nearby/service/java/com/android/server/nearby/provider/ProxyFastPairDataProvider.java
@@ -18,10 +18,20 @@
import android.annotation.Nullable;
import android.content.Context;
+import android.nearby.aidl.FastPairAccountDevicesMetadataRequestParcel;
+import android.nearby.aidl.FastPairAccountKeyDeviceMetadataParcel;
import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataParcel;
import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataRequestParcel;
+import android.nearby.aidl.FastPairEligibleAccountParcel;
+import android.nearby.aidl.FastPairEligibleAccountsRequestParcel;
+import android.nearby.aidl.FastPairManageAccountDeviceRequestParcel;
+import android.nearby.aidl.FastPairManageAccountRequestParcel;
+import android.nearby.aidl.IFastPairAccountDevicesMetadataCallback;
import android.nearby.aidl.IFastPairAntispoofkeyDeviceMetadataCallback;
import android.nearby.aidl.IFastPairDataProvider;
+import android.nearby.aidl.IFastPairEligibleAccountsCallback;
+import android.nearby.aidl.IFastPairManageAccountCallback;
+import android.nearby.aidl.IFastPairManageAccountDeviceCallback;
import android.os.IBinder;
import android.os.RemoteException;
@@ -36,13 +46,13 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
-import service.proto.Rpcs;
-
/**
* Proxy for IFastPairDataProvider implementations.
*/
public class ProxyFastPairDataProvider implements ServiceListener<BoundServiceInfo> {
+ private static final int TIME_OUT_MILLIS = 10000;
+
/**
* Creates and registers this proxy. If no suitable service is available for the proxy, returns
* null.
@@ -71,7 +81,9 @@
return mServiceMonitor.checkServiceResolves();
}
- /** User service watch to connect to actually services implemented by OEMs. */
+ /**
+ * User service watch to connect to actually services implemented by OEMs.
+ */
public void register() {
mServiceMonitor.register();
}
@@ -88,29 +100,151 @@
public void onUnbind() {
}
- /** Invoke loadFastPairDeviceMetadata. */
+ /**
+ * Invokes system api loadFastPairEligibleAccounts.
+ *
+ * @return an array of acccounts and their opt in status.
+ */
@WorkerThread
@Nullable
- Rpcs.GetObservedDeviceResponse loadFastPairDeviceMetadata(byte[] modelId) {
+ public FastPairEligibleAccountParcel[] loadFastPairEligibleAccounts(
+ FastPairEligibleAccountsRequestParcel requestParcel) {
final CountDownLatch waitForCompletionLatch = new CountDownLatch(1);
- final AtomicReference<Rpcs.GetObservedDeviceResponse> response = new AtomicReference<>();
+ final AtomicReference<FastPairEligibleAccountParcel[]> response = new AtomicReference<>();
mServiceMonitor.runOnBinder(new ServiceMonitor.BinderOperation() {
@Override
public void run(IBinder binder) throws RemoteException {
IFastPairDataProvider provider = IFastPairDataProvider.Stub.asInterface(binder);
- FastPairAntispoofkeyDeviceMetadataRequestParcel requestParcel =
- new FastPairAntispoofkeyDeviceMetadataRequestParcel();
- requestParcel.modelId = modelId;
+ IFastPairEligibleAccountsCallback callback =
+ new IFastPairEligibleAccountsCallback.Stub() {
+ public void onFastPairEligibleAccountsReceived(
+ FastPairEligibleAccountParcel[] accountParcels) {
+ response.set(accountParcels);
+ waitForCompletionLatch.countDown();
+ }
+
+ public void onError(int code, String message) {
+ waitForCompletionLatch.countDown();
+ }
+ };
+ provider.loadFastPairEligibleAccounts(requestParcel, callback);
+ }
+
+ @Override
+ public void onError() {
+ waitForCompletionLatch.countDown();
+ }
+ });
+ try {
+ waitForCompletionLatch.await(TIME_OUT_MILLIS, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ // skip.
+ }
+ return response.get();
+ }
+
+ /**
+ * Invokes system api manageFastPairAccount to opt in account, or opt out account.
+ */
+ @WorkerThread
+ public void manageFastPairAccount(FastPairManageAccountRequestParcel requestParcel) {
+ final CountDownLatch waitForCompletionLatch = new CountDownLatch(1);
+ mServiceMonitor.runOnBinder(new ServiceMonitor.BinderOperation() {
+ @Override
+ public void run(IBinder binder) throws RemoteException {
+ IFastPairDataProvider provider = IFastPairDataProvider.Stub.asInterface(binder);
+ IFastPairManageAccountCallback callback =
+ new IFastPairManageAccountCallback.Stub() {
+ public void onSuccess() {
+ waitForCompletionLatch.countDown();
+ }
+
+ public void onError(int code, String message) {
+ waitForCompletionLatch.countDown();
+ }
+ };
+ provider.manageFastPairAccount(requestParcel, callback);
+ }
+
+ @Override
+ public void onError() {
+ waitForCompletionLatch.countDown();
+ }
+ });
+ try {
+ waitForCompletionLatch.await(TIME_OUT_MILLIS, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ // skip.
+ }
+ return;
+ }
+
+ /**
+ * Invokes system api manageFastPairAccountDevice to add or remove a device from a Fast Pair
+ * account.
+ */
+ @WorkerThread
+ public void manageFastPairAccountDevice(
+ FastPairManageAccountDeviceRequestParcel requestParcel) {
+ final CountDownLatch waitForCompletionLatch = new CountDownLatch(1);
+ mServiceMonitor.runOnBinder(new ServiceMonitor.BinderOperation() {
+ @Override
+ public void run(IBinder binder) throws RemoteException {
+ IFastPairDataProvider provider = IFastPairDataProvider.Stub.asInterface(binder);
+ IFastPairManageAccountDeviceCallback callback =
+ new IFastPairManageAccountDeviceCallback.Stub() {
+ public void onSuccess() {
+ waitForCompletionLatch.countDown();
+ }
+
+ public void onError(int code, String message) {
+ waitForCompletionLatch.countDown();
+ }
+ };
+ provider.manageFastPairAccountDevice(requestParcel, callback);
+ }
+
+ @Override
+ public void onError() {
+ waitForCompletionLatch.countDown();
+ }
+ });
+ try {
+ waitForCompletionLatch.await(TIME_OUT_MILLIS, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ // skip.
+ }
+ return;
+ }
+
+ /**
+ * Invokes system api loadFastPairAntispoofkeyDeviceMetadata.
+ *
+ * @return the Fast Pair AntispoofKeyDeviceMetadata of a given device.
+ */
+ @WorkerThread
+ @Nullable
+ FastPairAntispoofkeyDeviceMetadataParcel loadFastPairAntispoofkeyDeviceMetadata(
+ FastPairAntispoofkeyDeviceMetadataRequestParcel requestParcel) {
+ final CountDownLatch waitForCompletionLatch = new CountDownLatch(1);
+ final AtomicReference<FastPairAntispoofkeyDeviceMetadataParcel> response =
+ new AtomicReference<>();
+ mServiceMonitor.runOnBinder(new ServiceMonitor.BinderOperation() {
+ @Override
+ public void run(IBinder binder) throws RemoteException {
+ IFastPairDataProvider provider = IFastPairDataProvider.Stub.asInterface(binder);
IFastPairAntispoofkeyDeviceMetadataCallback callback =
new IFastPairAntispoofkeyDeviceMetadataCallback.Stub() {
- public void onFastPairAntispoofkeyDeviceMetadataReceived(
- FastPairAntispoofkeyDeviceMetadataParcel metadata) {
- response.set(Utils.convert(metadata));
- waitForCompletionLatch.countDown();
- }
- public void onError(int code, String message) {
- }
- };
+ public void onFastPairAntispoofkeyDeviceMetadataReceived(
+ FastPairAntispoofkeyDeviceMetadataParcel metadata) {
+ response.set(metadata);
+ waitForCompletionLatch.countDown();
+ }
+
+ public void onError(int code, String message) {
+ waitForCompletionLatch.countDown();
+ }
+ };
provider.loadFastPairAntispoofkeyDeviceMetadata(requestParcel, callback);
}
@@ -120,7 +254,51 @@
}
});
try {
- waitForCompletionLatch.await(10000, TimeUnit.MILLISECONDS);
+ waitForCompletionLatch.await(TIME_OUT_MILLIS, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ // skip.
+ }
+ return response.get();
+ }
+
+ /**
+ * Invokes loadFastPairAccountDevicesMetadata.
+ *
+ * @return the metadata of Fast Pair devices that are associated with a given account.
+ */
+ @WorkerThread
+ @Nullable
+ FastPairAccountKeyDeviceMetadataParcel[] loadFastPairAccountDevicesMetadata(
+ FastPairAccountDevicesMetadataRequestParcel requestParcel) {
+ final CountDownLatch waitForCompletionLatch = new CountDownLatch(1);
+ final AtomicReference<FastPairAccountKeyDeviceMetadataParcel[]> response =
+ new AtomicReference<>();
+ mServiceMonitor.runOnBinder(new ServiceMonitor.BinderOperation() {
+ @Override
+ public void run(IBinder binder) throws RemoteException {
+ IFastPairDataProvider provider = IFastPairDataProvider.Stub.asInterface(binder);
+ IFastPairAccountDevicesMetadataCallback callback =
+ new IFastPairAccountDevicesMetadataCallback.Stub() {
+ public void onFastPairAccountDevicesMetadataReceived(
+ FastPairAccountKeyDeviceMetadataParcel[] metadatas) {
+ response.set(metadatas);
+ waitForCompletionLatch.countDown();
+ }
+
+ public void onError(int code, String message) {
+ waitForCompletionLatch.countDown();
+ }
+ };
+ provider.loadFastPairAccountDevicesMetadata(requestParcel, callback);
+ }
+
+ @Override
+ public void onError() {
+ waitForCompletionLatch.countDown();
+ }
+ });
+ try {
+ waitForCompletionLatch.await(TIME_OUT_MILLIS, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
// skip.
}
diff --git a/nearby/service/java/com/android/server/nearby/provider/Utils.java b/nearby/service/java/com/android/server/nearby/provider/Utils.java
index ca0a390..c06d017 100644
--- a/nearby/service/java/com/android/server/nearby/provider/Utils.java
+++ b/nearby/service/java/com/android/server/nearby/provider/Utils.java
@@ -16,80 +16,248 @@
package com.android.server.nearby.provider;
+import android.accounts.Account;
+import android.annotation.Nullable;
+import android.nearby.aidl.FastPairAccountKeyDeviceMetadataParcel;
import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataParcel;
+import android.nearby.aidl.FastPairDeviceMetadataParcel;
+import android.nearby.aidl.FastPairDiscoveryItemParcel;
+import android.nearby.aidl.FastPairEligibleAccountParcel;
+
+import com.android.server.nearby.fastpair.footprint.FastPairUploadInfo;
import com.google.protobuf.ByteString;
+import java.util.ArrayList;
+import java.util.List;
+
+import service.proto.Cache;
+import service.proto.FastPairString.FastPairStrings;
import service.proto.Rpcs;
+/**
+ * Utility classes to convert between different data classes.
+ */
class Utils {
- static Rpcs.GetObservedDeviceResponse convert(
- FastPairAntispoofkeyDeviceMetadataParcel metadata) {
+ static List<Account> convertFastPairEligibleAccountsToAccountList(
+ @Nullable FastPairEligibleAccountParcel[] accountParcels) {
+ if (accountParcels == null) {
+ return new ArrayList<Account>(0);
+ }
+ List<Account> accounts = new ArrayList<Account>(accountParcels.length);
+ for (FastPairEligibleAccountParcel parcel : accountParcels) {
+ accounts.add(parcel.account);
+ }
+ return accounts;
+ }
+
+ static @Nullable Rpcs.GetObservedDeviceResponse
+ convertFastPairAntispoofkeyDeviceMetadataToGetObservedDeviceResponse(
+ @Nullable FastPairAntispoofkeyDeviceMetadataParcel metadata) {
+ if (metadata == null) {
+ return null;
+ }
return Rpcs.GetObservedDeviceResponse.newBuilder()
- .setDevice(Rpcs.Device.newBuilder()
- .setAntiSpoofingKeyPair(Rpcs.AntiSpoofingKeyPair.newBuilder()
- .setPublicKey(ByteString.copyFrom(metadata.antiSpoofPublicKey))
- .build())
- .setTrueWirelessImages(
- Rpcs.TrueWirelessHeadsetImages.newBuilder()
- .setLeftBudUrl(
- metadata.deviceMetadata.trueWirelessImageUrlLeftBud)
- .setRightBudUrl(
- metadata.deviceMetadata.trueWirelessImageUrlRightBud)
- .setCaseUrl(metadata.deviceMetadata.trueWirelessImageUrlCase)
- .build())
- .setImageUrl(metadata.deviceMetadata.imageUrl)
- .setIntentUri(metadata.deviceMetadata.intentUri)
- .setBleTxPower(metadata.deviceMetadata.bleTxPower)
- .setTriggerDistance(metadata.deviceMetadata.triggerDistance)
- .setDeviceType(Rpcs.DeviceType.forNumber(metadata.deviceMetadata.deviceType))
- .build())
- .setImage(ByteString.copyFrom(metadata.deviceMetadata.image))
- .setStrings(Rpcs.ObservedDeviceStrings.newBuilder()
- .setAssistantSetupHalfSheet(metadata.deviceMetadata.assistantSetupHalfSheet)
- .setAssistantSetupNotification(metadata.deviceMetadata.assistantSetupNotification)
- .setConfirmPinDescription(metadata.deviceMetadata.confirmPinDescription)
- .setConfirmPinTitle(metadata.deviceMetadata.confirmPinTitle)
- .setConnectSuccessCompanionAppInstalled(
- metadata.deviceMetadata.connectSuccessCompanionAppInstalled)
- .setConnectSuccessCompanionAppNotInstalled(
- metadata.deviceMetadata.connectSuccessCompanionAppNotInstalled)
- .setDownloadCompanionAppDescription(
- metadata.deviceMetadata.downloadCompanionAppDescription)
- .setFailConnectGoToSettingsDescription(
- metadata.deviceMetadata.failConnectGoToSettingsDescription)
- .setFastPairTvConnectDeviceNoAccountDescription(
- metadata.deviceMetadata.fastPairTvConnectDeviceNoAccountDescription)
- .setInitialNotificationDescription(
- metadata.deviceMetadata.initialNotificationDescription)
- .setInitialNotificationDescriptionNoAccount(
- metadata.deviceMetadata.initialNotificationDescriptionNoAccount)
- .setInitialPairingDescription(metadata.deviceMetadata.initialPairingDescription)
- .setLocale(metadata.deviceMetadata.locale)
- .setOpenCompanionAppDescription(
- metadata.deviceMetadata.openCompanionAppDescription)
- .setRetroactivePairingDescription(
- metadata.deviceMetadata.retroactivePairingDescription)
- .setSubsequentPairingDescription(
- metadata.deviceMetadata.subsequentPairingDescription)
- .setSyncContactsDescription(
- metadata.deviceMetadata.syncContactsDescription)
- .setSyncContactsTitle(
- metadata.deviceMetadata.syncContactsTitle)
- .setSyncSmsDescription(
- metadata.deviceMetadata.syncSmsDescription)
- .setSyncSmsTitle(
- metadata.deviceMetadata.syncSmsTitle)
- .setUnableToConnectDescription(
- metadata.deviceMetadata.unableToConnectDescription)
- .setUnableToConnectTitle(
- metadata.deviceMetadata.unableToConnectTitle)
- .setUpdateCompanionAppDescription(
- metadata.deviceMetadata.updateCompanionAppDescription)
- .setWaitLaunchCompanionAppDescription(
- metadata.deviceMetadata.waitLaunchCompanionAppDescription)
- .build())
+ .setDevice(Rpcs.Device.newBuilder()
+ .setAntiSpoofingKeyPair(Rpcs.AntiSpoofingKeyPair.newBuilder()
+ .setPublicKey(ByteString.copyFrom(metadata.antiSpoofPublicKey))
+ .build())
+ .setTrueWirelessImages(Rpcs.TrueWirelessHeadsetImages.newBuilder()
+ .setLeftBudUrl(
+ metadata.deviceMetadata.trueWirelessImageUrlLeftBud)
+ .setRightBudUrl(
+ metadata.deviceMetadata
+ .trueWirelessImageUrlRightBud)
+ .setCaseUrl(
+ metadata.deviceMetadata
+ .trueWirelessImageUrlCase
+ )
+ .build())
+ .setImageUrl(metadata.deviceMetadata.imageUrl)
+ .setIntentUri(metadata.deviceMetadata.intentUri)
+ .setBleTxPower(metadata.deviceMetadata.bleTxPower)
+ .setTriggerDistance(metadata.deviceMetadata.triggerDistance)
+ .setDeviceType(
+ Rpcs.DeviceType.forNumber(metadata.deviceMetadata.deviceType))
+ .build())
+ .setImage(ByteString.copyFrom(metadata.deviceMetadata.image))
+ .setStrings(Rpcs.ObservedDeviceStrings.newBuilder()
+ .setAssistantSetupHalfSheet(metadata.deviceMetadata.assistantSetupHalfSheet)
+ .setAssistantSetupNotification(
+ metadata.deviceMetadata.assistantSetupNotification)
+ .setConfirmPinDescription(metadata.deviceMetadata.confirmPinDescription)
+ .setConfirmPinTitle(metadata.deviceMetadata.confirmPinTitle)
+ .setConnectSuccessCompanionAppInstalled(
+ metadata.deviceMetadata.connectSuccessCompanionAppInstalled)
+ .setConnectSuccessCompanionAppNotInstalled(
+ metadata.deviceMetadata.connectSuccessCompanionAppNotInstalled)
+ .setDownloadCompanionAppDescription(
+ metadata.deviceMetadata.downloadCompanionAppDescription)
+ .setFailConnectGoToSettingsDescription(
+ metadata.deviceMetadata.failConnectGoToSettingsDescription)
+ .setFastPairTvConnectDeviceNoAccountDescription(
+ metadata.deviceMetadata.fastPairTvConnectDeviceNoAccountDescription)
+ .setInitialNotificationDescription(
+ metadata.deviceMetadata.initialNotificationDescription)
+ .setInitialNotificationDescriptionNoAccount(
+ metadata.deviceMetadata.initialNotificationDescriptionNoAccount)
+ .setInitialPairingDescription(
+ metadata.deviceMetadata.initialPairingDescription)
+ .setLocale(metadata.deviceMetadata.locale)
+ .setOpenCompanionAppDescription(
+ metadata.deviceMetadata.openCompanionAppDescription)
+ .setRetroactivePairingDescription(
+ metadata.deviceMetadata.retroactivePairingDescription)
+ .setSubsequentPairingDescription(
+ metadata.deviceMetadata.subsequentPairingDescription)
+ .setSyncContactsDescription(
+ metadata.deviceMetadata.syncContactsDescription)
+ .setSyncContactsTitle(
+ metadata.deviceMetadata.syncContactsTitle)
+ .setSyncSmsDescription(
+ metadata.deviceMetadata.syncSmsDescription)
+ .setSyncSmsTitle(
+ metadata.deviceMetadata.syncSmsTitle)
+ .setUnableToConnectDescription(
+ metadata.deviceMetadata.unableToConnectDescription)
+ .setUnableToConnectTitle(
+ metadata.deviceMetadata.unableToConnectTitle)
+ .setUpdateCompanionAppDescription(
+ metadata.deviceMetadata.updateCompanionAppDescription)
+ .setWaitLaunchCompanionAppDescription(
+ metadata.deviceMetadata.waitLaunchCompanionAppDescription)
+ .build())
.build();
}
+
+ static @Nullable FastPairAccountKeyDeviceMetadataParcel
+ convertFastPairUploadInfoToFastPairAccountKeyDeviceMetadata(
+ FastPairUploadInfo uploadInfo) {
+ if (uploadInfo == null) {
+ return null;
+ }
+
+ FastPairAccountKeyDeviceMetadataParcel accountKeyDeviceMetadataParcel =
+ new FastPairAccountKeyDeviceMetadataParcel();
+ accountKeyDeviceMetadataParcel.accountKey = uploadInfo.getAccountKey().toByteArray();
+ accountKeyDeviceMetadataParcel.sha256AccountKeyPublicAddress =
+ uploadInfo.getSha256AccountKeyPublicAddress().toByteArray();
+ accountKeyDeviceMetadataParcel.metadata =
+ convertStoredDiscoveryItemToFastPairDeviceMetadata(
+ uploadInfo.getStoredDiscoveryItem());
+ accountKeyDeviceMetadataParcel.discoveryItem =
+ convertStoredDiscoveryItemToFastPairDiscoveryItem(
+ uploadInfo.getStoredDiscoveryItem());
+
+ return accountKeyDeviceMetadataParcel;
+ }
+
+ private static @Nullable FastPairDiscoveryItemParcel
+ convertStoredDiscoveryItemToFastPairDiscoveryItem(
+ @Nullable Cache.StoredDiscoveryItem storedDiscoveryItem) {
+ if (storedDiscoveryItem == null) {
+ return null;
+ }
+
+ FastPairDiscoveryItemParcel discoveryItemParcel = new FastPairDiscoveryItemParcel();
+ discoveryItemParcel.actionUrl = storedDiscoveryItem.getActionUrl();
+ discoveryItemParcel.actionUrlType = storedDiscoveryItem.getActionUrlType().getNumber();
+ discoveryItemParcel.appName = storedDiscoveryItem.getAppName();
+ discoveryItemParcel.attachmentType = storedDiscoveryItem.getAttachmentType().getNumber();
+ discoveryItemParcel.attachmentType = storedDiscoveryItem.getAttachmentType().getNumber();
+ discoveryItemParcel.authenticationPublicKeySecp256r1 =
+ storedDiscoveryItem.getAuthenticationPublicKeySecp256R1().toByteArray();
+ discoveryItemParcel.bleRecordBytes = storedDiscoveryItem.getBleRecordBytes().toByteArray();
+ discoveryItemParcel.debugCategory = storedDiscoveryItem.getDebugCategory().getNumber();
+ discoveryItemParcel.debugMessage = storedDiscoveryItem.getDebugMessage();
+ discoveryItemParcel.description = storedDiscoveryItem.getDescription();
+ discoveryItemParcel.deviceName = storedDiscoveryItem.getDeviceName();
+ discoveryItemParcel.displayUrl = storedDiscoveryItem.getDisplayUrl();
+ discoveryItemParcel.entityId = storedDiscoveryItem.getEntityId();
+ discoveryItemParcel.featureGraphicUrl = storedDiscoveryItem.getFeatureGraphicUrl();
+ discoveryItemParcel.firstObservationTimestampMillis =
+ storedDiscoveryItem.getFirstObservationTimestampMillis();
+ discoveryItemParcel.groupId = storedDiscoveryItem.getGroupId();
+ discoveryItemParcel.iconFifeUrl = storedDiscoveryItem.getIconFifeUrl();
+ discoveryItemParcel.iconPng = storedDiscoveryItem.getIconPng().toByteArray();
+ discoveryItemParcel.id = storedDiscoveryItem.getId();
+ discoveryItemParcel.lastObservationTimestampMillis =
+ storedDiscoveryItem.getLastObservationTimestampMillis();
+ discoveryItemParcel.lastUserExperience =
+ storedDiscoveryItem.getLastUserExperience().getNumber();
+ discoveryItemParcel.lostMillis = storedDiscoveryItem.getLostMillis();
+ discoveryItemParcel.macAddress = storedDiscoveryItem.getMacAddress();
+ discoveryItemParcel.packageName = storedDiscoveryItem.getPackageName();
+ discoveryItemParcel.pendingAppInstallTimestampMillis =
+ storedDiscoveryItem.getPendingAppInstallTimestampMillis();
+ discoveryItemParcel.rssi = storedDiscoveryItem.getRssi();
+ discoveryItemParcel.state = storedDiscoveryItem.getState().getNumber();
+ discoveryItemParcel.title = storedDiscoveryItem.getTitle();
+ discoveryItemParcel.triggerId = storedDiscoveryItem.getTriggerId();
+ discoveryItemParcel.txPower = storedDiscoveryItem.getTxPower();
+ discoveryItemParcel.type = storedDiscoveryItem.getType().getNumber();
+
+ return discoveryItemParcel;
+ }
+
+ /* Do we upload these?
+ String downloadCompanionAppDescription =
+ bundle.getString("downloadCompanionAppDescription");
+ String locale = bundle.getString("locale");
+ String openCompanionAppDescription = bundle.getString("openCompanionAppDescription");
+ float triggerDistance = bundle.getFloat("triggerDistance");
+ String unableToConnectDescription = bundle.getString("unableToConnectDescription");
+ String unableToConnectTitle = bundle.getString("unableToConnectTitle");
+ String updateCompanionAppDescription = bundle.getString("updateCompanionAppDescription");
+ */
+ private static @Nullable FastPairDeviceMetadataParcel
+ convertStoredDiscoveryItemToFastPairDeviceMetadata(
+ @Nullable Cache.StoredDiscoveryItem storedDiscoveryItem) {
+ if (storedDiscoveryItem == null) {
+ return null;
+ }
+
+ FastPairStrings fpStrings = storedDiscoveryItem.getFastPairStrings();
+
+ FastPairDeviceMetadataParcel metadataParcel = new FastPairDeviceMetadataParcel();
+ metadataParcel.assistantSetupHalfSheet = fpStrings.getAssistantHalfSheetDescription();
+ metadataParcel.assistantSetupNotification = fpStrings.getAssistantNotificationDescription();
+ metadataParcel.confirmPinDescription = fpStrings.getConfirmPinDescription();
+ metadataParcel.confirmPinTitle = fpStrings.getConfirmPinTitle();
+ metadataParcel.connectSuccessCompanionAppInstalled =
+ fpStrings.getPairingFinishedCompanionAppInstalled();
+ metadataParcel.connectSuccessCompanionAppNotInstalled =
+ fpStrings.getPairingFinishedCompanionAppNotInstalled();
+ metadataParcel.failConnectGoToSettingsDescription = fpStrings.getPairingFailDescription();
+ metadataParcel.fastPairTvConnectDeviceNoAccountDescription =
+ fpStrings.getFastPairTvConnectDeviceNoAccountDescription();
+ metadataParcel.initialNotificationDescription = fpStrings.getTapToPairWithAccount();
+ metadataParcel.initialNotificationDescriptionNoAccount =
+ fpStrings.getTapToPairWithoutAccount();
+ metadataParcel.initialPairingDescription = fpStrings.getInitialPairingDescription();
+ metadataParcel.retroactivePairingDescription = fpStrings.getRetroactivePairingDescription();
+ metadataParcel.subsequentPairingDescription = fpStrings.getSubsequentPairingDescription();
+ metadataParcel.syncContactsDescription = fpStrings.getSyncContactsDescription();
+ metadataParcel.syncContactsTitle = fpStrings.getSyncContactsTitle();
+ metadataParcel.syncSmsDescription = fpStrings.getSyncSmsDescription();
+ metadataParcel.syncSmsTitle = fpStrings.getSyncSmsTitle();
+ metadataParcel.waitLaunchCompanionAppDescription = fpStrings.getWaitAppLaunchDescription();
+
+ Cache.FastPairInformation fpInformation = storedDiscoveryItem.getFastPairInformation();
+ metadataParcel.trueWirelessImageUrlCase =
+ fpInformation.getTrueWirelessImages().getCaseUrl();
+ metadataParcel.trueWirelessImageUrlLeftBud =
+ fpInformation.getTrueWirelessImages().getLeftBudUrl();
+ metadataParcel.trueWirelessImageUrlRightBud =
+ fpInformation.getTrueWirelessImages().getRightBudUrl();
+ metadataParcel.deviceType = fpInformation.getDeviceType().getNumber();
+
+ metadataParcel.bleTxPower = storedDiscoveryItem.getTxPower();
+ metadataParcel.image = storedDiscoveryItem.getIconPng().toByteArray();
+ metadataParcel.imageUrl = storedDiscoveryItem.getIconFifeUrl();
+ metadataParcel.intentUri = storedDiscoveryItem.getActionUrl();
+
+ return metadataParcel;
+ }
}
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..743a8e7 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderBaseTest.java
@@ -16,9 +16,8 @@
package android.nearby.cts;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
@@ -50,6 +49,7 @@
import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
import com.google.common.collect.ImmutableList;
@@ -74,7 +74,7 @@
"CONNECT_SUCCESS_COMPANION_APP_INSTALLED";
private static final String CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED =
"CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED";
- private static final double DELTA = 0.000001;
+ private static final float DELTA = 0.001f;
private static final int DEVICE_TYPE = 7;
private static final String DOWNLOAD_COMPANION_APP_DESCRIPTION =
"DOWNLOAD_COMPANION_APP_DESCRIPTION";
@@ -193,18 +193,18 @@
HAPPY_PATH_FAST_PAIR_ANTI_SPOOF_KEY_DEVICE_METADATA =
genHappyPathFastPairAntispoofkeyDeviceMetadata();
- private @Captor ArgumentCaptor<FastPairEligibleAccountParcel[]>
+ @Captor private ArgumentCaptor<FastPairEligibleAccountParcel[]>
mFastPairEligibleAccountParcelsArgumentCaptor;
- private @Captor ArgumentCaptor<FastPairAccountKeyDeviceMetadataParcel[]>
+ @Captor private ArgumentCaptor<FastPairAccountKeyDeviceMetadataParcel[]>
mFastPairAccountKeyDeviceMetadataParcelsArgumentCaptor;
- private @Mock FastPairDataProviderBase mMockFastPairDataProviderBase;
- private @Mock IFastPairAntispoofkeyDeviceMetadataCallback.Stub
+ @Mock private FastPairDataProviderBase mMockFastPairDataProviderBase;
+ @Mock private IFastPairAntispoofkeyDeviceMetadataCallback.Stub
mAntispoofkeyDeviceMetadataCallback;
- private @Mock IFastPairAccountDevicesMetadataCallback.Stub mAccountDevicesMetadataCallback;
- private @Mock IFastPairEligibleAccountsCallback.Stub mEligibleAccountsCallback;
- private @Mock IFastPairManageAccountCallback.Stub mManageAccountCallback;
- private @Mock IFastPairManageAccountDeviceCallback.Stub mManageAccountDeviceCallback;
+ @Mock private IFastPairAccountDevicesMetadataCallback.Stub mAccountDevicesMetadataCallback;
+ @Mock private IFastPairEligibleAccountsCallback.Stub mEligibleAccountsCallback;
+ @Mock private IFastPairManageAccountCallback.Stub mManageAccountCallback;
+ @Mock private IFastPairManageAccountDeviceCallback.Stub mManageAccountDeviceCallback;
private MyHappyPathProvider mHappyPathFastPairDataProvider;
private MyErrorPathProvider mErrorPathFastPairDataProvider;
@@ -220,6 +220,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathLoadFastPairAntispoofkeyDeviceMetadata() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().loadFastPairAntispoofkeyDeviceMetadata(
@@ -246,6 +247,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathLoadFastPairAccountDevicesMetadata() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().loadFastPairAccountDevicesMetadata(
@@ -270,6 +272,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathLoadFastPairEligibleAccounts() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().loadFastPairEligibleAccounts(
@@ -293,6 +296,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathManageFastPairAccount() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().manageFastPairAccount(
@@ -314,6 +318,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testHappyPathManageFastPairAccountDevice() throws Exception {
// AOSP sends calls to OEM via Parcelable.
mHappyPathFastPairDataProvider.asProvider().manageFastPairAccountDevice(
@@ -335,6 +340,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 +353,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testErrorPathLoadFastPairAccountDevicesMetadata() throws Exception {
mErrorPathFastPairDataProvider.asProvider().loadFastPairAccountDevicesMetadata(
FAST_PAIR_ACCOUNT_DEVICES_METADATA_REQUEST_PARCEL,
@@ -359,6 +366,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testErrorPathLoadFastPairEligibleAccounts() throws Exception {
mErrorPathFastPairDataProvider.asProvider().loadFastPairEligibleAccounts(
FAST_PAIR_ELIGIBLE_ACCOUNTS_REQUEST_PARCEL,
@@ -371,6 +379,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testErrorPathManageFastPairAccount() throws Exception {
mErrorPathFastPairDataProvider.asProvider().manageFastPairAccount(
FAST_PAIR_MANAGE_ACCOUNT_REQUEST_PARCEL,
@@ -382,6 +391,7 @@
}
@Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testErrorPathManageFastPairAccountDevice() throws Exception {
mErrorPathFastPairDataProvider.asProvider().manageFastPairAccountDevice(
FAST_PAIR_MANAGE_ACCOUNT_DEVICE_REQUEST_PARCEL,
@@ -773,13 +783,13 @@
/* Verifies Happy Path AntispoofkeyDeviceMetadataRequest. */
private static void ensureHappyPathAsExpected(
FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataRequest request) {
- assertEquals(REQUEST_MODEL_ID, request.getModelId());
+ assertThat(request.getModelId()).isEqualTo(REQUEST_MODEL_ID);
}
/* Verifies Happy Path AccountDevicesMetadataRequest. */
private static void ensureHappyPathAsExpected(
FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest request) {
- assertEquals(ACCOUNTDEVICES_METADATA_ACCOUNT, request.getAccount());
+ assertThat(request.getAccount()).isEqualTo(ACCOUNTDEVICES_METADATA_ACCOUNT);
}
/* Verifies Happy Path FastPairEligibleAccountsRequest. */
@@ -792,32 +802,32 @@
/* Verifies Happy Path FastPairManageAccountRequest. */
private static void ensureHappyPathAsExpected(
FastPairDataProviderBase.FastPairManageAccountRequest request) {
- assertEquals(MANAGE_ACCOUNT, request.getAccount());
- assertEquals(MANAGE_ACCOUNT_REQUEST_TYPE, request.getRequestType());
+ assertThat(request.getAccount()).isEqualTo(MANAGE_ACCOUNT);
+ assertThat(request.getRequestType()).isEqualTo(MANAGE_ACCOUNT_REQUEST_TYPE);
}
/* Verifies Happy Path FastPairManageAccountDeviceRequest. */
private static void ensureHappyPathAsExpected(
FastPairDataProviderBase.FastPairManageAccountDeviceRequest request) {
- assertEquals(MANAGE_ACCOUNT, request.getAccount());
- assertEquals(MANAGE_ACCOUNT_REQUEST_TYPE, request.getRequestType());
- assertEquals(BLE_ADDRESS, request.getBleAddress());
+ assertThat(request.getAccount()).isEqualTo(MANAGE_ACCOUNT);
+ assertThat(request.getRequestType()).isEqualTo(MANAGE_ACCOUNT_REQUEST_TYPE);
+ assertThat(request.getBleAddress()).isEqualTo(BLE_ADDRESS);
ensureHappyPathAsExpected(request.getAccountKeyDeviceMetadata());
}
/* Verifies Happy Path AntispoofkeyDeviceMetadataParcel. */
private static void ensureHappyPathAsExpected(
FastPairAntispoofkeyDeviceMetadataParcel metadataParcel) {
- assertNotNull(metadataParcel);
- assertEquals(ANTI_SPOOFING_KEY, metadataParcel.antiSpoofPublicKey);
+ assertThat(metadataParcel).isNotNull();
+ assertThat(metadataParcel.antiSpoofPublicKey).isEqualTo(ANTI_SPOOFING_KEY);
ensureHappyPathAsExpected(metadataParcel.deviceMetadata);
}
/* Verifies Happy Path FastPairAccountKeyDeviceMetadataParcel[]. */
private static void ensureHappyPathAsExpected(
FastPairAccountKeyDeviceMetadataParcel[] metadataParcels) {
- assertNotNull(metadataParcels);
- assertEquals(ACCOUNTKEY_DEVICE_NUM, metadataParcels.length);
+ assertThat(metadataParcels).isNotNull();
+ assertThat(metadataParcels).hasLength(ACCOUNTKEY_DEVICE_NUM);
for (FastPairAccountKeyDeviceMetadataParcel parcel: metadataParcels) {
ensureHappyPathAsExpected(parcel);
}
@@ -826,10 +836,10 @@
/* Verifies Happy Path FastPairAccountKeyDeviceMetadataParcel. */
private static void ensureHappyPathAsExpected(
FastPairAccountKeyDeviceMetadataParcel metadataParcel) {
- assertNotNull(metadataParcel);
- assertEquals(ACCOUNT_KEY, metadataParcel.accountKey);
- assertEquals(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS,
- metadataParcel.sha256AccountKeyPublicAddress);
+ assertThat(metadataParcel).isNotNull();
+ assertThat(metadataParcel.accountKey).isEqualTo(ACCOUNT_KEY);
+ assertThat(metadataParcel.sha256AccountKeyPublicAddress)
+ .isEqualTo(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS);
ensureHappyPathAsExpected(metadataParcel.metadata);
ensureHappyPathAsExpected(metadataParcel.discoveryItem);
}
@@ -837,191 +847,217 @@
/* Verifies Happy Path FastPairAccountKeyDeviceMetadata. */
private static void ensureHappyPathAsExpected(
FastPairAccountKeyDeviceMetadata metadata) {
- assertEquals(ACCOUNT_KEY, metadata.getAccountKey());
- assertEquals(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS,
- metadata.getSha256AccountKeyPublicAddress());
+ assertThat(metadata.getAccountKey()).isEqualTo(ACCOUNT_KEY);
+ assertThat(metadata.getSha256AccountKeyPublicAddress())
+ .isEqualTo(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS);
ensureHappyPathAsExpected(metadata.getFastPairDeviceMetadata());
ensureHappyPathAsExpected(metadata.getFastPairDiscoveryItem());
}
/* Verifies Happy Path DeviceMetadataParcel. */
private static void ensureHappyPathAsExpected(FastPairDeviceMetadataParcel metadataParcel) {
- assertNotNull(metadataParcel);
- assertEquals(ASSISTANT_SETUP_HALFSHEET, metadataParcel.assistantSetupHalfSheet);
- assertEquals(ASSISTANT_SETUP_NOTIFICATION, metadataParcel.assistantSetupNotification);
- assertEquals(BLE_TX_POWER, metadataParcel.bleTxPower);
- assertEquals(CONFIRM_PIN_DESCRIPTION, metadataParcel.confirmPinDescription);
- assertEquals(CONFIRM_PIN_TITLE, metadataParcel.confirmPinTitle);
- assertEquals(CONNECT_SUCCESS_COMPANION_APP_INSTALLED,
- metadataParcel.connectSuccessCompanionAppInstalled);
- assertEquals(CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED,
- metadataParcel.connectSuccessCompanionAppNotInstalled);
- assertEquals(DEVICE_TYPE, metadataParcel.deviceType);
- assertEquals(DOWNLOAD_COMPANION_APP_DESCRIPTION,
- metadataParcel.downloadCompanionAppDescription);
- assertEquals(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION,
- metadataParcel.failConnectGoToSettingsDescription);
- assertEquals(FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION,
- metadataParcel.fastPairTvConnectDeviceNoAccountDescription);
- assertArrayEquals(IMAGE, metadataParcel.image);
- assertEquals(IMAGE_URL, metadataParcel.imageUrl);
- assertEquals(INITIAL_NOTIFICATION_DESCRIPTION,
- metadataParcel.initialNotificationDescription);
- assertEquals(INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT,
- metadataParcel.initialNotificationDescriptionNoAccount);
- assertEquals(INITIAL_PAIRING_DESCRIPTION, metadataParcel.initialPairingDescription);
- assertEquals(INTENT_URI, metadataParcel.intentUri);
- assertEquals(LOCALE, metadataParcel.locale);
- assertEquals(OPEN_COMPANION_APP_DESCRIPTION, metadataParcel.openCompanionAppDescription);
- assertEquals(RETRO_ACTIVE_PAIRING_DESCRIPTION,
- metadataParcel.retroactivePairingDescription);
- assertEquals(SUBSEQUENT_PAIRING_DESCRIPTION, metadataParcel.subsequentPairingDescription);
- assertEquals(SYNC_CONTACT_DESCRPTION, metadataParcel.syncContactsDescription);
- assertEquals(SYNC_CONTACTS_TITLE, metadataParcel.syncContactsTitle);
- assertEquals(SYNC_SMS_DESCRIPTION, metadataParcel.syncSmsDescription);
- assertEquals(SYNC_SMS_TITLE, metadataParcel.syncSmsTitle);
- assertEquals(TRIGGER_DISTANCE, metadataParcel.triggerDistance, DELTA);
- assertEquals(TRUE_WIRELESS_IMAGE_URL_CASE, metadataParcel.trueWirelessImageUrlCase);
- assertEquals(TRUE_WIRELESS_IMAGE_URL_LEFT_BUD, metadataParcel.trueWirelessImageUrlLeftBud);
- assertEquals(TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD,
- metadataParcel.trueWirelessImageUrlRightBud);
- assertEquals(UNABLE_TO_CONNECT_DESCRIPTION, metadataParcel.unableToConnectDescription);
- assertEquals(UNABLE_TO_CONNECT_TITLE, metadataParcel.unableToConnectTitle);
- assertEquals(UPDATE_COMPANION_APP_DESCRIPTION,
- metadataParcel.updateCompanionAppDescription);
- assertEquals(WAIT_LAUNCH_COMPANION_APP_DESCRIPTION,
- metadataParcel.waitLaunchCompanionAppDescription);
+ assertThat(metadataParcel).isNotNull();
+
+ assertThat(metadataParcel.assistantSetupHalfSheet).isEqualTo(ASSISTANT_SETUP_HALFSHEET);
+ assertThat(metadataParcel.assistantSetupNotification).isEqualTo(
+ ASSISTANT_SETUP_NOTIFICATION);
+
+ assertThat(metadataParcel.bleTxPower).isEqualTo(BLE_TX_POWER);
+
+ assertThat(metadataParcel.confirmPinDescription).isEqualTo(CONFIRM_PIN_DESCRIPTION);
+ assertThat(metadataParcel.confirmPinTitle).isEqualTo(CONFIRM_PIN_TITLE);
+ assertThat(metadataParcel.connectSuccessCompanionAppInstalled).isEqualTo(
+ CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
+ assertThat(metadataParcel.connectSuccessCompanionAppNotInstalled).isEqualTo(
+ CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED);
+
+ assertThat(metadataParcel.deviceType).isEqualTo(DEVICE_TYPE);
+ assertThat(metadataParcel.downloadCompanionAppDescription).isEqualTo(
+ DOWNLOAD_COMPANION_APP_DESCRIPTION);
+
+ assertThat(metadataParcel.failConnectGoToSettingsDescription).isEqualTo(
+ FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
+ assertThat(metadataParcel.fastPairTvConnectDeviceNoAccountDescription).isEqualTo(
+ FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
+
+ assertThat(metadataParcel.image).isEqualTo(IMAGE);
+ assertThat(metadataParcel.imageUrl).isEqualTo(IMAGE_URL);
+ assertThat(metadataParcel.initialNotificationDescription).isEqualTo(
+ INITIAL_NOTIFICATION_DESCRIPTION);
+ assertThat(metadataParcel.initialNotificationDescriptionNoAccount).isEqualTo(
+ INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT);
+ assertThat(metadataParcel.initialPairingDescription).isEqualTo(INITIAL_PAIRING_DESCRIPTION);
+ assertThat(metadataParcel.intentUri).isEqualTo(INTENT_URI);
+
+ assertThat(metadataParcel.locale).isEqualTo(LOCALE);
+
+ assertThat(metadataParcel.openCompanionAppDescription).isEqualTo(
+ OPEN_COMPANION_APP_DESCRIPTION);
+
+ assertThat(metadataParcel.retroactivePairingDescription).isEqualTo(
+ RETRO_ACTIVE_PAIRING_DESCRIPTION);
+
+ assertThat(metadataParcel.subsequentPairingDescription).isEqualTo(
+ SUBSEQUENT_PAIRING_DESCRIPTION);
+ assertThat(metadataParcel.syncContactsDescription).isEqualTo(SYNC_CONTACT_DESCRPTION);
+ assertThat(metadataParcel.syncContactsTitle).isEqualTo(SYNC_CONTACTS_TITLE);
+ assertThat(metadataParcel.syncSmsDescription).isEqualTo(SYNC_SMS_DESCRIPTION);
+ assertThat(metadataParcel.syncSmsTitle).isEqualTo(SYNC_SMS_TITLE);
+
+ assertThat(metadataParcel.triggerDistance).isWithin(DELTA).of(TRIGGER_DISTANCE);
+ assertThat(metadataParcel.trueWirelessImageUrlCase).isEqualTo(TRUE_WIRELESS_IMAGE_URL_CASE);
+ assertThat(metadataParcel.trueWirelessImageUrlLeftBud).isEqualTo(
+ TRUE_WIRELESS_IMAGE_URL_LEFT_BUD);
+ assertThat(metadataParcel.trueWirelessImageUrlRightBud).isEqualTo(
+ TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD);
+
+ assertThat(metadataParcel.unableToConnectDescription).isEqualTo(
+ UNABLE_TO_CONNECT_DESCRIPTION);
+ assertThat(metadataParcel.unableToConnectTitle).isEqualTo(UNABLE_TO_CONNECT_TITLE);
+ assertThat(metadataParcel.updateCompanionAppDescription).isEqualTo(
+ UPDATE_COMPANION_APP_DESCRIPTION);
+
+ assertThat(metadataParcel.waitLaunchCompanionAppDescription).isEqualTo(
+ WAIT_LAUNCH_COMPANION_APP_DESCRIPTION);
}
/* Verifies Happy Path DeviceMetadata. */
private static void ensureHappyPathAsExpected(FastPairDeviceMetadata metadata) {
- assertEquals(ASSISTANT_SETUP_HALFSHEET, metadata.getAssistantSetupHalfSheet());
- assertEquals(ASSISTANT_SETUP_NOTIFICATION, metadata.getAssistantSetupNotification());
- assertEquals(BLE_TX_POWER, metadata.getBleTxPower());
- assertEquals(CONFIRM_PIN_DESCRIPTION, metadata.getConfirmPinDescription());
- assertEquals(CONFIRM_PIN_TITLE, metadata.getConfirmPinTitle());
- assertEquals(CONNECT_SUCCESS_COMPANION_APP_INSTALLED,
- metadata.getConnectSuccessCompanionAppInstalled());
- assertEquals(CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED,
- metadata.getConnectSuccessCompanionAppNotInstalled());
- assertEquals(DEVICE_TYPE, metadata.getDeviceType());
- assertEquals(DOWNLOAD_COMPANION_APP_DESCRIPTION,
- metadata.getDownloadCompanionAppDescription());
- assertEquals(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION,
- metadata.getFailConnectGoToSettingsDescription());
- assertEquals(FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION,
- metadata.getFastPairTvConnectDeviceNoAccountDescription());
- assertArrayEquals(IMAGE, metadata.getImage());
- assertEquals(IMAGE_URL, metadata.getImageUrl());
- assertEquals(INITIAL_NOTIFICATION_DESCRIPTION,
- metadata.getInitialNotificationDescription());
- assertEquals(INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT,
- metadata.getInitialNotificationDescriptionNoAccount());
- assertEquals(INITIAL_PAIRING_DESCRIPTION, metadata.getInitialPairingDescription());
- assertEquals(INTENT_URI, metadata.getIntentUri());
- assertEquals(LOCALE, metadata.getLocale());
- assertEquals(OPEN_COMPANION_APP_DESCRIPTION, metadata.getOpenCompanionAppDescription());
- assertEquals(RETRO_ACTIVE_PAIRING_DESCRIPTION,
- metadata.getRetroactivePairingDescription());
- assertEquals(SUBSEQUENT_PAIRING_DESCRIPTION, metadata.getSubsequentPairingDescription());
- assertEquals(SYNC_CONTACT_DESCRPTION, metadata.getSyncContactsDescription());
- assertEquals(SYNC_CONTACTS_TITLE, metadata.getSyncContactsTitle());
- assertEquals(SYNC_SMS_DESCRIPTION, metadata.getSyncSmsDescription());
- assertEquals(SYNC_SMS_TITLE, metadata.getSyncSmsTitle());
- assertEquals(TRIGGER_DISTANCE, metadata.getTriggerDistance(), DELTA);
- assertEquals(TRUE_WIRELESS_IMAGE_URL_CASE, metadata.getTrueWirelessImageUrlCase());
- assertEquals(TRUE_WIRELESS_IMAGE_URL_LEFT_BUD, metadata.getTrueWirelessImageUrlLeftBud());
- assertEquals(TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD,
- metadata.getTrueWirelessImageUrlRightBud());
- assertEquals(UNABLE_TO_CONNECT_DESCRIPTION, metadata.getUnableToConnectDescription());
- assertEquals(UNABLE_TO_CONNECT_TITLE, metadata.getUnableToConnectTitle());
- assertEquals(UPDATE_COMPANION_APP_DESCRIPTION,
- metadata.getUpdateCompanionAppDescription());
- assertEquals(WAIT_LAUNCH_COMPANION_APP_DESCRIPTION,
- metadata.getWaitLaunchCompanionAppDescription());
+ assertThat(metadata.getAssistantSetupHalfSheet()).isEqualTo(ASSISTANT_SETUP_HALFSHEET);
+ assertThat(metadata.getAssistantSetupNotification())
+ .isEqualTo(ASSISTANT_SETUP_NOTIFICATION);
+ assertThat(metadata.getBleTxPower()).isEqualTo(BLE_TX_POWER);
+ assertThat(metadata.getConfirmPinDescription()).isEqualTo(CONFIRM_PIN_DESCRIPTION);
+ assertThat(metadata.getConfirmPinTitle()).isEqualTo(CONFIRM_PIN_TITLE);
+ assertThat(metadata.getConnectSuccessCompanionAppInstalled())
+ .isEqualTo(CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
+ assertThat(metadata.getConnectSuccessCompanionAppNotInstalled())
+ .isEqualTo(CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED);
+ assertThat(metadata.getDeviceType()).isEqualTo(DEVICE_TYPE);
+ assertThat(metadata.getDownloadCompanionAppDescription())
+ .isEqualTo(DOWNLOAD_COMPANION_APP_DESCRIPTION);
+ assertThat(metadata.getFailConnectGoToSettingsDescription())
+ .isEqualTo(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
+ assertThat(metadata.getFastPairTvConnectDeviceNoAccountDescription())
+ .isEqualTo(FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
+ assertThat(metadata.getImage()).isEqualTo(IMAGE);
+ assertThat(metadata.getImageUrl()).isEqualTo(IMAGE_URL);
+ assertThat(metadata.getInitialNotificationDescription())
+ .isEqualTo(INITIAL_NOTIFICATION_DESCRIPTION);
+ assertThat(metadata.getInitialNotificationDescriptionNoAccount())
+ .isEqualTo(INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT);
+ assertThat(metadata.getInitialPairingDescription()).isEqualTo(INITIAL_PAIRING_DESCRIPTION);
+ assertThat(metadata.getIntentUri()).isEqualTo(INTENT_URI);
+ assertThat(metadata.getLocale()).isEqualTo(LOCALE);
+ assertThat(metadata.getOpenCompanionAppDescription())
+ .isEqualTo(OPEN_COMPANION_APP_DESCRIPTION);
+ assertThat(metadata.getRetroactivePairingDescription())
+ .isEqualTo(RETRO_ACTIVE_PAIRING_DESCRIPTION);
+ assertThat(metadata.getSubsequentPairingDescription())
+ .isEqualTo(SUBSEQUENT_PAIRING_DESCRIPTION);
+ assertThat(metadata.getSyncContactsDescription()).isEqualTo(SYNC_CONTACT_DESCRPTION);
+ assertThat(metadata.getSyncContactsTitle()).isEqualTo(SYNC_CONTACTS_TITLE);
+ assertThat(metadata.getSyncSmsDescription()).isEqualTo(SYNC_SMS_DESCRIPTION);
+ assertThat(metadata.getSyncSmsTitle()).isEqualTo(SYNC_SMS_TITLE);
+ assertThat(metadata.getTriggerDistance()).isWithin(DELTA).of(TRIGGER_DISTANCE);
+ assertThat(metadata.getTrueWirelessImageUrlCase()).isEqualTo(TRUE_WIRELESS_IMAGE_URL_CASE);
+ assertThat(metadata.getTrueWirelessImageUrlLeftBud())
+ .isEqualTo(TRUE_WIRELESS_IMAGE_URL_LEFT_BUD);
+ assertThat(metadata.getTrueWirelessImageUrlRightBud())
+ .isEqualTo(TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD);
+ assertThat(metadata.getUnableToConnectDescription())
+ .isEqualTo(UNABLE_TO_CONNECT_DESCRIPTION);
+ assertThat(metadata.getUnableToConnectTitle()).isEqualTo(UNABLE_TO_CONNECT_TITLE);
+ assertThat(metadata.getUpdateCompanionAppDescription())
+ .isEqualTo(UPDATE_COMPANION_APP_DESCRIPTION);
+ assertThat(metadata.getWaitLaunchCompanionAppDescription())
+ .isEqualTo(WAIT_LAUNCH_COMPANION_APP_DESCRIPTION);
}
/* Verifies Happy Path FastPairDiscoveryItemParcel. */
private static void ensureHappyPathAsExpected(FastPairDiscoveryItemParcel itemParcel) {
- assertEquals(ACTION_URL, itemParcel.actionUrl);
- assertEquals(ACTION_URL_TYPE, itemParcel.actionUrlType);
- assertEquals(APP_NAME, itemParcel.appName);
- assertEquals(ATTACHMENT_TYPE, itemParcel.attachmentType);
- assertArrayEquals(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1,
- itemParcel.authenticationPublicKeySecp256r1);
- assertArrayEquals(BLE_RECORD_BYTES, itemParcel.bleRecordBytes);
- assertEquals(DEBUG_CATEGORY, itemParcel.debugCategory);
- assertEquals(DEBUG_MESSAGE, itemParcel.debugMessage);
- assertEquals(DESCRIPTION, itemParcel.description);
- assertEquals(DEVICE_NAME, itemParcel.deviceName);
- assertEquals(DISPLAY_URL, itemParcel.displayUrl);
- assertEquals(ENTITY_ID, itemParcel.entityId);
- assertEquals(FEATURE_GRAPHIC_URL, itemParcel.featureGraphicUrl);
- assertEquals(FIRST_OBSERVATION_TIMESTAMP_MILLIS,
- itemParcel.firstObservationTimestampMillis);
- assertEquals(GROUP_ID, itemParcel.groupId);
- assertEquals(ICON_FIFE_URL, itemParcel.iconFifeUrl);
- assertEquals(ICON_PNG, itemParcel.iconPng);
- assertEquals(ID, itemParcel.id);
- assertEquals(LAST_OBSERVATION_TIMESTAMP_MILLIS, itemParcel.lastObservationTimestampMillis);
- assertEquals(LAST_USER_EXPERIENCE, itemParcel.lastUserExperience);
- assertEquals(LOST_MILLIS, itemParcel.lostMillis);
- assertEquals(MAC_ADDRESS, itemParcel.macAddress);
- assertEquals(PACKAGE_NAME, itemParcel.packageName);
- assertEquals(PENDING_APP_INSTALL_TIMESTAMP_MILLIS,
- itemParcel.pendingAppInstallTimestampMillis);
- assertEquals(RSSI, itemParcel.rssi);
- assertEquals(STATE, itemParcel.state);
- assertEquals(TITLE, itemParcel.title);
- assertEquals(TRIGGER_ID, itemParcel.triggerId);
- assertEquals(TX_POWER, itemParcel.txPower);
- assertEquals(TYPE, itemParcel.type);
+ assertThat(itemParcel.actionUrl).isEqualTo(ACTION_URL);
+ assertThat(itemParcel.actionUrlType).isEqualTo(ACTION_URL_TYPE);
+ assertThat(itemParcel.appName).isEqualTo(APP_NAME);
+ assertThat(itemParcel.attachmentType).isEqualTo(ATTACHMENT_TYPE);
+ assertThat(itemParcel.authenticationPublicKeySecp256r1)
+ .isEqualTo(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
+ assertThat(itemParcel.bleRecordBytes).isEqualTo(BLE_RECORD_BYTES);
+ assertThat(itemParcel.debugCategory).isEqualTo(DEBUG_CATEGORY);
+ assertThat(itemParcel.debugMessage).isEqualTo(DEBUG_MESSAGE);
+ assertThat(itemParcel.description).isEqualTo(DESCRIPTION);
+ assertThat(itemParcel.deviceName).isEqualTo(DEVICE_NAME);
+ assertThat(itemParcel.displayUrl).isEqualTo(DISPLAY_URL);
+ assertThat(itemParcel.entityId).isEqualTo(ENTITY_ID);
+ assertThat(itemParcel.featureGraphicUrl).isEqualTo(FEATURE_GRAPHIC_URL);
+ assertThat(itemParcel.firstObservationTimestampMillis)
+ .isEqualTo(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
+ assertThat(itemParcel.groupId).isEqualTo(GROUP_ID);
+ assertThat(itemParcel.iconFifeUrl).isEqualTo(ICON_FIFE_URL);
+ assertThat(itemParcel.iconPng).isEqualTo(ICON_PNG);
+ assertThat(itemParcel.id).isEqualTo(ID);
+ assertThat(itemParcel.lastObservationTimestampMillis)
+ .isEqualTo(LAST_OBSERVATION_TIMESTAMP_MILLIS);
+ assertThat(itemParcel.lastUserExperience).isEqualTo(LAST_USER_EXPERIENCE);
+ assertThat(itemParcel.lostMillis).isEqualTo(LOST_MILLIS);
+ assertThat(itemParcel.macAddress).isEqualTo(MAC_ADDRESS);
+ assertThat(itemParcel.packageName).isEqualTo(PACKAGE_NAME);
+ assertThat(itemParcel.pendingAppInstallTimestampMillis)
+ .isEqualTo(PENDING_APP_INSTALL_TIMESTAMP_MILLIS);
+ assertThat(itemParcel.rssi).isEqualTo(RSSI);
+ assertThat(itemParcel.state).isEqualTo(STATE);
+ assertThat(itemParcel.title).isEqualTo(TITLE);
+ assertThat(itemParcel.triggerId).isEqualTo(TRIGGER_ID);
+ assertThat(itemParcel.txPower).isEqualTo(TX_POWER);
+ assertThat(itemParcel.type).isEqualTo(TYPE);
}
/* Verifies Happy Path FastPairDiscoveryItem. */
private static void ensureHappyPathAsExpected(FastPairDiscoveryItem item) {
- assertEquals(ACTION_URL, item.getActionUrl());
- assertEquals(ACTION_URL_TYPE, item.getActionUrlType());
- assertEquals(APP_NAME, item.getAppName());
- assertEquals(ATTACHMENT_TYPE, item.getAttachmentType());
- assertArrayEquals(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1,
- item.getAuthenticationPublicKeySecp256r1());
- assertArrayEquals(BLE_RECORD_BYTES, item.getBleRecordBytes());
- assertEquals(DEBUG_CATEGORY, item.getDebugCategory());
- assertEquals(DEBUG_MESSAGE, item.getDebugMessage());
- assertEquals(DESCRIPTION, item.getDescription());
- assertEquals(DEVICE_NAME, item.getDeviceName());
- assertEquals(DISPLAY_URL, item.getDisplayUrl());
- assertEquals(ENTITY_ID, item.getEntityId());
- assertEquals(FEATURE_GRAPHIC_URL, item.getFeatureGraphicUrl());
- assertEquals(FIRST_OBSERVATION_TIMESTAMP_MILLIS,
- item.getFirstObservationTimestampMillis());
- assertEquals(GROUP_ID, item.getGroupId());
- assertEquals(ICON_FIFE_URL, item.getIconFfeUrl());
- assertEquals(ICON_PNG, item.getIconPng());
- assertEquals(ID, item.getId());
- assertEquals(LAST_OBSERVATION_TIMESTAMP_MILLIS, item.getLastObservationTimestampMillis());
- assertEquals(LAST_USER_EXPERIENCE, item.getLastUserExperience());
- assertEquals(LOST_MILLIS, item.getLostMillis());
- assertEquals(MAC_ADDRESS, item.getMacAddress());
- assertEquals(PACKAGE_NAME, item.getPackageName());
- assertEquals(PENDING_APP_INSTALL_TIMESTAMP_MILLIS,
- item.getPendingAppInstallTimestampMillis());
- assertEquals(RSSI, item.getRssi());
- assertEquals(STATE, item.getState());
- assertEquals(TITLE, item.getTitle());
- assertEquals(TRIGGER_ID, item.getTriggerId());
- assertEquals(TX_POWER, item.getTxPower());
- assertEquals(TYPE, item.getType());
+ assertThat(item.getActionUrl()).isEqualTo(ACTION_URL);
+ assertThat(item.getActionUrlType()).isEqualTo(ACTION_URL_TYPE);
+ assertThat(item.getAppName()).isEqualTo(APP_NAME);
+ assertThat(item.getAttachmentType()).isEqualTo(ATTACHMENT_TYPE);
+ assertThat(item.getAuthenticationPublicKeySecp256r1())
+ .isEqualTo(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
+ assertThat(item.getBleRecordBytes()).isEqualTo(BLE_RECORD_BYTES);
+ assertThat(item.getDebugCategory()).isEqualTo(DEBUG_CATEGORY);
+ assertThat(item.getDebugMessage()).isEqualTo(DEBUG_MESSAGE);
+ assertThat(item.getDescription()).isEqualTo(DESCRIPTION);
+ assertThat(item.getDeviceName()).isEqualTo(DEVICE_NAME);
+ assertThat(item.getDisplayUrl()).isEqualTo(DISPLAY_URL);
+ assertThat(item.getEntityId()).isEqualTo(ENTITY_ID);
+ assertThat(item.getFeatureGraphicUrl()).isEqualTo(FEATURE_GRAPHIC_URL);
+ assertThat(item.getFirstObservationTimestampMillis())
+ .isEqualTo(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
+ assertThat(item.getGroupId()).isEqualTo(GROUP_ID);
+ assertThat(item.getIconFfeUrl()).isEqualTo(ICON_FIFE_URL);
+ assertThat(item.getIconPng()).isEqualTo(ICON_PNG);
+ assertThat(item.getId()).isEqualTo(ID);
+ assertThat(item.getLastObservationTimestampMillis())
+ .isEqualTo(LAST_OBSERVATION_TIMESTAMP_MILLIS);
+ assertThat(item.getLastUserExperience()).isEqualTo(LAST_USER_EXPERIENCE);
+ assertThat(item.getLostMillis()).isEqualTo(LOST_MILLIS);
+ assertThat(item.getMacAddress()).isEqualTo(MAC_ADDRESS);
+ assertThat(item.getPackageName()).isEqualTo(PACKAGE_NAME);
+ assertThat(item.getPendingAppInstallTimestampMillis())
+ .isEqualTo(PENDING_APP_INSTALL_TIMESTAMP_MILLIS);
+ assertThat(item.getRssi()).isEqualTo(RSSI);
+ assertThat(item.getState()).isEqualTo(STATE);
+ assertThat(item.getTitle()).isEqualTo(TITLE);
+ assertThat(item.getTriggerId()).isEqualTo(TRIGGER_ID);
+ assertThat(item.getTxPower()).isEqualTo(TX_POWER);
+ assertThat(item.getType()).isEqualTo(TYPE);
}
/* Verifies Happy Path EligibleAccountParcel[]. */
private static void ensureHappyPathAsExpected(FastPairEligibleAccountParcel[] accountsParcel) {
- assertEquals(ELIGIBLE_ACCOUNTS_NUM, accountsParcel.length);
- assertEquals(ELIGIBLE_ACCOUNT_1, accountsParcel[0].account);
- assertEquals(ELIGIBLE_ACCOUNT_1_OPT_IN, accountsParcel[0].optIn);
+ assertThat(accountsParcel).hasLength(ELIGIBLE_ACCOUNTS_NUM);
- assertEquals(ELIGIBLE_ACCOUNT_2, accountsParcel[1].account);
- assertEquals(ELIGIBLE_ACCOUNT_2_OPT_IN, accountsParcel[1].optIn);
+ assertThat(accountsParcel[0].account).isEqualTo(ELIGIBLE_ACCOUNT_1);
+ assertThat(accountsParcel[0].optIn).isEqualTo(ELIGIBLE_ACCOUNT_1_OPT_IN);
+
+ assertThat(accountsParcel[1].account).isEqualTo(ELIGIBLE_ACCOUNT_2);
+ assertThat(accountsParcel[1].optIn).isEqualTo(ELIGIBLE_ACCOUNT_2_OPT_IN);
}
}
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);