Merge "Add Fast Pair system apis including subsequent pairing."
diff --git a/nearby/framework/api/system-current.txt b/nearby/framework/api/system-current.txt
index 9d0d135..6666c8d 100644
--- a/nearby/framework/api/system-current.txt
+++ b/nearby/framework/api/system-current.txt
@@ -1,36 +1,240 @@
// Signature format: 2.0
package android.nearby {
+ public class FastPairAccountKeyDeviceMetadata {
+ method @Nullable public byte[] getAccountKey();
+ method @Nullable public android.nearby.FastPairDeviceMetadata getFastPairDeviceMetadata();
+ method @Nullable public android.nearby.FastPairDiscoveryItem getFastPairDiscoveryItem();
+ method @Nullable public byte[] getSha256AccountKeyPublicAddress();
+ }
+
+ public static final class FastPairAccountKeyDeviceMetadata.Builder {
+ ctor public FastPairAccountKeyDeviceMetadata.Builder();
+ method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata build();
+ method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata.Builder setAccountKey(@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 setSha256AccountKeyPublicAddress(@Nullable byte[]);
+ }
+
+ public class FastPairAntispoofkeyDeviceMetadata {
+ }
+
+ 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 FastPairDataProviderBase {
ctor public FastPairDataProviderBase(@NonNull String);
method @Nullable public final android.os.IBinder getBinder();
- method public abstract void onLoadFastPairDeviceMetadata(@NonNull android.nearby.FastPairDataProviderBase.FastPairDeviceMetadataRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairDeviceMetadataCallback);
+ method public abstract void onLoadFastPairAccountDevicesMetadata(@NonNull android.nearby.FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairAccountDevicesMetadataCallback);
+ method public abstract void onLoadFastPairAntispoofkeyDeviceMetadata(@NonNull android.nearby.FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataCallback);
+ method public abstract void onLoadFastPairEligibleAccounts(@NonNull android.nearby.FastPairDataProviderBase.FastPairEligibleAccountsRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairEligibleAccountsCallback);
+ method public abstract void onManageFastPairAccount(@NonNull android.nearby.FastPairDataProviderBase.FastPairManageAccountRequest, @NonNull android.nearby.FastPairDataProviderBase.FastPairManageActionCallback);
+ method public abstract void onManageFastPairAccountDevice(@NonNull android.nearby.FastPairDataProviderBase.FastPairManageAccountDeviceRequest, @NonNull android.nearby.FastPairDataProviderBase.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 class FastPairDataProviderBase.FastPairDeviceMetadata {
+ public static interface FastPairDataProviderBase.FastPairAccountDevicesMetadataCallback {
+ method public void onError(int, @Nullable String);
+ method public void onFastPairAccountDevicesMetadataReceived(@NonNull java.util.Collection<android.nearby.FastPairAccountKeyDeviceMetadata>);
}
- public static final class FastPairDataProviderBase.FastPairDeviceMetadata.Builder {
- ctor public FastPairDataProviderBase.FastPairDeviceMetadata.Builder();
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata build();
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setAntiSpoofPublicKey(@NonNull byte[]);
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setBleTxPower(int);
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setDeviceType(int);
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setImage(@NonNull byte[]);
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setImageUrl(@NonNull String);
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setIntentUri(@NonNull String);
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setTriggerDistance(float);
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setTrueWirelessImageUriLeftBud(@NonNull byte[]);
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setTrueWirelessImageUrlCase(@NonNull byte[]);
- method @NonNull public android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata.Builder setTrueWirelessImageUrlRightBud(@NonNull byte[]);
+ public static class FastPairDataProviderBase.FastPairAccountDevicesMetadataRequest {
+ method @NonNull public android.accounts.Account getAccount();
}
- public static interface FastPairDataProviderBase.FastPairDeviceMetadataCallback {
- method public void onFastPairDeviceMetadataReceived(@NonNull android.nearby.FastPairDataProviderBase.FastPairDeviceMetadata);
+ public static interface FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataCallback {
+ method public void onError(int, @Nullable String);
+ method public void onFastPairAntispoofkeyDeviceMetadataReceived(@NonNull android.nearby.FastPairAntispoofkeyDeviceMetadata);
}
- public static class FastPairDataProviderBase.FastPairDeviceMetadataRequest {
- method @Nullable public byte[] getModelId();
+ public static class FastPairDataProviderBase.FastPairAntispoofkeyDeviceMetadataRequest {
+ method @NonNull public byte[] getModelId();
+ }
+
+ public static interface FastPairDataProviderBase.FastPairEligibleAccountsCallback {
+ method public void onError(int, @Nullable String);
+ method public void onFastPairEligibleAccountsReceived(@NonNull java.util.Collection<android.nearby.FastPairEligibleAccount>);
+ }
+
+ public static class FastPairDataProviderBase.FastPairEligibleAccountsRequest {
+ }
+
+ public static class FastPairDataProviderBase.FastPairManageAccountDeviceRequest {
+ method @NonNull public android.accounts.Account getAccount();
+ method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata getAccountKeyDeviceMetadata();
+ method @Nullable public String getBleAddress();
+ method public int getRequestType();
+ }
+
+ public static class FastPairDataProviderBase.FastPairManageAccountRequest {
+ method @NonNull public android.accounts.Account getAccount();
+ method public int getRequestType();
+ }
+
+ public static interface FastPairDataProviderBase.FastPairManageActionCallback {
+ method public void onError(int, @Nullable String);
+ method public void onSuccess();
+ }
+
+ public class FastPairDeviceMetadata {
+ method @Nullable public String getAssistantSetupHalfSheet();
+ method @Nullable public String getAssistantSetupNotification();
+ method public int getBleTxPower();
+ method @Nullable public String getConfirmPinDescription();
+ method @Nullable public String getConfirmPinTitle();
+ 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 String getFastPairTvConnectDeviceNoAccountDescription();
+ 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 getLocale();
+ method @Nullable public String getOpenCompanionAppDescription();
+ method @Nullable public String getRetroactivePairingDescription();
+ method @Nullable public String getSubsequentPairingDescription();
+ method @Nullable public String getSyncContactsDescription();
+ method @Nullable public String getSyncContactsTitle();
+ method @Nullable public String getSyncSmsDescription();
+ method @Nullable public String getSyncSmsTitle();
+ 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 setAssistantSetupHalfSheet(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setAssistantSetupNotification(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setBleTxPower(int);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setConfirmPinDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setConfirmPinTitle(@Nullable String);
+ 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 setFastPairTvConnectDeviceNoAccountDescription(@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 setLocale(@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 setSyncContactsDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSyncContactsTitle(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSyncSmsDescription(@Nullable String);
+ method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSyncSmsTitle(@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 public int getAttachmentType();
+ method @Nullable public byte[] getAuthenticationPublicKeySecp256r1();
+ method @Nullable public byte[] getBleRecordBytes();
+ method public int getDebugCategory();
+ method @Nullable public String getDebugMessage();
+ method @Nullable public String getDescription();
+ method @Nullable public String getDeviceName();
+ method @Nullable public String getDisplayUrl();
+ method @Nullable public String getEntityId();
+ method @Nullable public String getFeatureGraphicUrl();
+ method public long getFirstObservationTimestampMillis();
+ method @Nullable public String getGroupId();
+ method @Nullable public String getIconFfeUrl();
+ method @Nullable public byte[] getIconPng();
+ method @Nullable public String getId();
+ method public long getLastObservationTimestampMillis();
+ method public int getLastUserExperience();
+ method public long getLostMillis();
+ 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();
+ method public int getType();
+ }
+
+ 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 setAttachmentType(int);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setAuthenticationPublicKeySecp256r1(@Nullable byte[]);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setBleRecordBytes(@Nullable byte[]);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDebugCategory(int);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setDebugMessage(@Nullable String);
+ 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 setEntityId(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setFeatureGraphicUrl(@Nullable String);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setFirstObservationTimestampMillis(long);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setGroupId(@Nullable String);
+ 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 setLastUserExperience(int);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setLostMillis(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);
+ method @NonNull public android.nearby.FastPairDiscoveryItem.Builder setType(int);
+ }
+
+ public class FastPairEligibleAccount {
+ }
+
+ 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 {
diff --git a/nearby/framework/java/android/nearby/FastPairAccountKeyDeviceMetadata.java b/nearby/framework/java/android/nearby/FastPairAccountKeyDeviceMetadata.java
new file mode 100644
index 0000000..c8a480e
--- /dev/null
+++ b/nearby/framework/java/android/nearby/FastPairAccountKeyDeviceMetadata.java
@@ -0,0 +1,153 @@
+/*
+ * 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;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.nearby.aidl.FastPairAccountKeyDeviceMetadataParcel;
+
+/**
+ * Class for metadata of a Fast Pair device associated with an account.
+ *
+ * @hide
+ */
+@SystemApi
+public class FastPairAccountKeyDeviceMetadata {
+
+ FastPairAccountKeyDeviceMetadataParcel mMetadataParcel;
+
+ FastPairAccountKeyDeviceMetadata(FastPairAccountKeyDeviceMetadataParcel metadataParcel) {
+ this.mMetadataParcel = metadataParcel;
+ }
+
+ /**
+ * Get Account Key, which uniquely identfies a Fast Pair device associated with an account.
+ */
+ @Nullable
+ public byte[] getAccountKey() {
+ return mMetadataParcel.accountKey;
+ }
+
+ /**
+ * Get a hash value of account key and public bluetooh address without revealing the public
+ * bluetooth address.
+ */
+ @Nullable
+ public byte[] getSha256AccountKeyPublicAddress() {
+ return mMetadataParcel.sha256AccountKeyPublicAddress;
+ }
+
+ /**
+ * Get metadata of a Fast Pair device type.
+ */
+ @Nullable
+ public FastPairDeviceMetadata getFastPairDeviceMetadata() {
+ if (mMetadataParcel.metadata == null) {
+ return null;
+ }
+ return new FastPairDeviceMetadata(mMetadataParcel.metadata);
+ }
+
+ /**
+ * Get Fast Pair discovery item, which is tied to both the device type and the account.
+ */
+ @Nullable
+ public FastPairDiscoveryItem getFastPairDiscoveryItem() {
+ if (mMetadataParcel.discoveryItem == null) {
+ return null;
+ }
+ return new FastPairDiscoveryItem(mMetadataParcel.discoveryItem);
+ }
+
+ /**
+ * Builder used to create FastPairAccountKeyDeviceMetadata.
+ */
+ public static final class Builder {
+
+ private final FastPairAccountKeyDeviceMetadataParcel mBuilderParcel;
+
+ /**
+ * Default constructor of Builder.
+ */
+ public Builder() {
+ mBuilderParcel = new FastPairAccountKeyDeviceMetadataParcel();
+ mBuilderParcel.accountKey = null;
+ mBuilderParcel.sha256AccountKeyPublicAddress = null;
+ mBuilderParcel.metadata = null;
+ mBuilderParcel.discoveryItem = null;
+ }
+
+ /**
+ * Set Account Key.
+ *
+ * @param accountKey Fast Pair device account key.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setAccountKey(@Nullable byte[] accountKey) {
+ mBuilderParcel.accountKey = accountKey;
+ return this;
+ }
+
+ /**
+ * Set sha256 account key and public address.
+ *
+ * @param sha256AccountKeyPublicAddress Hash value of account key and public address.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setSha256AccountKeyPublicAddress(
+ @Nullable byte[] sha256AccountKeyPublicAddress) {
+ mBuilderParcel.sha256AccountKeyPublicAddress = sha256AccountKeyPublicAddress;
+ return this;
+ }
+
+
+ /**
+ * Set Fast Pair metadata.
+ *
+ * @param metadata Fast Pair metadata.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setFastPairDeviceMetadata(@Nullable FastPairDeviceMetadata metadata) {
+ mBuilderParcel.metadata = metadata.mMetadataParcel;
+ return this;
+ }
+
+ /**
+ * Set Fast Pair discovery item.
+ *
+ * @param discoveryItem Fast Pair discovery item.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setFastPairDiscoveryItem(@Nullable FastPairDiscoveryItem discoveryItem) {
+ mBuilderParcel.discoveryItem = discoveryItem.mMetadataParcel;
+ return this;
+ }
+
+ /**
+ * Build {@link FastPairAccountKeyDeviceMetadata} with the currently set configuration.
+ */
+ @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
new file mode 100644
index 0000000..f756020
--- /dev/null
+++ b/nearby/framework/java/android/nearby/FastPairAntispoofkeyDeviceMetadata.java
@@ -0,0 +1,88 @@
+/*
+ * 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;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SuppressLint;
+import android.annotation.SystemApi;
+import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataParcel;
+
+/**
+ * Class for a type of registered Fast Pair device keyed by modelID, or antiSpoofKey.
+ * @hide
+ */
+@SystemApi
+public class FastPairAntispoofkeyDeviceMetadata {
+
+ FastPairAntispoofkeyDeviceMetadataParcel mMetadataParcel;
+ FastPairAntispoofkeyDeviceMetadata(
+ FastPairAntispoofkeyDeviceMetadataParcel metadataParcel) {
+ this.mMetadataParcel = metadataParcel;
+ }
+
+ /**
+ * Builder used to create FastPairAntisppofkeyDeviceMetadata.
+ */
+ public static final class Builder {
+
+ private final FastPairAntispoofkeyDeviceMetadataParcel mBuilderParcel;
+
+ /**
+ * Default constructor of Builder.
+ */
+ public Builder() {
+ mBuilderParcel = new FastPairAntispoofkeyDeviceMetadataParcel();
+ mBuilderParcel.antiSpoofPublicKey = null;
+ mBuilderParcel.deviceMetadata = null;
+ }
+
+ /**
+ * Set AntiSpoof public key, which uniquely identify a Fast Pair device type.
+ *
+ * @param antiSpoofPublicKey AntiSpoof public key.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @SuppressLint("MissingGetterMatchingBuilder")
+ @NonNull
+ public Builder setAntiSpoofPublicKey(@Nullable byte[] antiSpoofPublicKey) {
+ mBuilderParcel.antiSpoofPublicKey = antiSpoofPublicKey;
+ return this;
+ }
+
+ /**
+ * Set Fast Pair metadata, which is the property of a Fast Pair device type, including
+ * device images and strings.
+ *
+ * @param metadata Fast Pair device meta data.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @SuppressLint("MissingGetterMatchingBuilder")
+ @NonNull
+ public Builder setFastPairDeviceMetadata(@Nullable FastPairDeviceMetadata metadata) {
+ mBuilderParcel.deviceMetadata = metadata.mMetadataParcel;
+ return this;
+ }
+
+ /**
+ * Build {@link FastPairAntispoofkeyDeviceMetadata} with the currently set configuration.
+ */
+ @NonNull
+ public FastPairAntispoofkeyDeviceMetadata build() {
+ return new FastPairAntispoofkeyDeviceMetadata(mBuilderParcel);
+ }
+ }
+}
diff --git a/nearby/framework/java/android/nearby/FastPairDataProviderBase.java b/nearby/framework/java/android/nearby/FastPairDataProviderBase.java
index 36c3be0..81a5908 100644
--- a/nearby/framework/java/android/nearby/FastPairDataProviderBase.java
+++ b/nearby/framework/java/android/nearby/FastPairDataProviderBase.java
@@ -16,14 +16,32 @@
package android.nearby;
+import android.accounts.Account;
+import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.SuppressLint;
import android.annotation.SystemApi;
+import android.nearby.aidl.FastPairAccountDevicesMetadataRequestParcel;
+import android.nearby.aidl.FastPairAccountKeyDeviceMetadataParcel;
+import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataRequestParcel;
+import android.nearby.aidl.FastPairEligibleAccountParcel;
+import android.nearby.aidl.FastPairEligibleAccountsRequestParcel;
+import android.nearby.aidl.FastPairManageAccountDeviceRequestParcel;
+import android.nearby.aidl.FastPairManageAccountRequestParcel;
+import android.nearby.aidl.IFastPairAccountDevicesMetadataCallback;
+import android.nearby.aidl.IFastPairAntispoofkeyDeviceMetadataCallback;
+import android.nearby.aidl.IFastPairDataProvider;
+import android.nearby.aidl.IFastPairEligibleAccountsCallback;
+import android.nearby.aidl.IFastPairManageAccountCallback;
+import android.nearby.aidl.IFastPairManageAccountDeviceCallback;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Collection;
+
/**
* Base class for fast pair providers outside the system server.
*
@@ -38,33 +56,145 @@
*/
@SystemApi
public abstract class FastPairDataProviderBase {
+ /**
+ * The action the wrapping service should have in its intent filter to implement the
+ * {@link android.nearby.FastPairDataProviderBase}.
+ */
+ public static final String ACTION_FAST_PAIR_DATA_PROVIDER =
+ "android.nearby.action.FAST_PAIR_DATA_PROVIDER";
+
+ /**
+ * Manage request type to add, or opt-in.
+ */
+ public static final int MANAGE_REQUEST_ADD = 0;
+ /**
+ * Manage request type to remove, or opt-out.
+ */
+ public static final int MANAGE_REQUEST_REMOVE = 1;
+
+ /**
+ * @hide
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {
+ MANAGE_REQUEST_ADD,
+ MANAGE_REQUEST_REMOVE})
+ @interface ManageRequestType {}
+
+
+ public static final int ERROR_CODE_BAD_REQUEST = 0;
+ public static final int ERROR_CODE_INTERNAL_ERROR = 1;
+ /**
+ * @hide
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(value = {
+ ERROR_CODE_BAD_REQUEST,
+ ERROR_CODE_INTERNAL_ERROR})
+ @interface ErrorCode {}
private final IBinder mBinder;
private final String mTag;
+ /**
+ * Constructor of FastPairDataProviderBase.
+ *
+ * @param tag TAG for on device logging.
+ */
public FastPairDataProviderBase(@NonNull String tag) {
mBinder = new Service();
mTag = tag;
}
/**
- * Callback to be invoked when a device metadata is loaded.
+ * Callback to be invoked when an antispoofkeyed device metadata is loaded.
*/
- public interface FastPairDeviceMetadataCallback {
+ public interface FastPairAntispoofkeyDeviceMetadataCallback {
/**
- * Should be invoked once the meta data is loaded.
+ * Invoked once the meta data is loaded.
*/
- void onFastPairDeviceMetadataReceived(@NonNull FastPairDeviceMetadata metadata);
+ void onFastPairAntispoofkeyDeviceMetadataReceived(
+ @NonNull FastPairAntispoofkeyDeviceMetadata metadata);
+ /** Invoked in case of error. */
+ void onError(@ErrorCode int code, @Nullable String message);
}
/**
- * Fullfills the load device metadata request by using callback to send back the serialized
- * device meta data of the given modelId.
+ * Callback to be invoked when Fast Pair devices of a given account is loaded.
*/
- public abstract void onLoadFastPairDeviceMetadata(
- @NonNull FastPairDeviceMetadataRequest request,
- @NonNull FastPairDeviceMetadataCallback callback);
+ public interface FastPairAccountDevicesMetadataCallback {
+
+ /**
+ * Should be invoked once the metadatas are loaded.
+ */
+ void onFastPairAccountDevicesMetadataReceived(
+ @NonNull Collection<FastPairAccountKeyDeviceMetadata> metadatas);
+ /** Invoked in case of error. */
+ void onError(@ErrorCode int code, @Nullable String message);
+ }
+
+ /** Callback to be invoked when FastPair eligible accounts are loaded. */
+ public interface FastPairEligibleAccountsCallback {
+
+ /**
+ * Should be invoked once the eligible accounts are loaded.
+ */
+ void onFastPairEligibleAccountsReceived(
+ @NonNull Collection<FastPairEligibleAccount> accounts);
+ /** Invoked in case of error. */
+ void onError(@ErrorCode int code, @Nullable String message);
+ }
+
+ /**
+ * Callback to be invoked when a management action is finished.
+ */
+ public interface FastPairManageActionCallback {
+
+ /**
+ * Should be invoked once the manage action is successful.
+ */
+ void onSuccess();
+ /** Invoked in case of error. */
+ void onError(@ErrorCode int code, @Nullable String message);
+ }
+
+ /**
+ * Fulfills the Fast Pair device metadata request by using callback to send back the
+ * device meta data of a given modelId.
+ */
+ public abstract void onLoadFastPairAntispoofkeyDeviceMetadata(
+ @NonNull FastPairAntispoofkeyDeviceMetadataRequest request,
+ @NonNull FastPairAntispoofkeyDeviceMetadataCallback callback);
+
+ /**
+ * Fulfills the account tied Fast Pair devices metadata request by using callback to send back
+ * all Fast Pair device's metadata of a given account.
+ */
+ public abstract void onLoadFastPairAccountDevicesMetadata(
+ @NonNull FastPairAccountDevicesMetadataRequest request,
+ @NonNull FastPairAccountDevicesMetadataCallback callback);
+
+ /**
+ * Fulfills the Fast Pair eligible accounts request by using callback to send back Fast Pair
+ * eligible accounts */
+ public abstract void onLoadFastPairEligibleAccounts(
+ @NonNull FastPairEligibleAccountsRequest request,
+ @NonNull FastPairEligibleAccountsCallback callback);
+
+ /**
+ * Fulfills the Fast Pair account management request by using callback to send back result.
+ */
+ public abstract void onManageFastPairAccount(
+ @NonNull FastPairManageAccountRequest request,
+ @NonNull FastPairManageActionCallback callback);
+
+ /**
+ * Fulfills the request to manage device-account mapping by using callback to send back result.
+ */
+ public abstract void onManageFastPairAccountDevice(
+ @NonNull FastPairManageAccountDeviceRequest request,
+ @NonNull FastPairManageActionCallback callback);
/**
* Returns the IBinder instance that should be returned from the {@link
@@ -75,187 +205,304 @@
}
/**
- * Class for building FastPairDeviceMetadata.
+ * Class for reading FastPairAntispoofkeyDeviceMetadataRequest.
*/
- public static class FastPairDeviceMetadata {
+ public static class FastPairAntispoofkeyDeviceMetadataRequest {
- private FastPairDeviceMetadataParcel mMetadataParcel;
+ private final FastPairAntispoofkeyDeviceMetadataRequestParcel mMetadataRequestParcel;
- private FastPairDeviceMetadata(FastPairDeviceMetadataParcel metadataParcel) {
- this.mMetadataParcel = metadataParcel;
- }
-
- /**
- * Builder used to create FastPairDeviceMetadata.
- */
- public static final class Builder {
-
- private final FastPairDeviceMetadataParcel mBuilderParcel;
-
- /**
- * Default constructor of Builder.
- */
- public Builder() {
- mBuilderParcel = new FastPairDeviceMetadataParcel();
- mBuilderParcel.imageUrl = null;
- mBuilderParcel.intentUri = null;
- mBuilderParcel.antiSpoofPublicKey = null;
- mBuilderParcel.bleTxPower = 0;
- mBuilderParcel.triggerDistance = 0;
- mBuilderParcel.image = null;
- mBuilderParcel.deviceType = 0; // DEVICE_TYPE_UNSPECIFIED
- mBuilderParcel.trueWirelessImageUrlLeftBud = null;
- mBuilderParcel.trueWirelessImageUrlRightBud = null;
- mBuilderParcel.trueWirelessImageUrlCase = null;
- }
-
- /**
- * Set ImageUlr.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setImageUrl(@NonNull String imageUrl) {
- mBuilderParcel.imageUrl = imageUrl;
- return this;
- }
-
- /**
- * Set IntentUri.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setIntentUri(@NonNull String intentUri) {
- mBuilderParcel.intentUri = intentUri;
- return this;
- }
-
- /**
- * Set AntiSpoof public key.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setAntiSpoofPublicKey(@NonNull byte[] antiSpoofPublicKey) {
- mBuilderParcel.antiSpoofPublicKey = antiSpoofPublicKey;
- return this;
- }
-
- /**
- * Set ble transmission power.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setBleTxPower(int bleTxPower) {
- mBuilderParcel.bleTxPower = bleTxPower;
- return this;
- }
-
- /**
- * Set trigger distance.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setTriggerDistance(float triggerDistance) {
- mBuilderParcel.triggerDistance = triggerDistance;
- return this;
- }
-
- /**
- * Set image.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setImage(@NonNull byte[] image) {
- mBuilderParcel.image = image;
- return this;
- }
-
- /**
- * Set device type.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setDeviceType(int deviceType) {
- mBuilderParcel.deviceType = deviceType;
- return this;
- }
-
- /**
- * Set true wireless image url for left bud.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setTrueWirelessImageUriLeftBud(
- @NonNull byte[] trueWirelessImageUrlLeftBud) {
- mBuilderParcel.trueWirelessImageUrlLeftBud = trueWirelessImageUrlLeftBud;
- return this;
- }
-
- /**
- * Set true wireless image url for right bud.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setTrueWirelessImageUrlRightBud(
- @NonNull byte[] trueWirelessImageUrlRightBud) {
- mBuilderParcel.trueWirelessImageUrlRightBud = trueWirelessImageUrlRightBud;
- return this;
- }
-
- /**
- * Set true wireless image url for right bud.
- */
- @SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setTrueWirelessImageUrlCase(@NonNull byte[] trueWirelessImageUrlCase) {
- mBuilderParcel.trueWirelessImageUrlCase = trueWirelessImageUrlCase;
- return this;
- }
-
- /**
- * Build {@link FastPairDeviceMetadataRequest} with the currently set configuration.
- */
- @NonNull
- public FastPairDeviceMetadata build() {
- return new FastPairDeviceMetadata(mBuilderParcel);
- }
- }
- }
-
- /**
- * Class for reading FastPairDeviceMetadataRequest.
- */
- public static class FastPairDeviceMetadataRequest {
-
- private final FastPairDeviceMetadataRequestParcel mMetadataRequestParcel;
-
- private FastPairDeviceMetadataRequest(
- final FastPairDeviceMetadataRequestParcel metaDataRequestParcel) {
+ private FastPairAntispoofkeyDeviceMetadataRequest(
+ final FastPairAntispoofkeyDeviceMetadataRequestParcel metaDataRequestParcel) {
this.mMetadataRequestParcel = metaDataRequestParcel;
}
- public @Nullable byte[] getModelId() {
+ /** Get modelId, the key for FastPairAntispoofkeyDeviceMetadata. */
+ public @NonNull byte[] getModelId() {
return this.mMetadataRequestParcel.modelId;
}
}
/**
- * Call back class that sends back data.
+ * Class for reading FastPairAccountDevicesMetadataRequest.
*/
- private final class Callback implements FastPairDeviceMetadataCallback {
+ public static class FastPairAccountDevicesMetadataRequest {
- private IFastPairDataCallback mCallback;
+ private final FastPairAccountDevicesMetadataRequestParcel mMetadataRequestParcel;
- private Callback(IFastPairDataCallback callback) {
+ private FastPairAccountDevicesMetadataRequest(
+ final FastPairAccountDevicesMetadataRequestParcel metaDataRequestParcel) {
+ this.mMetadataRequestParcel = metaDataRequestParcel;
+ }
+ /** Get account. */
+ public @NonNull Account getAccount() {
+ return this.mMetadataRequestParcel.account;
+ }
+ }
+
+ /** Class for reading FastPairEligibleAccountsRequest. */
+ public static class FastPairEligibleAccountsRequest {
+ @SuppressWarnings("UnusedVariable")
+ private final FastPairEligibleAccountsRequestParcel mAccountsRequestParcel;
+
+ private FastPairEligibleAccountsRequest(
+ final FastPairEligibleAccountsRequestParcel accountsRequestParcel) {
+ this.mAccountsRequestParcel = accountsRequestParcel;
+ }
+ }
+
+ /** Class for reading FastPairManageAccountRequest. */
+ public static class FastPairManageAccountRequest {
+
+ private final FastPairManageAccountRequestParcel mAccountRequestParcel;
+
+ private FastPairManageAccountRequest(
+ final FastPairManageAccountRequestParcel accountRequestParcel) {
+ this.mAccountRequestParcel = accountRequestParcel;
+ }
+
+ /** Get request type: MANAGE_REQUEST_ADD, or MANAGE_REQUEST_REMOVE. */
+ public @ManageRequestType int getRequestType() {
+ return this.mAccountRequestParcel.requestType;
+ }
+ /** Get account. */
+ public @NonNull Account getAccount() {
+ return this.mAccountRequestParcel.account;
+ }
+ }
+
+ /** Class for reading FastPairManageAccountDeviceRequest. */
+ public static class FastPairManageAccountDeviceRequest {
+
+ private final FastPairManageAccountDeviceRequestParcel mRequestParcel;
+
+ private FastPairManageAccountDeviceRequest(
+ final FastPairManageAccountDeviceRequestParcel requestParcel) {
+ this.mRequestParcel = requestParcel;
+ }
+
+ /** Get request type: MANAGE_REQUEST_ADD, or MANAGE_REQUEST_REMOVE. */
+ public @ManageRequestType int getRequestType() {
+ return this.mRequestParcel.requestType;
+ }
+ /** Get account. */
+ public @NonNull Account getAccount() {
+ return this.mRequestParcel.account;
+ }
+ /** Get BleAddress. */
+ public @Nullable String getBleAddress() {
+ return this.mRequestParcel.bleAddress;
+ }
+ /** Get account key device metadata. */
+ public @NonNull FastPairAccountKeyDeviceMetadata getAccountKeyDeviceMetadata() {
+ return new FastPairAccountKeyDeviceMetadata(
+ this.mRequestParcel.accountKeyDeviceMetadata);
+ }
+ }
+
+ /**
+ * Callback class that sends back FastPairAntispoofkeyDeviceMetadata.
+ */
+ private final class WrapperFastPairAntispoofkeyDeviceMetadataCallback implements
+ FastPairAntispoofkeyDeviceMetadataCallback {
+
+ private IFastPairAntispoofkeyDeviceMetadataCallback mCallback;
+
+ private WrapperFastPairAntispoofkeyDeviceMetadataCallback(
+ IFastPairAntispoofkeyDeviceMetadataCallback callback) {
mCallback = callback;
}
/**
- * Sends back the serialized device meta data.
+ * Sends back FastPairAntispoofkeyDeviceMetadata.
*/
@Override
- public void onFastPairDeviceMetadataReceived(@NonNull FastPairDeviceMetadata metadata) {
+ public void onFastPairAntispoofkeyDeviceMetadataReceived(
+ @NonNull FastPairAntispoofkeyDeviceMetadata metadata) {
try {
- mCallback.onFastPairDeviceMetadataReceived(metadata.mMetadataParcel);
+ mCallback.onFastPairAntispoofkeyDeviceMetadataReceived(metadata.mMetadataParcel);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ } catch (RuntimeException e) {
+ Log.w(mTag, e);
+ }
+ }
+
+ @Override
+ public void onError(@ErrorCode int code, @Nullable String message) {
+ try {
+ mCallback.onError(code, message);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ } catch (RuntimeException e) {
+ Log.w(mTag, e);
+ }
+ }
+ }
+
+ /**
+ * Callback class that sends back collection of FastPairAccountKeyDeviceMetadata.
+ */
+ private final class WrapperFastPairAccountDevicesMetadataCallback implements
+ FastPairAccountDevicesMetadataCallback {
+
+ private IFastPairAccountDevicesMetadataCallback mCallback;
+
+ private WrapperFastPairAccountDevicesMetadataCallback(
+ IFastPairAccountDevicesMetadataCallback callback) {
+ mCallback = callback;
+ }
+
+ /**
+ * Sends back collection of FastPairAccountKeyDeviceMetadata.
+ */
+ @Override
+ public void onFastPairAccountDevicesMetadataReceived(
+ @NonNull Collection<FastPairAccountKeyDeviceMetadata> metadatas) {
+ FastPairAccountKeyDeviceMetadataParcel[] metadataParcels =
+ new FastPairAccountKeyDeviceMetadataParcel[metadatas.size()];
+ int i = 0;
+ for (FastPairAccountKeyDeviceMetadata metadata : metadatas) {
+ metadataParcels[i] = metadata.mMetadataParcel;
+ i = i + 1;
+ }
+ try {
+ mCallback.onFastPairAccountDevicesMetadataReceived(metadataParcels);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ } catch (RuntimeException e) {
+ Log.w(mTag, e);
+ }
+ }
+
+ @Override
+ public void onError(@ErrorCode int code, @Nullable String message) {
+ try {
+ mCallback.onError(code, message);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ } catch (RuntimeException e) {
+ Log.w(mTag, e);
+ }
+ }
+ }
+
+ /**
+ * Callback class that sends back eligible Fast Pair accounts.
+ */
+ private final class WrapperFastPairEligibleAccountsCallback implements
+ FastPairEligibleAccountsCallback {
+
+ private IFastPairEligibleAccountsCallback mCallback;
+
+ private WrapperFastPairEligibleAccountsCallback(
+ IFastPairEligibleAccountsCallback callback) {
+ mCallback = callback;
+ }
+
+ /**
+ * Sends back the eligble Fast Pair accounts.
+ */
+ @Override
+ public void onFastPairEligibleAccountsReceived(
+ @NonNull Collection<FastPairEligibleAccount> accounts) {
+ int i = 0;
+ FastPairEligibleAccountParcel[] accountParcels =
+ new FastPairEligibleAccountParcel[accounts.size()];
+ for (FastPairEligibleAccount account: accounts) {
+ accountParcels[i] = account.mAccountParcel;
+ i = i + 1;
+ }
+ try {
+ mCallback.onFastPairEligibleAccountsReceived(accountParcels);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ } catch (RuntimeException e) {
+ Log.w(mTag, e);
+ }
+ }
+
+ @Override
+ public void onError(@ErrorCode int code, @Nullable String message) {
+ try {
+ mCallback.onError(code, message);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ } catch (RuntimeException e) {
+ Log.w(mTag, e);
+ }
+ }
+ }
+
+ /**
+ * Callback class that sends back Fast Pair account management result.
+ */
+ private final class WrapperFastPairManageAccountCallback implements
+ FastPairManageActionCallback {
+
+ private IFastPairManageAccountCallback mCallback;
+
+ private WrapperFastPairManageAccountCallback(
+ IFastPairManageAccountCallback callback) {
+ mCallback = callback;
+ }
+
+ /**
+ * Sends back Fast Pair account opt in result.
+ */
+ @Override
+ public void onSuccess() {
+ try {
+ mCallback.onSuccess();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ } catch (RuntimeException e) {
+ Log.w(mTag, e);
+ }
+ }
+
+ @Override
+ public void onError(@ErrorCode int code, @Nullable String message) {
+ try {
+ mCallback.onError(code, message);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ } catch (RuntimeException e) {
+ Log.w(mTag, e);
+ }
+ }
+ }
+
+ /**
+ * Call back class that sends back account-device mapping management result.
+ */
+ private final class WrapperFastPairManageAccountDeviceCallback implements
+ FastPairManageActionCallback {
+
+ private IFastPairManageAccountDeviceCallback mCallback;
+
+ private WrapperFastPairManageAccountDeviceCallback(
+ IFastPairManageAccountDeviceCallback callback) {
+ mCallback = callback;
+ }
+
+ /**
+ * Sends back the account-device mapping management result.
+ */
+ @Override
+ public void onSuccess() {
+ try {
+ mCallback.onSuccess();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ } catch (RuntimeException e) {
+ Log.w(mTag, e);
+ }
+ }
+
+ @Override
+ public void onError(@ErrorCode int code, @Nullable String message) {
+ try {
+ mCallback.onError(code, message);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
} catch (RuntimeException e) {
@@ -270,11 +517,45 @@
}
@Override
- public void loadFastPairDeviceMetadata(
- @NonNull FastPairDeviceMetadataRequestParcel requestParcel,
- IFastPairDataCallback callback) {
- onLoadFastPairDeviceMetadata(new FastPairDeviceMetadataRequest(requestParcel),
- new Callback(callback));
+ public void loadFastPairAntispoofkeyDeviceMetadata(
+ @NonNull FastPairAntispoofkeyDeviceMetadataRequestParcel requestParcel,
+ IFastPairAntispoofkeyDeviceMetadataCallback callback) {
+ onLoadFastPairAntispoofkeyDeviceMetadata(
+ new FastPairAntispoofkeyDeviceMetadataRequest(requestParcel),
+ new WrapperFastPairAntispoofkeyDeviceMetadataCallback(callback));
+ }
+
+ @Override
+ public void loadFastPairAccountDevicesMetadata(
+ @NonNull FastPairAccountDevicesMetadataRequestParcel requestParcel,
+ IFastPairAccountDevicesMetadataCallback callback) {
+ onLoadFastPairAccountDevicesMetadata(
+ new FastPairAccountDevicesMetadataRequest(requestParcel),
+ new WrapperFastPairAccountDevicesMetadataCallback(callback));
+ }
+
+ @Override
+ public void loadFastPairEligibleAccounts(
+ @NonNull FastPairEligibleAccountsRequestParcel requestParcel,
+ IFastPairEligibleAccountsCallback callback) {
+ onLoadFastPairEligibleAccounts(new FastPairEligibleAccountsRequest(requestParcel),
+ new WrapperFastPairEligibleAccountsCallback(callback));
+ }
+
+ @Override
+ public void manageFastPairAccount(
+ @NonNull FastPairManageAccountRequestParcel requestParcel,
+ IFastPairManageAccountCallback callback) {
+ onManageFastPairAccount(new FastPairManageAccountRequest(requestParcel),
+ new WrapperFastPairManageAccountCallback(callback));
+ }
+
+ @Override
+ public void manageFastPairAccountDevice(
+ @NonNull FastPairManageAccountDeviceRequestParcel requestParcel,
+ IFastPairManageAccountDeviceCallback callback) {
+ onManageFastPairAccountDevice(new FastPairManageAccountDeviceRequest(requestParcel),
+ new WrapperFastPairManageAccountDeviceCallback(callback));
}
}
}
diff --git a/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java b/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java
new file mode 100644
index 0000000..e8043ca2
--- /dev/null
+++ b/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java
@@ -0,0 +1,786 @@
+/*
+ * 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;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.nearby.aidl.FastPairDeviceMetadataParcel;
+
+/**
+ * Class for the properties of a given type of Fast Pair device, including images and text.
+ *
+ * @hide
+ */
+@SystemApi
+public class FastPairDeviceMetadata {
+
+ FastPairDeviceMetadataParcel mMetadataParcel;
+
+ FastPairDeviceMetadata(
+ FastPairDeviceMetadataParcel metadataParcel) {
+ this.mMetadataParcel = metadataParcel;
+ }
+
+ /**
+ * Get ImageUlr.
+ */
+ @Nullable
+ public String getImageUrl() {
+ return mMetadataParcel.imageUrl;
+ }
+
+ /**
+ * Get IntentUri.
+ */
+ @Nullable
+ public String getIntentUri() {
+ return mMetadataParcel.intentUri;
+ }
+
+ /**
+ * Get ble transmission power.
+ */
+ public int getBleTxPower() {
+ return mMetadataParcel.bleTxPower;
+ }
+
+ /**
+ * Get trigger distance.
+ */
+ public float getTriggerDistance() {
+ return mMetadataParcel.triggerDistance;
+ }
+
+ /**
+ * Get image.
+ */
+ @Nullable
+ public byte[] getImage() {
+ return mMetadataParcel.image;
+ }
+
+ /**
+ * Get device type.
+ */
+ public int getDeviceType() {
+ return mMetadataParcel.deviceType;
+ }
+
+ /**
+ * Get true wireless image url for left bud.
+ */
+ @Nullable
+ public String getTrueWirelessImageUrlLeftBud() {
+ return mMetadataParcel.trueWirelessImageUrlLeftBud;
+ }
+
+ /**
+ * Get true wireless image url for right bud.
+ */
+ @Nullable
+ public String getTrueWirelessImageUrlRightBud() {
+ return mMetadataParcel.trueWirelessImageUrlRightBud;
+ }
+
+ /**
+ * Get true wireless image url for case.
+ */
+ @Nullable
+ public String getTrueWirelessImageUrlCase() {
+ return mMetadataParcel.trueWirelessImageUrlCase;
+ }
+
+ /**
+ * Get Locale.
+ */
+ @Nullable
+ public String getLocale() {
+ return mMetadataParcel.locale;
+ }
+
+ /**
+ * Get InitialNotificationDescription.
+ */
+ @Nullable
+ public String getInitialNotificationDescription() {
+ return mMetadataParcel.initialNotificationDescription;
+ }
+
+ /**
+ * Get InitialNotificationDescriptionNoAccount.
+ */
+ @Nullable
+ public String getInitialNotificationDescriptionNoAccount() {
+ return mMetadataParcel.initialNotificationDescriptionNoAccount;
+ }
+
+ /**
+ * Get OpenCompanionAppDescription.
+ */
+ @Nullable
+ public String getOpenCompanionAppDescription() {
+ return mMetadataParcel.openCompanionAppDescription;
+ }
+
+ /**
+ * Get UpdateCompanionAppDescription.
+ */
+ @Nullable
+ public String getUpdateCompanionAppDescription() {
+ return mMetadataParcel.updateCompanionAppDescription;
+ }
+
+ /**
+ * Get DownloadCompanionAppDescription.
+ */
+ @Nullable
+ public String getDownloadCompanionAppDescription() {
+ return mMetadataParcel.downloadCompanionAppDescription;
+ }
+
+ /**
+ * Get UnableToConnectTitle.
+ */
+ @Nullable
+ public String getUnableToConnectTitle() {
+ return mMetadataParcel.unableToConnectTitle;
+ }
+
+ /**
+ * Get UnableToConnectDescription.
+ */
+ @Nullable
+ public String getUnableToConnectDescription() {
+ return mMetadataParcel.unableToConnectDescription;
+ }
+
+ /**
+ * Get InitialPairingDescription.
+ */
+ @Nullable
+ public String getInitialPairingDescription() {
+ return mMetadataParcel.initialPairingDescription;
+ }
+
+ /**
+ * Get ConnectSuccessCompanionAppInstalled.
+ */
+ @Nullable
+ public String getConnectSuccessCompanionAppInstalled() {
+ return mMetadataParcel.connectSuccessCompanionAppInstalled;
+ }
+
+ /**
+ * Get ConnectSuccessCompanionAppNotInstalled.
+ */
+ @Nullable
+ public String getConnectSuccessCompanionAppNotInstalled() {
+ return mMetadataParcel.connectSuccessCompanionAppNotInstalled;
+ }
+
+ /**
+ * Get SubsequentPairingDescription.
+ */
+ @Nullable
+ public String getSubsequentPairingDescription() {
+ return mMetadataParcel.subsequentPairingDescription;
+ }
+
+ /**
+ * Get RetroactivePairingDescription.
+ */
+ @Nullable
+ public String getRetroactivePairingDescription() {
+ return mMetadataParcel.retroactivePairingDescription;
+ }
+
+ /**
+ * Get WaitLaunchCompanionAppDescription.
+ */
+ @Nullable
+ public String getWaitLaunchCompanionAppDescription() {
+ return mMetadataParcel.waitLaunchCompanionAppDescription;
+ }
+
+ /**
+ * Get FailConnectGoToSettingsDescription.
+ */
+ @Nullable
+ public String getFailConnectGoToSettingsDescription() {
+ return mMetadataParcel.failConnectGoToSettingsDescription;
+ }
+
+ /**
+ * Get ConfirmPinTitle.
+ */
+ @Nullable
+ public String getConfirmPinTitle() {
+ return mMetadataParcel.confirmPinTitle;
+ }
+
+ /**
+ * Get ConfirmPinDescription.
+ */
+ @Nullable
+ public String getConfirmPinDescription() {
+ return mMetadataParcel.confirmPinDescription;
+ }
+
+ /**
+ * Get SyncContactsTitle.
+ */
+ @Nullable
+ public String getSyncContactsTitle() {
+ return mMetadataParcel.syncContactsTitle;
+ }
+
+ /**
+ * Get SyncContactsDescription.
+ */
+ @Nullable
+ public String getSyncContactsDescription() {
+ return mMetadataParcel.syncContactsDescription;
+ }
+
+ /**
+ * Get SyncSmsTitle.
+ */
+ @Nullable
+ public String getSyncSmsTitle() {
+ return mMetadataParcel.syncSmsTitle;
+ }
+
+ /**
+ * Get SyncSmsDescription.
+ */
+ @Nullable
+ public String getSyncSmsDescription() {
+ return mMetadataParcel.syncSmsDescription;
+ }
+
+ /**
+ * Get AssistantSetupHalfSheet.
+ */
+ @Nullable
+ public String getAssistantSetupHalfSheet() {
+ return mMetadataParcel.assistantSetupHalfSheet;
+ }
+
+ /**
+ * Get AssistantSetupNotification.
+ */
+ @Nullable
+ public String getAssistantSetupNotification() {
+ return mMetadataParcel.assistantSetupNotification;
+ }
+
+ /**
+ * Get FastPairTvConnectDeviceNoAccountDescription.
+ */
+ @Nullable
+ public String getFastPairTvConnectDeviceNoAccountDescription() {
+ return mMetadataParcel.fastPairTvConnectDeviceNoAccountDescription;
+ }
+
+ /**
+ * Builder used to create FastPairDeviceMetadata.
+ */
+ public static final class Builder {
+
+ private final FastPairDeviceMetadataParcel mBuilderParcel;
+
+ /**
+ * Default constructor of Builder.
+ */
+ public Builder() {
+ mBuilderParcel = new FastPairDeviceMetadataParcel();
+ mBuilderParcel.imageUrl = null;
+ mBuilderParcel.intentUri = null;
+ mBuilderParcel.bleTxPower = 0;
+ mBuilderParcel.triggerDistance = 0;
+ mBuilderParcel.image = null;
+ mBuilderParcel.deviceType = 0; // DEVICE_TYPE_UNSPECIFIED
+ mBuilderParcel.trueWirelessImageUrlLeftBud = null;
+ mBuilderParcel.trueWirelessImageUrlRightBud = null;
+ mBuilderParcel.trueWirelessImageUrlCase = null;
+ mBuilderParcel.locale = null;
+ mBuilderParcel.initialNotificationDescription = null;
+ mBuilderParcel.initialNotificationDescriptionNoAccount = null;
+ mBuilderParcel.openCompanionAppDescription = null;
+ mBuilderParcel.updateCompanionAppDescription = null;
+ mBuilderParcel.downloadCompanionAppDescription = null;
+ mBuilderParcel.unableToConnectTitle = null;
+ mBuilderParcel.unableToConnectDescription = null;
+ mBuilderParcel.initialPairingDescription = null;
+ mBuilderParcel.connectSuccessCompanionAppInstalled = null;
+ mBuilderParcel.connectSuccessCompanionAppNotInstalled = null;
+ mBuilderParcel.subsequentPairingDescription = null;
+ mBuilderParcel.retroactivePairingDescription = null;
+ mBuilderParcel.waitLaunchCompanionAppDescription = null;
+ mBuilderParcel.failConnectGoToSettingsDescription = null;
+ mBuilderParcel.confirmPinTitle = null;
+ mBuilderParcel.confirmPinDescription = null;
+ mBuilderParcel.syncContactsTitle = null;
+ mBuilderParcel.syncContactsDescription = null;
+ mBuilderParcel.syncSmsTitle = null;
+ mBuilderParcel.syncSmsDescription = null;
+ mBuilderParcel.assistantSetupHalfSheet = null;
+ mBuilderParcel.assistantSetupNotification = null;
+ mBuilderParcel.fastPairTvConnectDeviceNoAccountDescription = null;
+ }
+
+ /**
+ * Set ImageUlr.
+ *
+ * @param imageUrl Image Ulr.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setImageUrl(@Nullable String imageUrl) {
+ mBuilderParcel.imageUrl = imageUrl;
+ return this;
+ }
+
+ /**
+ * Set IntentUri.
+ *
+ * @param intentUri Intent uri.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setIntentUri(@Nullable String intentUri) {
+ mBuilderParcel.intentUri = intentUri;
+ return this;
+ }
+
+ /**
+ * Set ble transmission power.
+ *
+ * @param bleTxPower Ble transimmision power.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+
+ */
+ @NonNull
+ public Builder setBleTxPower(int bleTxPower) {
+ mBuilderParcel.bleTxPower = bleTxPower;
+ return this;
+ }
+
+ /**
+ * Set trigger distance.
+ *
+ * @param triggerDistance Fast Pair trigger distance.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setTriggerDistance(float triggerDistance) {
+ mBuilderParcel.triggerDistance = triggerDistance;
+ return this;
+ }
+
+ /**
+ * Set image.
+ *
+ * @param image Fast Pair device image.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setImage(@Nullable byte[] image) {
+ mBuilderParcel.image = image;
+ return this;
+ }
+
+ /**
+ * Set device type.
+ *
+ * @param deviceType Fast Pair device type.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setDeviceType(int deviceType) {
+ mBuilderParcel.deviceType = deviceType;
+ return this;
+ }
+
+ /**
+ * Set true wireless image url for left bud.
+ *
+ * @param trueWirelessImageUrlLeftBud True wireless image url for left bud.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setTrueWirelessImageUrlLeftBud(
+ @Nullable String trueWirelessImageUrlLeftBud) {
+ mBuilderParcel.trueWirelessImageUrlLeftBud = trueWirelessImageUrlLeftBud;
+ return this;
+ }
+
+ /**
+ * Set true wireless image url for right bud.
+ *
+ * @param trueWirelessImageUrlRightBud True wireless image url for right bud.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setTrueWirelessImageUrlRightBud(
+ @Nullable String trueWirelessImageUrlRightBud) {
+ mBuilderParcel.trueWirelessImageUrlRightBud = trueWirelessImageUrlRightBud;
+ return this;
+ }
+
+ /**
+ * Set true wireless image url for case.
+ *
+ * @param trueWirelessImageUrlCase True wireless image url for case.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setTrueWirelessImageUrlCase(@Nullable String trueWirelessImageUrlCase) {
+ mBuilderParcel.trueWirelessImageUrlCase = trueWirelessImageUrlCase;
+ return this;
+ }
+
+ /**
+ * Set Locale.
+ *
+ * @param locale Device locale.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setLocale(@Nullable String locale) {
+ mBuilderParcel.locale = locale;
+ return this;
+ }
+
+ /**
+ * Set InitialNotificationDescription.
+ *
+ * @param initialNotificationDescription Initial notification description.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setInitialNotificationDescription(
+ @Nullable String initialNotificationDescription) {
+ mBuilderParcel.initialNotificationDescription = initialNotificationDescription;
+ return this;
+ }
+
+ /**
+ * Set InitialNotificationDescriptionNoAccount.
+ *
+ * @param initialNotificationDescriptionNoAccount Initial notification description when
+ * account is not present.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setInitialNotificationDescriptionNoAccount(
+ @Nullable String initialNotificationDescriptionNoAccount) {
+ mBuilderParcel.initialNotificationDescriptionNoAccount =
+ initialNotificationDescriptionNoAccount;
+ return this;
+ }
+
+ /**
+ * Set OpenCompanionAppDescription.
+ *
+ * @param openCompanionAppDescription Description for opening companion app.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setOpenCompanionAppDescription(
+ @Nullable String openCompanionAppDescription) {
+ mBuilderParcel.openCompanionAppDescription = openCompanionAppDescription;
+ return this;
+ }
+
+ /**
+ * Set UpdateCompanionAppDescription.
+ *
+ * @param updateCompanionAppDescription Description for updating companion app.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setUpdateCompanionAppDescription(
+ @Nullable String updateCompanionAppDescription) {
+ mBuilderParcel.updateCompanionAppDescription = updateCompanionAppDescription;
+ return this;
+ }
+
+ /**
+ * Set DownloadCompanionAppDescription.
+ *
+ * @param downloadCompanionAppDescription Description for downloading companion app.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setDownloadCompanionAppDescription(
+ @Nullable String downloadCompanionAppDescription) {
+ mBuilderParcel.downloadCompanionAppDescription = downloadCompanionAppDescription;
+ return this;
+ }
+
+ /**
+ * Set UnableToConnectTitle.
+ *
+ * @param unableToConnectTitle Title when Fast Pair device is unable to be connected to.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setUnableToConnectTitle(@Nullable String unableToConnectTitle) {
+ mBuilderParcel.unableToConnectTitle = unableToConnectTitle;
+ return this;
+ }
+
+ /**
+ * Set UnableToConnectDescription.
+ *
+ * @param unableToConnectDescription Description when Fast Pair device is uanble to be
+ * connected to.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setUnableToConnectDescription(
+ @Nullable String unableToConnectDescription) {
+ mBuilderParcel.unableToConnectDescription = unableToConnectDescription;
+ return this;
+ }
+
+ /**
+ * Set InitialPairingDescription.
+ *
+ * @param initialPairingDescription Description for Fast Pair initial pairing.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setInitialPairingDescription(@Nullable String initialPairingDescription) {
+ mBuilderParcel.initialPairingDescription = initialPairingDescription;
+ return this;
+ }
+
+ /**
+ * Set ConnectSuccessCompanionAppInstalled.
+ *
+ * @param connectSuccessCompanionAppInstalled Description that let user open the companion
+ * app.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setConnectSuccessCompanionAppInstalled(
+ @Nullable String connectSuccessCompanionAppInstalled) {
+ mBuilderParcel.connectSuccessCompanionAppInstalled =
+ connectSuccessCompanionAppInstalled;
+ return this;
+ }
+
+ /**
+ * Set ConnectSuccessCompanionAppNotInstalled.
+ *
+ * @param connectSuccessCompanionAppNotInstalled Description that let user download the
+ * companion app.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setConnectSuccessCompanionAppNotInstalled(
+ @Nullable String connectSuccessCompanionAppNotInstalled) {
+ mBuilderParcel.connectSuccessCompanionAppNotInstalled =
+ connectSuccessCompanionAppNotInstalled;
+ return this;
+ }
+
+ /**
+ * Set SubsequentPairingDescription.
+ *
+ * @param subsequentPairingDescription Description that reminds user there is a paired
+ * device nearby.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setSubsequentPairingDescription(
+ @Nullable String subsequentPairingDescription) {
+ mBuilderParcel.subsequentPairingDescription = subsequentPairingDescription;
+ return this;
+ }
+
+ /**
+ * Set RetroactivePairingDescription.
+ *
+ * @param retroactivePairingDescription Description that reminds users opt in their device.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setRetroactivePairingDescription(
+ @Nullable String retroactivePairingDescription) {
+ mBuilderParcel.retroactivePairingDescription = retroactivePairingDescription;
+ return this;
+ }
+
+ /**
+ * Set WaitLaunchCompanionAppDescription.
+ *
+ * @param waitLaunchCompanionAppDescription Description that indicates companion app is
+ * about to launch.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setWaitLaunchCompanionAppDescription(
+ @Nullable String waitLaunchCompanionAppDescription) {
+ mBuilderParcel.waitLaunchCompanionAppDescription =
+ waitLaunchCompanionAppDescription;
+ return this;
+ }
+
+ /**
+ * Set FailConnectGoToSettingsDescription.
+ *
+ * @param failConnectGoToSettingsDescription Description that indicates go to bluetooth
+ * settings when connection fail.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setFailConnectGoToSettingsDescription(
+ @Nullable String failConnectGoToSettingsDescription) {
+ mBuilderParcel.failConnectGoToSettingsDescription =
+ failConnectGoToSettingsDescription;
+ return this;
+ }
+
+ /**
+ * Set ConfirmPinTitle.
+ *
+ * @param confirmPinTitle Title of the UI to ask the user to confirm the pin code.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setConfirmPinTitle(@Nullable String confirmPinTitle) {
+ mBuilderParcel.confirmPinTitle = confirmPinTitle;
+ return this;
+ }
+
+ /**
+ * Set ConfirmPinDescription.
+ *
+ * @param confirmPinDescription Description of the UI to ask the user to confirm the pin
+ * code.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setConfirmPinDescription(@Nullable String confirmPinDescription) {
+ mBuilderParcel.confirmPinDescription = confirmPinDescription;
+ return this;
+ }
+
+ /**
+ * Set SyncContactsTitle.
+ *
+ * @param syncContactsTitle Title of the UI to ask the user to confirm to sync contacts.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setSyncContactsTitle(@Nullable String syncContactsTitle) {
+ mBuilderParcel.syncContactsTitle = syncContactsTitle;
+ return this;
+ }
+
+ /**
+ * Set SyncContactsDescription.
+ *
+ * @param syncContactsDescription Description of the UI to ask the user to confirm to sync
+ * contacts.
+ */
+ @NonNull
+ public Builder setSyncContactsDescription(@Nullable String syncContactsDescription) {
+ mBuilderParcel.syncContactsDescription = syncContactsDescription;
+ return this;
+ }
+
+ /**
+ * Set SyncSmsTitle.
+ *
+ * @param syncSmsTitle Title of the UI to ask the user to confirm to sync SMS.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setSyncSmsTitle(@Nullable String syncSmsTitle) {
+ mBuilderParcel.syncSmsTitle = syncSmsTitle;
+ return this;
+ }
+
+ /**
+ * Set SyncSmsDescription.
+ *
+ * @param syncSmsDescription Description of the UI to ask the user to confirm to sync SMS.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setSyncSmsDescription(@Nullable String syncSmsDescription) {
+ mBuilderParcel.syncSmsDescription = syncSmsDescription;
+ return this;
+ }
+
+ /**
+ * Set AssistantSetupHalfSheet.
+ *
+ * @param assistantSetupHalfSheet Description in half sheet to ask user setup google
+ * assistant.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setAssistantSetupHalfSheet(@Nullable String assistantSetupHalfSheet) {
+ mBuilderParcel.assistantSetupHalfSheet = assistantSetupHalfSheet;
+ return this;
+ }
+
+ /**
+ * Set AssistantSetupNotification.
+ *
+ * @param assistantSetupNotification Description in notification to ask user setup google
+ * assistant.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setAssistantSetupNotification(
+ @Nullable String assistantSetupNotification) {
+ mBuilderParcel.assistantSetupNotification = assistantSetupNotification;
+ return this;
+ }
+
+ /**
+ * Set FastPairTvConnectDeviceNoAccountDescription.
+ *
+ * @param fastPairTvConnectDeviceNoAccountDescription Description of the connect device
+ * action on TV, when user is not logged
+ * in.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setFastPairTvConnectDeviceNoAccountDescription(
+ @Nullable String fastPairTvConnectDeviceNoAccountDescription) {
+ mBuilderParcel.fastPairTvConnectDeviceNoAccountDescription =
+ fastPairTvConnectDeviceNoAccountDescription;
+ return this;
+ }
+
+ /**
+ * Build {@link FastPairDeviceMetadata} with the currently set configuration.
+ */
+ @NonNull
+ public FastPairDeviceMetadata build() {
+ return new FastPairDeviceMetadata(mBuilderParcel);
+ }
+ }
+}
diff --git a/nearby/framework/java/android/nearby/FastPairDeviceMetadataParcel.aidl b/nearby/framework/java/android/nearby/FastPairDeviceMetadataParcel.aidl
deleted file mode 100644
index 6fafa66..0000000
--- a/nearby/framework/java/android/nearby/FastPairDeviceMetadataParcel.aidl
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2020 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;
-
-/**
- * Configuration details for requesting tethering.
- * @hide
- */
-parcelable FastPairDeviceMetadataParcel {
-
- // The image to show on the notification.
- String imageUrl;
-
- // The intent that will be launched via the notification.
- String intentUri;
-
- // Anti spoof public key;
- byte[] antiSpoofPublicKey;
-
- // The transmit power of the device's BLE chip.
- int bleTxPower;
-
- // The distance that the device must be within to show a notification.
- // If no distance is set, we default to 0.6 meters. Only Nearby admins can
- // change this.
- float triggerDistance;
-
- // The image icon that shows in the notification.
- byte[] image;
-
- int deviceType;
-
- // The image for device with device type "true wireless".
- byte[] trueWirelessImageUrlLeftBud;
- byte[] trueWirelessImageUrlRightBud;
- byte[] trueWirelessImageUrlCase;
-}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java b/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java
new file mode 100644
index 0000000..bb06a75
--- /dev/null
+++ b/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java
@@ -0,0 +1,659 @@
+/*
+ * 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;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.nearby.aidl.FastPairDiscoveryItemParcel;
+
+/**
+ * Class for FastPairDiscoveryItem and its builder.
+ *
+ * @hide
+ */
+@SystemApi
+public class FastPairDiscoveryItem {
+
+ FastPairDiscoveryItemParcel mMetadataParcel;
+
+ FastPairDiscoveryItem(
+ FastPairDiscoveryItemParcel metadataParcel) {
+ this.mMetadataParcel = metadataParcel;
+ }
+
+ /**
+ * Get Id.
+ */
+ @Nullable
+ public String getId() {
+ return mMetadataParcel.id;
+ }
+
+ /**
+ * Get Type.
+ */
+ public int getType() {
+ return mMetadataParcel.type;
+ }
+
+ /**
+ * Get MacAddress.
+ */
+ @Nullable
+ public String getMacAddress() {
+ return mMetadataParcel.macAddress;
+ }
+
+ /**
+ * Get ActionUrl.
+ */
+ @Nullable
+ public String getActionUrl() {
+ return mMetadataParcel.actionUrl;
+ }
+
+ /**
+ * Get DeviceName.
+ */
+ @Nullable
+ public String getDeviceName() {
+ return mMetadataParcel.deviceName;
+ }
+
+ /**
+ * Get Title.
+ */
+ @Nullable
+ public String getTitle() {
+ return mMetadataParcel.title;
+ }
+
+ /**
+ * Get Description.
+ */
+ @Nullable
+ public String getDescription() {
+ return mMetadataParcel.description;
+ }
+
+ /**
+ * Get DisplayUrl.
+ */
+ @Nullable
+ public String getDisplayUrl() {
+ return mMetadataParcel.displayUrl;
+ }
+
+ /**
+ * Get LastObservationTimestampMillis.
+ */
+ public long getLastObservationTimestampMillis() {
+ return mMetadataParcel.lastObservationTimestampMillis;
+ }
+
+ /**
+ * Get FirstObservationTimestampMillis.
+ */
+ public long getFirstObservationTimestampMillis() {
+ return mMetadataParcel.firstObservationTimestampMillis;
+ }
+
+ /**
+ * Get State.
+ */
+ public int getState() {
+ return mMetadataParcel.state;
+ }
+
+ /**
+ * Get ActionUrlType.
+ */
+ public int getActionUrlType() {
+ return mMetadataParcel.actionUrlType;
+ }
+
+ /**
+ * Get Rssi.
+ */
+ public int getRssi() {
+ return mMetadataParcel.rssi;
+ }
+
+ /**
+ * Get PendingAppInstallTimestampMillis.
+ */
+ public long getPendingAppInstallTimestampMillis() {
+ return mMetadataParcel.pendingAppInstallTimestampMillis;
+ }
+
+ /**
+ * Get TxPower.
+ */
+ public int getTxPower() {
+ return mMetadataParcel.txPower;
+ }
+
+ /**
+ * Get AppName.
+ */
+ @Nullable
+ public String getAppName() {
+ return mMetadataParcel.appName;
+ }
+
+ /**
+ * Get GroupId.
+ */
+ @Nullable
+ public String getGroupId() {
+ return mMetadataParcel.groupId;
+ }
+
+ /**
+ * Get AttachmentType.
+ */
+ public int getAttachmentType() {
+ return mMetadataParcel.attachmentType;
+ }
+
+ /**
+ * Get PackageName.
+ */
+ @Nullable
+ public String getPackageName() {
+ return mMetadataParcel.packageName;
+ }
+
+ /**
+ * Get FeatureGraphicUrl.
+ */
+ @Nullable
+ public String getFeatureGraphicUrl() {
+ return mMetadataParcel.featureGraphicUrl;
+ }
+
+ /**
+ * Get TriggerId.
+ */
+ @Nullable
+ public String getTriggerId() {
+ return mMetadataParcel.triggerId;
+ }
+
+ /**
+ * Get IconPng.
+ */
+ @Nullable
+ public byte[] getIconPng() {
+ return mMetadataParcel.iconPng;
+ }
+
+ /**
+ * Get IconFifeUrl.
+ */
+ @Nullable
+ public String getIconFfeUrl() {
+ return mMetadataParcel.iconFifeUrl;
+ }
+
+ /**
+ * Get DebugMessage.
+ */
+ @Nullable
+ public String getDebugMessage() {
+ return mMetadataParcel.debugMessage;
+ }
+
+ /**
+ * Get DebugCategory.
+ */
+ public int getDebugCategory() {
+ return mMetadataParcel.debugCategory;
+ }
+
+ /**
+ * Get LostMillis.
+ */
+ public long getLostMillis() {
+ return mMetadataParcel.lostMillis;
+ }
+
+ /**
+ * Get LastUserExperience.
+ */
+ public int getLastUserExperience() {
+ return mMetadataParcel.lastUserExperience;
+ }
+
+ /**
+ * Get BleRecordBytes.
+ */
+ @Nullable
+ public byte[] getBleRecordBytes() {
+ return mMetadataParcel.bleRecordBytes;
+ }
+
+ /**
+ * Get EntityId.
+ */
+ @Nullable
+ public String getEntityId() {
+ return mMetadataParcel.entityId;
+ }
+
+ /**
+ * Get authenticationPublicKeySecp256r1.
+ */
+ @Nullable
+ public byte[] getAuthenticationPublicKeySecp256r1() {
+ return mMetadataParcel.authenticationPublicKeySecp256r1;
+ }
+
+ /**
+ * Builder used to create FastPairDiscoveryItem.
+ */
+ public static final class Builder {
+
+ private final FastPairDiscoveryItemParcel mBuilderParcel;
+
+ /**
+ * Default constructor of Builder.
+ */
+ public Builder() {
+ mBuilderParcel = new FastPairDiscoveryItemParcel();
+ }
+
+ /**
+ * Set Id.
+ *
+ * @param id Unique id.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setId(@Nullable String id) {
+ mBuilderParcel.id = id;
+ return this;
+ }
+
+ /**
+ * Set Nearby Type.
+ *
+ * @param type Nearby type.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setType(int type) {
+ mBuilderParcel.type = type;
+ return this;
+ }
+
+ /**
+ * Set MacAddress.
+ *
+ * @param macAddress Fast Pair device rotating mac address.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setMacAddress(@Nullable String macAddress) {
+ mBuilderParcel.macAddress = macAddress;
+ return this;
+ }
+
+ /**
+ * Set ActionUrl.
+ *
+ * @param actionUrl Action Url of Fast Pair device.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setActionUrl(@Nullable String actionUrl) {
+ mBuilderParcel.actionUrl = actionUrl;
+ return this;
+ }
+
+ /**
+ * Set DeviceName.
+ * @param deviceName Fast Pair device name.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setDeviceName(@Nullable String deviceName) {
+ mBuilderParcel.deviceName = deviceName;
+ return this;
+ }
+
+ /**
+ * Set Title.
+ *
+ * @param title Title of Fast Pair device.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setTitle(@Nullable String title) {
+ mBuilderParcel.title = title;
+ return this;
+ }
+
+ /**
+ * Set Description.
+ *
+ * @param description Description of Fast Pair device.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setDescription(@Nullable String description) {
+ mBuilderParcel.description = description;
+ return this;
+ }
+
+ /**
+ * Set DisplayUrl.
+ *
+ * @param displayUrl Display Url of Fast Pair device.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setDisplayUrl(@Nullable String displayUrl) {
+ mBuilderParcel.displayUrl = displayUrl;
+ return this;
+ }
+
+ /**
+ * Set LastObservationTimestampMillis.
+ *
+ * @param lastObservationTimestampMillis Last observed timestamp of Fast Pair device, keyed
+ * by a rotating id.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setLastObservationTimestampMillis(
+ long lastObservationTimestampMillis) {
+ mBuilderParcel.lastObservationTimestampMillis = lastObservationTimestampMillis;
+ return this;
+ }
+
+ /**
+ * Set FirstObservationTimestampMillis.
+ *
+ * @param firstObservationTimestampMillis First observed timestamp of Fast Pair device,
+ * keyed by a rotating id.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setFirstObservationTimestampMillis(
+ long firstObservationTimestampMillis) {
+ mBuilderParcel.firstObservationTimestampMillis = firstObservationTimestampMillis;
+ return this;
+ }
+
+ /**
+ * Set State.
+ *
+ * @param state Item's current state. e.g. if the item is blocked.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setState(int state) {
+ mBuilderParcel.state = state;
+ return this;
+ }
+
+ /**
+ * Set ActionUrlType.
+ *
+ * @param actionUrlType The resolved url type for the action_url.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setActionUrlType(int actionUrlType) {
+ mBuilderParcel.actionUrlType = actionUrlType;
+ return this;
+ }
+
+ /**
+ * Set Rssi.
+ *
+ * @param rssi Beacon's RSSI value.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setRssi(int rssi) {
+ mBuilderParcel.rssi = rssi;
+ return this;
+ }
+
+ /**
+ * Set PendingAppInstallTimestampMillis.
+ *
+ * @param pendingAppInstallTimestampMillis The timestamp when the user is redirected to App
+ * Store after clicking on the item.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setPendingAppInstallTimestampMillis(long pendingAppInstallTimestampMillis) {
+ mBuilderParcel.pendingAppInstallTimestampMillis = pendingAppInstallTimestampMillis;
+ return this;
+ }
+
+ /**
+ * Set TxPower.
+ *
+ * @param txPower Beacon's tx power.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setTxPower(int txPower) {
+ mBuilderParcel.txPower = txPower;
+ return this;
+ }
+
+ /**
+ * Set AppName.
+ *
+ * @param appName Human readable name of the app designated to open the uri.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setAppName(@Nullable String appName) {
+ mBuilderParcel.appName = appName;
+ return this;
+ }
+
+ /**
+ * Set GroupId.
+ *
+ * @param groupId ID used for associating several DiscoveryItems. These items may be
+ * visually displayed together.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setGroupId(@Nullable String groupId) {
+ mBuilderParcel.groupId = groupId;
+ return this;
+ }
+
+ /**
+ * Set AttachmentType.
+ *
+ * @param attachmentType Whether the attachment is created in debug namespace.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setAttachmentType(int attachmentType) {
+ mBuilderParcel.attachmentType = attachmentType;
+ return this;
+ }
+
+ /**
+ * Set PackageName.
+ *
+ * @param packageName Package name of the App that owns this item.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setPackageName(@Nullable String packageName) {
+ mBuilderParcel.packageName = packageName;
+ return this;
+ }
+
+ /**
+ * Set FeatureGraphicUrl.
+ *
+ * @param featureGraphicUrl The "feature" graphic image url used for large sized list view
+ * entries.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setFeatureGraphicUrl(@Nullable String featureGraphicUrl) {
+ mBuilderParcel.featureGraphicUrl = featureGraphicUrl;
+ return this;
+ }
+
+ /**
+ * Set TriggerId.
+ *
+ * @param triggerId TriggerId identifies the trigger/beacon that is attached with a message.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setTriggerId(@Nullable String triggerId) {
+ mBuilderParcel.triggerId = triggerId;
+ return this;
+ }
+
+ /**
+ * Set IconPng.
+ *
+ * @param iconPng Bytes of item icon in PNG format displayed in Discovery item list.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setIconPng(@Nullable byte[] iconPng) {
+ mBuilderParcel.iconPng = iconPng;
+ return this;
+ }
+
+ /**
+ * Set IconFifeUrl.
+ *
+ * @param iconFifeUrl A FIFE URL of the item icon displayed in Discovery item list.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setIconFfeUrl(@Nullable String iconFifeUrl) {
+ mBuilderParcel.iconFifeUrl = iconFifeUrl;
+ return this;
+ }
+
+ /**
+ * Set DebugMessage.
+ *
+ * @param debugMessage Message written to bugreport for 3P developers.(No sensitive info)
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setDebugMessage(@Nullable String debugMessage) {
+ mBuilderParcel.debugMessage = debugMessage;
+ return this;
+ }
+
+ /**
+ * Set DebugCategory.
+ *
+ * @param debugCategory Weather the item is filtered out on server.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setDebugCategory(int debugCategory) {
+ mBuilderParcel.debugCategory = debugCategory;
+ return this;
+ }
+
+ /**
+ * Set LostMillis.
+ *
+ * @param lostMillis Client timestamp when the trigger (e.g. beacon) was last lost
+ * (e.g. when Messages told us the beacon's no longer nearby).
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setLostMillis(long lostMillis) {
+ mBuilderParcel.lostMillis = lostMillis;
+ return this;
+ }
+
+ /**
+ * Set LastUserExperience.
+ *
+ * @param lastUserExperience The kind of expereince the user last had with this (e.g. if
+ * they dismissed the notification, that's bad; but if they tapped
+ * it, that's good).
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setLastUserExperience(int lastUserExperience) {
+ mBuilderParcel.lastUserExperience = lastUserExperience;
+ return this;
+ }
+
+ /**
+ * Set BleRecordBytes.
+ *
+ * @param bleRecordBytes The most recent BLE advertisement related to this item.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setBleRecordBytes(@Nullable byte[] bleRecordBytes) {
+ mBuilderParcel.bleRecordBytes = bleRecordBytes;
+ return this;
+ }
+
+ /**
+ * Set EntityId.
+ *
+ * @param entityId An ID generated on the server to uniquely identify content.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setEntityId(@Nullable String entityId) {
+ mBuilderParcel.entityId = entityId;
+ return this;
+ }
+
+ /**
+ * Set authenticationPublicKeySecp256r1.
+ *
+ * @param authenticationPublicKeySecp256r1 Fast Pair device public key.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @NonNull
+ public Builder setAuthenticationPublicKeySecp256r1(
+ @Nullable byte[] authenticationPublicKeySecp256r1) {
+ mBuilderParcel.authenticationPublicKeySecp256r1 = authenticationPublicKeySecp256r1;
+ return this;
+ }
+
+ /**
+ * Build {@link FastPairDiscoveryItem} with the currently set configuration.
+ */
+ @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
new file mode 100644
index 0000000..8195a16
--- /dev/null
+++ b/nearby/framework/java/android/nearby/FastPairEligibleAccount.java
@@ -0,0 +1,90 @@
+/*
+ * 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;
+
+import android.accounts.Account;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SuppressLint;
+import android.annotation.SystemApi;
+import android.nearby.aidl.FastPairEligibleAccountParcel;
+
+/**
+ * Class for FastPairEligibleAccount and its builder.
+ *
+ * @hide
+ */
+@SystemApi
+public class FastPairEligibleAccount {
+
+ FastPairEligibleAccountParcel mAccountParcel;
+
+ FastPairEligibleAccount(FastPairEligibleAccountParcel accountParcel) {
+ this.mAccountParcel = accountParcel;
+ }
+
+ /**
+ * Builder used to create FastPairEligibleAccount.
+ */
+ public static final class Builder {
+
+ private final FastPairEligibleAccountParcel mBuilderParcel;
+
+ /**
+ * Default constructor of Builder.
+ */
+ public Builder() {
+ mBuilderParcel = new FastPairEligibleAccountParcel();
+ mBuilderParcel.account = null;
+ mBuilderParcel.optIn = false;
+ }
+
+ /**
+ * Set Account.
+ *
+ * @param account Fast Pair eligible account.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @SuppressLint("MissingGetterMatchingBuilder")
+ @NonNull
+ public Builder setAccount(@Nullable Account account) {
+ mBuilderParcel.account = account;
+ return this;
+ }
+
+ /**
+ * Set whether the account is opt into Fast Pair.
+ *
+ * @param optIn Whether the Fast Pair eligible account opts into Fast Pair.
+ * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
+ */
+ @SuppressLint("MissingGetterMatchingBuilder")
+ @NonNull
+ public Builder setOptIn(boolean optIn) {
+ mBuilderParcel.optIn = optIn;
+ return this;
+ }
+
+ /**
+ * Build {@link FastPairEligibleAccount} with the currently set configuration.
+ */
+ @NonNull
+ public FastPairEligibleAccount build() {
+ return new FastPairEligibleAccount(mBuilderParcel);
+ }
+ }
+}
diff --git a/nearby/framework/java/android/nearby/IFastPairDataProvider.aidl b/nearby/framework/java/android/nearby/IFastPairDataProvider.aidl
deleted file mode 100644
index c3c04d6..0000000
--- a/nearby/framework/java/android/nearby/IFastPairDataProvider.aidl
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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;
-
-import android.nearby.FastPairDeviceMetadataRequestParcel;
-import android.nearby.IFastPairDataCallback;
-
-/**
- * Interface for communicating with the fast pair providers.
- *
- * @hide
- */
-oneway interface IFastPairDataProvider {
- void loadFastPairDeviceMetadata(in FastPairDeviceMetadataRequestParcel modelId,
- in IFastPairDataCallback callback);
-}
diff --git a/nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairAccountDevicesMetadataRequestParcel.aidl
similarity index 66%
copy from nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl
copy to nearby/framework/java/android/nearby/aidl/FastPairAccountDevicesMetadataRequestParcel.aidl
index 2799e5d..2cff632 100644
--- a/nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl
+++ b/nearby/framework/java/android/nearby/aidl/FastPairAccountDevicesMetadataRequestParcel.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Android Open Source Project
+ * 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.
@@ -14,12 +14,14 @@
* limitations under the License.
*/
-package android.nearby;
+package android.nearby.aidl;
+
+import android.accounts.Account;
/**
- * Configuration details for requesting tethering.
- * @hide
+ * Request details for Metadata of Fast Pair devices associated with an account.
+ * {@hide}
*/
-parcelable FastPairDeviceMetadataRequestParcel {
- byte[] modelId;
+parcelable FastPairAccountDevicesMetadataRequestParcel {
+ Account account;
}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/aidl/FastPairAccountKeyDeviceMetadataParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairAccountKeyDeviceMetadataParcel.aidl
new file mode 100644
index 0000000..8880d35
--- /dev/null
+++ b/nearby/framework/java/android/nearby/aidl/FastPairAccountKeyDeviceMetadataParcel.aidl
@@ -0,0 +1,35 @@
+// 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.aidl;
+
+import android.nearby.aidl.FastPairDeviceMetadataParcel;
+import android.nearby.aidl.FastPairDiscoveryItemParcel;
+
+/**
+ * Metadata of a Fast Pair device associated with an account.
+ * {@hide}
+ */
+ // TODO(b/204780849): remove unnecessary fields and polish comments.
+parcelable FastPairAccountKeyDeviceMetadataParcel {
+ // Key of the Fast Pair device associated with the account.
+ byte[] accountKey;
+ // Hash function of account key and public bluetooth address.
+ byte[] sha256AccountKeyPublicAddress;
+ // Fast Pair device metadata for the Fast Pair device.
+ FastPairDeviceMetadataParcel metadata;
+ // Fast Pair discovery item tied to both the Fast Pair device and the
+ // account.
+ FastPairDiscoveryItemParcel discoveryItem;
+}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/aidl/FastPairAntispoofkeyDeviceMetadataParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairAntispoofkeyDeviceMetadataParcel.aidl
new file mode 100644
index 0000000..8ca66d2
--- /dev/null
+++ b/nearby/framework/java/android/nearby/aidl/FastPairAntispoofkeyDeviceMetadataParcel.aidl
@@ -0,0 +1,31 @@
+// 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.aidl;
+
+import android.nearby.aidl.FastPairDeviceMetadataParcel;
+
+/**
+ * Metadata of a Fast Pair device keyed by Antispoofkey,
+ * Used by initial pairing without account association.
+ *
+ * {@hide}
+ */
+parcelable FastPairAntispoofkeyDeviceMetadataParcel {
+ // Anti spoof public key.
+ byte[] antiSpoofPublicKey;
+
+ // Fast Pair device metadata for the Fast Pair device.
+ FastPairDeviceMetadataParcel deviceMetadata;
+}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairAntispoofkeyDeviceMetadataRequestParcel.aidl
similarity index 70%
copy from nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl
copy to nearby/framework/java/android/nearby/aidl/FastPairAntispoofkeyDeviceMetadataRequestParcel.aidl
index 2799e5d..175d73c 100644
--- a/nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl
+++ b/nearby/framework/java/android/nearby/aidl/FastPairAntispoofkeyDeviceMetadataRequestParcel.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Android Open Source Project
+ * 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.
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-package android.nearby;
+package android.nearby.aidl;
/**
- * Configuration details for requesting tethering.
- * @hide
+ * Request details for metadata of a Fast Pair device keyed by either
+ * antispoofkey or modelId.
+ * {@hide}
*/
-parcelable FastPairDeviceMetadataRequestParcel {
+parcelable FastPairAntispoofkeyDeviceMetadataRequestParcel {
byte[] modelId;
}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/aidl/FastPairDeviceMetadataParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairDeviceMetadataParcel.aidl
new file mode 100644
index 0000000..565439b
--- /dev/null
+++ b/nearby/framework/java/android/nearby/aidl/FastPairDeviceMetadataParcel.aidl
@@ -0,0 +1,127 @@
+/*
+ * 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.aidl;
+
+/**
+ * Fast Pair Device Metadata for a given device model ID.
+ * @hide
+ */
+// TODO(b/204780849): remove unnecessary fields and polish comments.
+parcelable FastPairDeviceMetadataParcel {
+ // The image to show on the notification.
+ String imageUrl;
+
+ // The intent that will be launched via the notification.
+ String intentUri;
+
+ // The transmit power of the device's BLE chip.
+ int bleTxPower;
+
+ // The distance that the device must be within to show a notification.
+ // If no distance is set, we default to 0.6 meters. Only Nearby admins can
+ // change this.
+ float triggerDistance;
+
+ // The image icon that shows in the notification.
+ byte[] image;
+
+ int deviceType;
+
+ // The image urls for device with device type "true wireless".
+ String trueWirelessImageUrlLeftBud;
+ String trueWirelessImageUrlRightBud;
+ String trueWirelessImageUrlCase;
+
+ // Stings to be displayed in notification surfaced for a device.
+ // The locale of all of the Strings.
+ String locale;
+
+ // The notification description for when the device is initially discovered.
+ String initialNotificationDescription;
+
+ // The notification description for when the device is initially discovered
+ // and no account is logged in.
+ String initialNotificationDescriptionNoAccount;
+
+ // The notification description for once we have finished pairing and the
+ // companion app has been opened. For Bisto devices, this String will point
+ // users to setting up the assistant.
+ String openCompanionAppDescription;
+
+ // The notification description for once we have finished pairing and the
+ // companion app needs to be updated before use.
+ String updateCompanionAppDescription;
+
+ // The notification description for once we have finished pairing and the
+ // companion app needs to be installed.
+ String downloadCompanionAppDescription;
+
+ // The notification title when a pairing fails.
+ String unableToConnectTitle;
+
+ // The notification summary when a pairing fails.
+ String unableToConnectDescription;
+
+ // The description that helps user initially paired with device.
+ String initialPairingDescription;
+
+ // The description that let user open the companion app.
+ String connectSuccessCompanionAppInstalled;
+
+ // The description that let user download the companion app.
+ String connectSuccessCompanionAppNotInstalled;
+
+ // The description that reminds user there is a paired device nearby.
+ String subsequentPairingDescription;
+
+ // The description that reminds users opt in their device.
+ String retroactivePairingDescription;
+
+ // The description that indicates companion app is about to launch.
+ String waitLaunchCompanionAppDescription;
+
+ // The description that indicates go to bluetooth settings when connection
+ // fail.
+ String failConnectGoToSettingsDescription;
+
+ // The title of the UI to ask the user to confirm the pin code.
+ String confirmPinTitle;
+
+ // The description of the UI to ask the user to confirm the pin code.
+ String confirmPinDescription;
+
+ // The title of the UI to ask the user to confirm to sync contacts.
+ String syncContactsTitle;
+
+ // The description of the UI to ask the user to confirm to sync contacts.
+ String syncContactsDescription;
+
+ // The title of the UI to ask the user to confirm to sync SMS.
+ String syncSmsTitle;
+
+ // The description of the UI to ask the user to confirm to sync SMS.
+ String syncSmsDescription;
+
+ // The description in half sheet to ask user setup google assistant
+ String assistantSetupHalfSheet;
+
+ // The description in notification to ask user setup google assistant
+ String assistantSetupNotification;
+
+ // Description of the connect device action on TV, when user is not logged in.
+ String fastPairTvConnectDeviceNoAccountDescription;
+}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/aidl/FastPairDiscoveryItemParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairDiscoveryItemParcel.aidl
new file mode 100644
index 0000000..5ba18bb
--- /dev/null
+++ b/nearby/framework/java/android/nearby/aidl/FastPairDiscoveryItemParcel.aidl
@@ -0,0 +1,126 @@
+/*
+ * 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.aidl;
+
+/**
+ * Fast Pair Discovery Item.
+ * @hide
+ */
+// TODO(b/204780849): remove unnecessary fields and polish comments.
+parcelable FastPairDiscoveryItemParcel {
+ // Offline item: unique ID generated on client.
+ // Online item: unique ID generated on server.
+ String id;
+
+ int type;
+
+ // The most recent all upper case mac associated with this item.
+ // (Mac-to-DiscoveryItem is a many-to-many relationship)
+ String macAddress;
+
+ String actionUrl;
+
+ // The bluetooth device name from advertisement
+ String deviceName;
+
+ // Item's title
+ String title;
+
+ // Item's description.
+ String description;
+
+ // The URL for display
+ String displayUrl;
+
+ // Client timestamp when the beacon was last observed in BLE scan.
+ long lastObservationTimestampMillis;
+
+ // Client timestamp when the beacon was first observed in BLE scan.
+ long firstObservationTimestampMillis;
+
+ // Item's current state. e.g. if the item is blocked.
+ int state;
+
+ // The resolved url type for the action_url.
+ int actionUrlType;
+
+ // The timestamp when the user is redirected to Play Store after clicking on
+ // the item.
+ long pendingAppInstallTimestampMillis;
+
+ // Beacon's RSSI value
+ int rssi;
+
+ // Beacon's tx power
+ int txPower;
+
+ // Human readable name of the app designated to open the uri
+ // Used in the second line of the notification, "Open in {} app"
+ String appName;
+
+ // ID used for associating several DiscoveryItems. These items may be
+ // visually displayed together.
+ String groupId;
+
+ // Whether the attachment is created in debug namespace
+ int attachmentType;
+
+ // Package name of the App that owns this item.
+ String packageName;
+
+ // The "feature" graphic image url used for large sized list view entries.
+ String featureGraphicUrl;
+
+ // TriggerId identifies the trigger/beacon that is attached with a message.
+ // It's generated from server for online messages to synchronize formatting
+ // across client versions.
+ // Example:
+ // * BLE_UID: 3||deadbeef
+ // * BLE_URL: http://trigger.id
+ // See go/discovery-store-message-and-trigger-id for more details.
+ String triggerId;
+
+ // Bytes of item icon in PNG format displayed in Discovery item list.
+ byte[] iconPng;
+
+ // A FIFE URL of the item icon displayed in Discovery item list.
+ String iconFifeUrl;
+
+ // Message written to bugreport for 3P developers.(No sensitive info)
+ // null if the item is valid
+ String debugMessage;
+
+ // Weather the item is filtered out on server.
+ int debugCategory;
+
+ // Client timestamp when the trigger (e.g. beacon) was last lost (e.g. when
+ // Messages told us the beacon's no longer nearby).
+ long lostMillis;
+
+ // The kind of experience the user last had with this (e.g. if they dismissed
+ // the notification, that's bad; but if they tapped it, that's good).
+ int lastUserExperience;
+
+ // The most recent BLE advertisement related to this item.
+ byte[] bleRecordBytes;
+
+ // An ID generated on the server to uniquely identify content.
+ String entityId;
+
+ // Fast Pair antispoof key.
+ byte[] authenticationPublicKeySecp256r1;
+}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairEligibleAccountParcel.aidl
similarity index 66%
copy from nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl
copy to nearby/framework/java/android/nearby/aidl/FastPairEligibleAccountParcel.aidl
index 2799e5d..747758d 100644
--- a/nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl
+++ b/nearby/framework/java/android/nearby/aidl/FastPairEligibleAccountParcel.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Android Open Source Project
+ * 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.
@@ -14,12 +14,16 @@
* limitations under the License.
*/
-package android.nearby;
+package android.nearby.aidl;
+
+import android.accounts.Account;
/**
- * Configuration details for requesting tethering.
- * @hide
+ * Fast Pair Eligible Account.
+ * {@hide}
*/
-parcelable FastPairDeviceMetadataRequestParcel {
- byte[] modelId;
+parcelable FastPairEligibleAccountParcel {
+ Account account;
+ // Whether the account opts in Fast Pair.
+ boolean optIn;
}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairEligibleAccountsRequestParcel.aidl
similarity index 70%
rename from nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl
rename to nearby/framework/java/android/nearby/aidl/FastPairEligibleAccountsRequestParcel.aidl
index 2799e5d..8db3356 100644
--- a/nearby/framework/java/android/nearby/FastPairDeviceMetadataRequestParcel.aidl
+++ b/nearby/framework/java/android/nearby/aidl/FastPairEligibleAccountsRequestParcel.aidl
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020 The Android Open Source Project
+ * 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.
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package android.nearby;
+package android.nearby.aidl;
/**
- * Configuration details for requesting tethering.
- * @hide
+ * Request details for Fast Pair eligible accounts.
+ * Empty place holder for future expansion.
+ * {@hide}
*/
-parcelable FastPairDeviceMetadataRequestParcel {
- byte[] modelId;
+parcelable FastPairEligibleAccountsRequestParcel {
}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/aidl/FastPairManageAccountDeviceRequestParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairManageAccountDeviceRequestParcel.aidl
new file mode 100644
index 0000000..82cf550
--- /dev/null
+++ b/nearby/framework/java/android/nearby/aidl/FastPairManageAccountDeviceRequestParcel.aidl
@@ -0,0 +1,36 @@
+/*
+ * 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.aidl;
+
+import android.accounts.Account;
+import android.nearby.aidl.FastPairAccountKeyDeviceMetadataParcel;
+
+/**
+ * Request details for managing Fast Pair device-account mapping.
+ * {@hide}
+ */
+ // TODO(b/204780849): remove unnecessary fields and polish comments.
+parcelable FastPairManageAccountDeviceRequestParcel {
+ Account account;
+ // MANAGE_ACCOUNT_DEVICE_ADD: add Fast Pair device to the account.
+ // MANAGE_ACCOUNT_DEVICE_REMOVE: remove Fast Pair device from the account.
+ int requestType;
+ // Fast Pair account key-ed device metadata.
+ FastPairAccountKeyDeviceMetadataParcel accountKeyDeviceMetadata;
+ // BLE address of the device at the device add time.
+ String bleAddress;
+}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/aidl/FastPairManageAccountRequestParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairManageAccountRequestParcel.aidl
new file mode 100644
index 0000000..3d92064
--- /dev/null
+++ b/nearby/framework/java/android/nearby/aidl/FastPairManageAccountRequestParcel.aidl
@@ -0,0 +1,31 @@
+/*
+ * 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.aidl;
+
+import android.accounts.Account;
+
+/**
+ * Request details for managing a Fast Pair account.
+ *
+ * {@hide}
+ */
+parcelable FastPairManageAccountRequestParcel {
+ Account account;
+ // MANAGE_ACCOUNT_OPT_IN: opt account into Fast Pair.
+ // MANAGE_ACCOUNT_OPT_OUT: opt account out of Fast Pair.
+ int requestType;
+}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/aidl/IFastPairAccountDevicesMetadataCallback.aidl b/nearby/framework/java/android/nearby/aidl/IFastPairAccountDevicesMetadataCallback.aidl
new file mode 100644
index 0000000..7db18d0
--- /dev/null
+++ b/nearby/framework/java/android/nearby/aidl/IFastPairAccountDevicesMetadataCallback.aidl
@@ -0,0 +1,28 @@
+// 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.aidl;
+
+import android.nearby.aidl.FastPairAccountKeyDeviceMetadataParcel;
+
+/**
+ * Provides callback interface for OEMs to send back metadata of FastPair
+ * devices associated with an account.
+ *
+ * {@hide}
+ */
+interface IFastPairAccountDevicesMetadataCallback {
+ void onFastPairAccountDevicesMetadataReceived(in FastPairAccountKeyDeviceMetadataParcel[] accountDevicesMetadata);
+ void onError(int code, String message);
+}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/IFastPairDataCallback.aidl b/nearby/framework/java/android/nearby/aidl/IFastPairAntispoofkeyDeviceMetadataCallback.aidl
similarity index 61%
copy from nearby/framework/java/android/nearby/IFastPairDataCallback.aidl
copy to nearby/framework/java/android/nearby/aidl/IFastPairAntispoofkeyDeviceMetadataCallback.aidl
index e4a0348..87c9796 100644
--- a/nearby/framework/java/android/nearby/IFastPairDataCallback.aidl
+++ b/nearby/framework/java/android/nearby/aidl/IFastPairAntispoofkeyDeviceMetadataCallback.aidl
@@ -12,15 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package android.nearby;
+package android.nearby.aidl;
-import android.nearby.FastPairDeviceMetadataParcel;
+import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataParcel;
/**
- * Provides callback interface for OEMs to send FastPair data back.
+ * Provides callback interface for OEMs to send FastPair Antispoofkey Device metadata back.
*
* {@hide}
*/
-interface IFastPairDataCallback {
- void onFastPairDeviceMetadataReceived(in FastPairDeviceMetadataParcel metadata);
- }
+interface IFastPairAntispoofkeyDeviceMetadataCallback {
+ void onFastPairAntispoofkeyDeviceMetadataReceived(in FastPairAntispoofkeyDeviceMetadataParcel metadata);
+ void onError(int code, String message);
+}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/aidl/IFastPairDataProvider.aidl b/nearby/framework/java/android/nearby/aidl/IFastPairDataProvider.aidl
new file mode 100644
index 0000000..73aef9e
--- /dev/null
+++ b/nearby/framework/java/android/nearby/aidl/IFastPairDataProvider.aidl
@@ -0,0 +1,44 @@
+// 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.aidl;
+
+import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataRequestParcel;
+import android.nearby.aidl.IFastPairAntispoofkeyDeviceMetadataCallback;
+import android.nearby.aidl.FastPairAccountDevicesMetadataRequestParcel;
+import android.nearby.aidl.IFastPairAccountDevicesMetadataCallback;
+import android.nearby.aidl.FastPairEligibleAccountsRequestParcel;
+import android.nearby.aidl.IFastPairEligibleAccountsCallback;
+import android.nearby.aidl.FastPairManageAccountRequestParcel;
+import android.nearby.aidl.IFastPairManageAccountCallback;
+import android.nearby.aidl.FastPairManageAccountDeviceRequestParcel;
+import android.nearby.aidl.IFastPairManageAccountDeviceCallback;
+
+/**
+ * Interface for communicating with the fast pair providers.
+ *
+ * {@hide}
+ */
+oneway interface IFastPairDataProvider {
+ void loadFastPairAntispoofkeyDeviceMetadata(in FastPairAntispoofkeyDeviceMetadataRequestParcel request,
+ in IFastPairAntispoofkeyDeviceMetadataCallback callback);
+ void loadFastPairAccountDevicesMetadata(in FastPairAccountDevicesMetadataRequestParcel request,
+ in IFastPairAccountDevicesMetadataCallback callback);
+ void loadFastPairEligibleAccounts(in FastPairEligibleAccountsRequestParcel request,
+ in IFastPairEligibleAccountsCallback callback);
+ void manageFastPairAccount(in FastPairManageAccountRequestParcel request,
+ in IFastPairManageAccountCallback callback);
+ void manageFastPairAccountDevice(in FastPairManageAccountDeviceRequestParcel request,
+ in IFastPairManageAccountDeviceCallback callback);
+}
diff --git a/nearby/framework/java/android/nearby/IFastPairDataCallback.aidl b/nearby/framework/java/android/nearby/aidl/IFastPairEligibleAccountsCallback.aidl
similarity index 62%
copy from nearby/framework/java/android/nearby/IFastPairDataCallback.aidl
copy to nearby/framework/java/android/nearby/aidl/IFastPairEligibleAccountsCallback.aidl
index e4a0348..9990014 100644
--- a/nearby/framework/java/android/nearby/IFastPairDataCallback.aidl
+++ b/nearby/framework/java/android/nearby/aidl/IFastPairEligibleAccountsCallback.aidl
@@ -12,15 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package android.nearby;
+package android.nearby.aidl;
-import android.nearby.FastPairDeviceMetadataParcel;
+import android.accounts.Account;
+import android.nearby.aidl.FastPairEligibleAccountParcel;
/**
- * Provides callback interface for OEMs to send FastPair data back.
+ * Provides callback interface for OEMs to return FastPair Eligible accounts.
*
* {@hide}
*/
-interface IFastPairDataCallback {
- void onFastPairDeviceMetadataReceived(in FastPairDeviceMetadataParcel metadata);
- }
+interface IFastPairEligibleAccountsCallback {
+ void onFastPairEligibleAccountsReceived(in FastPairEligibleAccountParcel[] accounts);
+ void onError(int code, String message);
+ }
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/IFastPairDataCallback.aidl b/nearby/framework/java/android/nearby/aidl/IFastPairManageAccountCallback.aidl
similarity index 70%
copy from nearby/framework/java/android/nearby/IFastPairDataCallback.aidl
copy to nearby/framework/java/android/nearby/aidl/IFastPairManageAccountCallback.aidl
index e4a0348..6b4aaee 100644
--- a/nearby/framework/java/android/nearby/IFastPairDataCallback.aidl
+++ b/nearby/framework/java/android/nearby/aidl/IFastPairManageAccountCallback.aidl
@@ -12,15 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package android.nearby;
-
-import android.nearby.FastPairDeviceMetadataParcel;
+package android.nearby.aidl;
/**
- * Provides callback interface for OEMs to send FastPair data back.
+ * Provides callback interface to send response for account management request.
*
* {@hide}
*/
-interface IFastPairDataCallback {
- void onFastPairDeviceMetadataReceived(in FastPairDeviceMetadataParcel metadata);
- }
+interface IFastPairManageAccountCallback {
+ void onSuccess();
+ void onError(int code, String message);
+}
\ No newline at end of file
diff --git a/nearby/framework/java/android/nearby/IFastPairDataCallback.aidl b/nearby/framework/java/android/nearby/aidl/IFastPairManageAccountDeviceCallback.aidl
similarity index 70%
rename from nearby/framework/java/android/nearby/IFastPairDataCallback.aidl
rename to nearby/framework/java/android/nearby/aidl/IFastPairManageAccountDeviceCallback.aidl
index e4a0348..bffc533 100644
--- a/nearby/framework/java/android/nearby/IFastPairDataCallback.aidl
+++ b/nearby/framework/java/android/nearby/aidl/IFastPairManageAccountDeviceCallback.aidl
@@ -12,15 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package android.nearby;
-
-import android.nearby.FastPairDeviceMetadataParcel;
+package android.nearby.aidl;
/**
- * Provides callback interface for OEMs to send FastPair data back.
+ * Provides callback interface to send response for account-device mapping
+ * management request.
*
* {@hide}
*/
-interface IFastPairDataCallback {
- void onFastPairDeviceMetadataReceived(in FastPairDeviceMetadataParcel metadata);
- }
+interface IFastPairManageAccountDeviceCallback {
+ void onSuccess();
+ void onError(int code, String message);
+}
\ No newline at end of file
diff --git a/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java b/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java
index cf9629b..b7c63c9 100644
--- a/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java
+++ b/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java
@@ -18,6 +18,7 @@
import android.annotation.Nullable;
import android.content.Context;
+import android.nearby.FastPairDataProviderBase;
import android.util.Log;
import androidx.annotation.WorkerThread;
@@ -28,9 +29,7 @@
public class FastPairDataProvider {
private static final String TAG = "FastPairDataProvider";
- // TODO(204780849): move this to system api.
- private static final String ACTION_FAST_PAIR_DATA_PROVIDER =
- "com.android.nearby.service.FastPairDataProvider";
+
private static FastPairDataProvider sInstance;
private ProxyFastPairDataProvider mProxyProvider;
@@ -54,7 +53,8 @@
}
private FastPairDataProvider(Context context) {
- mProxyProvider = ProxyFastPairDataProvider.create(context, ACTION_FAST_PAIR_DATA_PROVIDER);
+ mProxyProvider = ProxyFastPairDataProvider.create(
+ context, FastPairDataProviderBase.ACTION_FAST_PAIR_DATA_PROVIDER);
}
/** loadFastPairDeviceMetadata. */
diff --git a/nearby/service/java/com/android/server/nearby/provider/ProxyFastPairDataProvider.java b/nearby/service/java/com/android/server/nearby/provider/ProxyFastPairDataProvider.java
index 073518b..7bd53f4 100644
--- a/nearby/service/java/com/android/server/nearby/provider/ProxyFastPairDataProvider.java
+++ b/nearby/service/java/com/android/server/nearby/provider/ProxyFastPairDataProvider.java
@@ -18,10 +18,10 @@
import android.annotation.Nullable;
import android.content.Context;
-import android.nearby.FastPairDeviceMetadataParcel;
-import android.nearby.FastPairDeviceMetadataRequestParcel;
-import android.nearby.IFastPairDataCallback;
-import android.nearby.IFastPairDataProvider;
+import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataParcel;
+import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataRequestParcel;
+import android.nearby.aidl.IFastPairAntispoofkeyDeviceMetadataCallback;
+import android.nearby.aidl.IFastPairDataProvider;
import android.os.IBinder;
import android.os.RemoteException;
@@ -98,17 +98,20 @@
@Override
public void run(IBinder binder) throws RemoteException {
IFastPairDataProvider provider = IFastPairDataProvider.Stub.asInterface(binder);
- FastPairDeviceMetadataRequestParcel requestParcel =
- new FastPairDeviceMetadataRequestParcel();
+ FastPairAntispoofkeyDeviceMetadataRequestParcel requestParcel =
+ new FastPairAntispoofkeyDeviceMetadataRequestParcel();
requestParcel.modelId = modelId;
- IFastPairDataCallback callback = new IFastPairDataCallback.Stub() {
- public void onFastPairDeviceMetadataReceived(
- FastPairDeviceMetadataParcel metadata) {
+ IFastPairAntispoofkeyDeviceMetadataCallback callback =
+ new IFastPairAntispoofkeyDeviceMetadataCallback.Stub() {
+ public void onFastPairAntispoofkeyDeviceMetadataReceived(
+ FastPairAntispoofkeyDeviceMetadataParcel metadata) {
response.set(Utils.convert(metadata));
waitForCompletionLatch.countDown();
}
+ public void onError(int code, String message) {
+ }
};
- provider.loadFastPairDeviceMetadata(requestParcel, callback);
+ provider.loadFastPairAntispoofkeyDeviceMetadata(requestParcel, callback);
}
@Override
diff --git a/nearby/service/java/com/android/server/nearby/provider/Utils.java b/nearby/service/java/com/android/server/nearby/provider/Utils.java
index 115dfee..867774c 100644
--- a/nearby/service/java/com/android/server/nearby/provider/Utils.java
+++ b/nearby/service/java/com/android/server/nearby/provider/Utils.java
@@ -16,7 +16,7 @@
package com.android.server.nearby.provider;
-import android.nearby.FastPairDeviceMetadataParcel;
+import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataParcel;
import com.google.protobuf.ByteString;
@@ -24,21 +24,22 @@
class Utils {
- static Rpcs.GetObservedDeviceResponse convert(FastPairDeviceMetadataParcel metadata) {
+ static Rpcs.GetObservedDeviceResponse convert(
+ FastPairAntispoofkeyDeviceMetadataParcel metadata) {
return Rpcs.GetObservedDeviceResponse.newBuilder()
.setDevice(
Rpcs.Device.newBuilder()
- .setImageUrl(metadata.imageUrl)
- .setIntentUri(metadata.intentUri)
.setAntiSpoofingKeyPair(
Rpcs.AntiSpoofingKeyPair.newBuilder()
.setPublicKey(ByteString.copyFrom(metadata.antiSpoofPublicKey))
.build())
- .setBleTxPower(metadata.bleTxPower)
- .setTriggerDistance(metadata.triggerDistance)
- .setDeviceType(Rpcs.DeviceType.forNumber(metadata.deviceType))
+ .setImageUrl(metadata.deviceMetadata.imageUrl)
+ .setIntentUri(metadata.deviceMetadata.intentUri)
+ .setBleTxPower(metadata.deviceMetadata.bleTxPower)
+ .setTriggerDistance(metadata.deviceMetadata.triggerDistance)
+ .setDeviceType(Rpcs.DeviceType.forNumber(metadata.deviceMetadata.deviceType))
.build())
- .setImage(ByteString.copyFrom(metadata.image))
+ .setImage(ByteString.copyFrom(metadata.deviceMetadata.image))
.build();
}
}