Revert "Remove Fast Pair system APIs."
This reverts commit 74607dd786b9cbe017b5785833bd8e6d3a8cf4d8.
Reason for revert: Continue development in T+/U
Bug: 227513829
Test: cts test
Ignore-AOSP-First: nearby_not_in_aosp_yet
Change-Id: Ib648ed7163a2e1f11eeed3d0d3469decf64d9d86
CTS-Coverage-Bug: 205591293
diff --git a/framework-t/api/system-current.txt b/framework-t/api/system-current.txt
index c2d245c..4bae8f4 100644
--- a/framework-t/api/system-current.txt
+++ b/framework-t/api/system-current.txt
@@ -51,6 +51,208 @@
field @NonNull public static final android.os.Parcelable.Creator<android.nearby.DataElement> CREATOR;
}
+ public class FastPairAccountKeyDeviceMetadata {
+ method @Nullable public byte[] getDeviceAccountKey();
+ method @Nullable public android.nearby.FastPairDeviceMetadata getFastPairDeviceMetadata();
+ method @Nullable public android.nearby.FastPairDiscoveryItem getFastPairDiscoveryItem();
+ method @Nullable public byte[] getSha256DeviceAccountKeyPublicAddress();
+ }
+
+ public static final class FastPairAccountKeyDeviceMetadata.Builder {
+ ctor public FastPairAccountKeyDeviceMetadata.Builder();
+ method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata build();
+ method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata.Builder setDeviceAccountKey(@Nullable byte[]);
+ method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata.Builder setFastPairDeviceMetadata(@Nullable android.nearby.FastPairDeviceMetadata);
+ method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata.Builder setFastPairDiscoveryItem(@Nullable android.nearby.FastPairDiscoveryItem);
+ method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata.Builder setSha256DeviceAccountKeyPublicAddress(@Nullable byte[]);
+ }
+
+ public class FastPairAntispoofKeyDeviceMetadata {
+ method @Nullable public byte[] getAntispoofPublicKey();
+ method @Nullable public android.nearby.FastPairDeviceMetadata getFastPairDeviceMetadata();
+ }
+
+ public static final class FastPairAntispoofKeyDeviceMetadata.Builder {
+ ctor public FastPairAntispoofKeyDeviceMetadata.Builder();
+ method @NonNull public android.nearby.FastPairAntispoofKeyDeviceMetadata build();
+ method @NonNull public android.nearby.FastPairAntispoofKeyDeviceMetadata.Builder setAntispoofPublicKey(@Nullable byte[]);
+ method @NonNull public android.nearby.FastPairAntispoofKeyDeviceMetadata.Builder setFastPairDeviceMetadata(@Nullable android.nearby.FastPairDeviceMetadata);
+ }
+
+ public abstract class FastPairDataProviderService extends android.app.Service {
+ ctor public FastPairDataProviderService(@NonNull String);
+ method @NonNull public final android.os.IBinder onBind(@NonNull android.content.Intent);
+ method public abstract void onLoadFastPairAccountDevicesMetadata(@NonNull android.nearby.FastPairDataProviderService.FastPairAccountDevicesMetadataRequest, @NonNull android.nearby.FastPairDataProviderService.FastPairAccountDevicesMetadataCallback);
+ method public abstract void onLoadFastPairAntispoofKeyDeviceMetadata(@NonNull android.nearby.FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataRequest, @NonNull android.nearby.FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataCallback);
+ method public abstract void onLoadFastPairEligibleAccounts(@NonNull android.nearby.FastPairDataProviderService.FastPairEligibleAccountsRequest, @NonNull android.nearby.FastPairDataProviderService.FastPairEligibleAccountsCallback);
+ method public abstract void onManageFastPairAccount(@NonNull android.nearby.FastPairDataProviderService.FastPairManageAccountRequest, @NonNull android.nearby.FastPairDataProviderService.FastPairManageActionCallback);
+ method public abstract void onManageFastPairAccountDevice(@NonNull android.nearby.FastPairDataProviderService.FastPairManageAccountDeviceRequest, @NonNull android.nearby.FastPairDataProviderService.FastPairManageActionCallback);
+ field public static final String ACTION_FAST_PAIR_DATA_PROVIDER = "android.nearby.action.FAST_PAIR_DATA_PROVIDER";
+ field public static final int ERROR_CODE_BAD_REQUEST = 0; // 0x0
+ field public static final int ERROR_CODE_INTERNAL_ERROR = 1; // 0x1
+ field public static final int MANAGE_REQUEST_ADD = 0; // 0x0
+ field public static final int MANAGE_REQUEST_REMOVE = 1; // 0x1
+ }
+
+ public static interface FastPairDataProviderService.FastPairAccountDevicesMetadataCallback {
+ method public void onError(int, @Nullable String);
+ method public void onFastPairAccountDevicesMetadataReceived(@NonNull java.util.Collection<android.nearby.FastPairAccountKeyDeviceMetadata>);
+ }
+
+ public static class FastPairDataProviderService.FastPairAccountDevicesMetadataRequest {
+ method @NonNull public android.accounts.Account getAccount();
+ method @NonNull public java.util.Collection<byte[]> getDeviceAccountKeys();
+ }
+
+ public static interface FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataCallback {
+ method public void onError(int, @Nullable String);
+ method public void onFastPairAntispoofKeyDeviceMetadataReceived(@NonNull android.nearby.FastPairAntispoofKeyDeviceMetadata);
+ }
+
+ public static class FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataRequest {
+ method @NonNull public byte[] getModelId();
+ }
+
+ public static interface FastPairDataProviderService.FastPairEligibleAccountsCallback {
+ method public void onError(int, @Nullable String);
+ method public void onFastPairEligibleAccountsReceived(@NonNull java.util.Collection<android.nearby.FastPairEligibleAccount>);
+ }
+
+ public static class FastPairDataProviderService.FastPairEligibleAccountsRequest {
+ }
+
+ public static class FastPairDataProviderService.FastPairManageAccountDeviceRequest {
+ method @NonNull public android.accounts.Account getAccount();
+ method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata getAccountKeyDeviceMetadata();
+ method public int getRequestType();
+ }
+
+ public static class FastPairDataProviderService.FastPairManageAccountRequest {
+ method @NonNull public android.accounts.Account getAccount();
+ method public int getRequestType();
+ }
+
+ public static interface FastPairDataProviderService.FastPairManageActionCallback {
+ method public void onError(int, @Nullable String);
+ method public void onSuccess();
+ }
+
+ public class FastPairDeviceMetadata {
+ method public int getBleTxPower();
+ method @Nullable public String getConnectSuccessCompanionAppInstalled();
+ method @Nullable public String getConnectSuccessCompanionAppNotInstalled();
+ method public int getDeviceType();
+ method @Nullable public String getDownloadCompanionAppDescription();
+ method @Nullable public String getFailConnectGoToSettingsDescription();
+ method @Nullable public byte[] getImage();
+ method @Nullable public String getImageUrl();
+ method @Nullable public String getInitialNotificationDescription();
+ method @Nullable public String getInitialNotificationDescriptionNoAccount();
+ method @Nullable public String getInitialPairingDescription();
+ method @Nullable public String getIntentUri();
+ method @Nullable public String getName();
+ method @Nullable public String getOpenCompanionAppDescription();
+ method @Nullable public String getRetroactivePairingDescription();
+ method @Nullable public String getSubsequentPairingDescription();
+ method public float getTriggerDistance();
+ method @Nullable public String getTrueWirelessImageUrlCase();
+ method @Nullable public String getTrueWirelessImageUrlLeftBud();
+ method @Nullable public String getTrueWirelessImageUrlRightBud();
+ method @Nullable public String getUnableToConnectDescription();
+ method @Nullable public String getUnableToConnectTitle();
+ method @Nullable public String getUpdateCompanionAppDescription();
+ method @Nullable public String getWaitLaunchCompanionAppDescription();
+ }
+
+ public static final class FastPairDeviceMetadata.Builder {
+ ctor public FastPairDeviceMetadata.Builder();
+ method @NonNull public android.nearby.FastPairDeviceMetadata build();
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setBleTxPower(int);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setConnectSuccessCompanionAppInstalled(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setConnectSuccessCompanionAppNotInstalled(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setDeviceType(int);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setDownloadCompanionAppDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setFailConnectGoToSettingsDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setImage(@Nullable byte[]);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setImageUrl(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setInitialNotificationDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setInitialNotificationDescriptionNoAccount(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setInitialPairingDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setIntentUri(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setName(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setOpenCompanionAppDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setRetroactivePairingDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSubsequentPairingDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setTriggerDistance(float);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setTrueWirelessImageUrlCase(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setTrueWirelessImageUrlLeftBud(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setTrueWirelessImageUrlRightBud(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setUnableToConnectDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setUnableToConnectTitle(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setUpdateCompanionAppDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setWaitLaunchCompanionAppDescription(@Nullable String);
+ }
+
+ public class FastPairDiscoveryItem {
+ method @Nullable public String getActionUrl();
+ method public int getActionUrlType();
+ method @Nullable public String getAppName();
+ method @Nullable public byte[] getAuthenticationPublicKeySecp256r1();
+ method @Nullable public String getDescription();
+ method @Nullable public String getDeviceName();
+ method @Nullable public String getDisplayUrl();
+ method public long getFirstObservationTimestampMillis();
+ method @Nullable public String getIconFfeUrl();
+ method @Nullable public byte[] getIconPng();
+ method @Nullable public String getId();
+ method public long getLastObservationTimestampMillis();
+ method @Nullable public String getMacAddress();
+ method @Nullable public String getPackageName();
+ method public long getPendingAppInstallTimestampMillis();
+ method public int getRssi();
+ method public int getState();
+ method @Nullable public String getTitle();
+ method @Nullable public String getTriggerId();
+ method public int getTxPower();
+ }
+
+ public static final class FastPairDiscoveryItem.Builder {
+ ctor public FastPairDiscoveryItem.Builder();
+ method @NonNull public android.nearby.FastPairDiscoveryItem build();
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setActionUrl(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setActionUrlType(int);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setAppName(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setAuthenticationPublicKeySecp256r1(@Nullable byte[]);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDeviceName(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDisplayUrl(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setFirstObservationTimestampMillis(long);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setIconFfeUrl(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setIconPng(@Nullable byte[]);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setId(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setLastObservationTimestampMillis(long);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setMacAddress(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setPackageName(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setPendingAppInstallTimestampMillis(long);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setRssi(int);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setState(int);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setTitle(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setTriggerId(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setTxPower(int);
+ }
+
+ public class FastPairEligibleAccount {
+ method @Nullable public android.accounts.Account getAccount();
+ method public boolean isOptIn();
+ }
+
+ public static final class FastPairEligibleAccount.Builder {
+ ctor public FastPairEligibleAccount.Builder();
+ method @NonNull public android.nearby.FastPairEligibleAccount build();
+ method @NonNull public android.nearby.FastPairEligibleAccount.Builder setAccount(@Nullable android.accounts.Account);
+ method @NonNull public android.nearby.FastPairEligibleAccount.Builder setOptIn(boolean);
+ }
+
public abstract class NearbyDevice {
method @NonNull public java.util.List<java.lang.Integer> getMediums();
method @Nullable public String getName();
diff --git a/nearby/framework/java/android/nearby/FastPairAccountKeyDeviceMetadata.java b/nearby/framework/java/android/nearby/FastPairAccountKeyDeviceMetadata.java
index d42fbf4..160ad75 100644
--- a/nearby/framework/java/android/nearby/FastPairAccountKeyDeviceMetadata.java
+++ b/nearby/framework/java/android/nearby/FastPairAccountKeyDeviceMetadata.java
@@ -18,6 +18,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.nearby.aidl.FastPairAccountKeyDeviceMetadataParcel;
/**
@@ -25,6 +26,7 @@
*
* @hide
*/
+@SystemApi
public class FastPairAccountKeyDeviceMetadata {
FastPairAccountKeyDeviceMetadataParcel mMetadataParcel;
@@ -40,6 +42,7 @@
* @return 16-byte Account Key.
* @hide
*/
+ @SystemApi
@Nullable
public byte[] getDeviceAccountKey() {
return mMetadataParcel.deviceAccountKey;
@@ -52,6 +55,7 @@
* @return 32-byte Sha256 hash value.
* @hide
*/
+ @SystemApi
@Nullable
public byte[] getSha256DeviceAccountKeyPublicAddress() {
return mMetadataParcel.sha256DeviceAccountKeyPublicAddress;
@@ -62,6 +66,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public FastPairDeviceMetadata getFastPairDeviceMetadata() {
if (mMetadataParcel.metadata == null) {
@@ -75,6 +80,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public FastPairDiscoveryItem getFastPairDiscoveryItem() {
if (mMetadataParcel.discoveryItem == null) {
@@ -88,6 +94,7 @@
*
* @hide
*/
+ @SystemApi
public static final class Builder {
private final FastPairAccountKeyDeviceMetadataParcel mBuilderParcel;
@@ -97,6 +104,7 @@
*
* @hide
*/
+ @SystemApi
public Builder() {
mBuilderParcel = new FastPairAccountKeyDeviceMetadataParcel();
mBuilderParcel.deviceAccountKey = null;
@@ -113,6 +121,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setDeviceAccountKey(@Nullable byte[] deviceAccountKey) {
mBuilderParcel.deviceAccountKey = deviceAccountKey;
@@ -127,6 +136,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setSha256DeviceAccountKeyPublicAddress(
@Nullable byte[] sha256DeviceAccountKeyPublicAddress) {
@@ -143,6 +153,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setFastPairDeviceMetadata(@Nullable FastPairDeviceMetadata metadata) {
if (metadata == null) {
@@ -160,6 +171,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setFastPairDiscoveryItem(@Nullable FastPairDiscoveryItem discoveryItem) {
if (discoveryItem == null) {
@@ -175,6 +187,7 @@
*
* @hide
*/
+ @SystemApi
@NonNull
public FastPairAccountKeyDeviceMetadata build() {
return new FastPairAccountKeyDeviceMetadata(mBuilderParcel);
diff --git a/nearby/framework/java/android/nearby/FastPairAntispoofKeyDeviceMetadata.java b/nearby/framework/java/android/nearby/FastPairAntispoofKeyDeviceMetadata.java
index 74831d5..1837671 100644
--- a/nearby/framework/java/android/nearby/FastPairAntispoofKeyDeviceMetadata.java
+++ b/nearby/framework/java/android/nearby/FastPairAntispoofKeyDeviceMetadata.java
@@ -17,6 +17,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.nearby.aidl.FastPairAntispoofKeyDeviceMetadataParcel;
/**
@@ -24,6 +25,7 @@
*
* @hide
*/
+@SystemApi
public class FastPairAntispoofKeyDeviceMetadata {
FastPairAntispoofKeyDeviceMetadataParcel mMetadataParcel;
@@ -37,6 +39,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public byte[] getAntispoofPublicKey() {
return this.mMetadataParcel.antispoofPublicKey;
@@ -47,6 +50,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public FastPairDeviceMetadata getFastPairDeviceMetadata() {
if (this.mMetadataParcel.deviceMetadata == null) {
@@ -60,6 +64,7 @@
*
* @hide
*/
+ @SystemApi
public static final class Builder {
private final FastPairAntispoofKeyDeviceMetadataParcel mBuilderParcel;
@@ -69,6 +74,7 @@
*
* @hide
*/
+ @SystemApi
public Builder() {
mBuilderParcel = new FastPairAntispoofKeyDeviceMetadataParcel();
mBuilderParcel.antispoofPublicKey = null;
@@ -82,6 +88,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setAntispoofPublicKey(@Nullable byte[] antispoofPublicKey) {
mBuilderParcel.antispoofPublicKey = antispoofPublicKey;
@@ -96,6 +103,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setFastPairDeviceMetadata(@Nullable FastPairDeviceMetadata metadata) {
if (metadata != null) {
@@ -111,6 +119,7 @@
*
* @hide
*/
+ @SystemApi
@NonNull
public FastPairAntispoofKeyDeviceMetadata build() {
return new FastPairAntispoofKeyDeviceMetadata(mBuilderParcel);
diff --git a/nearby/framework/java/android/nearby/FastPairDataProviderService.java b/nearby/framework/java/android/nearby/FastPairDataProviderService.java
index f1d5074..b6c840d 100644
--- a/nearby/framework/java/android/nearby/FastPairDataProviderService.java
+++ b/nearby/framework/java/android/nearby/FastPairDataProviderService.java
@@ -20,6 +20,7 @@
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.app.Service;
import android.content.Intent;
import android.nearby.aidl.ByteArrayParcel;
@@ -58,6 +59,7 @@
*
* @hide
*/
+@SystemApi
public abstract class FastPairDataProviderService extends Service {
/**
* The action the wrapping service should have in its intent filter to implement the
@@ -65,6 +67,7 @@
*
* @hide
*/
+ @SystemApi
public static final String ACTION_FAST_PAIR_DATA_PROVIDER =
"android.nearby.action.FAST_PAIR_DATA_PROVIDER";
@@ -73,6 +76,7 @@
*
* @hide
*/
+ @SystemApi
public static final int MANAGE_REQUEST_ADD = 0;
/**
@@ -80,6 +84,7 @@
*
* @hide
*/
+ @SystemApi
public static final int MANAGE_REQUEST_REMOVE = 1;
/**
@@ -96,6 +101,7 @@
*
* @hide
*/
+ @SystemApi
public static final int ERROR_CODE_BAD_REQUEST = 0;
/**
@@ -103,6 +109,7 @@
*
* @hide
*/
+ @SystemApi
public static final int ERROR_CODE_INTERNAL_ERROR = 1;
/**
@@ -123,6 +130,7 @@
* @param tag TAG for on device logging.
* @hide
*/
+ @SystemApi
public FastPairDataProviderService(@NonNull String tag) {
mBinder = new Service();
mTag = tag;
@@ -139,6 +147,7 @@
*
* @hide
*/
+ @SystemApi
public interface FastPairAntispoofKeyDeviceMetadataCallback {
/**
@@ -146,6 +155,7 @@
*
* @hide
*/
+ @SystemApi
void onFastPairAntispoofKeyDeviceMetadataReceived(
@NonNull FastPairAntispoofKeyDeviceMetadata metadata);
@@ -153,6 +163,7 @@
*
* @hide
*/
+ @SystemApi
void onError(@ErrorCode int code, @Nullable String message);
}
@@ -161,6 +172,7 @@
*
* @hide
*/
+ @SystemApi
public interface FastPairAccountDevicesMetadataCallback {
/**
@@ -168,6 +180,7 @@
*
* @hide
*/
+ @SystemApi
void onFastPairAccountDevicesMetadataReceived(
@NonNull Collection<FastPairAccountKeyDeviceMetadata> metadatas);
/**
@@ -175,6 +188,7 @@
*
* @hide
*/
+ @SystemApi
void onError(@ErrorCode int code, @Nullable String message);
}
@@ -183,6 +197,7 @@
*
* @hide
*/
+ @SystemApi
public interface FastPairEligibleAccountsCallback {
/**
@@ -190,6 +205,7 @@
*
* @hide
*/
+ @SystemApi
void onFastPairEligibleAccountsReceived(
@NonNull Collection<FastPairEligibleAccount> accounts);
/**
@@ -197,6 +213,7 @@
*
* @hide
*/
+ @SystemApi
void onError(@ErrorCode int code, @Nullable String message);
}
@@ -205,6 +222,7 @@
*
* @hide
*/
+ @SystemApi
public interface FastPairManageActionCallback {
/**
@@ -212,12 +230,14 @@
*
* @hide
*/
+ @SystemApi
void onSuccess();
/**
* Invoked in case of error.
*
* @hide
*/
+ @SystemApi
void onError(@ErrorCode int code, @Nullable String message);
}
@@ -227,6 +247,7 @@
*
* @hide
*/
+ @SystemApi
public abstract void onLoadFastPairAntispoofKeyDeviceMetadata(
@NonNull FastPairAntispoofKeyDeviceMetadataRequest request,
@NonNull FastPairAntispoofKeyDeviceMetadataCallback callback);
@@ -237,6 +258,7 @@
*
* @hide
*/
+ @SystemApi
public abstract void onLoadFastPairAccountDevicesMetadata(
@NonNull FastPairAccountDevicesMetadataRequest request,
@NonNull FastPairAccountDevicesMetadataCallback callback);
@@ -247,6 +269,7 @@
*
* @hide
*/
+ @SystemApi
public abstract void onLoadFastPairEligibleAccounts(
@NonNull FastPairEligibleAccountsRequest request,
@NonNull FastPairEligibleAccountsCallback callback);
@@ -256,6 +279,7 @@
*
* @hide
*/
+ @SystemApi
public abstract void onManageFastPairAccount(
@NonNull FastPairManageAccountRequest request,
@NonNull FastPairManageActionCallback callback);
@@ -265,6 +289,7 @@
*
* @hide
*/
+ @SystemApi
public abstract void onManageFastPairAccountDevice(
@NonNull FastPairManageAccountDeviceRequest request,
@NonNull FastPairManageActionCallback callback);
@@ -276,6 +301,7 @@
*
* @hide
*/
+ @SystemApi
public static class FastPairAntispoofKeyDeviceMetadataRequest {
private final FastPairAntispoofKeyDeviceMetadataRequestParcel mMetadataRequestParcel;
@@ -295,6 +321,7 @@
* time.
* @hide
*/
+ @SystemApi
public @NonNull byte[] getModelId() {
return this.mMetadataRequestParcel.modelId;
}
@@ -315,6 +342,7 @@
* needs to set account with a non-empty allow list.
* @hide
*/
+ @SystemApi
public static class FastPairAccountDevicesMetadataRequest {
private final FastPairAccountDevicesMetadataRequestParcel mMetadataRequestParcel;
@@ -330,6 +358,7 @@
* @return a FastPair account.
* @hide
*/
+ @SystemApi
public @NonNull Account getAccount() {
return this.mMetadataRequestParcel.account;
}
@@ -344,6 +373,7 @@
* @return allowlist of Fast Pair devices using a collection of deviceAccountKeys.
* @hide
*/
+ @SystemApi
public @NonNull Collection<byte[]> getDeviceAccountKeys() {
if (this.mMetadataRequestParcel.deviceAccountKeys == null) {
return new ArrayList<byte[]>(0);
@@ -363,6 +393,7 @@
*
* @hide
*/
+ @SystemApi
public static class FastPairEligibleAccountsRequest {
@SuppressWarnings("UnusedVariable")
private final FastPairEligibleAccountsRequestParcel mAccountsRequestParcel;
@@ -381,6 +412,7 @@
*
* @hide
*/
+ @SystemApi
public static class FastPairManageAccountRequest {
private final FastPairManageAccountRequestParcel mAccountRequestParcel;
@@ -395,6 +427,7 @@
*
* @hide
*/
+ @SystemApi
public @ManageRequestType int getRequestType() {
return this.mAccountRequestParcel.requestType;
}
@@ -403,6 +436,7 @@
*
* @hide
*/
+ @SystemApi
public @NonNull Account getAccount() {
return this.mAccountRequestParcel.account;
}
@@ -416,6 +450,7 @@
*
* @hide
*/
+ @SystemApi
public static class FastPairManageAccountDeviceRequest {
private final FastPairManageAccountDeviceRequestParcel mRequestParcel;
@@ -430,6 +465,7 @@
*
* @hide
*/
+ @SystemApi
public @ManageRequestType int getRequestType() {
return this.mRequestParcel.requestType;
}
@@ -438,6 +474,7 @@
*
* @hide
*/
+ @SystemApi
public @NonNull Account getAccount() {
return this.mRequestParcel.account;
}
@@ -446,6 +483,7 @@
*
* @hide
*/
+ @SystemApi
public @NonNull FastPairAccountKeyDeviceMetadata getAccountKeyDeviceMetadata() {
return new FastPairAccountKeyDeviceMetadata(
this.mRequestParcel.accountKeyDeviceMetadata);
diff --git a/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java b/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java
index 0e2e79d..04845c0 100644
--- a/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java
+++ b/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java
@@ -18,6 +18,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.nearby.aidl.FastPairDeviceMetadataParcel;
/**
@@ -25,6 +26,7 @@
*
* @hide
*/
+@SystemApi
public class FastPairDeviceMetadata {
FastPairDeviceMetadataParcel mMetadataParcel;
@@ -39,6 +41,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getImageUrl() {
return mMetadataParcel.imageUrl;
@@ -49,6 +52,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getIntentUri() {
return mMetadataParcel.intentUri;
@@ -60,6 +64,7 @@
*
* @hide
*/
+ @SystemApi
public int getBleTxPower() {
return mMetadataParcel.bleTxPower;
}
@@ -69,6 +74,7 @@
*
* @hide
*/
+ @SystemApi
public float getTriggerDistance() {
return mMetadataParcel.triggerDistance;
}
@@ -80,6 +86,7 @@
* @return Fast Pair device image in 32-bit PNG with dimensions of 512px by 512px.
* @hide
*/
+ @SystemApi
@Nullable
public byte[] getImage() {
return mMetadataParcel.image;
@@ -92,6 +99,7 @@
* TRUE_WIRELESS_HEADPHONES = 7;
* @hide
*/
+ @SystemApi
public int getDeviceType() {
return mMetadataParcel.deviceType;
}
@@ -101,6 +109,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getName() {
return mMetadataParcel.name;
@@ -111,6 +120,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getTrueWirelessImageUrlLeftBud() {
return mMetadataParcel.trueWirelessImageUrlLeftBud;
@@ -121,6 +131,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getTrueWirelessImageUrlRightBud() {
return mMetadataParcel.trueWirelessImageUrlRightBud;
@@ -131,6 +142,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getTrueWirelessImageUrlCase() {
return mMetadataParcel.trueWirelessImageUrlCase;
@@ -142,6 +154,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getInitialNotificationDescription() {
return mMetadataParcel.initialNotificationDescription;
@@ -153,6 +166,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getInitialNotificationDescriptionNoAccount() {
return mMetadataParcel.initialNotificationDescriptionNoAccount;
@@ -164,6 +178,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getOpenCompanionAppDescription() {
return mMetadataParcel.openCompanionAppDescription;
@@ -175,6 +190,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getUpdateCompanionAppDescription() {
return mMetadataParcel.updateCompanionAppDescription;
@@ -186,6 +202,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getDownloadCompanionAppDescription() {
return mMetadataParcel.downloadCompanionAppDescription;
@@ -206,6 +223,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getUnableToConnectDescription() {
return mMetadataParcel.unableToConnectDescription;
@@ -217,6 +235,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getInitialPairingDescription() {
return mMetadataParcel.initialPairingDescription;
@@ -228,6 +247,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getConnectSuccessCompanionAppInstalled() {
return mMetadataParcel.connectSuccessCompanionAppInstalled;
@@ -239,6 +259,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getConnectSuccessCompanionAppNotInstalled() {
return mMetadataParcel.connectSuccessCompanionAppNotInstalled;
@@ -250,6 +271,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getSubsequentPairingDescription() {
return mMetadataParcel.subsequentPairingDescription;
@@ -261,6 +283,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getRetroactivePairingDescription() {
return mMetadataParcel.retroactivePairingDescription;
@@ -272,6 +295,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getWaitLaunchCompanionAppDescription() {
return mMetadataParcel.waitLaunchCompanionAppDescription;
@@ -283,6 +307,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getFailConnectGoToSettingsDescription() {
return mMetadataParcel.failConnectGoToSettingsDescription;
@@ -293,6 +318,7 @@
*
* @hide
*/
+ @SystemApi
public static final class Builder {
private final FastPairDeviceMetadataParcel mBuilderParcel;
@@ -302,6 +328,7 @@
*
* @hide
*/
+ @SystemApi
public Builder() {
mBuilderParcel = new FastPairDeviceMetadataParcel();
mBuilderParcel.imageUrl = null;
@@ -337,6 +364,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setImageUrl(@Nullable String imageUrl) {
mBuilderParcel.imageUrl = imageUrl;
@@ -350,6 +378,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setIntentUri(@Nullable String intentUri) {
mBuilderParcel.intentUri = intentUri;
@@ -363,6 +392,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setName(@Nullable String name) {
mBuilderParcel.name = name;
@@ -376,6 +406,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setBleTxPower(int bleTxPower) {
mBuilderParcel.bleTxPower = bleTxPower;
@@ -389,6 +420,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setTriggerDistance(float triggerDistance) {
mBuilderParcel.triggerDistance = triggerDistance;
@@ -404,6 +436,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setImage(@Nullable byte[] image) {
mBuilderParcel.image = image;
@@ -417,6 +450,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setDeviceType(int deviceType) {
mBuilderParcel.deviceType = deviceType;
@@ -430,6 +464,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setTrueWirelessImageUrlLeftBud(
@Nullable String trueWirelessImageUrlLeftBud) {
@@ -444,6 +479,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setTrueWirelessImageUrlRightBud(
@Nullable String trueWirelessImageUrlRightBud) {
@@ -458,6 +494,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setTrueWirelessImageUrlCase(@Nullable String trueWirelessImageUrlCase) {
mBuilderParcel.trueWirelessImageUrlCase = trueWirelessImageUrlCase;
@@ -471,6 +508,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setInitialNotificationDescription(
@Nullable String initialNotificationDescription) {
@@ -486,6 +524,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setInitialNotificationDescriptionNoAccount(
@Nullable String initialNotificationDescriptionNoAccount) {
@@ -501,6 +540,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setOpenCompanionAppDescription(
@Nullable String openCompanionAppDescription) {
@@ -515,6 +555,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setUpdateCompanionAppDescription(
@Nullable String updateCompanionAppDescription) {
@@ -529,6 +570,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setDownloadCompanionAppDescription(
@Nullable String downloadCompanionAppDescription) {
@@ -543,6 +585,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setUnableToConnectTitle(@Nullable String unableToConnectTitle) {
mBuilderParcel.unableToConnectTitle = unableToConnectTitle;
@@ -557,6 +600,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setUnableToConnectDescription(
@Nullable String unableToConnectDescription) {
@@ -571,6 +615,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setInitialPairingDescription(@Nullable String initialPairingDescription) {
mBuilderParcel.initialPairingDescription = initialPairingDescription;
@@ -585,6 +630,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setConnectSuccessCompanionAppInstalled(
@Nullable String connectSuccessCompanionAppInstalled) {
@@ -601,6 +647,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setConnectSuccessCompanionAppNotInstalled(
@Nullable String connectSuccessCompanionAppNotInstalled) {
@@ -617,6 +664,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setSubsequentPairingDescription(
@Nullable String subsequentPairingDescription) {
@@ -631,6 +679,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setRetroactivePairingDescription(
@Nullable String retroactivePairingDescription) {
@@ -646,6 +695,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setWaitLaunchCompanionAppDescription(
@Nullable String waitLaunchCompanionAppDescription) {
@@ -662,6 +712,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setFailConnectGoToSettingsDescription(
@Nullable String failConnectGoToSettingsDescription) {
@@ -675,6 +726,7 @@
*
* @hide
*/
+ @SystemApi
@NonNull
public FastPairDeviceMetadata build() {
return new FastPairDeviceMetadata(mBuilderParcel);
diff --git a/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java b/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java
index d8dfe29..ce7413a 100644
--- a/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java
+++ b/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java
@@ -18,6 +18,7 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.nearby.aidl.FastPairDiscoveryItemParcel;
/**
@@ -25,6 +26,7 @@
*
* @hide
*/
+@SystemApi
public class FastPairDiscoveryItem {
FastPairDiscoveryItemParcel mMetadataParcel;
@@ -39,6 +41,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getId() {
return mMetadataParcel.id;
@@ -49,6 +52,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getMacAddress() {
return mMetadataParcel.macAddress;
@@ -59,6 +63,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getActionUrl() {
return mMetadataParcel.actionUrl;
@@ -69,6 +74,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getDeviceName() {
return mMetadataParcel.deviceName;
@@ -79,6 +85,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getTitle() {
return mMetadataParcel.title;
@@ -89,6 +96,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getDescription() {
return mMetadataParcel.description;
@@ -99,6 +107,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getDisplayUrl() {
return mMetadataParcel.displayUrl;
@@ -109,6 +118,7 @@
*
* @hide
*/
+ @SystemApi
public long getLastObservationTimestampMillis() {
return mMetadataParcel.lastObservationTimestampMillis;
}
@@ -118,6 +128,7 @@
*
* @hide
*/
+ @SystemApi
public long getFirstObservationTimestampMillis() {
return mMetadataParcel.firstObservationTimestampMillis;
}
@@ -127,6 +138,7 @@
*
* @hide
*/
+ @SystemApi
public int getState() {
return mMetadataParcel.state;
}
@@ -136,6 +148,7 @@
*
* @hide
*/
+ @SystemApi
public int getActionUrlType() {
return mMetadataParcel.actionUrlType;
}
@@ -145,6 +158,7 @@
*
* @hide
*/
+ @SystemApi
public int getRssi() {
return mMetadataParcel.rssi;
}
@@ -154,6 +168,7 @@
*
* @hide
*/
+ @SystemApi
public long getPendingAppInstallTimestampMillis() {
return mMetadataParcel.pendingAppInstallTimestampMillis;
}
@@ -163,6 +178,7 @@
*
* @hide
*/
+ @SystemApi
public int getTxPower() {
return mMetadataParcel.txPower;
}
@@ -172,6 +188,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getAppName() {
return mMetadataParcel.appName;
@@ -182,6 +199,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getPackageName() {
return mMetadataParcel.packageName;
@@ -192,6 +210,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getTriggerId() {
return mMetadataParcel.triggerId;
@@ -204,6 +223,7 @@
* @return IconPng in 32-bit PNG with dimensions of 512px by 512px.
* @hide
*/
+ @SystemApi
@Nullable
public byte[] getIconPng() {
return mMetadataParcel.iconPng;
@@ -214,6 +234,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public String getIconFfeUrl() {
return mMetadataParcel.iconFifeUrl;
@@ -226,6 +247,7 @@
* @return 64-byte authenticationPublicKeySecp256r1.
* @hide
*/
+ @SystemApi
@Nullable
public byte[] getAuthenticationPublicKeySecp256r1() {
return mMetadataParcel.authenticationPublicKeySecp256r1;
@@ -236,6 +258,7 @@
*
* @hide
*/
+ @SystemApi
public static final class Builder {
private final FastPairDiscoveryItemParcel mBuilderParcel;
@@ -245,6 +268,7 @@
*
* @hide
*/
+ @SystemApi
public Builder() {
mBuilderParcel = new FastPairDiscoveryItemParcel();
}
@@ -257,6 +281,7 @@
*
* @hide
*/
+ @SystemApi
@NonNull
public Builder setId(@Nullable String id) {
mBuilderParcel.id = id;
@@ -270,6 +295,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setMacAddress(@Nullable String macAddress) {
mBuilderParcel.macAddress = macAddress;
@@ -283,6 +309,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setActionUrl(@Nullable String actionUrl) {
mBuilderParcel.actionUrl = actionUrl;
@@ -295,6 +322,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setDeviceName(@Nullable String deviceName) {
mBuilderParcel.deviceName = deviceName;
@@ -308,6 +336,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setTitle(@Nullable String title) {
mBuilderParcel.title = title;
@@ -321,6 +350,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setDescription(@Nullable String description) {
mBuilderParcel.description = description;
@@ -334,6 +364,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setDisplayUrl(@Nullable String displayUrl) {
mBuilderParcel.displayUrl = displayUrl;
@@ -348,6 +379,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setLastObservationTimestampMillis(
long lastObservationTimestampMillis) {
@@ -363,6 +395,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setFirstObservationTimestampMillis(
long firstObservationTimestampMillis) {
@@ -377,6 +410,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setState(int state) {
mBuilderParcel.state = state;
@@ -390,6 +424,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setActionUrlType(int actionUrlType) {
mBuilderParcel.actionUrlType = actionUrlType;
@@ -403,6 +438,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setRssi(int rssi) {
mBuilderParcel.rssi = rssi;
@@ -417,6 +453,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setPendingAppInstallTimestampMillis(long pendingAppInstallTimestampMillis) {
mBuilderParcel.pendingAppInstallTimestampMillis = pendingAppInstallTimestampMillis;
@@ -430,6 +467,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setTxPower(int txPower) {
mBuilderParcel.txPower = txPower;
@@ -443,6 +481,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setAppName(@Nullable String appName) {
mBuilderParcel.appName = appName;
@@ -456,6 +495,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setPackageName(@Nullable String packageName) {
mBuilderParcel.packageName = packageName;
@@ -469,6 +509,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setTriggerId(@Nullable String triggerId) {
mBuilderParcel.triggerId = triggerId;
@@ -482,6 +523,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setIconPng(@Nullable byte[] iconPng) {
mBuilderParcel.iconPng = iconPng;
@@ -495,6 +537,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setIconFfeUrl(@Nullable String iconFifeUrl) {
mBuilderParcel.iconFifeUrl = iconFifeUrl;
@@ -509,6 +552,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setAuthenticationPublicKeySecp256r1(
@Nullable byte[] authenticationPublicKeySecp256r1) {
@@ -521,6 +565,7 @@
*
* @hide
*/
+ @SystemApi
@NonNull
public FastPairDiscoveryItem build() {
return new FastPairDiscoveryItem(mBuilderParcel);
diff --git a/nearby/framework/java/android/nearby/FastPairEligibleAccount.java b/nearby/framework/java/android/nearby/FastPairEligibleAccount.java
index 8be4cca..e6c3047 100644
--- a/nearby/framework/java/android/nearby/FastPairEligibleAccount.java
+++ b/nearby/framework/java/android/nearby/FastPairEligibleAccount.java
@@ -19,6 +19,7 @@
import android.accounts.Account;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.nearby.aidl.FastPairEligibleAccountParcel;
/**
@@ -26,6 +27,7 @@
*
* @hide
*/
+@SystemApi
public class FastPairEligibleAccount {
FastPairEligibleAccountParcel mAccountParcel;
@@ -39,6 +41,7 @@
*
* @hide
*/
+ @SystemApi
@Nullable
public Account getAccount() {
return this.mAccountParcel.account;
@@ -49,6 +52,7 @@
*
* @hide
*/
+ @SystemApi
public boolean isOptIn() {
return this.mAccountParcel.optIn;
}
@@ -58,6 +62,7 @@
*
* @hide
*/
+ @SystemApi
public static final class Builder {
private final FastPairEligibleAccountParcel mBuilderParcel;
@@ -67,6 +72,7 @@
*
* @hide
*/
+ @SystemApi
public Builder() {
mBuilderParcel = new FastPairEligibleAccountParcel();
mBuilderParcel.account = null;
@@ -80,6 +86,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setAccount(@Nullable Account account) {
mBuilderParcel.account = account;
@@ -93,6 +100,7 @@
* @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
* @hide
*/
+ @SystemApi
@NonNull
public Builder setOptIn(boolean optIn) {
mBuilderParcel.optIn = optIn;
@@ -104,6 +112,7 @@
*
* @hide
*/
+ @SystemApi
@NonNull
public FastPairEligibleAccount build() {
return new FastPairEligibleAccount(mBuilderParcel);
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairAntispoofKeyDeviceMetadataTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairAntispoofKeyDeviceMetadataTest.java
new file mode 100644
index 0000000..65c061b
--- /dev/null
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairAntispoofKeyDeviceMetadataTest.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nearby.cts;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.nearby.FastPairAntispoofKeyDeviceMetadata;
+import android.nearby.FastPairDeviceMetadata;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class FastPairAntispoofKeyDeviceMetadataTest {
+
+ private static final String ASSISTANT_SETUP_HALFSHEET = "ASSISTANT_SETUP_HALFSHEET";
+ private static final String ASSISTANT_SETUP_NOTIFICATION = "ASSISTANT_SETUP_NOTIFICATION";
+ private static final int BLE_TX_POWER = 5;
+ private static final String CONFIRM_PIN_DESCRIPTION = "CONFIRM_PIN_DESCRIPTION";
+ private static final String CONFIRM_PIN_TITLE = "CONFIRM_PIN_TITLE";
+ private static final String CONNECT_SUCCESS_COMPANION_APP_INSTALLED =
+ "CONNECT_SUCCESS_COMPANION_APP_INSTALLED";
+ private static final String CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED =
+ "CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED";
+ 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";
+ private static final String FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION =
+ "FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION";
+ private static final String FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION =
+ "FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION";
+ private static final byte[] IMAGE = new byte[] {7, 9};
+ private static final String IMAGE_URL = "IMAGE_URL";
+ private static final String INITIAL_NOTIFICATION_DESCRIPTION =
+ "INITIAL_NOTIFICATION_DESCRIPTION";
+ private static final String INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT =
+ "INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT";
+ private static final String INITIAL_PAIRING_DESCRIPTION = "INITIAL_PAIRING_DESCRIPTION";
+ private static final String INTENT_URI = "INTENT_URI";
+ private static final String LOCALE = "LOCALE";
+ private static final String OPEN_COMPANION_APP_DESCRIPTION = "OPEN_COMPANION_APP_DESCRIPTION";
+ private static final String RETRO_ACTIVE_PAIRING_DESCRIPTION =
+ "RETRO_ACTIVE_PAIRING_DESCRIPTION";
+ private static final String SUBSEQUENT_PAIRING_DESCRIPTION = "SUBSEQUENT_PAIRING_DESCRIPTION";
+ private static final String SYNC_CONTACT_DESCRPTION = "SYNC_CONTACT_DESCRPTION";
+ private static final String SYNC_CONTACTS_TITLE = "SYNC_CONTACTS_TITLE";
+ private static final String SYNC_SMS_DESCRIPTION = "SYNC_SMS_DESCRIPTION";
+ private static final String SYNC_SMS_TITLE = "SYNC_SMS_TITLE";
+ private static final float TRIGGER_DISTANCE = 111;
+ private static final String TRUE_WIRELESS_IMAGE_URL_CASE = "TRUE_WIRELESS_IMAGE_URL_CASE";
+ private static final String TRUE_WIRELESS_IMAGE_URL_LEFT_BUD =
+ "TRUE_WIRELESS_IMAGE_URL_LEFT_BUD";
+ private static final String TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD =
+ "TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD";
+ private static final String UNABLE_TO_CONNECT_DESCRIPTION = "UNABLE_TO_CONNECT_DESCRIPTION";
+ private static final String UNABLE_TO_CONNECT_TITLE = "UNABLE_TO_CONNECT_TITLE";
+ private static final String UPDATE_COMPANION_APP_DESCRIPTION =
+ "UPDATE_COMPANION_APP_DESCRIPTION";
+ private static final String WAIT_LAUNCH_COMPANION_APP_DESCRIPTION =
+ "WAIT_LAUNCH_COMPANION_APP_DESCRIPTION";
+ private static final byte[] ANTI_SPOOFING_KEY = new byte[] {4, 5, 6};
+ private static final String NAME = "NAME";
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testSetGetFastPairAntispoofKeyDeviceMetadataNotNull() {
+ FastPairDeviceMetadata fastPairDeviceMetadata = genFastPairDeviceMetadata();
+ FastPairAntispoofKeyDeviceMetadata fastPairAntispoofKeyDeviceMetadata =
+ genFastPairAntispoofKeyDeviceMetadata(ANTI_SPOOFING_KEY, fastPairDeviceMetadata);
+
+ assertThat(fastPairAntispoofKeyDeviceMetadata.getAntispoofPublicKey()).isEqualTo(
+ ANTI_SPOOFING_KEY);
+ ensureFastPairDeviceMetadataAsExpected(
+ fastPairAntispoofKeyDeviceMetadata.getFastPairDeviceMetadata());
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testSetGetFastPairAntispoofKeyDeviceMetadataNull() {
+ FastPairAntispoofKeyDeviceMetadata fastPairAntispoofKeyDeviceMetadata =
+ genFastPairAntispoofKeyDeviceMetadata(null, null);
+ assertThat(fastPairAntispoofKeyDeviceMetadata.getAntispoofPublicKey()).isEqualTo(
+ null);
+ assertThat(fastPairAntispoofKeyDeviceMetadata.getFastPairDeviceMetadata()).isEqualTo(
+ null);
+ }
+
+ /* Verifies DeviceMetadata. */
+ private static void ensureFastPairDeviceMetadataAsExpected(FastPairDeviceMetadata metadata) {
+ assertThat(metadata.getBleTxPower()).isEqualTo(BLE_TX_POWER);
+ 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.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.getName()).isEqualTo(NAME);
+ 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.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);
+ }
+
+ /* Generates FastPairAntispoofKeyDeviceMetadata. */
+ private static FastPairAntispoofKeyDeviceMetadata genFastPairAntispoofKeyDeviceMetadata(
+ byte[] antispoofPublicKey, FastPairDeviceMetadata deviceMetadata) {
+ FastPairAntispoofKeyDeviceMetadata.Builder builder =
+ new FastPairAntispoofKeyDeviceMetadata.Builder();
+ builder.setAntispoofPublicKey(antispoofPublicKey);
+ builder.setFastPairDeviceMetadata(deviceMetadata);
+
+ return builder.build();
+ }
+
+ /* Generates FastPairDeviceMetadata. */
+ private static FastPairDeviceMetadata genFastPairDeviceMetadata() {
+ FastPairDeviceMetadata.Builder builder = new FastPairDeviceMetadata.Builder();
+ builder.setBleTxPower(BLE_TX_POWER);
+ builder.setConnectSuccessCompanionAppInstalled(CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
+ builder.setConnectSuccessCompanionAppNotInstalled(
+ CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED);
+ builder.setDeviceType(DEVICE_TYPE);
+ builder.setDownloadCompanionAppDescription(DOWNLOAD_COMPANION_APP_DESCRIPTION);
+ builder.setFailConnectGoToSettingsDescription(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
+ builder.setImage(IMAGE);
+ builder.setImageUrl(IMAGE_URL);
+ builder.setInitialNotificationDescription(INITIAL_NOTIFICATION_DESCRIPTION);
+ builder.setInitialNotificationDescriptionNoAccount(
+ INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT);
+ builder.setInitialPairingDescription(INITIAL_PAIRING_DESCRIPTION);
+ builder.setIntentUri(INTENT_URI);
+ builder.setName(NAME);
+ builder.setOpenCompanionAppDescription(OPEN_COMPANION_APP_DESCRIPTION);
+ builder.setRetroactivePairingDescription(RETRO_ACTIVE_PAIRING_DESCRIPTION);
+ builder.setSubsequentPairingDescription(SUBSEQUENT_PAIRING_DESCRIPTION);
+ builder.setTriggerDistance(TRIGGER_DISTANCE);
+ builder.setTrueWirelessImageUrlCase(TRUE_WIRELESS_IMAGE_URL_CASE);
+ builder.setTrueWirelessImageUrlLeftBud(TRUE_WIRELESS_IMAGE_URL_LEFT_BUD);
+ builder.setTrueWirelessImageUrlRightBud(TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD);
+ builder.setUnableToConnectDescription(UNABLE_TO_CONNECT_DESCRIPTION);
+ builder.setUnableToConnectTitle(UNABLE_TO_CONNECT_TITLE);
+ builder.setUpdateCompanionAppDescription(UPDATE_COMPANION_APP_DESCRIPTION);
+ builder.setWaitLaunchCompanionAppDescription(WAIT_LAUNCH_COMPANION_APP_DESCRIPTION);
+
+ return builder.build();
+ }
+}
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderServiceTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderServiceTest.java
new file mode 100644
index 0000000..160da56
--- /dev/null
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderServiceTest.java
@@ -0,0 +1,994 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nearby.cts;
+
+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;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import android.accounts.Account;
+import android.content.Intent;
+import android.nearby.FastPairAccountKeyDeviceMetadata;
+import android.nearby.FastPairAntispoofKeyDeviceMetadata;
+import android.nearby.FastPairDataProviderService;
+import android.nearby.FastPairDeviceMetadata;
+import android.nearby.FastPairDiscoveryItem;
+import android.nearby.FastPairEligibleAccount;
+import android.nearby.aidl.ByteArrayParcel;
+import android.nearby.aidl.FastPairAccountDevicesMetadataRequestParcel;
+import android.nearby.aidl.FastPairAccountKeyDeviceMetadataParcel;
+import android.nearby.aidl.FastPairAntispoofKeyDeviceMetadataParcel;
+import android.nearby.aidl.FastPairAntispoofKeyDeviceMetadataRequestParcel;
+import android.nearby.aidl.FastPairDeviceMetadataParcel;
+import android.nearby.aidl.FastPairDiscoveryItemParcel;
+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 androidx.annotation.NonNull;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
+
+import com.google.common.collect.ImmutableList;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+
+@RunWith(AndroidJUnit4.class)
+public class FastPairDataProviderServiceTest {
+
+ private static final String TAG = "FastPairDataProviderServiceTest";
+
+ private static final String ASSISTANT_SETUP_HALFSHEET = "ASSISTANT_SETUP_HALFSHEET";
+ private static final String ASSISTANT_SETUP_NOTIFICATION = "ASSISTANT_SETUP_NOTIFICATION";
+ private static final int BLE_TX_POWER = 5;
+ private static final String CONFIRM_PIN_DESCRIPTION = "CONFIRM_PIN_DESCRIPTION";
+ private static final String CONFIRM_PIN_TITLE = "CONFIRM_PIN_TITLE";
+ private static final String CONNECT_SUCCESS_COMPANION_APP_INSTALLED =
+ "CONNECT_SUCCESS_COMPANION_APP_INSTALLED";
+ private static final String CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED =
+ "CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED";
+ 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";
+ private static final Account ELIGIBLE_ACCOUNT_1 = new Account("abc@google.com", "type1");
+ private static final boolean ELIGIBLE_ACCOUNT_1_OPT_IN = true;
+ private static final Account ELIGIBLE_ACCOUNT_2 = new Account("def@gmail.com", "type2");
+ private static final boolean ELIGIBLE_ACCOUNT_2_OPT_IN = false;
+ private static final Account MANAGE_ACCOUNT = new Account("ghi@gmail.com", "type3");
+ private static final Account ACCOUNTDEVICES_METADATA_ACCOUNT =
+ new Account("jk@gmail.com", "type4");
+ private static final int NUM_ACCOUNT_DEVICES = 2;
+
+ private static final int ERROR_CODE_BAD_REQUEST =
+ FastPairDataProviderService.ERROR_CODE_BAD_REQUEST;
+ private static final int MANAGE_ACCOUNT_REQUEST_TYPE =
+ FastPairDataProviderService.MANAGE_REQUEST_ADD;
+ private static final String ERROR_STRING = "ERROR_STRING";
+ private static final String FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION =
+ "FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION";
+ private static final String FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION =
+ "FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION";
+ private static final byte[] IMAGE = new byte[] {7, 9};
+ private static final String IMAGE_URL = "IMAGE_URL";
+ private static final String INITIAL_NOTIFICATION_DESCRIPTION =
+ "INITIAL_NOTIFICATION_DESCRIPTION";
+ private static final String INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT =
+ "INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT";
+ private static final String INITIAL_PAIRING_DESCRIPTION = "INITIAL_PAIRING_DESCRIPTION";
+ private static final String INTENT_URI = "INTENT_URI";
+ private static final String LOCALE = "LOCALE";
+ private static final String OPEN_COMPANION_APP_DESCRIPTION = "OPEN_COMPANION_APP_DESCRIPTION";
+ private static final String RETRO_ACTIVE_PAIRING_DESCRIPTION =
+ "RETRO_ACTIVE_PAIRING_DESCRIPTION";
+ private static final String SUBSEQUENT_PAIRING_DESCRIPTION = "SUBSEQUENT_PAIRING_DESCRIPTION";
+ private static final String SYNC_CONTACT_DESCRPTION = "SYNC_CONTACT_DESCRPTION";
+ private static final String SYNC_CONTACTS_TITLE = "SYNC_CONTACTS_TITLE";
+ private static final String SYNC_SMS_DESCRIPTION = "SYNC_SMS_DESCRIPTION";
+ private static final String SYNC_SMS_TITLE = "SYNC_SMS_TITLE";
+ private static final float TRIGGER_DISTANCE = 111;
+ private static final String TRUE_WIRELESS_IMAGE_URL_CASE = "TRUE_WIRELESS_IMAGE_URL_CASE";
+ private static final String TRUE_WIRELESS_IMAGE_URL_LEFT_BUD =
+ "TRUE_WIRELESS_IMAGE_URL_LEFT_BUD";
+ private static final String TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD =
+ "TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD";
+ private static final String UNABLE_TO_CONNECT_DESCRIPTION = "UNABLE_TO_CONNECT_DESCRIPTION";
+ private static final String UNABLE_TO_CONNECT_TITLE = "UNABLE_TO_CONNECT_TITLE";
+ private static final String UPDATE_COMPANION_APP_DESCRIPTION =
+ "UPDATE_COMPANION_APP_DESCRIPTION";
+ private static final String WAIT_LAUNCH_COMPANION_APP_DESCRIPTION =
+ "WAIT_LAUNCH_COMPANION_APP_DESCRIPTION";
+ private static final byte[] ACCOUNT_KEY = new byte[] {3};
+ private static final byte[] ACCOUNT_KEY_2 = new byte[] {9, 3};
+ private static final byte[] SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS = new byte[] {2, 8};
+ private static final byte[] REQUEST_MODEL_ID = new byte[] {1, 2, 3};
+ private static final byte[] ANTI_SPOOFING_KEY = new byte[] {4, 5, 6};
+ private static final String ACTION_URL = "ACTION_URL";
+ private static final int ACTION_URL_TYPE = 5;
+ private static final String APP_NAME = "APP_NAME";
+ private static final int ATTACHMENT_TYPE = 8;
+ private static final byte[] AUTHENTICATION_PUBLIC_KEY_SEC_P256R1 = new byte[] {5, 7};
+ private static final byte[] BLE_RECORD_BYTES = new byte[]{2, 4};
+ private static final int DEBUG_CATEGORY = 9;
+ private static final String DEBUG_MESSAGE = "DEBUG_MESSAGE";
+ private static final String DESCRIPTION = "DESCRIPTION";
+ private static final String DEVICE_NAME = "DEVICE_NAME";
+ private static final String DISPLAY_URL = "DISPLAY_URL";
+ private static final String ENTITY_ID = "ENTITY_ID";
+ private static final String FEATURE_GRAPHIC_URL = "FEATURE_GRAPHIC_URL";
+ private static final long FIRST_OBSERVATION_TIMESTAMP_MILLIS = 8393L;
+ private static final String GROUP_ID = "GROUP_ID";
+ private static final String ICON_FIFE_URL = "ICON_FIFE_URL";
+ private static final byte[] ICON_PNG = new byte[]{2, 5};
+ private static final String ID = "ID";
+ private static final long LAST_OBSERVATION_TIMESTAMP_MILLIS = 934234L;
+ private static final int LAST_USER_EXPERIENCE = 93;
+ private static final long LOST_MILLIS = 393284L;
+ private static final String MAC_ADDRESS = "MAC_ADDRESS";
+ private static final String NAME = "NAME";
+ private static final String PACKAGE_NAME = "PACKAGE_NAME";
+ private static final long PENDING_APP_INSTALL_TIMESTAMP_MILLIS = 832393L;
+ private static final int RSSI = 9;
+ private static final int STATE = 63;
+ private static final String TITLE = "TITLE";
+ private static final String TRIGGER_ID = "TRIGGER_ID";
+ private static final int TX_POWER = 62;
+ private static final int TYPE = 73;
+ private static final String BLE_ADDRESS = "BLE_ADDRESS";
+
+ private static final int ELIGIBLE_ACCOUNTS_NUM = 2;
+ private static final ImmutableList<FastPairEligibleAccount> ELIGIBLE_ACCOUNTS =
+ ImmutableList.of(
+ genHappyPathFastPairEligibleAccount(ELIGIBLE_ACCOUNT_1,
+ ELIGIBLE_ACCOUNT_1_OPT_IN),
+ genHappyPathFastPairEligibleAccount(ELIGIBLE_ACCOUNT_2,
+ ELIGIBLE_ACCOUNT_2_OPT_IN));
+ private static final int ACCOUNTKEY_DEVICE_NUM = 2;
+ private static final ImmutableList<FastPairAccountKeyDeviceMetadata>
+ FAST_PAIR_ACCOUNT_DEVICES_METADATA =
+ ImmutableList.of(
+ genHappyPathFastPairAccountkeyDeviceMetadata(),
+ genHappyPathFastPairAccountkeyDeviceMetadata());
+
+ private static final FastPairAntispoofKeyDeviceMetadataRequestParcel
+ FAST_PAIR_ANTI_SPOOF_KEY_DEVICE_METADATA_REQUEST_PARCEL =
+ genFastPairAntispoofKeyDeviceMetadataRequestParcel();
+ private static final FastPairAccountDevicesMetadataRequestParcel
+ FAST_PAIR_ACCOUNT_DEVICES_METADATA_REQUEST_PARCEL =
+ genFastPairAccountDevicesMetadataRequestParcel();
+ private static final FastPairEligibleAccountsRequestParcel
+ FAST_PAIR_ELIGIBLE_ACCOUNTS_REQUEST_PARCEL =
+ genFastPairEligibleAccountsRequestParcel();
+ private static final FastPairManageAccountRequestParcel
+ FAST_PAIR_MANAGE_ACCOUNT_REQUEST_PARCEL =
+ genFastPairManageAccountRequestParcel();
+ private static final FastPairManageAccountDeviceRequestParcel
+ FAST_PAIR_MANAGE_ACCOUNT_DEVICE_REQUEST_PARCEL =
+ genFastPairManageAccountDeviceRequestParcel();
+ private static final FastPairAntispoofKeyDeviceMetadata
+ HAPPY_PATH_FAST_PAIR_ANTI_SPOOF_KEY_DEVICE_METADATA =
+ genHappyPathFastPairAntispoofKeyDeviceMetadata();
+
+ @Captor private ArgumentCaptor<FastPairEligibleAccountParcel[]>
+ mFastPairEligibleAccountParcelsArgumentCaptor;
+ @Captor private ArgumentCaptor<FastPairAccountKeyDeviceMetadataParcel[]>
+ mFastPairAccountKeyDeviceMetadataParcelsArgumentCaptor;
+
+ @Mock private FastPairDataProviderService mMockFastPairDataProviderService;
+ @Mock private IFastPairAntispoofKeyDeviceMetadataCallback.Stub
+ mAntispoofKeyDeviceMetadataCallback;
+ @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;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+
+ mHappyPathFastPairDataProvider =
+ new MyHappyPathProvider(TAG, mMockFastPairDataProviderService);
+ mErrorPathFastPairDataProvider =
+ new MyErrorPathProvider(TAG, mMockFastPairDataProviderService);
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testHappyPathLoadFastPairAntispoofKeyDeviceMetadata() throws Exception {
+ // AOSP sends calls to OEM via Parcelable.
+ mHappyPathFastPairDataProvider.asProvider().loadFastPairAntispoofKeyDeviceMetadata(
+ FAST_PAIR_ANTI_SPOOF_KEY_DEVICE_METADATA_REQUEST_PARCEL,
+ mAntispoofKeyDeviceMetadataCallback);
+
+ // OEM receives request and verifies that it is as expected.
+ final ArgumentCaptor<FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataRequest>
+ fastPairAntispoofKeyDeviceMetadataRequestCaptor =
+ ArgumentCaptor.forClass(
+ FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataRequest.class
+ );
+ verify(mMockFastPairDataProviderService).onLoadFastPairAntispoofKeyDeviceMetadata(
+ fastPairAntispoofKeyDeviceMetadataRequestCaptor.capture(),
+ any(FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataCallback.class));
+ ensureHappyPathAsExpected(fastPairAntispoofKeyDeviceMetadataRequestCaptor.getValue());
+
+ // AOSP receives responses and verifies that it is as expected.
+ final ArgumentCaptor<FastPairAntispoofKeyDeviceMetadataParcel>
+ fastPairAntispoofKeyDeviceMetadataParcelCaptor =
+ ArgumentCaptor.forClass(FastPairAntispoofKeyDeviceMetadataParcel.class);
+ verify(mAntispoofKeyDeviceMetadataCallback).onFastPairAntispoofKeyDeviceMetadataReceived(
+ fastPairAntispoofKeyDeviceMetadataParcelCaptor.capture());
+ ensureHappyPathAsExpected(fastPairAntispoofKeyDeviceMetadataParcelCaptor.getValue());
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testHappyPathLoadFastPairAccountDevicesMetadata() throws Exception {
+ // AOSP sends calls to OEM via Parcelable.
+ mHappyPathFastPairDataProvider.asProvider().loadFastPairAccountDevicesMetadata(
+ FAST_PAIR_ACCOUNT_DEVICES_METADATA_REQUEST_PARCEL,
+ mAccountDevicesMetadataCallback);
+
+ // OEM receives request and verifies that it is as expected.
+ final ArgumentCaptor<FastPairDataProviderService.FastPairAccountDevicesMetadataRequest>
+ fastPairAccountDevicesMetadataRequestCaptor =
+ ArgumentCaptor.forClass(
+ FastPairDataProviderService.FastPairAccountDevicesMetadataRequest.class);
+ verify(mMockFastPairDataProviderService).onLoadFastPairAccountDevicesMetadata(
+ fastPairAccountDevicesMetadataRequestCaptor.capture(),
+ any(FastPairDataProviderService.FastPairAccountDevicesMetadataCallback.class));
+ ensureHappyPathAsExpected(fastPairAccountDevicesMetadataRequestCaptor.getValue());
+
+ // AOSP receives responses and verifies that it is as expected.
+ verify(mAccountDevicesMetadataCallback).onFastPairAccountDevicesMetadataReceived(
+ mFastPairAccountKeyDeviceMetadataParcelsArgumentCaptor.capture());
+ ensureHappyPathAsExpected(
+ mFastPairAccountKeyDeviceMetadataParcelsArgumentCaptor.getValue());
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testHappyPathLoadFastPairEligibleAccounts() throws Exception {
+ // AOSP sends calls to OEM via Parcelable.
+ mHappyPathFastPairDataProvider.asProvider().loadFastPairEligibleAccounts(
+ FAST_PAIR_ELIGIBLE_ACCOUNTS_REQUEST_PARCEL,
+ mEligibleAccountsCallback);
+
+ // OEM receives request and verifies that it is as expected.
+ final ArgumentCaptor<FastPairDataProviderService.FastPairEligibleAccountsRequest>
+ fastPairEligibleAccountsRequestCaptor =
+ ArgumentCaptor.forClass(
+ FastPairDataProviderService.FastPairEligibleAccountsRequest.class);
+ verify(mMockFastPairDataProviderService).onLoadFastPairEligibleAccounts(
+ fastPairEligibleAccountsRequestCaptor.capture(),
+ any(FastPairDataProviderService.FastPairEligibleAccountsCallback.class));
+ ensureHappyPathAsExpected(fastPairEligibleAccountsRequestCaptor.getValue());
+
+ // AOSP receives responses and verifies that it is as expected.
+ verify(mEligibleAccountsCallback).onFastPairEligibleAccountsReceived(
+ mFastPairEligibleAccountParcelsArgumentCaptor.capture());
+ ensureHappyPathAsExpected(mFastPairEligibleAccountParcelsArgumentCaptor.getValue());
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testHappyPathManageFastPairAccount() throws Exception {
+ // AOSP sends calls to OEM via Parcelable.
+ mHappyPathFastPairDataProvider.asProvider().manageFastPairAccount(
+ FAST_PAIR_MANAGE_ACCOUNT_REQUEST_PARCEL,
+ mManageAccountCallback);
+
+ // OEM receives request and verifies that it is as expected.
+ final ArgumentCaptor<FastPairDataProviderService.FastPairManageAccountRequest>
+ fastPairManageAccountRequestCaptor =
+ ArgumentCaptor.forClass(
+ FastPairDataProviderService.FastPairManageAccountRequest.class);
+ verify(mMockFastPairDataProviderService).onManageFastPairAccount(
+ fastPairManageAccountRequestCaptor.capture(),
+ any(FastPairDataProviderService.FastPairManageActionCallback.class));
+ ensureHappyPathAsExpected(fastPairManageAccountRequestCaptor.getValue());
+
+ // AOSP receives SUCCESS response.
+ verify(mManageAccountCallback).onSuccess();
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testHappyPathManageFastPairAccountDevice() throws Exception {
+ // AOSP sends calls to OEM via Parcelable.
+ mHappyPathFastPairDataProvider.asProvider().manageFastPairAccountDevice(
+ FAST_PAIR_MANAGE_ACCOUNT_DEVICE_REQUEST_PARCEL,
+ mManageAccountDeviceCallback);
+
+ // OEM receives request and verifies that it is as expected.
+ final ArgumentCaptor<FastPairDataProviderService.FastPairManageAccountDeviceRequest>
+ fastPairManageAccountDeviceRequestCaptor =
+ ArgumentCaptor.forClass(
+ FastPairDataProviderService.FastPairManageAccountDeviceRequest.class);
+ verify(mMockFastPairDataProviderService).onManageFastPairAccountDevice(
+ fastPairManageAccountDeviceRequestCaptor.capture(),
+ any(FastPairDataProviderService.FastPairManageActionCallback.class));
+ ensureHappyPathAsExpected(fastPairManageAccountDeviceRequestCaptor.getValue());
+
+ // AOSP receives SUCCESS response.
+ verify(mManageAccountDeviceCallback).onSuccess();
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testErrorPathLoadFastPairAntispoofKeyDeviceMetadata() throws Exception {
+ mErrorPathFastPairDataProvider.asProvider().loadFastPairAntispoofKeyDeviceMetadata(
+ FAST_PAIR_ANTI_SPOOF_KEY_DEVICE_METADATA_REQUEST_PARCEL,
+ mAntispoofKeyDeviceMetadataCallback);
+ verify(mMockFastPairDataProviderService).onLoadFastPairAntispoofKeyDeviceMetadata(
+ any(FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataRequest.class),
+ any(FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataCallback.class));
+ verify(mAntispoofKeyDeviceMetadataCallback).onError(
+ eq(ERROR_CODE_BAD_REQUEST), eq(ERROR_STRING));
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testErrorPathLoadFastPairAccountDevicesMetadata() throws Exception {
+ mErrorPathFastPairDataProvider.asProvider().loadFastPairAccountDevicesMetadata(
+ FAST_PAIR_ACCOUNT_DEVICES_METADATA_REQUEST_PARCEL,
+ mAccountDevicesMetadataCallback);
+ verify(mMockFastPairDataProviderService).onLoadFastPairAccountDevicesMetadata(
+ any(FastPairDataProviderService.FastPairAccountDevicesMetadataRequest.class),
+ any(FastPairDataProviderService.FastPairAccountDevicesMetadataCallback.class));
+ verify(mAccountDevicesMetadataCallback).onError(
+ eq(ERROR_CODE_BAD_REQUEST), eq(ERROR_STRING));
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testErrorPathLoadFastPairEligibleAccounts() throws Exception {
+ mErrorPathFastPairDataProvider.asProvider().loadFastPairEligibleAccounts(
+ FAST_PAIR_ELIGIBLE_ACCOUNTS_REQUEST_PARCEL,
+ mEligibleAccountsCallback);
+ verify(mMockFastPairDataProviderService).onLoadFastPairEligibleAccounts(
+ any(FastPairDataProviderService.FastPairEligibleAccountsRequest.class),
+ any(FastPairDataProviderService.FastPairEligibleAccountsCallback.class));
+ verify(mEligibleAccountsCallback).onError(
+ eq(ERROR_CODE_BAD_REQUEST), eq(ERROR_STRING));
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testErrorPathManageFastPairAccount() throws Exception {
+ mErrorPathFastPairDataProvider.asProvider().manageFastPairAccount(
+ FAST_PAIR_MANAGE_ACCOUNT_REQUEST_PARCEL,
+ mManageAccountCallback);
+ verify(mMockFastPairDataProviderService).onManageFastPairAccount(
+ any(FastPairDataProviderService.FastPairManageAccountRequest.class),
+ any(FastPairDataProviderService.FastPairManageActionCallback.class));
+ verify(mManageAccountCallback).onError(eq(ERROR_CODE_BAD_REQUEST), eq(ERROR_STRING));
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testErrorPathManageFastPairAccountDevice() throws Exception {
+ mErrorPathFastPairDataProvider.asProvider().manageFastPairAccountDevice(
+ FAST_PAIR_MANAGE_ACCOUNT_DEVICE_REQUEST_PARCEL,
+ mManageAccountDeviceCallback);
+ verify(mMockFastPairDataProviderService).onManageFastPairAccountDevice(
+ any(FastPairDataProviderService.FastPairManageAccountDeviceRequest.class),
+ any(FastPairDataProviderService.FastPairManageActionCallback.class));
+ verify(mManageAccountDeviceCallback).onError(eq(ERROR_CODE_BAD_REQUEST), eq(ERROR_STRING));
+ }
+
+ public static class MyHappyPathProvider extends FastPairDataProviderService {
+
+ private final FastPairDataProviderService mMockFastPairDataProviderService;
+
+ public MyHappyPathProvider(@NonNull String tag, FastPairDataProviderService mock) {
+ super(tag);
+ mMockFastPairDataProviderService = mock;
+ }
+
+ public IFastPairDataProvider asProvider() {
+ Intent intent = new Intent();
+ return IFastPairDataProvider.Stub.asInterface(onBind(intent));
+ }
+
+ @Override
+ public void onLoadFastPairAntispoofKeyDeviceMetadata(
+ @NonNull FastPairAntispoofKeyDeviceMetadataRequest request,
+ @NonNull FastPairAntispoofKeyDeviceMetadataCallback callback) {
+ mMockFastPairDataProviderService.onLoadFastPairAntispoofKeyDeviceMetadata(
+ request, callback);
+ callback.onFastPairAntispoofKeyDeviceMetadataReceived(
+ HAPPY_PATH_FAST_PAIR_ANTI_SPOOF_KEY_DEVICE_METADATA);
+ }
+
+ @Override
+ public void onLoadFastPairAccountDevicesMetadata(
+ @NonNull FastPairAccountDevicesMetadataRequest request,
+ @NonNull FastPairAccountDevicesMetadataCallback callback) {
+ mMockFastPairDataProviderService.onLoadFastPairAccountDevicesMetadata(
+ request, callback);
+ callback.onFastPairAccountDevicesMetadataReceived(FAST_PAIR_ACCOUNT_DEVICES_METADATA);
+ }
+
+ @Override
+ public void onLoadFastPairEligibleAccounts(
+ @NonNull FastPairEligibleAccountsRequest request,
+ @NonNull FastPairEligibleAccountsCallback callback) {
+ mMockFastPairDataProviderService.onLoadFastPairEligibleAccounts(
+ request, callback);
+ callback.onFastPairEligibleAccountsReceived(ELIGIBLE_ACCOUNTS);
+ }
+
+ @Override
+ public void onManageFastPairAccount(
+ @NonNull FastPairManageAccountRequest request,
+ @NonNull FastPairManageActionCallback callback) {
+ mMockFastPairDataProviderService.onManageFastPairAccount(request, callback);
+ callback.onSuccess();
+ }
+
+ @Override
+ public void onManageFastPairAccountDevice(
+ @NonNull FastPairManageAccountDeviceRequest request,
+ @NonNull FastPairManageActionCallback callback) {
+ mMockFastPairDataProviderService.onManageFastPairAccountDevice(request, callback);
+ callback.onSuccess();
+ }
+ }
+
+ public static class MyErrorPathProvider extends FastPairDataProviderService {
+
+ private final FastPairDataProviderService mMockFastPairDataProviderService;
+
+ public MyErrorPathProvider(@NonNull String tag, FastPairDataProviderService mock) {
+ super(tag);
+ mMockFastPairDataProviderService = mock;
+ }
+
+ public IFastPairDataProvider asProvider() {
+ Intent intent = new Intent();
+ return IFastPairDataProvider.Stub.asInterface(onBind(intent));
+ }
+
+ @Override
+ public void onLoadFastPairAntispoofKeyDeviceMetadata(
+ @NonNull FastPairAntispoofKeyDeviceMetadataRequest request,
+ @NonNull FastPairAntispoofKeyDeviceMetadataCallback callback) {
+ mMockFastPairDataProviderService.onLoadFastPairAntispoofKeyDeviceMetadata(
+ request, callback);
+ callback.onError(ERROR_CODE_BAD_REQUEST, ERROR_STRING);
+ }
+
+ @Override
+ public void onLoadFastPairAccountDevicesMetadata(
+ @NonNull FastPairAccountDevicesMetadataRequest request,
+ @NonNull FastPairAccountDevicesMetadataCallback callback) {
+ mMockFastPairDataProviderService.onLoadFastPairAccountDevicesMetadata(
+ request, callback);
+ callback.onError(ERROR_CODE_BAD_REQUEST, ERROR_STRING);
+ }
+
+ @Override
+ public void onLoadFastPairEligibleAccounts(
+ @NonNull FastPairEligibleAccountsRequest request,
+ @NonNull FastPairEligibleAccountsCallback callback) {
+ mMockFastPairDataProviderService.onLoadFastPairEligibleAccounts(request, callback);
+ callback.onError(ERROR_CODE_BAD_REQUEST, ERROR_STRING);
+ }
+
+ @Override
+ public void onManageFastPairAccount(
+ @NonNull FastPairManageAccountRequest request,
+ @NonNull FastPairManageActionCallback callback) {
+ mMockFastPairDataProviderService.onManageFastPairAccount(request, callback);
+ callback.onError(ERROR_CODE_BAD_REQUEST, ERROR_STRING);
+ }
+
+ @Override
+ public void onManageFastPairAccountDevice(
+ @NonNull FastPairManageAccountDeviceRequest request,
+ @NonNull FastPairManageActionCallback callback) {
+ mMockFastPairDataProviderService.onManageFastPairAccountDevice(request, callback);
+ callback.onError(ERROR_CODE_BAD_REQUEST, ERROR_STRING);
+ }
+ }
+
+ /* Generates AntispoofKeyDeviceMetadataRequestParcel. */
+ private static FastPairAntispoofKeyDeviceMetadataRequestParcel
+ genFastPairAntispoofKeyDeviceMetadataRequestParcel() {
+ FastPairAntispoofKeyDeviceMetadataRequestParcel requestParcel =
+ new FastPairAntispoofKeyDeviceMetadataRequestParcel();
+ requestParcel.modelId = REQUEST_MODEL_ID;
+
+ return requestParcel;
+ }
+
+ /* Generates AccountDevicesMetadataRequestParcel. */
+ private static FastPairAccountDevicesMetadataRequestParcel
+ genFastPairAccountDevicesMetadataRequestParcel() {
+ FastPairAccountDevicesMetadataRequestParcel requestParcel =
+ new FastPairAccountDevicesMetadataRequestParcel();
+
+ requestParcel.account = ACCOUNTDEVICES_METADATA_ACCOUNT;
+ requestParcel.deviceAccountKeys = new ByteArrayParcel[NUM_ACCOUNT_DEVICES];
+ requestParcel.deviceAccountKeys[0] = new ByteArrayParcel();
+ requestParcel.deviceAccountKeys[1] = new ByteArrayParcel();
+ requestParcel.deviceAccountKeys[0].byteArray = ACCOUNT_KEY;
+ requestParcel.deviceAccountKeys[1].byteArray = ACCOUNT_KEY_2;
+
+ return requestParcel;
+ }
+
+ /* Generates FastPairEligibleAccountsRequestParcel. */
+ private static FastPairEligibleAccountsRequestParcel
+ genFastPairEligibleAccountsRequestParcel() {
+ FastPairEligibleAccountsRequestParcel requestParcel =
+ new FastPairEligibleAccountsRequestParcel();
+ // No fields since FastPairEligibleAccountsRequestParcel is just a place holder now.
+ return requestParcel;
+ }
+
+ /* Generates FastPairManageAccountRequestParcel. */
+ private static FastPairManageAccountRequestParcel
+ genFastPairManageAccountRequestParcel() {
+ FastPairManageAccountRequestParcel requestParcel =
+ new FastPairManageAccountRequestParcel();
+ requestParcel.account = MANAGE_ACCOUNT;
+ requestParcel.requestType = MANAGE_ACCOUNT_REQUEST_TYPE;
+
+ return requestParcel;
+ }
+
+ /* Generates FastPairManageAccountDeviceRequestParcel. */
+ private static FastPairManageAccountDeviceRequestParcel
+ genFastPairManageAccountDeviceRequestParcel() {
+ FastPairManageAccountDeviceRequestParcel requestParcel =
+ new FastPairManageAccountDeviceRequestParcel();
+ requestParcel.account = MANAGE_ACCOUNT;
+ requestParcel.requestType = MANAGE_ACCOUNT_REQUEST_TYPE;
+ requestParcel.accountKeyDeviceMetadata =
+ genHappyPathFastPairAccountkeyDeviceMetadataParcel();
+
+ return requestParcel;
+ }
+
+ /* Generates Happy Path AntispoofKeyDeviceMetadata. */
+ private static FastPairAntispoofKeyDeviceMetadata
+ genHappyPathFastPairAntispoofKeyDeviceMetadata() {
+ FastPairAntispoofKeyDeviceMetadata.Builder builder =
+ new FastPairAntispoofKeyDeviceMetadata.Builder();
+ builder.setAntispoofPublicKey(ANTI_SPOOFING_KEY);
+ builder.setFastPairDeviceMetadata(genHappyPathFastPairDeviceMetadata());
+
+ return builder.build();
+ }
+
+ /* Generates Happy Path FastPairAccountKeyDeviceMetadata. */
+ private static FastPairAccountKeyDeviceMetadata
+ genHappyPathFastPairAccountkeyDeviceMetadata() {
+ FastPairAccountKeyDeviceMetadata.Builder builder =
+ new FastPairAccountKeyDeviceMetadata.Builder();
+ builder.setDeviceAccountKey(ACCOUNT_KEY);
+ builder.setFastPairDeviceMetadata(genHappyPathFastPairDeviceMetadata());
+ builder.setSha256DeviceAccountKeyPublicAddress(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS);
+ builder.setFastPairDiscoveryItem(genHappyPathFastPairDiscoveryItem());
+
+ return builder.build();
+ }
+
+ /* Generates Happy Path FastPairAccountKeyDeviceMetadataParcel. */
+ private static FastPairAccountKeyDeviceMetadataParcel
+ genHappyPathFastPairAccountkeyDeviceMetadataParcel() {
+ FastPairAccountKeyDeviceMetadataParcel parcel =
+ new FastPairAccountKeyDeviceMetadataParcel();
+ parcel.deviceAccountKey = ACCOUNT_KEY;
+ parcel.metadata = genHappyPathFastPairDeviceMetadataParcel();
+ parcel.sha256DeviceAccountKeyPublicAddress = SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS;
+ parcel.discoveryItem = genHappyPathFastPairDiscoveryItemParcel();
+
+ return parcel;
+ }
+
+ /* Generates Happy Path DiscoveryItem. */
+ private static FastPairDiscoveryItem genHappyPathFastPairDiscoveryItem() {
+ FastPairDiscoveryItem.Builder builder = new FastPairDiscoveryItem.Builder();
+
+ builder.setActionUrl(ACTION_URL);
+ builder.setActionUrlType(ACTION_URL_TYPE);
+ builder.setAppName(APP_NAME);
+ builder.setAuthenticationPublicKeySecp256r1(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
+ builder.setDescription(DESCRIPTION);
+ builder.setDeviceName(DEVICE_NAME);
+ builder.setDisplayUrl(DISPLAY_URL);
+ builder.setFirstObservationTimestampMillis(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
+ builder.setIconFfeUrl(ICON_FIFE_URL);
+ builder.setIconPng(ICON_PNG);
+ builder.setId(ID);
+ builder.setLastObservationTimestampMillis(LAST_OBSERVATION_TIMESTAMP_MILLIS);
+ builder.setMacAddress(MAC_ADDRESS);
+ builder.setPackageName(PACKAGE_NAME);
+ builder.setPendingAppInstallTimestampMillis(PENDING_APP_INSTALL_TIMESTAMP_MILLIS);
+ builder.setRssi(RSSI);
+ builder.setState(STATE);
+ builder.setTitle(TITLE);
+ builder.setTriggerId(TRIGGER_ID);
+ builder.setTxPower(TX_POWER);
+
+ return builder.build();
+ }
+
+ /* Generates Happy Path DiscoveryItemParcel. */
+ private static FastPairDiscoveryItemParcel genHappyPathFastPairDiscoveryItemParcel() {
+ FastPairDiscoveryItemParcel parcel = new FastPairDiscoveryItemParcel();
+
+ parcel.actionUrl = ACTION_URL;
+ parcel.actionUrlType = ACTION_URL_TYPE;
+ parcel.appName = APP_NAME;
+ parcel.authenticationPublicKeySecp256r1 = AUTHENTICATION_PUBLIC_KEY_SEC_P256R1;
+ parcel.description = DESCRIPTION;
+ parcel.deviceName = DEVICE_NAME;
+ parcel.displayUrl = DISPLAY_URL;
+ parcel.firstObservationTimestampMillis = FIRST_OBSERVATION_TIMESTAMP_MILLIS;
+ parcel.iconFifeUrl = ICON_FIFE_URL;
+ parcel.iconPng = ICON_PNG;
+ parcel.id = ID;
+ parcel.lastObservationTimestampMillis = LAST_OBSERVATION_TIMESTAMP_MILLIS;
+ parcel.macAddress = MAC_ADDRESS;
+ parcel.packageName = PACKAGE_NAME;
+ parcel.pendingAppInstallTimestampMillis = PENDING_APP_INSTALL_TIMESTAMP_MILLIS;
+ parcel.rssi = RSSI;
+ parcel.state = STATE;
+ parcel.title = TITLE;
+ parcel.triggerId = TRIGGER_ID;
+ parcel.txPower = TX_POWER;
+
+ return parcel;
+ }
+
+ /* Generates Happy Path DeviceMetadata. */
+ private static FastPairDeviceMetadata genHappyPathFastPairDeviceMetadata() {
+ FastPairDeviceMetadata.Builder builder = new FastPairDeviceMetadata.Builder();
+ builder.setBleTxPower(BLE_TX_POWER);
+ builder.setConnectSuccessCompanionAppInstalled(CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
+ builder.setConnectSuccessCompanionAppNotInstalled(
+ CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED);
+ builder.setDeviceType(DEVICE_TYPE);
+ builder.setDownloadCompanionAppDescription(DOWNLOAD_COMPANION_APP_DESCRIPTION);
+ builder.setFailConnectGoToSettingsDescription(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
+ builder.setImage(IMAGE);
+ builder.setImageUrl(IMAGE_URL);
+ builder.setInitialNotificationDescription(INITIAL_NOTIFICATION_DESCRIPTION);
+ builder.setInitialNotificationDescriptionNoAccount(
+ INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT);
+ builder.setInitialPairingDescription(INITIAL_PAIRING_DESCRIPTION);
+ builder.setIntentUri(INTENT_URI);
+ builder.setName(NAME);
+ builder.setOpenCompanionAppDescription(OPEN_COMPANION_APP_DESCRIPTION);
+ builder.setRetroactivePairingDescription(RETRO_ACTIVE_PAIRING_DESCRIPTION);
+ builder.setSubsequentPairingDescription(SUBSEQUENT_PAIRING_DESCRIPTION);
+ builder.setTriggerDistance(TRIGGER_DISTANCE);
+ builder.setTrueWirelessImageUrlCase(TRUE_WIRELESS_IMAGE_URL_CASE);
+ builder.setTrueWirelessImageUrlLeftBud(TRUE_WIRELESS_IMAGE_URL_LEFT_BUD);
+ builder.setTrueWirelessImageUrlRightBud(TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD);
+ builder.setUnableToConnectDescription(UNABLE_TO_CONNECT_DESCRIPTION);
+ builder.setUnableToConnectTitle(UNABLE_TO_CONNECT_TITLE);
+ builder.setUpdateCompanionAppDescription(UPDATE_COMPANION_APP_DESCRIPTION);
+ builder.setWaitLaunchCompanionAppDescription(WAIT_LAUNCH_COMPANION_APP_DESCRIPTION);
+
+ return builder.build();
+ }
+
+ /* Generates Happy Path DeviceMetadataParcel. */
+ private static FastPairDeviceMetadataParcel genHappyPathFastPairDeviceMetadataParcel() {
+ FastPairDeviceMetadataParcel parcel = new FastPairDeviceMetadataParcel();
+
+ parcel.bleTxPower = BLE_TX_POWER;
+ parcel.connectSuccessCompanionAppInstalled = CONNECT_SUCCESS_COMPANION_APP_INSTALLED;
+ parcel.connectSuccessCompanionAppNotInstalled =
+ CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED;
+ parcel.deviceType = DEVICE_TYPE;
+ parcel.downloadCompanionAppDescription = DOWNLOAD_COMPANION_APP_DESCRIPTION;
+ parcel.failConnectGoToSettingsDescription = FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION;
+ parcel.image = IMAGE;
+ parcel.imageUrl = IMAGE_URL;
+ parcel.initialNotificationDescription = INITIAL_NOTIFICATION_DESCRIPTION;
+ parcel.initialNotificationDescriptionNoAccount =
+ INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT;
+ parcel.initialPairingDescription = INITIAL_PAIRING_DESCRIPTION;
+ parcel.intentUri = INTENT_URI;
+ parcel.name = NAME;
+ parcel.openCompanionAppDescription = OPEN_COMPANION_APP_DESCRIPTION;
+ parcel.retroactivePairingDescription = RETRO_ACTIVE_PAIRING_DESCRIPTION;
+ parcel.subsequentPairingDescription = SUBSEQUENT_PAIRING_DESCRIPTION;
+ parcel.triggerDistance = TRIGGER_DISTANCE;
+ parcel.trueWirelessImageUrlCase = TRUE_WIRELESS_IMAGE_URL_CASE;
+ parcel.trueWirelessImageUrlLeftBud = TRUE_WIRELESS_IMAGE_URL_LEFT_BUD;
+ parcel.trueWirelessImageUrlRightBud = TRUE_WIRELESS_IMAGE_URL_RIGHT_BUD;
+ parcel.unableToConnectDescription = UNABLE_TO_CONNECT_DESCRIPTION;
+ parcel.unableToConnectTitle = UNABLE_TO_CONNECT_TITLE;
+ parcel.updateCompanionAppDescription = UPDATE_COMPANION_APP_DESCRIPTION;
+ parcel.waitLaunchCompanionAppDescription = WAIT_LAUNCH_COMPANION_APP_DESCRIPTION;
+
+ return parcel;
+ }
+
+ /* Generates Happy Path FastPairEligibleAccount. */
+ private static FastPairEligibleAccount genHappyPathFastPairEligibleAccount(
+ Account account, boolean optIn) {
+ FastPairEligibleAccount.Builder builder = new FastPairEligibleAccount.Builder();
+ builder.setAccount(account);
+ builder.setOptIn(optIn);
+
+ return builder.build();
+ }
+
+ /* Verifies Happy Path AntispoofKeyDeviceMetadataRequest. */
+ private static void ensureHappyPathAsExpected(
+ FastPairDataProviderService.FastPairAntispoofKeyDeviceMetadataRequest request) {
+ assertThat(request.getModelId()).isEqualTo(REQUEST_MODEL_ID);
+ }
+
+ /* Verifies Happy Path AccountDevicesMetadataRequest. */
+ private static void ensureHappyPathAsExpected(
+ FastPairDataProviderService.FastPairAccountDevicesMetadataRequest request) {
+ assertThat(request.getAccount()).isEqualTo(ACCOUNTDEVICES_METADATA_ACCOUNT);
+ assertThat(request.getDeviceAccountKeys().size()).isEqualTo(ACCOUNTKEY_DEVICE_NUM);
+ assertThat(request.getDeviceAccountKeys()).contains(ACCOUNT_KEY);
+ assertThat(request.getDeviceAccountKeys()).contains(ACCOUNT_KEY_2);
+ }
+
+ /* Verifies Happy Path FastPairEligibleAccountsRequest. */
+ @SuppressWarnings("UnusedVariable")
+ private static void ensureHappyPathAsExpected(
+ FastPairDataProviderService.FastPairEligibleAccountsRequest request) {
+ // No fields since FastPairEligibleAccountsRequest is just a place holder now.
+ }
+
+ /* Verifies Happy Path FastPairManageAccountRequest. */
+ private static void ensureHappyPathAsExpected(
+ FastPairDataProviderService.FastPairManageAccountRequest request) {
+ assertThat(request.getAccount()).isEqualTo(MANAGE_ACCOUNT);
+ assertThat(request.getRequestType()).isEqualTo(MANAGE_ACCOUNT_REQUEST_TYPE);
+ }
+
+ /* Verifies Happy Path FastPairManageAccountDeviceRequest. */
+ private static void ensureHappyPathAsExpected(
+ FastPairDataProviderService.FastPairManageAccountDeviceRequest request) {
+ assertThat(request.getAccount()).isEqualTo(MANAGE_ACCOUNT);
+ assertThat(request.getRequestType()).isEqualTo(MANAGE_ACCOUNT_REQUEST_TYPE);
+ ensureHappyPathAsExpected(request.getAccountKeyDeviceMetadata());
+ }
+
+ /* Verifies Happy Path AntispoofKeyDeviceMetadataParcel. */
+ private static void ensureHappyPathAsExpected(
+ FastPairAntispoofKeyDeviceMetadataParcel metadataParcel) {
+ assertThat(metadataParcel).isNotNull();
+ assertThat(metadataParcel.antispoofPublicKey).isEqualTo(ANTI_SPOOFING_KEY);
+ ensureHappyPathAsExpected(metadataParcel.deviceMetadata);
+ }
+
+ /* Verifies Happy Path FastPairAccountKeyDeviceMetadataParcel[]. */
+ private static void ensureHappyPathAsExpected(
+ FastPairAccountKeyDeviceMetadataParcel[] metadataParcels) {
+ assertThat(metadataParcels).isNotNull();
+ assertThat(metadataParcels).hasLength(ACCOUNTKEY_DEVICE_NUM);
+ for (FastPairAccountKeyDeviceMetadataParcel parcel: metadataParcels) {
+ ensureHappyPathAsExpected(parcel);
+ }
+ }
+
+ /* Verifies Happy Path FastPairAccountKeyDeviceMetadataParcel. */
+ private static void ensureHappyPathAsExpected(
+ FastPairAccountKeyDeviceMetadataParcel metadataParcel) {
+ assertThat(metadataParcel).isNotNull();
+ assertThat(metadataParcel.deviceAccountKey).isEqualTo(ACCOUNT_KEY);
+ assertThat(metadataParcel.sha256DeviceAccountKeyPublicAddress)
+ .isEqualTo(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS);
+ ensureHappyPathAsExpected(metadataParcel.metadata);
+ ensureHappyPathAsExpected(metadataParcel.discoveryItem);
+ }
+
+ /* Verifies Happy Path FastPairAccountKeyDeviceMetadata. */
+ private static void ensureHappyPathAsExpected(
+ FastPairAccountKeyDeviceMetadata metadata) {
+ assertThat(metadata.getDeviceAccountKey()).isEqualTo(ACCOUNT_KEY);
+ assertThat(metadata.getSha256DeviceAccountKeyPublicAddress())
+ .isEqualTo(SHA256_ACCOUNT_KEY_PUBLIC_ADDRESS);
+ ensureHappyPathAsExpected(metadata.getFastPairDeviceMetadata());
+ ensureHappyPathAsExpected(metadata.getFastPairDiscoveryItem());
+ }
+
+ /* Verifies Happy Path DeviceMetadataParcel. */
+ private static void ensureHappyPathAsExpected(FastPairDeviceMetadataParcel metadataParcel) {
+ assertThat(metadataParcel).isNotNull();
+ assertThat(metadataParcel.bleTxPower).isEqualTo(BLE_TX_POWER);
+
+ 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.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.name).isEqualTo(NAME);
+
+ 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.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) {
+ assertThat(metadata.getBleTxPower()).isEqualTo(BLE_TX_POWER);
+ 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.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.getName()).isEqualTo(NAME);
+ 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.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) {
+ assertThat(itemParcel.actionUrl).isEqualTo(ACTION_URL);
+ assertThat(itemParcel.actionUrlType).isEqualTo(ACTION_URL_TYPE);
+ assertThat(itemParcel.appName).isEqualTo(APP_NAME);
+ assertThat(itemParcel.authenticationPublicKeySecp256r1)
+ .isEqualTo(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
+ assertThat(itemParcel.description).isEqualTo(DESCRIPTION);
+ assertThat(itemParcel.deviceName).isEqualTo(DEVICE_NAME);
+ assertThat(itemParcel.displayUrl).isEqualTo(DISPLAY_URL);
+ assertThat(itemParcel.firstObservationTimestampMillis)
+ .isEqualTo(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
+ 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.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);
+ }
+
+ /* Verifies Happy Path FastPairDiscoveryItem. */
+ private static void ensureHappyPathAsExpected(FastPairDiscoveryItem item) {
+ assertThat(item.getActionUrl()).isEqualTo(ACTION_URL);
+ assertThat(item.getActionUrlType()).isEqualTo(ACTION_URL_TYPE);
+ assertThat(item.getAppName()).isEqualTo(APP_NAME);
+ assertThat(item.getAuthenticationPublicKeySecp256r1())
+ .isEqualTo(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
+ assertThat(item.getDescription()).isEqualTo(DESCRIPTION);
+ assertThat(item.getDeviceName()).isEqualTo(DEVICE_NAME);
+ assertThat(item.getDisplayUrl()).isEqualTo(DISPLAY_URL);
+ assertThat(item.getFirstObservationTimestampMillis())
+ .isEqualTo(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
+ 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.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);
+ }
+
+ /* Verifies Happy Path EligibleAccountParcel[]. */
+ private static void ensureHappyPathAsExpected(FastPairEligibleAccountParcel[] accountsParcel) {
+ assertThat(accountsParcel).hasLength(ELIGIBLE_ACCOUNTS_NUM);
+
+ 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/FastPairEligibleAccountTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairEligibleAccountTest.java
new file mode 100644
index 0000000..0d91d4e
--- /dev/null
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairEligibleAccountTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.nearby.cts;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.accounts.Account;
+import android.nearby.FastPairEligibleAccount;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class FastPairEligibleAccountTest {
+
+ private static final Account ACCOUNT = new Account("abc@google.com", "type1");
+ private static final Account ACCOUNT_NULL = null;
+
+ private static final boolean OPT_IN_TRUE = true;
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testSetGetFastPairEligibleAccountNotNull() {
+ FastPairEligibleAccount eligibleAccount =
+ genFastPairEligibleAccount(ACCOUNT, OPT_IN_TRUE);
+
+ assertThat(eligibleAccount.getAccount()).isEqualTo(ACCOUNT);
+ assertThat(eligibleAccount.isOptIn()).isEqualTo(OPT_IN_TRUE);
+ }
+
+ @Test
+ @SdkSuppress(minSdkVersion = 32, codeName = "T")
+ public void testSetGetFastPairEligibleAccountNull() {
+ FastPairEligibleAccount eligibleAccount =
+ genFastPairEligibleAccount(ACCOUNT_NULL, OPT_IN_TRUE);
+
+ assertThat(eligibleAccount.getAccount()).isEqualTo(ACCOUNT_NULL);
+ assertThat(eligibleAccount.isOptIn()).isEqualTo(OPT_IN_TRUE);
+ }
+
+ /* Generates FastPairEligibleAccount. */
+ private static FastPairEligibleAccount genFastPairEligibleAccount(
+ Account account, boolean optIn) {
+ FastPairEligibleAccount.Builder builder = new FastPairEligibleAccount.Builder();
+ builder.setAccount(account);
+ builder.setOptIn(optIn);
+
+ return builder.build();
+ }
+}