Merge "Make some NetworkStats APIs system-current" into tm-dev
diff --git a/framework-t/api/system-current.txt b/framework-t/api/system-current.txt
index 407d588..74cf46f 100644
--- a/framework-t/api/system-current.txt
+++ b/framework-t/api/system-current.txt
@@ -123,7 +123,6 @@
public static class FastPairDataProviderService.FastPairManageAccountDeviceRequest {
method @NonNull public android.accounts.Account getAccount();
method @NonNull public android.nearby.FastPairAccountKeyDeviceMetadata getAccountKeyDeviceMetadata();
- method @Nullable public String getBleAddress();
method public int getRequestType();
}
@@ -138,32 +137,22 @@
}
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 getName();
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();
@@ -177,32 +166,22 @@
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 setName(@Nullable String);
method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setOpenCompanionAppDescription(@Nullable String);
method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setRetroactivePairingDescription(@Nullable String);
method @NonNull public android.nearby.FastPairDeviceMetadata.Builder setSubsequentPairingDescription(@Nullable String);
- method @NonNull public android.nearby.FastPairDeviceMetadata.Builder 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);
@@ -217,24 +196,15 @@
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();
@@ -243,7 +213,6 @@
method @Nullable public String getTitle();
method @Nullable public String getTriggerId();
method public int getTxPower();
- method public int getType();
}
public static final class FastPairDiscoveryItem.Builder {
@@ -252,24 +221,15 @@
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);
@@ -278,7 +238,6 @@
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 {
@@ -445,10 +404,8 @@
field public static final int SCAN_MODE_LOW_LATENCY = 2; // 0x2
field public static final int SCAN_MODE_LOW_POWER = 0; // 0x0
field public static final int SCAN_MODE_NO_POWER = -1; // 0xffffffff
- field public static final int SCAN_TYPE_EXPOSURE_NOTIFICATION = 4; // 0x4
field public static final int SCAN_TYPE_FAST_PAIR = 1; // 0x1
- field public static final int SCAN_TYPE_NEARBY_PRESENCE = 3; // 0x3
- field public static final int SCAN_TYPE_NEARBY_SHARE = 2; // 0x2
+ field public static final int SCAN_TYPE_NEARBY_PRESENCE = 2; // 0x2
}
public static final class ScanRequest.Builder {
diff --git a/framework/api/system-current.txt b/framework/api/system-current.txt
index 7a57426..db1d7e9 100644
--- a/framework/api/system-current.txt
+++ b/framework/api/system-current.txt
@@ -340,7 +340,7 @@
method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public android.net.NetworkCapabilities.Builder setSsid(@Nullable String);
method @NonNull public android.net.NetworkCapabilities.Builder setSubscriptionIds(@NonNull java.util.Set<java.lang.Integer>);
method @NonNull public android.net.NetworkCapabilities.Builder setTransportInfo(@Nullable android.net.TransportInfo);
- method @NonNull public android.net.NetworkCapabilities.Builder setUnderlyingNetworks(@Nullable java.util.List<android.net.Network>);
+ method @NonNull @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY) public android.net.NetworkCapabilities.Builder setUnderlyingNetworks(@Nullable java.util.List<android.net.Network>);
method @NonNull public static android.net.NetworkCapabilities.Builder withoutDefaultCapabilities();
}
diff --git a/framework/src/android/net/ConnectivityManager.java b/framework/src/android/net/ConnectivityManager.java
index e25a855..a174fe3 100644
--- a/framework/src/android/net/ConnectivityManager.java
+++ b/framework/src/android/net/ConnectivityManager.java
@@ -995,21 +995,25 @@
// LINT.ThenChange(packages/modules/Connectivity/service/native/include/Common.h)
/**
- * Specify default rule which may allow or drop packets depending on existing policy.
+ * A firewall rule which allows or drops packets depending on existing policy.
+ * Used by {@link #setUidFirewallRule(int, int, int)} to follow existing policy to handle
+ * specific uid's packets in specific firewall chain.
* @hide
*/
@SystemApi(client = MODULE_LIBRARIES)
public static final int FIREWALL_RULE_DEFAULT = 0;
/**
- * Specify allow rule which allows packets.
+ * A firewall rule which allows packets. Used by {@link #setUidFirewallRule(int, int, int)} to
+ * allow specific uid's packets in specific firewall chain.
* @hide
*/
@SystemApi(client = MODULE_LIBRARIES)
public static final int FIREWALL_RULE_ALLOW = 1;
/**
- * Specify deny rule which drops packets.
+ * A firewall rule which drops packets. Used by {@link #setUidFirewallRule(int, int, int)} to
+ * drop specific uid's packets in specific firewall chain.
* @hide
*/
@SystemApi(client = MODULE_LIBRARIES)
diff --git a/framework/src/android/net/NetworkCapabilities.java b/framework/src/android/net/NetworkCapabilities.java
index f7f2f57..97b1f32 100644
--- a/framework/src/android/net/NetworkCapabilities.java
+++ b/framework/src/android/net/NetworkCapabilities.java
@@ -863,8 +863,11 @@
}
/**
- * Get the underlying networks of this network. If the caller is not system privileged, this is
- * always redacted to null and it will be never useful to the caller.
+ * Get the underlying networks of this network. If the caller doesn't have one of
+ * {@link android.Manifest.permission.NETWORK_FACTORY},
+ * {@link android.Manifest.permission.NETWORK_SETTINGS} and
+ * {@link NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}, this is always redacted to null and
+ * it will be never useful to the caller.
*
* @return <li>If the list is null, this network hasn't declared underlying networks.</li>
* <li>If the list is empty, this network has declared that it has no underlying
@@ -2650,7 +2653,7 @@
/**
* Builder class for NetworkCapabilities.
*
- * This class is mainly for for {@link NetworkAgent} instances to use. Many fields in
+ * This class is mainly for {@link NetworkAgent} instances to use. Many fields in
* the built class require holding a signature permission to use - mostly
* {@link android.Manifest.permission.NETWORK_FACTORY}, but refer to the specific
* description of each setter. As this class lives entirely in app space it does not
@@ -3058,9 +3061,20 @@
/**
* Set the underlying networks of this network.
*
+ * <p>This API is mainly for {@link NetworkAgent}s who hold
+ * {@link android.Manifest.permission.NETWORK_FACTORY} to set its underlying networks.
+ *
+ * <p>The underlying networks are only visible for the receiver who has one of
+ * {@link android.Manifest.permission.NETWORK_FACTORY},
+ * {@link android.Manifest.permission.NETWORK_SETTINGS} and
+ * {@link NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}.
+ * If the receiver doesn't have required permissions, the field will be cleared before
+ * sending to the caller.</p>
+ *
* @param networks The underlying networks of this network.
*/
@NonNull
+ @RequiresPermission(android.Manifest.permission.NETWORK_FACTORY)
public Builder setUnderlyingNetworks(@Nullable List<Network> networks) {
mCaps.setUnderlyingNetworks(networks);
return this;
diff --git a/nearby/framework/java/android/nearby/FastPairDataProviderService.java b/nearby/framework/java/android/nearby/FastPairDataProviderService.java
index c6a1a65..b6c840d 100644
--- a/nearby/framework/java/android/nearby/FastPairDataProviderService.java
+++ b/nearby/framework/java/android/nearby/FastPairDataProviderService.java
@@ -479,15 +479,6 @@
return this.mRequestParcel.account;
}
/**
- * Get BleAddress.
- *
- * @hide
- */
- @SystemApi
- public @Nullable String getBleAddress() {
- return this.mRequestParcel.bleAddress;
- }
- /**
* Get account key device metadata.
*
* @hide
diff --git a/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java b/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java
index ea75271..04845c0 100644
--- a/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java
+++ b/nearby/framework/java/android/nearby/FastPairDeviceMetadata.java
@@ -149,17 +149,6 @@
}
/**
- * Get Locale of the device.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getLocale() {
- return mMetadataParcel.locale;
- }
-
- /**
* Get InitialNotificationDescription, which is a translated string of
* "Tap to pair. Earbuds will be tied to %s" based on locale.
*
@@ -325,111 +314,6 @@
}
/**
- * Get ConfirmPinTitle, which is a translated string of
- * based on locale.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getConfirmPinTitle() {
- return mMetadataParcel.confirmPinTitle;
- }
-
- /**
- * Get ConfirmPinDescription, which is a translated string of "confirm pin" based on locale.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getConfirmPinDescription() {
- return mMetadataParcel.confirmPinDescription;
- }
-
- /**
- * Get SyncContactsTitle, which is a translated string of "sync contacts title" based on locale.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getSyncContactsTitle() {
- return mMetadataParcel.syncContactsTitle;
- }
-
- /**
- * Get SyncContactsDescription, which is a translated string of "sync contacts description"
- * based on locale.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getSyncContactsDescription() {
- return mMetadataParcel.syncContactsDescription;
- }
-
- /**
- * Get SyncSmsTitle, which is a translated string of "sync sms title" based on locale.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getSyncSmsTitle() {
- return mMetadataParcel.syncSmsTitle;
- }
-
- /**
- * Get SyncSmsDescription, which is a translated string of "sync sms description" based on
- * locale.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getSyncSmsDescription() {
- return mMetadataParcel.syncSmsDescription;
- }
-
- /**
- * Get AssistantSetupHalfSheet, which is a translated string of
- * "Tap to set up your Google Assistant" based on locale.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getAssistantSetupHalfSheet() {
- return mMetadataParcel.assistantSetupHalfSheet;
- }
-
- /**
- * Get AssistantSetupNotification, which is a translated string of
- * "Tap to set up your Google Assistant" based on locale.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getAssistantSetupNotification() {
- return mMetadataParcel.assistantSetupNotification;
- }
-
- /**
- * Get FastPairTvConnectDeviceNoAccountDescription, which is a translated string of
- * "Select connect to pair your %s with this device" based on locale.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getFastPairTvConnectDeviceNoAccountDescription() {
- return mMetadataParcel.fastPairTvConnectDeviceNoAccountDescription;
- }
-
- /**
* Builder used to create FastPairDeviceMetadata.
*
* @hide
@@ -457,7 +341,6 @@
mBuilderParcel.trueWirelessImageUrlLeftBud = null;
mBuilderParcel.trueWirelessImageUrlRightBud = null;
mBuilderParcel.trueWirelessImageUrlCase = null;
- mBuilderParcel.locale = null;
mBuilderParcel.initialNotificationDescription = null;
mBuilderParcel.initialNotificationDescriptionNoAccount = null;
mBuilderParcel.openCompanionAppDescription = null;
@@ -472,15 +355,6 @@
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;
}
/**
@@ -628,20 +502,6 @@
}
/**
- * Set Locale.
- *
- * @param locale Device locale.
- * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
- * @hide
- */
- @SystemApi
- @NonNull
- public Builder setLocale(@Nullable String locale) {
- mBuilderParcel.locale = locale;
- return this;
- }
-
- /**
* Set InitialNotificationDescription.
*
* @param initialNotificationDescription Initial notification description.
@@ -862,140 +722,6 @@
}
/**
- * 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(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @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.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @NonNull
- public Builder setFastPairTvConnectDeviceNoAccountDescription(
- @Nullable String fastPairTvConnectDeviceNoAccountDescription) {
- mBuilderParcel.fastPairTvConnectDeviceNoAccountDescription =
- fastPairTvConnectDeviceNoAccountDescription;
- return this;
- }
-
- /**
* Build {@link FastPairDeviceMetadata} with the currently set configuration.
*
* @hide
diff --git a/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java b/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java
index bc6a6f8..ce7413a 100644
--- a/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java
+++ b/nearby/framework/java/android/nearby/FastPairDiscoveryItem.java
@@ -48,16 +48,6 @@
}
/**
- * Get Type.
- *
- * @hide
- */
- @SystemApi
- public int getType() {
- return mMetadataParcel.type;
- }
-
- /**
* Get MacAddress.
*
* @hide
@@ -205,27 +195,6 @@
}
/**
- * Get GroupId.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getGroupId() {
- return mMetadataParcel.groupId;
- }
-
- /**
- * Get AttachmentType.
- *
- * @hide
- */
- @SystemApi
- public int getAttachmentType() {
- return mMetadataParcel.attachmentType;
- }
-
- /**
* Get PackageName.
*
* @hide
@@ -237,17 +206,6 @@
}
/**
- * Get FeatureGraphicUrl.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getFeatureGraphicUrl() {
- return mMetadataParcel.featureGraphicUrl;
- }
-
- /**
* Get TriggerId.
*
* @hide
@@ -283,69 +241,6 @@
}
/**
- * Get DebugMessage.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getDebugMessage() {
- return mMetadataParcel.debugMessage;
- }
-
- /**
- * Get DebugCategory.
- *
- * @hide
- */
- @SystemApi
- public int getDebugCategory() {
- return mMetadataParcel.debugCategory;
- }
-
- /**
- * Get LostMillis.
- */
- public long getLostMillis() {
- return mMetadataParcel.lostMillis;
- }
-
- /**
- * Get LastUserExperience.
- *
- * @hide
- */
- @SystemApi
- public int getLastUserExperience() {
- return mMetadataParcel.lastUserExperience;
- }
-
- /**
- * Get BleRecordBytes. Raw bytes of {@link android.bluetooth.le.ScanRecord}.
- * It is the most recent BLE advertisement related to this item.
- *
- * @return the most recent BLE advertisement in raw bytes of
- * {@link android.bluetooth.le.ScanRecord}.
- * @hide
- */
- @SystemApi
- @Nullable
- public byte[] getBleRecordBytes() {
- return mMetadataParcel.bleRecordBytes;
- }
-
- /**
- * Get EntityId.
- *
- * @hide
- */
- @SystemApi
- @Nullable
- public String getEntityId() {
- return mMetadataParcel.entityId;
- }
-
- /**
* Get authenticationPublicKeySecp256r1, which is same as AntiSpoof public key, see
* <a href="https://developers.google.com/nearby/fast-pair/spec#data_format">Data Format</a>.
*
@@ -394,20 +289,6 @@
}
/**
- * Set Nearby Type.
- *
- * @param type Nearby type.
- * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
- * @hide
- */
- @SystemApi
- @NonNull
- public Builder setType(int type) {
- mBuilderParcel.type = type;
- return this;
- }
-
- /**
* Set MacAddress.
*
* @param macAddress Fast Pair device rotating mac address.
@@ -608,35 +489,6 @@
}
/**
- * 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(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @NonNull
- public Builder setAttachmentType(int attachmentType) {
- mBuilderParcel.attachmentType = attachmentType;
- return this;
- }
-
- /**
* Set PackageName.
*
* @param packageName Package name of the App that owns this item.
@@ -651,21 +503,6 @@
}
/**
- * 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(..)}.
- * @hide
- */
- @SystemApi
- @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.
@@ -708,94 +545,6 @@
}
/**
- * Set DebugMessage.
- *
- * @param debugMessage Message written to bugreport for 3P developers.(No sensitive info)
- * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @NonNull
- public Builder setLostMillis(long lostMillis) {
- mBuilderParcel.lostMillis = lostMillis;
- return this;
- }
-
- /**
- * Set LastUserExperience.
- *
- * @param lastUserExperience 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).
- * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
- * @hide
- */
- @SystemApi
- @NonNull
- public Builder setLastUserExperience(int lastUserExperience) {
- mBuilderParcel.lastUserExperience = lastUserExperience;
- return this;
- }
-
- /**
- * Set BleRecordBytes.
- *
- * @param bleRecordBytes The most recent BLE advertisement related to this item. Raw bytes
- * of {@link android.bluetooth.le.ScanRecord}.
- * @return The builder, to facilitate chaining {@code builder.setXXX(..).setXXX(..)}.
- * @hide
- */
- @SystemApi
- @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(..)}.
- * @hide
- */
- @SystemApi
- @NonNull
- public Builder setEntityId(@Nullable String entityId) {
- mBuilderParcel.entityId = entityId;
- return this;
- }
-
- /**
* Set authenticationPublicKeySecp256r1, which is same as AntiSpoof public key, see
* <a href="https://developers.google.com/nearby/fast-pair/spec#data_format">Data Format</a>
*
diff --git a/nearby/framework/java/android/nearby/ScanRequest.java b/nearby/framework/java/android/nearby/ScanRequest.java
index a90b72d..cf2dd43 100644
--- a/nearby/framework/java/android/nearby/ScanRequest.java
+++ b/nearby/framework/java/android/nearby/ScanRequest.java
@@ -44,12 +44,8 @@
/** Scan type for scanning devices using fast pair protocol. */
public static final int SCAN_TYPE_FAST_PAIR = 1;
- /** Scan type for scanning devices using nearby share protocol. */
- public static final int SCAN_TYPE_NEARBY_SHARE = 2;
/** Scan type for scanning devices using nearby presence protocol. */
- public static final int SCAN_TYPE_NEARBY_PRESENCE = 3;
- /** Scan type for scanning devices using exposure notification protocol. */
- public static final int SCAN_TYPE_EXPOSURE_NOTIFICATION = 4;
+ public static final int SCAN_TYPE_NEARBY_PRESENCE = 2;
/** Scan mode uses highest duty cycle. */
public static final int SCAN_MODE_LOW_LATENCY = 2;
@@ -130,9 +126,7 @@
*/
public static boolean isValidScanType(@ScanType int scanType) {
return scanType == SCAN_TYPE_FAST_PAIR
- || scanType == SCAN_TYPE_NEARBY_SHARE
- || scanType == SCAN_TYPE_NEARBY_PRESENCE
- || scanType == SCAN_TYPE_EXPOSURE_NOTIFICATION;
+ || scanType == SCAN_TYPE_NEARBY_PRESENCE;
}
/**
@@ -240,8 +234,7 @@
/** @hide **/
@Retention(RetentionPolicy.SOURCE)
- @IntDef({SCAN_TYPE_FAST_PAIR, SCAN_TYPE_NEARBY_SHARE, SCAN_TYPE_NEARBY_PRESENCE,
- SCAN_TYPE_EXPOSURE_NOTIFICATION})
+ @IntDef({SCAN_TYPE_FAST_PAIR, SCAN_TYPE_NEARBY_PRESENCE})
public @interface ScanType {
}
diff --git a/nearby/framework/java/android/nearby/aidl/FastPairDeviceMetadataParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairDeviceMetadataParcel.aidl
index ef00321..d90f6a1 100644
--- a/nearby/framework/java/android/nearby/aidl/FastPairDeviceMetadataParcel.aidl
+++ b/nearby/framework/java/android/nearby/aidl/FastPairDeviceMetadataParcel.aidl
@@ -49,10 +49,6 @@
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;
@@ -100,31 +96,4 @@
// 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
index 5ba18bb..2cc2daa 100644
--- a/nearby/framework/java/android/nearby/aidl/FastPairDiscoveryItemParcel.aidl
+++ b/nearby/framework/java/android/nearby/aidl/FastPairDiscoveryItemParcel.aidl
@@ -26,8 +26,6 @@
// 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;
@@ -72,19 +70,9 @@
// 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.
@@ -100,27 +88,6 @@
// 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/aidl/FastPairManageAccountDeviceRequestParcel.aidl b/nearby/framework/java/android/nearby/aidl/FastPairManageAccountDeviceRequestParcel.aidl
index 82cf550..59834b2 100644
--- a/nearby/framework/java/android/nearby/aidl/FastPairManageAccountDeviceRequestParcel.aidl
+++ b/nearby/framework/java/android/nearby/aidl/FastPairManageAccountDeviceRequestParcel.aidl
@@ -31,6 +31,4 @@
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/halfsheet/res/values-as/strings.xml b/nearby/halfsheet/res/values-as/strings.xml
new file mode 100644
index 0000000..8ff4946
--- /dev/null
+++ b/nearby/halfsheet/res/values-as/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"ছেটআপ আৰম্ভ কৰি থকা হৈছে…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"ডিভাইচ ছেট আপ কৰক"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"ডিভাইচ সংযোগ কৰা হ’ল"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"সংযোগ কৰিব পৰা নগ’ল"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"হ’ল"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"ছেভ কৰক"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"সংযোগ কৰক"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"ছেট আপ কৰক"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"ছেটিং"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-az/strings.xml b/nearby/halfsheet/res/values-az/strings.xml
new file mode 100644
index 0000000..af499ef
--- /dev/null
+++ b/nearby/halfsheet/res/values-az/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Ayarlama başladılır…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Cihazı quraşdırın"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Cihaz qoşulub"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Qoşulmaq mümkün olmadı"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Oldu"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Saxlayın"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Qoşun"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Ayarlayın"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Ayarlar"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-b+sr+Latn/strings.xml b/nearby/halfsheet/res/values-b+sr+Latn/strings.xml
new file mode 100644
index 0000000..eea6b64
--- /dev/null
+++ b/nearby/halfsheet/res/values-b+sr+Latn/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Podešavanje se pokreće…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Podesite uređaj"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Uređaj je povezan"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Povezivanje nije uspelo"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Gotovo"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Sačuvaj"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Poveži"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Podesi"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Podešavanja"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-bs/strings.xml b/nearby/halfsheet/res/values-bs/strings.xml
new file mode 100644
index 0000000..5a3de8f
--- /dev/null
+++ b/nearby/halfsheet/res/values-bs/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Pokretanje postavljanja…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Postavi uređaj"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Uređaj je povezan"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Povezivanje nije uspjelo"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Gotovo"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Spremi"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Poveži"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Postavi"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Postavke"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-de/strings.xml b/nearby/halfsheet/res/values-de/strings.xml
new file mode 100644
index 0000000..9186a44
--- /dev/null
+++ b/nearby/halfsheet/res/values-de/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Einrichtung wird gestartet..."</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Gerät einrichten"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Gerät verbunden"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Verbindung nicht möglich"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Fertig"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Speichern"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Verbinden"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Einrichten"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Einstellungen"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-en-rAU/strings.xml b/nearby/halfsheet/res/values-en-rAU/strings.xml
new file mode 100644
index 0000000..d4ed675
--- /dev/null
+++ b/nearby/halfsheet/res/values-en-rAU/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Starting setup…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Set up device"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Device connected"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Couldn\'t connect"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Done"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Save"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Connect"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Set up"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Settings"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-en-rCA/strings.xml b/nearby/halfsheet/res/values-en-rCA/strings.xml
new file mode 100644
index 0000000..d4ed675
--- /dev/null
+++ b/nearby/halfsheet/res/values-en-rCA/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Starting setup…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Set up device"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Device connected"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Couldn\'t connect"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Done"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Save"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Connect"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Set up"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Settings"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-en-rGB/strings.xml b/nearby/halfsheet/res/values-en-rGB/strings.xml
new file mode 100644
index 0000000..d4ed675
--- /dev/null
+++ b/nearby/halfsheet/res/values-en-rGB/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Starting setup…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Set up device"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Device connected"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Couldn\'t connect"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Done"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Save"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Connect"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Set up"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Settings"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-en-rIN/strings.xml b/nearby/halfsheet/res/values-en-rIN/strings.xml
new file mode 100644
index 0000000..d4ed675
--- /dev/null
+++ b/nearby/halfsheet/res/values-en-rIN/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Starting setup…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Set up device"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Device connected"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Couldn\'t connect"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Done"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Save"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Connect"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Set up"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Settings"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-en-rXC/strings.xml b/nearby/halfsheet/res/values-en-rXC/strings.xml
new file mode 100644
index 0000000..460cc1b
--- /dev/null
+++ b/nearby/halfsheet/res/values-en-rXC/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Starting Setup…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Set up device"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Device connected"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Couldn\'t connect"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Done"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Save"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Connect"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Set up"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Settings"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-gu/strings.xml b/nearby/halfsheet/res/values-gu/strings.xml
new file mode 100644
index 0000000..03b057d
--- /dev/null
+++ b/nearby/halfsheet/res/values-gu/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"સેટઅપ શરૂ કરી રહ્યાં છીએ…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"ડિવાઇસનું સેટઅપ કરો"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"ડિવાઇસ કનેક્ટ કર્યું"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"કનેક્ટ કરી શક્યા નથી"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"થઈ ગયું"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"સાચવો"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"કનેક્ટ કરો"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"સેટઅપ કરો"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"સેટિંગ"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-hi/strings.xml b/nearby/halfsheet/res/values-hi/strings.xml
new file mode 100644
index 0000000..ecd420e
--- /dev/null
+++ b/nearby/halfsheet/res/values-hi/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"सेट अप शुरू किया जा रहा है…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"डिवाइस सेट अप करें"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"डिवाइस कनेक्ट हो गया"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"कनेक्ट नहीं किया जा सका"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"हो गया"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"सेव करें"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"कनेक्ट करें"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"सेट अप करें"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"सेटिंग"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-hr/strings.xml b/nearby/halfsheet/res/values-hr/strings.xml
new file mode 100644
index 0000000..5a3de8f
--- /dev/null
+++ b/nearby/halfsheet/res/values-hr/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Pokretanje postavljanja…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Postavi uređaj"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Uređaj je povezan"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Povezivanje nije uspjelo"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Gotovo"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Spremi"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Poveži"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Postavi"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Postavke"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-kn/strings.xml b/nearby/halfsheet/res/values-kn/strings.xml
new file mode 100644
index 0000000..fb62bb1
--- /dev/null
+++ b/nearby/halfsheet/res/values-kn/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"ಸೆಟಪ್ ಪ್ರಾರಂಭಿಸಲಾಗುತ್ತಿದೆ…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"ಸಾಧನವನ್ನು ಸೆಟಪ್ ಮಾಡಿ"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"ಸಾಧನವನ್ನು ಕನೆಕ್ಟ್ ಮಾಡಲಾಗಿದೆ"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"ಕನೆಕ್ಟ್ ಮಾಡಲು ಸಾಧ್ಯವಾಗಲಿಲ್ಲ"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"ಮುಗಿದಿದೆ"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"ಉಳಿಸಿ"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"ಕನೆಕ್ಟ್ ಮಾಡಿ"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"ಸೆಟಪ್ ಮಾಡಿ"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"ಸೆಟ್ಟಿಂಗ್ಗಳು"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-mk/strings.xml b/nearby/halfsheet/res/values-mk/strings.xml
new file mode 100644
index 0000000..e29dfa1
--- /dev/null
+++ b/nearby/halfsheet/res/values-mk/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Се започнува со поставување…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Поставете го уредот"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Уредот е поврзан"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Не може да се поврзе"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Готово"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Зачувај"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Поврзи"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Поставете"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Поставки"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-ml/strings.xml b/nearby/halfsheet/res/values-ml/strings.xml
new file mode 100644
index 0000000..cbc171b
--- /dev/null
+++ b/nearby/halfsheet/res/values-ml/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"സജ്ജീകരിക്കൽ ആരംഭിക്കുന്നു…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"ഉപകരണം സജ്ജീകരിക്കുക"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"ഉപകരണം കണക്റ്റ് ചെയ്തു"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"കണക്റ്റ് ചെയ്യാനായില്ല"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"പൂർത്തിയായി"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"സംരക്ഷിക്കുക"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"കണക്റ്റ് ചെയ്യുക"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"സജ്ജീകരിക്കുക"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"ക്രമീകരണം"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-mn/strings.xml b/nearby/halfsheet/res/values-mn/strings.xml
new file mode 100644
index 0000000..6d21eff
--- /dev/null
+++ b/nearby/halfsheet/res/values-mn/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Тохируулгыг эхлүүлж байна…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Төхөөрөмж тохируулах"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Төхөөрөмж холбогдсон"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Холбогдож чадсангүй"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Болсон"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Хадгалах"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Холбох"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Тохируулах"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Тохиргоо"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-ms/strings.xml b/nearby/halfsheet/res/values-ms/strings.xml
new file mode 100644
index 0000000..4835c1b
--- /dev/null
+++ b/nearby/halfsheet/res/values-ms/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Memulakan Persediaan…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Sediakan peranti"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Peranti disambungkan"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Tidak dapat menyambung"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Selesai"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Simpan"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Sambung"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Sediakan"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Tetapan"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-ro/strings.xml b/nearby/halfsheet/res/values-ro/strings.xml
new file mode 100644
index 0000000..5b50f15
--- /dev/null
+++ b/nearby/halfsheet/res/values-ro/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Începe configurarea…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Configurați dispozitivul"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Dispozitivul s-a conectat"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Nu s-a putut conecta"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Gata"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Salvați"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Conectați"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Configurați"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Setări"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-sr/strings.xml b/nearby/halfsheet/res/values-sr/strings.xml
new file mode 100644
index 0000000..094be03
--- /dev/null
+++ b/nearby/halfsheet/res/values-sr/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Подешавање се покреће…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Подесите уређај"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Уређај је повезан"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Повезивање није успело"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Готово"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Сачувај"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Повежи"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Подеси"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Подешавања"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-te/strings.xml b/nearby/halfsheet/res/values-te/strings.xml
new file mode 100644
index 0000000..87be145
--- /dev/null
+++ b/nearby/halfsheet/res/values-te/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"సెటప్ ప్రారంభమవుతోంది…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"పరికరాన్ని సెటప్ చేయండి"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"పరికరం కనెక్ట్ చేయబడింది"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"కనెక్ట్ చేయడం సాధ్యపడలేదు"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"పూర్తయింది"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"సేవ్ చేయండి"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"కనెక్ట్ చేయండి"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"సెటప్ చేయండి"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"సెట్టింగ్లు"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-th/strings.xml b/nearby/halfsheet/res/values-th/strings.xml
new file mode 100644
index 0000000..bc4296b
--- /dev/null
+++ b/nearby/halfsheet/res/values-th/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"กำลังเริ่มการตั้งค่า…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"ตั้งค่าอุปกรณ์"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"เชื่อมต่ออุปกรณ์แล้ว"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"เชื่อมต่อไม่ได้"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"เสร็จสิ้น"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"บันทึก"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"เชื่อมต่อ"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"ตั้งค่า"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"การตั้งค่า"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-tl/strings.xml b/nearby/halfsheet/res/values-tl/strings.xml
new file mode 100644
index 0000000..a6de0e8
--- /dev/null
+++ b/nearby/halfsheet/res/values-tl/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Sinisimulan ang Pag-set Up…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"I-set up ang device"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Naikonekta na ang device"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Hindi makakonekta"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Tapos na"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"I-save"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Kumonekta"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"I-set up"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Mga Setting"</string>
+</resources>
diff --git a/nearby/halfsheet/res/values-zu/strings.xml b/nearby/halfsheet/res/values-zu/strings.xml
new file mode 100644
index 0000000..33fb405
--- /dev/null
+++ b/nearby/halfsheet/res/values-zu/strings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="fast_pair_setup_in_progress" msgid="4158762239172829807">"Iqalisa Ukusetha…"</string>
+ <string name="fast_pair_title_setup" msgid="2894360355540593246">"Setha idivayisi"</string>
+ <string name="fast_pair_device_ready" msgid="2903490346082833101">"Idivayisi ixhunyiwe"</string>
+ <string name="fast_pair_title_fail" msgid="5677174346601290232">"Ayikwazanga ukuxhuma"</string>
+ <string name="paring_action_done" msgid="6888875159174470731">"Kwenziwe"</string>
+ <string name="paring_action_save" msgid="6259357442067880136">"Londoloza"</string>
+ <string name="paring_action_connect" msgid="4801102939608129181">"Xhuma"</string>
+ <string name="paring_action_launch" msgid="8940808384126591230">"Setha"</string>
+ <string name="paring_action_settings" msgid="424875657242864302">"Amasethingi"</string>
+</resources>
diff --git a/nearby/halfsheet/src/com/android/nearby/halfsheet/utils/FastPairUtils.java b/nearby/halfsheet/src/com/android/nearby/halfsheet/utils/FastPairUtils.java
index 903ea90..00a365c 100644
--- a/nearby/halfsheet/src/com/android/nearby/halfsheet/utils/FastPairUtils.java
+++ b/nearby/halfsheet/src/com/android/nearby/halfsheet/utils/FastPairUtils.java
@@ -85,7 +85,6 @@
.setId(item.getModelId())
.setFirstObservationTimestampMillis(item.getFirstObservationTimestampMillis())
.setLastObservationTimestampMillis(item.getLastObservationTimestampMillis())
- .setType(Cache.NearbyType.NEARBY_DEVICE)
.setActionUrl(item.getActionUrl())
.setActionUrlType(Cache.ResolvedUrlType.APP)
.setTitle(
diff --git a/nearby/service/java/com/android/server/nearby/common/ble/util/RangingUtils.java b/nearby/service/java/com/android/server/nearby/common/ble/util/RangingUtils.java
index 321e125..eec52ad 100644
--- a/nearby/service/java/com/android/server/nearby/common/ble/util/RangingUtils.java
+++ b/nearby/service/java/com/android/server/nearby/common/ble/util/RangingUtils.java
@@ -23,12 +23,19 @@
* square of the frequency of the propagation signal.
*/
public final class RangingUtils {
- /*
- * Key to variable names used in this class (viz. Physics):
+ private static final int MAX_RSSI_VALUE = 126;
+ private static final int MIN_RSSI_VALUE = -127;
+
+ private RangingUtils() {
+ }
+
+ /* This was original derived in {@link com.google.android.gms.beacon.util.RangingUtils} from
+ * <a href="http://en.wikipedia.org/wiki/Free-space_path_loss">Free-space_path_loss</a>.
+ * Duplicated here for easy reference.
*
* c = speed of light (2.9979 x 10^8 m/s);
* f = frequency (Bluetooth center frequency is 2.44175GHz = 2.44175x10^9 Hz);
- * l = wavelength (meters);
+ * l = wavelength (in meters);
* d = distance (from transmitter to receiver in meters);
* dB = decibels
* dBm = decibel milliwatts
@@ -40,124 +47,115 @@
*
* FSPL = (4 * pi * d / l)^2 = (4 * pi * d * f / c)^2
*
- * FSPL (dB) = 10*log10((4 * pi * d * f / c)^2)
- * = 20*log10(4 * pi * d * f / c)
- * = 20*log10(d) + 20*log10(f) + 20*log10(4*pi/c)
+ * FSPL (dB) = 10 * log10((4 * pi * d * f / c)^2)
+ * = 20 * log10(4 * pi * d * f / c)
+ * = (20 * log10(d)) + (20 * log10(f)) + (20 * log10(4 * pi/c))
*
* Calculating constants:
*
- * FSPL_FREQ = 20*log10(f)
- * = 20*log10(2.44175 * 10^9)
+ * FSPL_FREQ = 20 * log10(f)
+ * = 20 * log10(2.44175 * 10^9)
* = 187.75
*
- * FSPL_LIGHT = 20*log10(4*pi/c)
- * = 20*log10(4*pi/(2.9979*10^8))
+ * FSPL_LIGHT = 20 * log10(4 * pi/c)
+ * = 20 * log10(4 * pi/(2.9979 * 10^8))
+ * = 20 * log10(4 * pi/(2.9979 * 10^8))
+ * = 20 * log10(41.9172441s * 10^-9)
* = -147.55
*
- * FSPL_DISTANCE_1M = 20*log10(1m)
+ * FSPL_DISTANCE_1M = 20 * log10(1)
* = 0
*
* PATH_LOSS_AT_1M = FSPL_DISTANCE_1M + FSPL_FREQ + FSPL_LIGHT
- * = 0 + 187.75 + (-147.55)
- * = 40.20 [round to 41]
+ * = 0 + 187.75 + (-147.55)
+ * = 40.20db [round to 41db]
*
- * Note that PATH_LOSS_AT_1M is rounded to 41 instead to the more natural 40. The first version
- * of this file had a typo that caused the value to be close to 41; when this was discovered,
- * the value 41 was already used in many places, and it was more important to be consistent
- * rather than exact.
- *
- * Given this we can work out a formula for distance from a given RSSI (received signal strength
- * indicator) and a given value for the expected strength at one meter from the beacon (aka
- * calibrated transmission power). Both values are in dBm.
- *
- * FSPL = 20*log10(d) + PATH_LOSS_AT_1M = full_power - RSSI
- * 20*log10(d) + PATH_LOSS_AT_1M = power_at_1m + PATH_LOSS_AT_1M - RSSI
- * 20*log10(d) = power_at_1m - RSSI
- * log10(d) = (power_at_1m - RSSI) / 20
- * d = 10 ^ ((power_at_1m - RSSI) / 20)
- *
- * Note: because of how logarithms work, units get a bit funny. If you take a two values x and y
- * whose units are dBm, the value of x - y has units of dB, not dBm. Similarly, if x is dBm and
- * y is in dB, then x - y will be in dBm.
+ * Note: Rounding up makes us "closer" and makes us more aggressive at showing notifications.
*/
-
- /* (dBm) PATH_LOSS at 1m for isotropic antenna transmitting BLE */
- public static final int PATH_LOSS_AT_1M = 41;
-
- /** Different region categories, based on distance range. */
- public static final class Region {
-
- public static final int UNKNOWN = -1;
- public static final int NEAR = 0;
- public static final int MID = 1;
- public static final int FAR = 2;
-
- private Region() {}
- }
-
- // Cutoff distances between different regions.
- public static final double NEAR_TO_MID_METERS = 0.5;
- public static final double MID_TO_FAR_METERS = 2.0;
-
- public static final int DEFAULT_CALIBRATED_TX_POWER = -77;
-
- private RangingUtils() {}
+ private static final int RSSI_DROP_OFF_AT_1_M = 41;
/**
- * Convert RSSI to path loss using the free space path loss equation. See <a
- * href="http://en.wikipedia.org/wiki/Free-space_path_loss">Free-space_path_loss</a>
+ * Convert target distance and txPower to a RSSI value using the Log-distance path loss model
+ * with Path Loss at 1m of 41db.
*
- * @param rssi Received Signal Strength Indication (RSSI) in dBm
- * @param calibratedTxPower the calibrated power of the transmitter (dBm) at 1 meter
- * @return The calculated path loss.
+ * @return RSSI expected at distanceInMeters with device broadcasting at txPower.
*/
- public static int pathLossFromRssi(int rssi, int calibratedTxPower) {
- return calibratedTxPower + PATH_LOSS_AT_1M - rssi;
- }
-
- /**
- * Convert RSSI to distance using the free space path loss equation. See <a
- * href="http://en.wikipedia.org/wiki/Free-space_path_loss">Free-space_path_loss</a>
- *
- * @param rssi Received Signal Strength Indication (RSSI) in dBm
- * @param calibratedTxPower the calibrated power of the transmitter (dBm) at 1 meter
- * @return the distance at which that rssi value would occur in meters
- */
- public static double distanceFromRssi(int rssi, int calibratedTxPower) {
- return Math.pow(10, (calibratedTxPower - rssi) / 20.0);
- }
-
- /**
- * Determine the region of a beacon given its perceived distance.
- *
- * @param distance The measured distance in meters.
- * @return the region as one of the constants in {@link Region}.
- */
- public static int regionFromDistance(double distance) {
- if (distance < 0) {
- return Region.UNKNOWN;
- }
- if (distance <= NEAR_TO_MID_METERS) {
- return Region.NEAR;
- }
- if (distance <= MID_TO_FAR_METERS) {
- return Region.MID;
- }
- return Region.FAR;
- }
-
- /**
- * Convert distance to RSSI using the free space path loss equation. See <a
- * href="http://en.wikipedia.org/wiki/Free-space_path_loss">Free-space_path_loss</a>
- *
- * @param distanceInMeters distance in meters (m)
- * @param calibratedTxPower transmitted power (dBm) calibrated to 1 meter
- * @return the rssi (dBm) that would be measured at that distance
- */
- public static int rssiFromDistance(double distanceInMeters, int calibratedTxPower) {
+ public static int rssiFromTargetDistance(double distanceInMeters, int txPower) {
+ /*
+ * See <a href="https://en.wikipedia.org/wiki/Log-distance_path_loss_model">
+ * Log-distance path loss model</a>.
+ *
+ * PL = total path loss in db
+ * txPower = TxPower in dbm
+ * rssi = Received signal strength in dbm
+ * PL_0 = Path loss at reference distance d_0 {@link RSSI_DROP_OFF_AT_1_M} dbm
+ * d = length of path
+ * d_0 = reference distance (1 m)
+ * gamma = path loss exponent (2 in free space)
+ *
+ * Log-distance path loss (LDPL) formula:
+ *
+ * PL = txPower - rssi = PL_0 + 10 * gamma * log_10(d / d_0)
+ * txPower - rssi = RSSI_DROP_OFF_AT_1_M + 10 * 2 * log_10
+ * (distanceInMeters / 1)
+ * - rssi = -txPower + RSSI_DROP_OFF_AT_1_M + 20 * log_10(distanceInMeters)
+ * rssi = txPower - RSSI_DROP_OFF_AT_1_M - 20 * log_10(distanceInMeters)
+ */
+ txPower = adjustPower(txPower);
return distanceInMeters == 0
- ? calibratedTxPower + PATH_LOSS_AT_1M
- : (int) (calibratedTxPower - (20 * Math.log10(distanceInMeters)));
+ ? txPower
+ : (int) Math.floor((txPower - RSSI_DROP_OFF_AT_1_M)
+ - 20 * Math.log10(distanceInMeters));
+ }
+
+ /**
+ * Convert RSSI and txPower to a distance value using the Log-distance path loss model with Path
+ * Loss at 1m of 41db.
+ *
+ * @return distance in meters with device broadcasting at txPower and given RSSI.
+ */
+ public static double distanceFromRssiAndTxPower(int rssi, int txPower) {
+ /*
+ * See <a href="https://en.wikipedia.org/wiki/Log-distance_path_loss_model">Log-distance
+ * path
+ * loss model</a>.
+ *
+ * PL = total path loss in db
+ * txPower = TxPower in dbm
+ * rssi = Received signal strength in dbm
+ * PL_0 = Path loss at reference distance d_0 {@link RSSI_DROP_OFF_AT_1_M} dbm
+ * d = length of path
+ * d_0 = reference distance (1 m)
+ * gamma = path loss exponent (2 in free space)
+ *
+ * Log-distance path loss (LDPL) formula:
+ *
+ * PL = txPower - rssi = PL_0 + 10 * gamma * log_10(d /
+ * d_0)
+ * txPower - rssi = RSSI_DROP_OFF_AT_1_M + 10 * gamma * log_10(d /
+ * d_0)
+ * txPower - rssi - RSSI_DROP_OFF_AT_1_M = 10 * 2 * log_10
+ * (distanceInMeters / 1)
+ * txPower - rssi - RSSI_DROP_OFF_AT_1_M = 20 * log_10(distanceInMeters / 1)
+ * (txPower - rssi - RSSI_DROP_OFF_AT_1_M) / 20 = log_10(distanceInMeters)
+ * 10 ^ ((txPower - rssi - RSSI_DROP_OFF_AT_1_M) / 20) = distanceInMeters
+ */
+ txPower = adjustPower(txPower);
+ rssi = adjustPower(rssi);
+ return Math.pow(10, (txPower - rssi - RSSI_DROP_OFF_AT_1_M) / 20.0);
+ }
+
+ /**
+ * Prevents the power from becoming too large or too small.
+ */
+ private static int adjustPower(int power) {
+ if (power > MAX_RSSI_VALUE) {
+ return MAX_RSSI_VALUE;
+ }
+ if (power < MIN_RSSI_VALUE) {
+ return MIN_RSSI_VALUE;
+ }
+ return power;
}
}
diff --git a/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java b/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
index b175234..2ecce47 100644
--- a/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
+++ b/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
@@ -27,7 +27,9 @@
import android.nearby.NearbyDevice;
import android.util.Log;
+import com.android.internal.annotations.VisibleForTesting;
import com.android.server.nearby.common.ble.decode.FastPairDecoder;
+import com.android.server.nearby.common.ble.util.RangingUtils;
import com.android.server.nearby.common.bloomfilter.BloomFilter;
import com.android.server.nearby.common.bloomfilter.FastPairBloomFilterHasher;
import com.android.server.nearby.common.locator.Locator;
@@ -52,6 +54,8 @@
String mBleAddress;
// Need to be deleted after notification manager in use.
private boolean mIsFirst = false;
+ private FastPairDataProvider mPairDataProvider;
+ private static final double NEARBY_DISTANCE_THRESHOLD = 0.6;
/** The types about how the bloomfilter is processed. */
public enum ProcessBloomFilterType {
@@ -68,6 +72,12 @@
mContext = context;
}
+ @VisibleForTesting
+ FastPairAdvHandler(Context context, FastPairDataProvider dataProvider) {
+ mContext = context;
+ mPairDataProvider = dataProvider;
+ }
+
/**
* Handles all of the scanner result. Fast Pair will handle model id broadcast bloomfilter
* broadcast and battery level broadcast.
@@ -75,23 +85,33 @@
public void handleBroadcast(NearbyDevice device) {
FastPairDevice fastPairDevice = (FastPairDevice) device;
mBleAddress = fastPairDevice.getBluetoothAddress();
- FastPairDataProvider dataProvider = FastPairDataProvider.getInstance();
- if (dataProvider == null) {
+ if (mPairDataProvider == null) {
+ mPairDataProvider = FastPairDataProvider.getInstance();
+ }
+ if (mPairDataProvider == null) {
return;
}
- List<Account> accountList = dataProvider.loadFastPairEligibleAccounts();
+
if (FastPairDecoder.checkModelId(fastPairDevice.getData())) {
byte[] model = FastPairDecoder.getModelId(fastPairDevice.getData());
Log.d(TAG, "On discovery model id " + Hex.bytesToStringLowercase(model));
// Use api to get anti spoofing key from model id.
try {
+ List<Account> accountList = mPairDataProvider.loadFastPairEligibleAccounts();
Rpcs.GetObservedDeviceResponse response =
- dataProvider.loadFastPairAntispoofKeyDeviceMetadata(model);
+ mPairDataProvider.loadFastPairAntispoofKeyDeviceMetadata(model);
if (response == null) {
Log.e(TAG, "server does not have model id "
+ Hex.bytesToStringLowercase(model));
return;
}
+ // Check the distance of the device if the distance is larger than the threshold
+ // do not show half sheet.
+ if (!isNearby(fastPairDevice.getRssi(),
+ response.getDevice().getBleTxPower() == 0 ? fastPairDevice.getTxPower()
+ : response.getDevice().getBleTxPower())) {
+ return;
+ }
Locator.get(mContext, FastPairHalfSheetManager.class).showHalfSheet(
DataUtils.toScanFastPairStoreItem(
response, mBleAddress,
@@ -102,6 +122,7 @@
} else {
// Start to process bloom filter
try {
+ List<Account> accountList = mPairDataProvider.loadFastPairEligibleAccounts();
byte[] bloomFilterByteArray = FastPairDecoder
.getBloomFilter(fastPairDevice.getData());
byte[] bloomFilterSalt = FastPairDecoder
@@ -111,7 +132,7 @@
}
for (Account account : accountList) {
List<Data.FastPairDeviceWithAccountKey> listDevices =
- dataProvider.loadFastPairDeviceWithAccountKey(account);
+ mPairDataProvider.loadFastPairDeviceWithAccountKey(account);
Data.FastPairDeviceWithAccountKey recognizedDevice =
findRecognizedDevice(listDevices,
new BloomFilter(bloomFilterByteArray,
@@ -120,6 +141,15 @@
if (recognizedDevice != null) {
Log.d(TAG, "find matched device show notification to remind"
+ " user to pair");
+ // Check the distance of the device if the distance is larger than the
+ // threshold
+ // do not show half sheet.
+ if (!isNearby(fastPairDevice.getRssi(),
+ recognizedDevice.getDiscoveryItem().getTxPower() == 0
+ ? fastPairDevice.getTxPower()
+ : recognizedDevice.getDiscoveryItem().getTxPower())) {
+ return;
+ }
// Check if the device is already paired
List<Cache.StoredFastPairItem> storedFastPairItemList =
Locator.get(mContext, FastPairCacheManager.class)
@@ -141,8 +171,9 @@
// Get full info from api the initial request will only return
// part of the info due to size limit.
List<Data.FastPairDeviceWithAccountKey> resList =
- dataProvider.loadFastPairDeviceWithAccountKey(account,
- List.of(recognizedDevice.getAccountKey().toByteArray()));
+ mPairDataProvider.loadFastPairDeviceWithAccountKey(account,
+ List.of(recognizedDevice.getAccountKey()
+ .toByteArray()));
if (resList != null && resList.size() > 0) {
//Saved device from footprint does not have ble address so
// fill ble address with current scan result.
@@ -154,7 +185,7 @@
Locator.get(mContext, FastPairController.class).pair(
new DiscoveryItem(mContext, storedDiscoveryItem),
resList.get(0).getAccountKey().toByteArray(),
- /** companionApp=*/ null);
+ /** companionApp=*/null);
}
}
}
@@ -212,4 +243,11 @@
return null;
}
+ /**
+ * Check the device distance for certain rssi value.
+ */
+ boolean isNearby(int rssi, int txPower) {
+ return RangingUtils.distanceFromRssiAndTxPower(rssi, txPower) < NEARBY_DISTANCE_THRESHOLD;
+ }
+
}
diff --git a/nearby/service/java/com/android/server/nearby/fastpair/FastPairManager.java b/nearby/service/java/com/android/server/nearby/fastpair/FastPairManager.java
index 16c04de..2d7cba9 100644
--- a/nearby/service/java/com/android/server/nearby/fastpair/FastPairManager.java
+++ b/nearby/service/java/com/android/server/nearby/fastpair/FastPairManager.java
@@ -103,8 +103,9 @@
private final BroadcastReceiver mScreenBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
- Log.d(TAG, "onReceive: ACTION_SCREEN_ON.");
+ if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)
+ || intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
+ Log.d(TAG, "onReceive: ACTION_SCREEN_ON or boot complete.");
invalidateScan();
} else if (intent.getAction().equals(BluetoothDevice.ACTION_BOND_STATE_CHANGED)) {
processBluetoothConnectionEvent(intent);
@@ -149,6 +150,7 @@
mIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
mIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
mIntentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
+ mIntentFilter.addAction(Intent.ACTION_BOOT_COMPLETED);
mLocatorContextWrapper.getContext()
.registerReceiver(mScreenBroadcastReceiver, mIntentFilter);
diff --git a/nearby/service/java/com/android/server/nearby/fastpair/cache/DiscoveryItem.java b/nearby/service/java/com/android/server/nearby/fastpair/cache/DiscoveryItem.java
index b8a9796..6065f99 100644
--- a/nearby/service/java/com/android/server/nearby/fastpair/cache/DiscoveryItem.java
+++ b/nearby/service/java/com/android/server/nearby/fastpair/cache/DiscoveryItem.java
@@ -47,7 +47,7 @@
*/
public class DiscoveryItem implements Comparable<DiscoveryItem> {
- private static final String ACTION_FAST_PAIR =
+ private static final String ACTION_FAST_PAIR =
"com.android.server.nearby:ACTION_FAST_PAIR";
private static final int BEACON_STALENESS_MILLIS = 120000;
private static final int ITEM_EXPIRATION_MILLIS = 20000;
@@ -66,14 +66,15 @@
Cache.StoredDiscoveryItem.State.STATE_DISABLED_BY_SYSTEM_VALUE
})
@Retention(RetentionPolicy.SOURCE)
- public @interface ItemState {}
+ public @interface ItemState {
+ }
public DiscoveryItem(LocatorContextWrapper locatorContextWrapper,
Cache.StoredDiscoveryItem mStoredDiscoveryItem) {
this.mFastPairCacheManager =
locatorContextWrapper.getLocator().get(FastPairCacheManager.class);
this.mClock =
- locatorContextWrapper.getLocator().get(Clock.class);
+ locatorContextWrapper.getLocator().get(Clock.class);
this.mStoredDiscoveryItem = mStoredDiscoveryItem;
}
@@ -91,23 +92,6 @@
return storedDiscoveryItem.build();
}
- /** @return True if the item is currently nearby. */
- public boolean isNearby() {
- return isNearby(mStoredDiscoveryItem, mClock.millis());
- }
-
- /**
- * Checks if the item is Nearby
- */
- static boolean isNearby(Cache.StoredDiscoveryItem item, long currentTimeMillis) {
- // A notification may disappear early, if we get a lost callback from Messages.
- // But regardless, if we haven't detected the thing in Xmin, consider it gone.
- return !isLost(item)
- && !isExpired(
- currentTimeMillis,
- item.getLastObservationTimestampMillis());
- }
-
/**
* Checks if store discovery item support fast pair or not.
*/
@@ -122,28 +106,6 @@
}
/**
- * Sets the pairing result to done.
- */
- public void setPairingProcessDone(boolean success) {
- setLastUserExperience(success ? Cache.StoredDiscoveryItem.ExperienceType.EXPERIENCE_GOOD
- : Cache.StoredDiscoveryItem.ExperienceType.EXPERIENCE_BAD);
- setLostMillis(mClock.millis());
- Log.d("FastPairDiscovery",
- "FastPair: set Lost when pairing process done, " + getId());
- }
-
- /**
- * Sets the store discovery item lost time.
- */
- public void setLostMillis(long lostMillis) {
- mStoredDiscoveryItem = mStoredDiscoveryItem.toBuilder().setLostMillis(lostMillis).build();
-
- mStoredDiscoveryItem = mStoredDiscoveryItem.toBuilder().clearRssi().build();
-
- mFastPairCacheManager.saveDiscoveryItem(this);
- }
-
- /**
* Sets the store discovery item mac address.
*/
public void setMacAddress(String address) {
@@ -153,28 +115,6 @@
}
/**
- * Sets the user experience to be good or bad.
- */
- public void setLastUserExperience(Cache.StoredDiscoveryItem.ExperienceType experienceType) {
- mStoredDiscoveryItem = mStoredDiscoveryItem.toBuilder()
- .setLastUserExperience(experienceType).build();
- mFastPairCacheManager.saveDiscoveryItem(this);
- }
- /**
- * Gets the user experience to be good or bad.
- */
- public Cache.StoredDiscoveryItem.ExperienceType getLastUserExperience() {
- return mStoredDiscoveryItem.getLastUserExperience();
- }
-
- /**
- * Checks if the item is lost.
- */
- private static boolean isLost(Cache.StoredDiscoveryItem item) {
- return item.getLastObservationTimestampMillis() <= item.getLostMillis();
- }
-
- /**
* Checks if the item is expired. Expired items are those over getItemExpirationMillis() eg. 2
* minutes
*/
@@ -224,39 +164,16 @@
/** Checks if the item has enough data to be shown */
public boolean isReadyForDisplay() {
- if (isOffline()) {
- return true;
- }
boolean hasUrlOrPopularApp = !mStoredDiscoveryItem.getActionUrl().isEmpty();
return !TextUtils.isEmpty(mStoredDiscoveryItem.getTitle()) && hasUrlOrPopularApp;
}
- /** Checks if the item has server error */
- public boolean isDisabledByServer() {
- return mStoredDiscoveryItem.getDebugCategory()
- == Cache.StoredDiscoveryItem.DebugMessageCategory.STATUS_DISABLED_BY_SERVER;
- }
-
- private boolean isOffline() {
- return isOfflineType(getType());
- }
-
- /** Checks if the item can be generated on client side. */
- private static boolean isOfflineType(Cache.NearbyType type) {
- return type == Cache.NearbyType.NEARBY_CHROMECAST || type == Cache.NearbyType.NEARBY_WEAR;
- }
-
/** Checks if the action url is app install */
public boolean isApp() {
return mStoredDiscoveryItem.getActionUrlType() == Cache.ResolvedUrlType.APP;
}
- /** Checks if it's device item. e.g. Chromecast / Wear */
- public boolean isDevice() {
- return isDeviceType(mStoredDiscoveryItem.getType());
- }
-
/** Returns true if an item is muted, or if state is unavailable. */
public boolean isMuted() {
return mStoredDiscoveryItem.getState() != Cache.StoredDiscoveryItem.State.STATE_ENABLED;
@@ -293,25 +210,16 @@
/** Gets hash code of UI related data so we can collapse identical items. */
public int getUiHashCode() {
- switch (mStoredDiscoveryItem.getType()) {
- case NEARBY_CHROMECAST:
- case NEARBY_WEAR:
- // For the special-case device types, show one item per type.
- return Objects.hashCode(mStoredDiscoveryItem.getType());
- case NEARBY_DEVICE:
- case NEARBY_TYPE_UNKNOWN:
- default:
- return Objects.hash(
- mStoredDiscoveryItem.getType(),
+ return Objects.hash(
mStoredDiscoveryItem.getTitle(),
mStoredDiscoveryItem.getDescription(),
mStoredDiscoveryItem.getAppName(),
mStoredDiscoveryItem.getDisplayUrl(),
mStoredDiscoveryItem.getMacAddress());
- }
}
// Getters below
+
/**
* Returns the id of store discovery item.
*/
@@ -321,14 +229,6 @@
}
/**
- * Returns the type of store discovery item.
- */
- @Nullable
- public Cache.NearbyType getType() {
- return mStoredDiscoveryItem.getType();
- }
-
- /**
* Returns the title of discovery item.
*/
@Nullable
@@ -376,7 +276,7 @@
Intent intent = parseIntentScheme(mStoredDiscoveryItem.getActionUrl());
if (intent == null) {
Log.d("FastPairDiscoveryItem", "FastPair: fail to parse action url "
- + mStoredDiscoveryItem.getActionUrl());
+ + mStoredDiscoveryItem.getActionUrl());
return null;
}
return intent.getStringExtra(EXTRA_FAST_PAIR_SECRET);
@@ -407,15 +307,6 @@
return mStoredDiscoveryItem.getPackageName();
}
-
- /**
- * Returns the feature graph url of discovery item.
- */
- @Nullable
- private String getHeroImage() {
- return mStoredDiscoveryItem.getFeatureGraphicUrl();
- }
-
/**
* Returns the action url of discovery item.
*/
@@ -433,14 +324,6 @@
}
/**
- * Returns the ble record of discovery item.
- */
- @Nullable
- public byte[] getBleRecordBytes() {
- return mStoredDiscoveryItem.getBleRecordBytes().toByteArray();
- }
-
- /**
* Returns the TX power of discovery item.
*/
@Nullable
@@ -472,7 +355,7 @@
@Nullable
public Double getEstimatedDistance() {
// In the future, we may want to do a foreground subscription to leverage onDistanceChanged.
- return RangingUtils.distanceFromRssi(mStoredDiscoveryItem.getRssi(),
+ return RangingUtils.distanceFromRssiAndTxPower(mStoredDiscoveryItem.getRssi(),
mStoredDiscoveryItem.getTxPower());
}
@@ -501,15 +384,6 @@
}
/**
- * Gets group id of storedDiscoveryItem.
- */
- @Nullable
- public String getGroupId() {
- return mStoredDiscoveryItem.getGroupId();
- }
-
-
- /**
* Compares this object to the specified object: 1. By device type. Device setups are 'greater
* than' beacons. 2. By relevance. More relevant items are 'greater than' less relevant items.
* 3.By distance. Nearer items are 'greater than' further items.
@@ -518,10 +392,6 @@
*/
@Override
public int compareTo(DiscoveryItem another) {
- if (getType() != another.getType()) {
- // For device type v.s. beacon type, rank device item higher.
- return isDevice() ? 1 : -1;
- }
// For items of the same relevance, compare distance.
Double distance1 = getEstimatedDistance();
Double distance2 = another.getEstimatedDistance();
@@ -531,12 +401,6 @@
return -distance1.compareTo(distance2);
}
-
- public Integer getTriggerIdAttachmentTypeHash() {
- return Objects.hash(mStoredDiscoveryItem.getTriggerId(),
- mStoredDiscoveryItem.getAttachmentType());
- }
-
@Nullable
public String getTriggerId() {
return mStoredDiscoveryItem.getTriggerId();
@@ -558,9 +422,7 @@
@Override
public String toString() {
return String.format(
- "[type=%s], [triggerId=%s], [id=%s], [title=%s], [url=%s], "
- + "[ready=%s], [macAddress=%s]",
- getType().name(),
+ "[triggerId=%s], [id=%s], [title=%s], [url=%s], [ready=%s], [macAddress=%s]",
getTriggerId(),
getId(),
getTitle(),
diff --git a/nearby/service/java/com/android/server/nearby/provider/ChreCommunication.java b/nearby/service/java/com/android/server/nearby/provider/ChreCommunication.java
index 607c579..5077ffe 100644
--- a/nearby/service/java/com/android/server/nearby/provider/ChreCommunication.java
+++ b/nearby/service/java/com/android/server/nearby/provider/ChreCommunication.java
@@ -75,7 +75,7 @@
}
public boolean available() {
- return mInjector.getContextHubManagerAdapter() != null;
+ return mContextHubClient != null;
}
/**
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 22e31cd..0f1c567 100644
--- a/nearby/service/java/com/android/server/nearby/provider/Utils.java
+++ b/nearby/service/java/com/android/server/nearby/provider/Utils.java
@@ -79,31 +79,11 @@
if (metadataParcel.discoveryItem.appName != null) {
storedDiscoveryItemBuilder.setAppName(metadataParcel.discoveryItem.appName);
}
- Cache.DiscoveryAttachmentType attachmentType =
- Cache.DiscoveryAttachmentType.forNumber(
- metadataParcel.discoveryItem.attachmentType);
- if (attachmentType != null) {
- storedDiscoveryItemBuilder.setAttachmentType(attachmentType);
- }
if (metadataParcel.discoveryItem.authenticationPublicKeySecp256r1 != null) {
storedDiscoveryItemBuilder.setAuthenticationPublicKeySecp256R1(
ByteString.copyFrom(
metadataParcel.discoveryItem.authenticationPublicKeySecp256r1));
}
- if (metadataParcel.discoveryItem.bleRecordBytes != null) {
- storedDiscoveryItemBuilder.setBleRecordBytes(
- ByteString.copyFrom(metadataParcel.discoveryItem.bleRecordBytes));
- }
- Cache.StoredDiscoveryItem.DebugMessageCategory debugMessageCategory =
- Cache.StoredDiscoveryItem.DebugMessageCategory.forNumber(
- metadataParcel.discoveryItem.debugCategory);
- if (debugMessageCategory != null) {
- storedDiscoveryItemBuilder.setDebugCategory(debugMessageCategory);
- }
- if (metadataParcel.discoveryItem.debugMessage != null) {
- storedDiscoveryItemBuilder.setDebugMessage(
- metadataParcel.discoveryItem.debugMessage);
- }
if (metadataParcel.discoveryItem.description != null) {
storedDiscoveryItemBuilder.setDescription(
metadataParcel.discoveryItem.description);
@@ -116,19 +96,8 @@
storedDiscoveryItemBuilder.setDisplayUrl(
metadataParcel.discoveryItem.displayUrl);
}
- if (metadataParcel.discoveryItem.entityId != null) {
- storedDiscoveryItemBuilder.setEntityId(
- metadataParcel.discoveryItem.entityId);
- }
- if (metadataParcel.discoveryItem.featureGraphicUrl != null) {
- storedDiscoveryItemBuilder.setFeatureGraphicUrl(
- metadataParcel.discoveryItem.featureGraphicUrl);
- }
storedDiscoveryItemBuilder.setFirstObservationTimestampMillis(
metadataParcel.discoveryItem.firstObservationTimestampMillis);
- if (metadataParcel.discoveryItem.groupId != null) {
- storedDiscoveryItemBuilder.setGroupId(metadataParcel.discoveryItem.groupId);
- }
if (metadataParcel.discoveryItem.iconFifeUrl != null) {
storedDiscoveryItemBuilder.setIconFifeUrl(
metadataParcel.discoveryItem.iconFifeUrl);
@@ -142,13 +111,6 @@
}
storedDiscoveryItemBuilder.setLastObservationTimestampMillis(
metadataParcel.discoveryItem.lastObservationTimestampMillis);
- Cache.StoredDiscoveryItem.ExperienceType experienceType =
- Cache.StoredDiscoveryItem.ExperienceType.forNumber(
- metadataParcel.discoveryItem.lastUserExperience);
- if (experienceType != null) {
- storedDiscoveryItemBuilder.setLastUserExperience(experienceType);
- }
- storedDiscoveryItemBuilder.setLostMillis(metadataParcel.discoveryItem.lostMillis);
if (metadataParcel.discoveryItem.macAddress != null) {
storedDiscoveryItemBuilder.setMacAddress(
metadataParcel.discoveryItem.macAddress);
@@ -173,30 +135,9 @@
storedDiscoveryItemBuilder.setTriggerId(metadataParcel.discoveryItem.triggerId);
}
storedDiscoveryItemBuilder.setTxPower(metadataParcel.discoveryItem.txPower);
- Cache.NearbyType type =
- Cache.NearbyType.forNumber(metadataParcel.discoveryItem.type);
- if (type != null) {
- storedDiscoveryItemBuilder.setType(type);
- }
}
if (metadataParcel.metadata != null) {
FastPairStrings.Builder stringsBuilder = FastPairStrings.newBuilder();
- if (metadataParcel.metadata.assistantSetupHalfSheet != null) {
- stringsBuilder.setAssistantHalfSheetDescription(
- metadataParcel.metadata.assistantSetupHalfSheet);
- }
- if (metadataParcel.metadata.assistantSetupNotification != null) {
- stringsBuilder.setAssistantNotificationDescription(
- metadataParcel.metadata.assistantSetupNotification);
- }
- if (metadataParcel.metadata.confirmPinDescription != null) {
- stringsBuilder.setConfirmPinDescription(
- metadataParcel.metadata.confirmPinDescription);
- }
- if (metadataParcel.metadata.confirmPinTitle != null) {
- stringsBuilder.setConfirmPinTitle(
- metadataParcel.metadata.confirmPinTitle);
- }
if (metadataParcel.metadata.connectSuccessCompanionAppInstalled != null) {
stringsBuilder.setPairingFinishedCompanionAppInstalled(
metadataParcel.metadata.connectSuccessCompanionAppInstalled);
@@ -209,10 +150,6 @@
stringsBuilder.setPairingFailDescription(
metadataParcel.metadata.failConnectGoToSettingsDescription);
}
- if (metadataParcel.metadata.fastPairTvConnectDeviceNoAccountDescription != null) {
- stringsBuilder.setFastPairTvConnectDeviceNoAccountDescription(
- metadataParcel.metadata.fastPairTvConnectDeviceNoAccountDescription);
- }
if (metadataParcel.metadata.initialNotificationDescription != null) {
stringsBuilder.setTapToPairWithAccount(
metadataParcel.metadata.initialNotificationDescription);
@@ -233,21 +170,6 @@
stringsBuilder.setSubsequentPairingDescription(
metadataParcel.metadata.subsequentPairingDescription);
}
- if (metadataParcel.metadata.syncContactsDescription != null) {
- stringsBuilder.setSyncContactsDescription(
- metadataParcel.metadata.syncContactsDescription);
- }
- if (metadataParcel.metadata.syncContactsTitle != null) {
- stringsBuilder.setSyncContactsTitle(
- metadataParcel.metadata.syncContactsTitle);
- }
- if (metadataParcel.metadata.syncSmsDescription != null) {
- stringsBuilder.setSyncSmsDescription(
- metadataParcel.metadata.syncSmsDescription);
- }
- if (metadataParcel.metadata.syncSmsTitle != null) {
- stringsBuilder.setSyncSmsTitle(metadataParcel.metadata.syncSmsTitle);
- }
if (metadataParcel.metadata.waitLaunchCompanionAppDescription != null) {
stringsBuilder.setWaitAppLaunchDescription(
metadataParcel.metadata.waitLaunchCompanionAppDescription);
@@ -357,20 +279,6 @@
}
Rpcs.ObservedDeviceStrings.Builder stringsBuilder = Rpcs.ObservedDeviceStrings.newBuilder();
- if (metadata.deviceMetadata.assistantSetupHalfSheet != null) {
- stringsBuilder
- .setAssistantSetupHalfSheet(metadata.deviceMetadata.assistantSetupHalfSheet);
- }
- if (metadata.deviceMetadata.assistantSetupNotification != null) {
- stringsBuilder.setAssistantSetupNotification(
- metadata.deviceMetadata.assistantSetupNotification);
- }
- if (metadata.deviceMetadata.confirmPinDescription != null) {
- stringsBuilder.setConfirmPinDescription(metadata.deviceMetadata.confirmPinDescription);
- }
- if (metadata.deviceMetadata.confirmPinTitle != null) {
- stringsBuilder.setConfirmPinTitle(metadata.deviceMetadata.confirmPinTitle);
- }
if (metadata.deviceMetadata.connectSuccessCompanionAppInstalled != null) {
stringsBuilder.setConnectSuccessCompanionAppInstalled(
metadata.deviceMetadata.connectSuccessCompanionAppInstalled);
@@ -387,10 +295,6 @@
stringsBuilder.setFailConnectGoToSettingsDescription(
metadata.deviceMetadata.failConnectGoToSettingsDescription);
}
- if (metadata.deviceMetadata.fastPairTvConnectDeviceNoAccountDescription != null) {
- stringsBuilder.setFastPairTvConnectDeviceNoAccountDescription(
- metadata.deviceMetadata.fastPairTvConnectDeviceNoAccountDescription);
- }
if (metadata.deviceMetadata.initialNotificationDescription != null) {
stringsBuilder.setInitialNotificationDescription(
metadata.deviceMetadata.initialNotificationDescription);
@@ -403,9 +307,6 @@
stringsBuilder.setInitialPairingDescription(
metadata.deviceMetadata.initialPairingDescription);
}
- if (metadata.deviceMetadata.locale != null) {
- stringsBuilder.setLocale(metadata.deviceMetadata.locale);
- }
if (metadata.deviceMetadata.openCompanionAppDescription != null) {
stringsBuilder.setOpenCompanionAppDescription(
metadata.deviceMetadata.openCompanionAppDescription);
@@ -418,22 +319,6 @@
stringsBuilder.setSubsequentPairingDescription(
metadata.deviceMetadata.subsequentPairingDescription);
}
- if (metadata.deviceMetadata.syncContactsDescription != null) {
- stringsBuilder.setSyncContactsDescription(
- metadata.deviceMetadata.syncContactsDescription);
- }
- if (metadata.deviceMetadata.syncContactsTitle != null) {
- stringsBuilder.setSyncContactsTitle(
- metadata.deviceMetadata.syncContactsTitle);
- }
- if (metadata.deviceMetadata.syncSmsDescription != null) {
- stringsBuilder.setSyncSmsDescription(
- metadata.deviceMetadata.syncSmsDescription);
- }
- if (metadata.deviceMetadata.syncSmsTitle != null) {
- stringsBuilder.setSyncSmsTitle(
- metadata.deviceMetadata.syncSmsTitle);
- }
if (metadata.deviceMetadata.unableToConnectDescription != null) {
stringsBuilder.setUnableToConnectDescription(
metadata.deviceMetadata.unableToConnectDescription);
@@ -513,28 +398,18 @@
discoveryItemParcel.actionUrl = storedDiscoveryItem.getActionUrl();
discoveryItemParcel.actionUrlType = storedDiscoveryItem.getActionUrlType().getNumber();
discoveryItemParcel.appName = storedDiscoveryItem.getAppName();
- discoveryItemParcel.attachmentType = storedDiscoveryItem.getAttachmentType().getNumber();
discoveryItemParcel.authenticationPublicKeySecp256r1 =
storedDiscoveryItem.getAuthenticationPublicKeySecp256R1().toByteArray();
- discoveryItemParcel.bleRecordBytes = storedDiscoveryItem.getBleRecordBytes().toByteArray();
- discoveryItemParcel.debugCategory = storedDiscoveryItem.getDebugCategory().getNumber();
- discoveryItemParcel.debugMessage = storedDiscoveryItem.getDebugMessage();
discoveryItemParcel.description = storedDiscoveryItem.getDescription();
discoveryItemParcel.deviceName = storedDiscoveryItem.getDeviceName();
discoveryItemParcel.displayUrl = storedDiscoveryItem.getDisplayUrl();
- discoveryItemParcel.entityId = storedDiscoveryItem.getEntityId();
- discoveryItemParcel.featureGraphicUrl = storedDiscoveryItem.getFeatureGraphicUrl();
discoveryItemParcel.firstObservationTimestampMillis =
storedDiscoveryItem.getFirstObservationTimestampMillis();
- discoveryItemParcel.groupId = storedDiscoveryItem.getGroupId();
discoveryItemParcel.iconFifeUrl = storedDiscoveryItem.getIconFifeUrl();
discoveryItemParcel.iconPng = storedDiscoveryItem.getIconPng().toByteArray();
discoveryItemParcel.id = storedDiscoveryItem.getId();
discoveryItemParcel.lastObservationTimestampMillis =
storedDiscoveryItem.getLastObservationTimestampMillis();
- discoveryItemParcel.lastUserExperience =
- storedDiscoveryItem.getLastUserExperience().getNumber();
- discoveryItemParcel.lostMillis = storedDiscoveryItem.getLostMillis();
discoveryItemParcel.macAddress = storedDiscoveryItem.getMacAddress();
discoveryItemParcel.packageName = storedDiscoveryItem.getPackageName();
discoveryItemParcel.pendingAppInstallTimestampMillis =
@@ -544,7 +419,6 @@
discoveryItemParcel.title = storedDiscoveryItem.getTitle();
discoveryItemParcel.triggerId = storedDiscoveryItem.getTriggerId();
discoveryItemParcel.txPower = storedDiscoveryItem.getTxPower();
- discoveryItemParcel.type = storedDiscoveryItem.getType().getNumber();
return discoveryItemParcel;
}
@@ -564,27 +438,17 @@
FastPairStrings fpStrings = storedDiscoveryItem.getFastPairStrings();
FastPairDeviceMetadataParcel metadataParcel = new FastPairDeviceMetadataParcel();
- metadataParcel.assistantSetupHalfSheet = fpStrings.getAssistantHalfSheetDescription();
- metadataParcel.assistantSetupNotification = fpStrings.getAssistantNotificationDescription();
- metadataParcel.confirmPinDescription = fpStrings.getConfirmPinDescription();
- metadataParcel.confirmPinTitle = fpStrings.getConfirmPinTitle();
metadataParcel.connectSuccessCompanionAppInstalled =
fpStrings.getPairingFinishedCompanionAppInstalled();
metadataParcel.connectSuccessCompanionAppNotInstalled =
fpStrings.getPairingFinishedCompanionAppNotInstalled();
metadataParcel.failConnectGoToSettingsDescription = fpStrings.getPairingFailDescription();
- metadataParcel.fastPairTvConnectDeviceNoAccountDescription =
- fpStrings.getFastPairTvConnectDeviceNoAccountDescription();
metadataParcel.initialNotificationDescription = fpStrings.getTapToPairWithAccount();
metadataParcel.initialNotificationDescriptionNoAccount =
fpStrings.getTapToPairWithoutAccount();
metadataParcel.initialPairingDescription = fpStrings.getInitialPairingDescription();
metadataParcel.retroactivePairingDescription = fpStrings.getRetroactivePairingDescription();
metadataParcel.subsequentPairingDescription = fpStrings.getSubsequentPairingDescription();
- metadataParcel.syncContactsDescription = fpStrings.getSyncContactsDescription();
- metadataParcel.syncContactsTitle = fpStrings.getSyncContactsTitle();
- metadataParcel.syncSmsDescription = fpStrings.getSyncSmsDescription();
- metadataParcel.syncSmsTitle = fpStrings.getSyncSmsTitle();
metadataParcel.waitLaunchCompanionAppDescription = fpStrings.getWaitAppLaunchDescription();
Cache.FastPairInformation fpInformation = storedDiscoveryItem.getFastPairInformation();
diff --git a/nearby/service/java/com/android/server/nearby/util/DataUtils.java b/nearby/service/java/com/android/server/nearby/util/DataUtils.java
index 0b01bc0..8bb83e9 100644
--- a/nearby/service/java/com/android/server/nearby/util/DataUtils.java
+++ b/nearby/service/java/com/android/server/nearby/util/DataUtils.java
@@ -84,12 +84,6 @@
+ fastPairStrings.getRetroactivePairingDescription()
+ ", waitAppLaunchDescription=" + fastPairStrings.getWaitAppLaunchDescription()
+ ", pairingFailDescription=" + fastPairStrings.getPairingFailDescription()
- + ", assistantHalfSheetDescription="
- + fastPairStrings.getAssistantHalfSheetDescription()
- + ", assistantNotificationDescription="
- + fastPairStrings.getAssistantNotificationDescription()
- + ", fastPairTvConnectDeviceNoAccountDescription="
- + fastPairStrings.getFastPairTvConnectDeviceNoAccountDescription()
+ "]";
}
@@ -112,10 +106,6 @@
.setRetroactivePairingDescription(strings.getRetroactivePairingDescription())
.setWaitAppLaunchDescription(strings.getWaitLaunchCompanionAppDescription())
.setPairingFailDescription(strings.getFailConnectGoToSettingsDescription())
- .setAssistantHalfSheetDescription(strings.getAssistantSetupHalfSheet())
- .setAssistantNotificationDescription(strings.getAssistantSetupNotification())
- .setFastPairTvConnectDeviceNoAccountDescription(
- strings.getFastPairTvConnectDeviceNoAccountDescription())
.build();
}
}
diff --git a/nearby/service/proto/src/fastpair/cache.proto b/nearby/service/proto/src/fastpair/cache.proto
index 12731fb..d4c7c3d 100644
--- a/nearby/service/proto/src/fastpair/cache.proto
+++ b/nearby/service/proto/src/fastpair/cache.proto
@@ -112,9 +112,6 @@
string id = 1;
// REQUIRED
- NearbyType type = 2;
-
- // REQUIRED
// The most recent all upper case mac associated with this item.
// (Mac-to-DiscoveryItem is a many-to-many relationship)
string mac_address = 4;
@@ -164,28 +161,18 @@
// Used in the second line of the notification, "Open in {} app"
string app_name = 25;
- // ID used for associating several DiscoveryItems. These items may be
- // visually displayed together.
- string group_id = 26;
-
// The timestamp when the attachment was created on PBS server. In case there
// are duplicate
// items with the same scanId/groupID, only show the one with the latest
// timestamp.
int64 attachment_creation_sec = 28;
- // Whether the attachment is created in debug namespace
- DiscoveryAttachmentType attachment_type = 29;
-
// Package name of the App that owns this item.
string package_name = 30;
// The average star rating of the app.
float star_rating = 31;
- // The "feature" graphic image url used for large sized list view entries.
- string feature_graphic_url = 32;
-
// 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.
@@ -201,27 +188,6 @@
// A FIFE URL of the item icon displayed in Discovery item list.
string icon_fife_url = 49;
- // Message written to bugreport for 3P developers.(No sensitive info)
- // null if the item is valid
- string debug_message = 37;
-
- // Weather the item is filtered out on server.
- DebugMessageCategory debug_category = 38;
-
- // Client timestamp when the trigger (e.g. beacon) was last lost (e.g. when
- // Messages told us the beacon's no longer nearby).
- int64 lost_millis = 41;
-
- // 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).
- ExperienceType last_user_experience = 42;
-
- // The most recent BLE advertisement related to this item.
- bytes ble_record_bytes = 43;
-
- // An ID generated on the server to uniquely identify content.
- string entity_id = 44;
-
// See equivalent field in NearbyItem.
bytes authentication_public_key_secp256r1 = 45;
@@ -235,7 +201,7 @@
FastPairStrings fast_pair_strings = 48;
// Deprecated fields.
- reserved 3, 12, 13, 14, 15, 16, 18, 21, 24, 27, 33, 35, 39, 40;
+ reserved 2, 3, 12, 13, 14, 15, 16, 18, 21, 24, 26, 27, 29, 32, 33, 35, 37, 38, 39, 40, 41, 42, 43, 44;
}
enum ResolvedUrlType {
RESOLVED_URL_TYPE_UNKNOWN = 0;
diff --git a/nearby/service/proto/src/fastpair/fast_pair_string.proto b/nearby/service/proto/src/fastpair/fast_pair_string.proto
index 6dfc19a..f318c1a 100644
--- a/nearby/service/proto/src/fastpair/fast_pair_string.proto
+++ b/nearby/service/proto/src/fastpair/fast_pair_string.proto
@@ -36,30 +36,5 @@
// Description when user fail to pair with device
optional string pairing_fail_description = 9;
- // Title to ask the user to confirm the pin code.
- optional string confirm_pin_title = 10;
-
- // Description to ask the user to confirm the pin code.
- optional string confirm_pin_description = 11;
-
- // The title of the UI to ask the user to confirm to sync contacts.
- optional string sync_contacts_title = 12;
-
- // The description of the UI to ask the user to confirm to sync contacts.
- optional string sync_contacts_description = 13;
-
- // The title of the UI to ask the user to confirm to sync SMS.
- optional string sync_sms_title = 14;
-
- // The description of the UI to ask the user to confirm to sync SMS.
- optional string sync_sms_description = 15;
-
- // The description for half sheet to ask user to setup google assistant.
- optional string assistant_half_sheet_description = 16;
-
- // The description for notification to ask user to setup google assistant.
- optional string assistant_notification_description = 17;
-
- // Description of the connect device action on TV, when user is not logged in.
- optional string fast_pair_tv_connect_device_no_account_description = 18;
+ reserved 10, 11, 12, 13, 14,15, 16, 17, 18;
}
diff --git a/nearby/service/proto/src/fastpair/rpcs.proto b/nearby/service/proto/src/fastpair/rpcs.proto
index 0399d09..bce4378 100644
--- a/nearby/service/proto/src/fastpair/rpcs.proto
+++ b/nearby/service/proto/src/fastpair/rpcs.proto
@@ -234,9 +234,6 @@
// Strings to be displayed in notifications surfaced for a device.
message ObservedDeviceStrings {
- // The locale of all of the strings.
- string locale = 1;
-
// The notification description for when the device is initially discovered.
string initial_notification_description = 2;
@@ -285,32 +282,7 @@
// fail.
string fail_connect_go_to_settings_description = 15;
- // The title of the UI to ask the user to confirm the pin code.
- string confirm_pin_title = 16;
-
- // The description of the UI to ask the user to confirm the pin code.
- string confirm_pin_description = 17;
-
- // The title of the UI to ask the user to confirm to sync contacts.
- string sync_contacts_title = 18;
-
- // The description of the UI to ask the user to confirm to sync contacts.
- string sync_contacts_description = 19;
-
- // The title of the UI to ask the user to confirm to sync SMS.
- string sync_sms_title = 20;
-
- // The description of the UI to ask the user to confirm to sync SMS.
- string sync_sms_description = 21;
-
- // The description in half sheet to ask user setup google assistant
- string assistant_setup_half_sheet = 22;
-
- // The description in notification to ask user setup google assistant
- string assistant_setup_notification = 23;
-
- // Description of the connect device action on TV, when user is not logged in.
- string fast_pair_tv_connect_device_no_account_description = 24;
+ reserved 1, 16, 17, 18, 19, 20, 21, 22, 23, 24;
}
// The buffer size range of a Fast Pair devices support dynamic buffer size.
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairAntispoofKeyDeviceMetadataTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairAntispoofKeyDeviceMetadataTest.java
index 226efbb..65c061b 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairAntispoofKeyDeviceMetadataTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairAntispoofKeyDeviceMetadataTest.java
@@ -105,12 +105,7 @@
/* Verifies DeviceMetadata. */
private static void ensureFastPairDeviceMetadataAsExpected(FastPairDeviceMetadata metadata) {
- assertThat(metadata.getAssistantSetupHalfSheet()).isEqualTo(ASSISTANT_SETUP_HALFSHEET);
- assertThat(metadata.getAssistantSetupNotification())
- .isEqualTo(ASSISTANT_SETUP_NOTIFICATION);
assertThat(metadata.getBleTxPower()).isEqualTo(BLE_TX_POWER);
- assertThat(metadata.getConfirmPinDescription()).isEqualTo(CONFIRM_PIN_DESCRIPTION);
- assertThat(metadata.getConfirmPinTitle()).isEqualTo(CONFIRM_PIN_TITLE);
assertThat(metadata.getConnectSuccessCompanionAppInstalled())
.isEqualTo(CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
assertThat(metadata.getConnectSuccessCompanionAppNotInstalled())
@@ -120,8 +115,6 @@
.isEqualTo(DOWNLOAD_COMPANION_APP_DESCRIPTION);
assertThat(metadata.getFailConnectGoToSettingsDescription())
.isEqualTo(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
- assertThat(metadata.getFastPairTvConnectDeviceNoAccountDescription())
- .isEqualTo(FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
assertThat(metadata.getImage()).isEqualTo(IMAGE);
assertThat(metadata.getImageUrl()).isEqualTo(IMAGE_URL);
assertThat(metadata.getInitialNotificationDescription())
@@ -130,7 +123,6 @@
.isEqualTo(INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT);
assertThat(metadata.getInitialPairingDescription()).isEqualTo(INITIAL_PAIRING_DESCRIPTION);
assertThat(metadata.getIntentUri()).isEqualTo(INTENT_URI);
- assertThat(metadata.getLocale()).isEqualTo(LOCALE);
assertThat(metadata.getName()).isEqualTo(NAME);
assertThat(metadata.getOpenCompanionAppDescription())
.isEqualTo(OPEN_COMPANION_APP_DESCRIPTION);
@@ -138,10 +130,6 @@
.isEqualTo(RETRO_ACTIVE_PAIRING_DESCRIPTION);
assertThat(metadata.getSubsequentPairingDescription())
.isEqualTo(SUBSEQUENT_PAIRING_DESCRIPTION);
- assertThat(metadata.getSyncContactsDescription()).isEqualTo(SYNC_CONTACT_DESCRPTION);
- assertThat(metadata.getSyncContactsTitle()).isEqualTo(SYNC_CONTACTS_TITLE);
- assertThat(metadata.getSyncSmsDescription()).isEqualTo(SYNC_SMS_DESCRIPTION);
- assertThat(metadata.getSyncSmsTitle()).isEqualTo(SYNC_SMS_TITLE);
assertThat(metadata.getTriggerDistance()).isWithin(DELTA).of(TRIGGER_DISTANCE);
assertThat(metadata.getTrueWirelessImageUrlCase()).isEqualTo(TRUE_WIRELESS_IMAGE_URL_CASE);
assertThat(metadata.getTrueWirelessImageUrlLeftBud())
@@ -171,19 +159,13 @@
/* Generates FastPairDeviceMetadata. */
private static FastPairDeviceMetadata genFastPairDeviceMetadata() {
FastPairDeviceMetadata.Builder builder = new FastPairDeviceMetadata.Builder();
- builder.setAssistantSetupHalfSheet(ASSISTANT_SETUP_HALFSHEET);
- builder.setAssistantSetupNotification(ASSISTANT_SETUP_NOTIFICATION);
builder.setBleTxPower(BLE_TX_POWER);
- builder.setConfirmPinDescription(CONFIRM_PIN_DESCRIPTION);
- builder.setConfirmPinTitle(CONFIRM_PIN_TITLE);
builder.setConnectSuccessCompanionAppInstalled(CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
builder.setConnectSuccessCompanionAppNotInstalled(
CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED);
builder.setDeviceType(DEVICE_TYPE);
builder.setDownloadCompanionAppDescription(DOWNLOAD_COMPANION_APP_DESCRIPTION);
builder.setFailConnectGoToSettingsDescription(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
- builder.setFastPairTvConnectDeviceNoAccountDescription(
- FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
builder.setImage(IMAGE);
builder.setImageUrl(IMAGE_URL);
builder.setInitialNotificationDescription(INITIAL_NOTIFICATION_DESCRIPTION);
@@ -191,15 +173,10 @@
INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT);
builder.setInitialPairingDescription(INITIAL_PAIRING_DESCRIPTION);
builder.setIntentUri(INTENT_URI);
- builder.setLocale(LOCALE);
builder.setName(NAME);
builder.setOpenCompanionAppDescription(OPEN_COMPANION_APP_DESCRIPTION);
builder.setRetroactivePairingDescription(RETRO_ACTIVE_PAIRING_DESCRIPTION);
builder.setSubsequentPairingDescription(SUBSEQUENT_PAIRING_DESCRIPTION);
- builder.setSyncContactsDescription(SYNC_CONTACT_DESCRPTION);
- builder.setSyncContactsTitle(SYNC_CONTACTS_TITLE);
- builder.setSyncSmsDescription(SYNC_SMS_DESCRIPTION);
- builder.setSyncSmsTitle(SYNC_SMS_TITLE);
builder.setTriggerDistance(TRIGGER_DISTANCE);
builder.setTrueWirelessImageUrlCase(TRUE_WIRELESS_IMAGE_URL_CASE);
builder.setTrueWirelessImageUrlLeftBud(TRUE_WIRELESS_IMAGE_URL_LEFT_BUD);
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderServiceTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderServiceTest.java
index 171b6e8..160da56 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderServiceTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/FastPairDataProviderServiceTest.java
@@ -577,7 +577,6 @@
new FastPairManageAccountDeviceRequestParcel();
requestParcel.account = MANAGE_ACCOUNT;
requestParcel.requestType = MANAGE_ACCOUNT_REQUEST_TYPE;
- requestParcel.bleAddress = BLE_ADDRESS;
requestParcel.accountKeyDeviceMetadata =
genHappyPathFastPairAccountkeyDeviceMetadataParcel();
@@ -628,24 +627,15 @@
builder.setActionUrl(ACTION_URL);
builder.setActionUrlType(ACTION_URL_TYPE);
builder.setAppName(APP_NAME);
- builder.setAttachmentType(ATTACHMENT_TYPE);
builder.setAuthenticationPublicKeySecp256r1(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
- builder.setBleRecordBytes(BLE_RECORD_BYTES);
- builder.setDebugCategory(DEBUG_CATEGORY);
- builder.setDebugMessage(DEBUG_MESSAGE);
builder.setDescription(DESCRIPTION);
builder.setDeviceName(DEVICE_NAME);
builder.setDisplayUrl(DISPLAY_URL);
- builder.setEntityId(ENTITY_ID);
- builder.setFeatureGraphicUrl(FEATURE_GRAPHIC_URL);
builder.setFirstObservationTimestampMillis(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
- builder.setGroupId(GROUP_ID);
builder.setIconFfeUrl(ICON_FIFE_URL);
builder.setIconPng(ICON_PNG);
builder.setId(ID);
builder.setLastObservationTimestampMillis(LAST_OBSERVATION_TIMESTAMP_MILLIS);
- builder.setLastUserExperience(LAST_USER_EXPERIENCE);
- builder.setLostMillis(LOST_MILLIS);
builder.setMacAddress(MAC_ADDRESS);
builder.setPackageName(PACKAGE_NAME);
builder.setPendingAppInstallTimestampMillis(PENDING_APP_INSTALL_TIMESTAMP_MILLIS);
@@ -654,7 +644,6 @@
builder.setTitle(TITLE);
builder.setTriggerId(TRIGGER_ID);
builder.setTxPower(TX_POWER);
- builder.setType(TYPE);
return builder.build();
}
@@ -666,24 +655,15 @@
parcel.actionUrl = ACTION_URL;
parcel.actionUrlType = ACTION_URL_TYPE;
parcel.appName = APP_NAME;
- parcel.attachmentType = ATTACHMENT_TYPE;
parcel.authenticationPublicKeySecp256r1 = AUTHENTICATION_PUBLIC_KEY_SEC_P256R1;
- parcel.bleRecordBytes = BLE_RECORD_BYTES;
- parcel.debugCategory = DEBUG_CATEGORY;
- parcel.debugMessage = DEBUG_MESSAGE;
parcel.description = DESCRIPTION;
parcel.deviceName = DEVICE_NAME;
parcel.displayUrl = DISPLAY_URL;
- parcel.entityId = ENTITY_ID;
- parcel.featureGraphicUrl = FEATURE_GRAPHIC_URL;
parcel.firstObservationTimestampMillis = FIRST_OBSERVATION_TIMESTAMP_MILLIS;
- parcel.groupId = GROUP_ID;
parcel.iconFifeUrl = ICON_FIFE_URL;
parcel.iconPng = ICON_PNG;
parcel.id = ID;
parcel.lastObservationTimestampMillis = LAST_OBSERVATION_TIMESTAMP_MILLIS;
- parcel.lastUserExperience = LAST_USER_EXPERIENCE;
- parcel.lostMillis = LOST_MILLIS;
parcel.macAddress = MAC_ADDRESS;
parcel.packageName = PACKAGE_NAME;
parcel.pendingAppInstallTimestampMillis = PENDING_APP_INSTALL_TIMESTAMP_MILLIS;
@@ -692,7 +672,6 @@
parcel.title = TITLE;
parcel.triggerId = TRIGGER_ID;
parcel.txPower = TX_POWER;
- parcel.type = TYPE;
return parcel;
}
@@ -700,19 +679,13 @@
/* Generates Happy Path DeviceMetadata. */
private static FastPairDeviceMetadata genHappyPathFastPairDeviceMetadata() {
FastPairDeviceMetadata.Builder builder = new FastPairDeviceMetadata.Builder();
- builder.setAssistantSetupHalfSheet(ASSISTANT_SETUP_HALFSHEET);
- builder.setAssistantSetupNotification(ASSISTANT_SETUP_NOTIFICATION);
builder.setBleTxPower(BLE_TX_POWER);
- builder.setConfirmPinDescription(CONFIRM_PIN_DESCRIPTION);
- builder.setConfirmPinTitle(CONFIRM_PIN_TITLE);
builder.setConnectSuccessCompanionAppInstalled(CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
builder.setConnectSuccessCompanionAppNotInstalled(
CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED);
builder.setDeviceType(DEVICE_TYPE);
builder.setDownloadCompanionAppDescription(DOWNLOAD_COMPANION_APP_DESCRIPTION);
builder.setFailConnectGoToSettingsDescription(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
- builder.setFastPairTvConnectDeviceNoAccountDescription(
- FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
builder.setImage(IMAGE);
builder.setImageUrl(IMAGE_URL);
builder.setInitialNotificationDescription(INITIAL_NOTIFICATION_DESCRIPTION);
@@ -720,15 +693,10 @@
INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT);
builder.setInitialPairingDescription(INITIAL_PAIRING_DESCRIPTION);
builder.setIntentUri(INTENT_URI);
- builder.setLocale(LOCALE);
builder.setName(NAME);
builder.setOpenCompanionAppDescription(OPEN_COMPANION_APP_DESCRIPTION);
builder.setRetroactivePairingDescription(RETRO_ACTIVE_PAIRING_DESCRIPTION);
builder.setSubsequentPairingDescription(SUBSEQUENT_PAIRING_DESCRIPTION);
- builder.setSyncContactsDescription(SYNC_CONTACT_DESCRPTION);
- builder.setSyncContactsTitle(SYNC_CONTACTS_TITLE);
- builder.setSyncSmsDescription(SYNC_SMS_DESCRIPTION);
- builder.setSyncSmsTitle(SYNC_SMS_TITLE);
builder.setTriggerDistance(TRIGGER_DISTANCE);
builder.setTrueWirelessImageUrlCase(TRUE_WIRELESS_IMAGE_URL_CASE);
builder.setTrueWirelessImageUrlLeftBud(TRUE_WIRELESS_IMAGE_URL_LEFT_BUD);
@@ -745,19 +713,13 @@
private static FastPairDeviceMetadataParcel genHappyPathFastPairDeviceMetadataParcel() {
FastPairDeviceMetadataParcel parcel = new FastPairDeviceMetadataParcel();
- parcel.assistantSetupHalfSheet = ASSISTANT_SETUP_HALFSHEET;
- parcel.assistantSetupNotification = ASSISTANT_SETUP_NOTIFICATION;
parcel.bleTxPower = BLE_TX_POWER;
- parcel.confirmPinDescription = CONFIRM_PIN_DESCRIPTION;
- parcel.confirmPinTitle = CONFIRM_PIN_TITLE;
parcel.connectSuccessCompanionAppInstalled = CONNECT_SUCCESS_COMPANION_APP_INSTALLED;
parcel.connectSuccessCompanionAppNotInstalled =
CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED;
parcel.deviceType = DEVICE_TYPE;
parcel.downloadCompanionAppDescription = DOWNLOAD_COMPANION_APP_DESCRIPTION;
parcel.failConnectGoToSettingsDescription = FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION;
- parcel.fastPairTvConnectDeviceNoAccountDescription =
- FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION;
parcel.image = IMAGE;
parcel.imageUrl = IMAGE_URL;
parcel.initialNotificationDescription = INITIAL_NOTIFICATION_DESCRIPTION;
@@ -765,15 +727,10 @@
INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT;
parcel.initialPairingDescription = INITIAL_PAIRING_DESCRIPTION;
parcel.intentUri = INTENT_URI;
- parcel.locale = LOCALE;
parcel.name = NAME;
parcel.openCompanionAppDescription = OPEN_COMPANION_APP_DESCRIPTION;
parcel.retroactivePairingDescription = RETRO_ACTIVE_PAIRING_DESCRIPTION;
parcel.subsequentPairingDescription = SUBSEQUENT_PAIRING_DESCRIPTION;
- parcel.syncContactsDescription = SYNC_CONTACT_DESCRPTION;
- parcel.syncContactsTitle = SYNC_CONTACTS_TITLE;
- parcel.syncSmsDescription = SYNC_SMS_DESCRIPTION;
- parcel.syncSmsTitle = SYNC_SMS_TITLE;
parcel.triggerDistance = TRIGGER_DISTANCE;
parcel.trueWirelessImageUrlCase = TRUE_WIRELESS_IMAGE_URL_CASE;
parcel.trueWirelessImageUrlLeftBud = TRUE_WIRELESS_IMAGE_URL_LEFT_BUD;
@@ -830,7 +787,6 @@
FastPairDataProviderService.FastPairManageAccountDeviceRequest request) {
assertThat(request.getAccount()).isEqualTo(MANAGE_ACCOUNT);
assertThat(request.getRequestType()).isEqualTo(MANAGE_ACCOUNT_REQUEST_TYPE);
- assertThat(request.getBleAddress()).isEqualTo(BLE_ADDRESS);
ensureHappyPathAsExpected(request.getAccountKeyDeviceMetadata());
}
@@ -876,15 +832,8 @@
/* Verifies Happy Path DeviceMetadataParcel. */
private static void ensureHappyPathAsExpected(FastPairDeviceMetadataParcel metadataParcel) {
assertThat(metadataParcel).isNotNull();
-
- assertThat(metadataParcel.assistantSetupHalfSheet).isEqualTo(ASSISTANT_SETUP_HALFSHEET);
- assertThat(metadataParcel.assistantSetupNotification).isEqualTo(
- ASSISTANT_SETUP_NOTIFICATION);
-
assertThat(metadataParcel.bleTxPower).isEqualTo(BLE_TX_POWER);
- assertThat(metadataParcel.confirmPinDescription).isEqualTo(CONFIRM_PIN_DESCRIPTION);
- assertThat(metadataParcel.confirmPinTitle).isEqualTo(CONFIRM_PIN_TITLE);
assertThat(metadataParcel.connectSuccessCompanionAppInstalled).isEqualTo(
CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
assertThat(metadataParcel.connectSuccessCompanionAppNotInstalled).isEqualTo(
@@ -896,8 +845,6 @@
assertThat(metadataParcel.failConnectGoToSettingsDescription).isEqualTo(
FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
- assertThat(metadataParcel.fastPairTvConnectDeviceNoAccountDescription).isEqualTo(
- FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
assertThat(metadataParcel.image).isEqualTo(IMAGE);
assertThat(metadataParcel.imageUrl).isEqualTo(IMAGE_URL);
@@ -908,7 +855,6 @@
assertThat(metadataParcel.initialPairingDescription).isEqualTo(INITIAL_PAIRING_DESCRIPTION);
assertThat(metadataParcel.intentUri).isEqualTo(INTENT_URI);
- assertThat(metadataParcel.locale).isEqualTo(LOCALE);
assertThat(metadataParcel.name).isEqualTo(NAME);
assertThat(metadataParcel.openCompanionAppDescription).isEqualTo(
@@ -919,10 +865,6 @@
assertThat(metadataParcel.subsequentPairingDescription).isEqualTo(
SUBSEQUENT_PAIRING_DESCRIPTION);
- assertThat(metadataParcel.syncContactsDescription).isEqualTo(SYNC_CONTACT_DESCRPTION);
- assertThat(metadataParcel.syncContactsTitle).isEqualTo(SYNC_CONTACTS_TITLE);
- assertThat(metadataParcel.syncSmsDescription).isEqualTo(SYNC_SMS_DESCRIPTION);
- assertThat(metadataParcel.syncSmsTitle).isEqualTo(SYNC_SMS_TITLE);
assertThat(metadataParcel.triggerDistance).isWithin(DELTA).of(TRIGGER_DISTANCE);
assertThat(metadataParcel.trueWirelessImageUrlCase).isEqualTo(TRUE_WIRELESS_IMAGE_URL_CASE);
@@ -943,12 +885,7 @@
/* Verifies Happy Path DeviceMetadata. */
private static void ensureHappyPathAsExpected(FastPairDeviceMetadata metadata) {
- assertThat(metadata.getAssistantSetupHalfSheet()).isEqualTo(ASSISTANT_SETUP_HALFSHEET);
- assertThat(metadata.getAssistantSetupNotification())
- .isEqualTo(ASSISTANT_SETUP_NOTIFICATION);
assertThat(metadata.getBleTxPower()).isEqualTo(BLE_TX_POWER);
- assertThat(metadata.getConfirmPinDescription()).isEqualTo(CONFIRM_PIN_DESCRIPTION);
- assertThat(metadata.getConfirmPinTitle()).isEqualTo(CONFIRM_PIN_TITLE);
assertThat(metadata.getConnectSuccessCompanionAppInstalled())
.isEqualTo(CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
assertThat(metadata.getConnectSuccessCompanionAppNotInstalled())
@@ -958,8 +895,6 @@
.isEqualTo(DOWNLOAD_COMPANION_APP_DESCRIPTION);
assertThat(metadata.getFailConnectGoToSettingsDescription())
.isEqualTo(FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
- assertThat(metadata.getFastPairTvConnectDeviceNoAccountDescription())
- .isEqualTo(FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
assertThat(metadata.getImage()).isEqualTo(IMAGE);
assertThat(metadata.getImageUrl()).isEqualTo(IMAGE_URL);
assertThat(metadata.getInitialNotificationDescription())
@@ -968,7 +903,6 @@
.isEqualTo(INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT);
assertThat(metadata.getInitialPairingDescription()).isEqualTo(INITIAL_PAIRING_DESCRIPTION);
assertThat(metadata.getIntentUri()).isEqualTo(INTENT_URI);
- assertThat(metadata.getLocale()).isEqualTo(LOCALE);
assertThat(metadata.getName()).isEqualTo(NAME);
assertThat(metadata.getOpenCompanionAppDescription())
.isEqualTo(OPEN_COMPANION_APP_DESCRIPTION);
@@ -976,10 +910,6 @@
.isEqualTo(RETRO_ACTIVE_PAIRING_DESCRIPTION);
assertThat(metadata.getSubsequentPairingDescription())
.isEqualTo(SUBSEQUENT_PAIRING_DESCRIPTION);
- assertThat(metadata.getSyncContactsDescription()).isEqualTo(SYNC_CONTACT_DESCRPTION);
- assertThat(metadata.getSyncContactsTitle()).isEqualTo(SYNC_CONTACTS_TITLE);
- assertThat(metadata.getSyncSmsDescription()).isEqualTo(SYNC_SMS_DESCRIPTION);
- assertThat(metadata.getSyncSmsTitle()).isEqualTo(SYNC_SMS_TITLE);
assertThat(metadata.getTriggerDistance()).isWithin(DELTA).of(TRIGGER_DISTANCE);
assertThat(metadata.getTrueWirelessImageUrlCase()).isEqualTo(TRUE_WIRELESS_IMAGE_URL_CASE);
assertThat(metadata.getTrueWirelessImageUrlLeftBud())
@@ -1000,27 +930,18 @@
assertThat(itemParcel.actionUrl).isEqualTo(ACTION_URL);
assertThat(itemParcel.actionUrlType).isEqualTo(ACTION_URL_TYPE);
assertThat(itemParcel.appName).isEqualTo(APP_NAME);
- assertThat(itemParcel.attachmentType).isEqualTo(ATTACHMENT_TYPE);
assertThat(itemParcel.authenticationPublicKeySecp256r1)
.isEqualTo(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
- assertThat(itemParcel.bleRecordBytes).isEqualTo(BLE_RECORD_BYTES);
- assertThat(itemParcel.debugCategory).isEqualTo(DEBUG_CATEGORY);
- assertThat(itemParcel.debugMessage).isEqualTo(DEBUG_MESSAGE);
assertThat(itemParcel.description).isEqualTo(DESCRIPTION);
assertThat(itemParcel.deviceName).isEqualTo(DEVICE_NAME);
assertThat(itemParcel.displayUrl).isEqualTo(DISPLAY_URL);
- assertThat(itemParcel.entityId).isEqualTo(ENTITY_ID);
- assertThat(itemParcel.featureGraphicUrl).isEqualTo(FEATURE_GRAPHIC_URL);
assertThat(itemParcel.firstObservationTimestampMillis)
.isEqualTo(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
- assertThat(itemParcel.groupId).isEqualTo(GROUP_ID);
assertThat(itemParcel.iconFifeUrl).isEqualTo(ICON_FIFE_URL);
assertThat(itemParcel.iconPng).isEqualTo(ICON_PNG);
assertThat(itemParcel.id).isEqualTo(ID);
assertThat(itemParcel.lastObservationTimestampMillis)
.isEqualTo(LAST_OBSERVATION_TIMESTAMP_MILLIS);
- assertThat(itemParcel.lastUserExperience).isEqualTo(LAST_USER_EXPERIENCE);
- assertThat(itemParcel.lostMillis).isEqualTo(LOST_MILLIS);
assertThat(itemParcel.macAddress).isEqualTo(MAC_ADDRESS);
assertThat(itemParcel.packageName).isEqualTo(PACKAGE_NAME);
assertThat(itemParcel.pendingAppInstallTimestampMillis)
@@ -1030,7 +951,6 @@
assertThat(itemParcel.title).isEqualTo(TITLE);
assertThat(itemParcel.triggerId).isEqualTo(TRIGGER_ID);
assertThat(itemParcel.txPower).isEqualTo(TX_POWER);
- assertThat(itemParcel.type).isEqualTo(TYPE);
}
/* Verifies Happy Path FastPairDiscoveryItem. */
@@ -1038,27 +958,18 @@
assertThat(item.getActionUrl()).isEqualTo(ACTION_URL);
assertThat(item.getActionUrlType()).isEqualTo(ACTION_URL_TYPE);
assertThat(item.getAppName()).isEqualTo(APP_NAME);
- assertThat(item.getAttachmentType()).isEqualTo(ATTACHMENT_TYPE);
assertThat(item.getAuthenticationPublicKeySecp256r1())
.isEqualTo(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
- assertThat(item.getBleRecordBytes()).isEqualTo(BLE_RECORD_BYTES);
- assertThat(item.getDebugCategory()).isEqualTo(DEBUG_CATEGORY);
- assertThat(item.getDebugMessage()).isEqualTo(DEBUG_MESSAGE);
assertThat(item.getDescription()).isEqualTo(DESCRIPTION);
assertThat(item.getDeviceName()).isEqualTo(DEVICE_NAME);
assertThat(item.getDisplayUrl()).isEqualTo(DISPLAY_URL);
- assertThat(item.getEntityId()).isEqualTo(ENTITY_ID);
- assertThat(item.getFeatureGraphicUrl()).isEqualTo(FEATURE_GRAPHIC_URL);
assertThat(item.getFirstObservationTimestampMillis())
.isEqualTo(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
- assertThat(item.getGroupId()).isEqualTo(GROUP_ID);
assertThat(item.getIconFfeUrl()).isEqualTo(ICON_FIFE_URL);
assertThat(item.getIconPng()).isEqualTo(ICON_PNG);
assertThat(item.getId()).isEqualTo(ID);
assertThat(item.getLastObservationTimestampMillis())
.isEqualTo(LAST_OBSERVATION_TIMESTAMP_MILLIS);
- assertThat(item.getLastUserExperience()).isEqualTo(LAST_USER_EXPERIENCE);
- assertThat(item.getLostMillis()).isEqualTo(LOST_MILLIS);
assertThat(item.getMacAddress()).isEqualTo(MAC_ADDRESS);
assertThat(item.getPackageName()).isEqualTo(PACKAGE_NAME);
assertThat(item.getPendingAppInstallTimestampMillis())
@@ -1068,7 +979,6 @@
assertThat(item.getTitle()).isEqualTo(TITLE);
assertThat(item.getTriggerId()).isEqualTo(TRIGGER_ID);
assertThat(item.getTxPower()).isEqualTo(TX_POWER);
- assertThat(item.getType()).isEqualTo(TYPE);
}
/* Verifies Happy Path EligibleAccountParcel[]. */
diff --git a/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java b/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java
index 019f8ec..3a73b9f 100644
--- a/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java
+++ b/nearby/tests/cts/fastpair/src/android/nearby/cts/ScanRequestTest.java
@@ -21,10 +21,8 @@
import static android.nearby.ScanRequest.SCAN_MODE_LOW_LATENCY;
import static android.nearby.ScanRequest.SCAN_MODE_LOW_POWER;
import static android.nearby.ScanRequest.SCAN_MODE_NO_POWER;
-import static android.nearby.ScanRequest.SCAN_TYPE_EXPOSURE_NOTIFICATION;
import static android.nearby.ScanRequest.SCAN_TYPE_FAST_PAIR;
import static android.nearby.ScanRequest.SCAN_TYPE_NEARBY_PRESENCE;
-import static android.nearby.ScanRequest.SCAN_TYPE_NEARBY_SHARE;
import static com.google.common.truth.Truth.assertThat;
@@ -80,7 +78,7 @@
@SdkSuppress(minSdkVersion = 32, codeName = "T")
public void testSetWorkSource_nullValue() {
ScanRequest request = new ScanRequest.Builder()
- .setScanType(SCAN_TYPE_EXPOSURE_NOTIFICATION)
+ .setScanType(SCAN_TYPE_FAST_PAIR)
.setWorkSource(null)
.build();
@@ -94,14 +92,14 @@
public void testToString() {
WorkSource workSource = getWorkSource();
ScanRequest request = new ScanRequest.Builder()
- .setScanType(SCAN_TYPE_NEARBY_SHARE)
+ .setScanType(SCAN_TYPE_FAST_PAIR)
.setScanMode(SCAN_MODE_BALANCED)
.setBleEnabled(true)
.setWorkSource(workSource)
.build();
assertThat(request.toString()).isEqualTo(
- "Request[scanType=2, scanMode=SCAN_MODE_BALANCED, "
+ "Request[scanType=1, scanMode=SCAN_MODE_BALANCED, "
+ "enableBle=true, workSource=WorkSource{" + UID + " " + APP_NAME
+ "}, scanFilters=[]]");
}
@@ -132,9 +130,7 @@
@SdkSuppress(minSdkVersion = 32, codeName = "T")
public void test_isValidScanType() {
assertThat(ScanRequest.isValidScanType(SCAN_TYPE_FAST_PAIR)).isTrue();
- assertThat(ScanRequest.isValidScanType(SCAN_TYPE_NEARBY_SHARE)).isTrue();
assertThat(ScanRequest.isValidScanType(SCAN_TYPE_NEARBY_PRESENCE)).isTrue();
- assertThat(ScanRequest.isValidScanType(SCAN_TYPE_EXPOSURE_NOTIFICATION)).isTrue();
assertThat(ScanRequest.isValidScanType(0)).isFalse();
assertThat(ScanRequest.isValidScanType(5)).isFalse();
diff --git a/nearby/tests/multidevices/clients/proguard.flags b/nearby/tests/multidevices/clients/proguard.flags
index fd494a8..11938cd 100644
--- a/nearby/tests/multidevices/clients/proguard.flags
+++ b/nearby/tests/multidevices/clients/proguard.flags
@@ -3,8 +3,8 @@
*;
}
-# Keep simulator reflection callback.
--keep class android.nearby.fastpair.provider.** {
+# Keep AdvertisingSetCallback#onOwnAddressRead callback.
+-keep class * extends android.bluetooth.le.AdvertisingSetCallback {
*;
}
diff --git a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/provider/FastPairProviderSimulatorSnippet.kt b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/provider/FastPairProviderSimulatorSnippet.kt
index 4a8a772..922e950 100644
--- a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/provider/FastPairProviderSimulatorSnippet.kt
+++ b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/provider/FastPairProviderSimulatorSnippet.kt
@@ -70,4 +70,10 @@
fun getBluetoothLeAddress(): String {
return fastPairProviderSimulatorController.getProviderSimulatorBleAddress()
}
+
+ /** Gets the latest account key received on the Fast Pair provider simulator */
+ @Rpc(description = "Gets the latest account key received on the Fast Pair provider simulator.")
+ fun getLatestReceivedAccountKey(): String? {
+ return fastPairProviderSimulatorController.getLatestReceivedAccountKey()
+ }
}
diff --git a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/provider/controller/FastPairProviderSimulatorController.kt b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/provider/controller/FastPairProviderSimulatorController.kt
index 2ab6dbd..a2d2659 100644
--- a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/provider/controller/FastPairProviderSimulatorController.kt
+++ b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/provider/controller/FastPairProviderSimulatorController.kt
@@ -21,7 +21,7 @@
import android.nearby.fastpair.provider.FastPairSimulator
import android.nearby.fastpair.provider.bluetooth.BluetoothController
import com.google.android.mobly.snippet.util.Log
-import com.google.common.io.BaseEncoding
+import com.google.common.io.BaseEncoding.base64
class FastPairProviderSimulatorController(private val context: Context) :
FastPairSimulator.AdvertisingChangedCallback, BluetoothController.EventListener {
@@ -50,7 +50,7 @@
) {
eventListener = listener
- val antiSpoofingKey = BaseEncoding.base64().decode(antiSpoofingKeyString)
+ val antiSpoofingKey = base64().decode(antiSpoofingKeyString)
simulator = FastPairSimulator(
context, FastPairSimulator.Options.builder(modelId)
.setAdvertisingModelId(modelId)
@@ -68,6 +68,9 @@
fun getProviderSimulatorBleAddress() = simulator!!.bleAddress!!
+ fun getLatestReceivedAccountKey() =
+ simulator!!.accountKey?.let { base64().encode(it.toByteArray()) }
+
/**
* Called when we change our BLE advertisement.
*
diff --git a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/FastPairSeekerSnippet.kt b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/FastPairSeekerSnippet.kt
index 65856d8..fd4f4b4 100644
--- a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/FastPairSeekerSnippet.kt
+++ b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/FastPairSeekerSnippet.kt
@@ -23,9 +23,11 @@
import android.nearby.ScanRequest
import android.nearby.fastpair.seeker.FAKE_TEST_ACCOUNT_NAME
import android.nearby.multidevices.fastpair.seeker.data.FastPairTestDataManager
+import android.nearby.multidevices.fastpair.seeker.events.PairingCallbackEvents
import android.nearby.multidevices.fastpair.seeker.events.ScanCallbackEvents
import android.nearby.multidevices.fastpair.seeker.ui.CheckNearbyHalfSheetUiTest
import android.nearby.multidevices.fastpair.seeker.ui.DismissNearbyHalfSheetUiTest
+import android.nearby.multidevices.fastpair.seeker.ui.PairByNearbyHalfSheetUiTest
import androidx.test.core.app.ApplicationProvider
import com.google.android.mobly.snippet.Snippet
import com.google.android.mobly.snippet.rpc.AsyncRpc
@@ -114,7 +116,7 @@
@Rpc(description = "Puts an array of FastPairAccountKeyDeviceMetadata into test data cache.")
fun putAccountKeyDeviceMetadata(json: String) {
Log.i("Puts an array of FastPairAccountKeyDeviceMetadata into test data cache.")
- fastPairTestDataManager.sendAccountKeyDeviceMetadata(json)
+ fastPairTestDataManager.sendAccountKeyDeviceMetadataJsonArray(json)
}
/** Dumps all FastPairAccountKeyDeviceMetadata from the test data cache. */
@@ -142,11 +144,25 @@
DismissNearbyHalfSheetUiTest().dismissHalfSheet()
}
+ /** Starts pairing by interacting with half sheet UI.
+ *
+ * @param callbackId the callback ID corresponding to the
+ * {@link FastPairSeekerSnippet#startPairing} call that started the pairing.
+ */
+ @AsyncRpc(description = "Starts pairing by interacting with half sheet UI.")
+ fun startPairing(callbackId: String) {
+ Log.i("Starts pairing by interacting with half sheet UI.")
+
+ PairByNearbyHalfSheetUiTest().clickConnectButton()
+ fastPairTestDataManager.registerDataReceiveListener(PairingCallbackEvents(callbackId))
+ }
+
/** Invokes when the snippet runner shutting down. */
override fun shutdown() {
super.shutdown()
Log.i("Resets the Fast Pair test data cache.")
+ fastPairTestDataManager.unregisterDataReceiveListener()
fastPairTestDataManager.sendResetCache()
}
}
\ No newline at end of file
diff --git a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/data/FastPairTestDataManager.kt b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/data/FastPairTestDataManager.kt
index 291aad8..239ac61 100644
--- a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/data/FastPairTestDataManager.kt
+++ b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/data/FastPairTestDataManager.kt
@@ -19,12 +19,20 @@
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
-import android.nearby.fastpair.seeker.*
+import android.content.IntentFilter
+import android.nearby.fastpair.seeker.ACTION_RESET_TEST_DATA_CACHE
+import android.nearby.fastpair.seeker.ACTION_SEND_ACCOUNT_KEY_DEVICE_METADATA
+import android.nearby.fastpair.seeker.ACTION_SEND_ANTISPOOF_KEY_DEVICE_METADATA
+import android.nearby.fastpair.seeker.ACTION_WRITE_ACCOUNT_KEY_DEVICE_METADATA
+import android.nearby.fastpair.seeker.DATA_JSON_STRING_KEY
+import android.nearby.fastpair.seeker.DATA_MODEL_ID_STRING_KEY
+import android.nearby.fastpair.seeker.FastPairTestDataCache
import android.util.Log
/** Manage local FastPairTestDataCache and send to/sync from the remote cache in data provider. */
class FastPairTestDataManager(private val context: Context) : BroadcastReceiver() {
val testDataCache = FastPairTestDataCache()
+ var listener: EventListener? = null
/** Puts a model id to FastPairAntispoofKeyDeviceMetadata pair into local and remote cache.
*
@@ -41,17 +49,17 @@
testDataCache.putAntispoofKeyDeviceMetadata(modelId, json)
}
- /** Puts account key device metadata to local and remote cache.
+ /** Puts account key device metadata array to local and remote cache.
*
* @param json a string of FastPairAccountKeyDeviceMetadata JSON array.
*/
- fun sendAccountKeyDeviceMetadata(json: String) {
+ fun sendAccountKeyDeviceMetadataJsonArray(json: String) {
Intent().also { intent ->
intent.action = ACTION_SEND_ACCOUNT_KEY_DEVICE_METADATA
intent.putExtra(DATA_JSON_STRING_KEY, json)
context.sendBroadcast(intent)
}
- testDataCache.putAccountKeyDeviceMetadata(json)
+ testDataCache.putAccountKeyDeviceMetadataJsonArray(json)
}
/** Clears local and remote cache. */
@@ -73,12 +81,33 @@
ACTION_WRITE_ACCOUNT_KEY_DEVICE_METADATA -> {
Log.d(TAG, "ACTION_WRITE_ACCOUNT_KEY_DEVICE_METADATA received!")
val json = intent.getStringExtra(DATA_JSON_STRING_KEY)!!
- testDataCache.putAccountKeyDeviceMetadata(json)
+ testDataCache.putAccountKeyDeviceMetadataJsonObject(json)
+ listener?.onManageFastPairAccountDevice(json)
}
else -> Log.d(TAG, "Unknown action received!")
}
}
+ fun registerDataReceiveListener(listener: EventListener) {
+ this.listener = listener
+ val bondStateFilter = IntentFilter(ACTION_WRITE_ACCOUNT_KEY_DEVICE_METADATA)
+ context.registerReceiver(this, bondStateFilter)
+ }
+
+ fun unregisterDataReceiveListener() {
+ this.listener = null
+ context.unregisterReceiver(this)
+ }
+
+ /** Interface for listening the data receive from the remote cache in data provider. */
+ interface EventListener {
+ /** Reports a FastPairAccountKeyDeviceMetadata write into the cache.
+ *
+ * @param json the FastPairAccountKeyDeviceMetadata as JSON object string.
+ */
+ fun onManageFastPairAccountDevice(json: String)
+ }
+
companion object {
private const val TAG = "FastPairTestDataManager"
}
diff --git a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/events/PairingCallbackEvents.kt b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/events/PairingCallbackEvents.kt
new file mode 100644
index 0000000..19de1d9
--- /dev/null
+++ b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/events/PairingCallbackEvents.kt
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2022 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.multidevices.fastpair.seeker.events
+
+import android.nearby.multidevices.fastpair.seeker.data.FastPairTestDataManager
+import com.google.android.mobly.snippet.util.postSnippetEvent
+
+/** The Mobly snippet events to report to the Python side. */
+class PairingCallbackEvents(private val callbackId: String) :
+ FastPairTestDataManager.EventListener {
+
+ /** Reports a FastPairAccountKeyDeviceMetadata write into the cache.
+ *
+ * @param json the FastPairAccountKeyDeviceMetadata as JSON object string.
+ */
+ override fun onManageFastPairAccountDevice(json: String) {
+ postSnippetEvent(callbackId, "onManageAccountDevice") {
+ putString("accountDeviceJsonString", json)
+ }
+ }
+}
\ No newline at end of file
diff --git a/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/ui/PairByNearbyHalfSheetUiTest.kt b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/ui/PairByNearbyHalfSheetUiTest.kt
new file mode 100644
index 0000000..9028668
--- /dev/null
+++ b/nearby/tests/multidevices/clients/src/android/nearby/multidevices/fastpair/seeker/ui/PairByNearbyHalfSheetUiTest.kt
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2022 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.multidevices.fastpair.seeker.ui
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.platform.app.InstrumentationRegistry
+import androidx.test.uiautomator.UiDevice
+import androidx.test.uiautomator.Until
+import org.junit.Test
+import org.junit.runner.RunWith
+
+/** An instrumented test to start pairing by interacting with Nearby half sheet UI.
+ *
+ * To run this test directly:
+ * am instrument -w -r \
+ * -e class android.nearby.multidevices.fastpair.seeker.ui.PairByNearbyHalfSheetUiTest \
+ * android.nearby.multidevices/androidx.test.runner.AndroidJUnitRunner
+ */
+@RunWith(AndroidJUnit4::class)
+class PairByNearbyHalfSheetUiTest {
+ private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
+
+ @Test
+ fun clickConnectButton() {
+ val connectButton = NearbyHalfSheetUiMap.DevicePairingFragment.connectButton
+ device.findObject(connectButton).click()
+ device.wait(Until.gone(connectButton), CONNECT_BUTTON_TIMEOUT_MILLS)
+ }
+
+ companion object {
+ const val CONNECT_BUTTON_TIMEOUT_MILLS = 3000L
+ }
+}
\ No newline at end of file
diff --git a/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/shared/android/nearby/fastpair/seeker/FastPairTestDataCache.kt b/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/shared/android/nearby/fastpair/seeker/FastPairTestDataCache.kt
index be94031..4fb8832 100644
--- a/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/shared/android/nearby/fastpair/seeker/FastPairTestDataCache.kt
+++ b/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/shared/android/nearby/fastpair/seeker/FastPairTestDataCache.kt
@@ -31,12 +31,18 @@
private val antispoofKeyDeviceMetadataDataMap =
mutableMapOf<String, FastPairAntispoofKeyDeviceMetadataData>()
- fun putAccountKeyDeviceMetadata(json: String) {
+ fun putAccountKeyDeviceMetadataJsonArray(json: String) {
accountKeyDeviceMetadataList +=
gson.fromJson(json, Array<FastPairAccountKeyDeviceMetadataData>::class.java)
.map { it.toFastPairAccountKeyDeviceMetadata() }
}
+ fun putAccountKeyDeviceMetadataJsonObject(json: String) {
+ accountKeyDeviceMetadataList +=
+ gson.fromJson(json, FastPairAccountKeyDeviceMetadataData::class.java)
+ .toFastPairAccountKeyDeviceMetadata()
+ }
+
fun putAccountKeyDeviceMetadata(accountKeyDeviceMetadata: FastPairAccountKeyDeviceMetadata) {
accountKeyDeviceMetadataList += accountKeyDeviceMetadata
}
@@ -103,31 +109,21 @@
}
data class FastPairDeviceMetadataData(
- @SerializedName("assistant_setup_half_sheet") val assistantSetupHalfSheet: String?,
- @SerializedName("assistant_setup_notification") val assistantSetupNotification: String?,
@SerializedName("ble_tx_power") val bleTxPower: Int,
- @SerializedName("confirm_pin_description") val confirmPinDescription: String?,
- @SerializedName("confirm_pin_title") val confirmPinTitle: String?,
@SerializedName("connect_success_companion_app_installed") val compAppInstalled: String?,
@SerializedName("connect_success_companion_app_not_installed") val comAppNotIns: String?,
@SerializedName("device_type") val deviceType: Int,
@SerializedName("download_companion_app_description") val downloadComApp: String?,
@SerializedName("fail_connect_go_to_settings_description") val failConnectDes: String?,
- @SerializedName("fast_pair_tv_connect_device_no_account_description") val accDes: String?,
@SerializedName("image_url") val imageUrl: String?,
@SerializedName("initial_notification_description") val initNotification: String?,
@SerializedName("initial_notification_description_no_account") val initNoAccount: String?,
@SerializedName("initial_pairing_description") val initialPairingDescription: String?,
@SerializedName("intent_uri") val intentUri: String?,
- @SerializedName("locale") val locale: String?,
@SerializedName("name") val name: String?,
@SerializedName("open_companion_app_description") val openCompanionAppDescription: String?,
@SerializedName("retroactive_pairing_description") val retroactivePairingDes: String?,
@SerializedName("subsequent_pairing_description") val subsequentPairingDescription: String?,
- @SerializedName("sync_contacts_description") val syncContactsDescription: String?,
- @SerializedName("sync_contacts_title") val syncContactsTitle: String?,
- @SerializedName("sync_sms_description") val syncSmsDescription: String?,
- @SerializedName("sync_sms_title") val syncSmsTitle: String?,
@SerializedName("trigger_distance") val triggerDistance: Double,
@SerializedName("case_url") val trueWirelessImageUrlCase: String?,
@SerializedName("left_bud_url") val trueWirelessImageUrlLeftBud: String?,
@@ -138,31 +134,21 @@
@SerializedName("wait_launch_companion_app_description") val waitLaunchCompApp: String?
) {
constructor(meta: FastPairDeviceMetadata) : this(
- assistantSetupHalfSheet = meta.assistantSetupHalfSheet,
- assistantSetupNotification = meta.assistantSetupNotification,
bleTxPower = meta.bleTxPower,
- confirmPinDescription = meta.confirmPinDescription,
- confirmPinTitle = meta.confirmPinTitle,
compAppInstalled = meta.connectSuccessCompanionAppInstalled,
comAppNotIns = meta.connectSuccessCompanionAppNotInstalled,
deviceType = meta.deviceType,
downloadComApp = meta.downloadCompanionAppDescription,
failConnectDes = meta.failConnectGoToSettingsDescription,
- accDes = meta.fastPairTvConnectDeviceNoAccountDescription,
imageUrl = meta.imageUrl,
initNotification = meta.initialNotificationDescription,
initNoAccount = meta.initialNotificationDescriptionNoAccount,
initialPairingDescription = meta.initialPairingDescription,
intentUri = meta.intentUri,
- locale = meta.locale,
name = meta.name,
openCompanionAppDescription = meta.openCompanionAppDescription,
retroactivePairingDes = meta.retroactivePairingDescription,
subsequentPairingDescription = meta.subsequentPairingDescription,
- syncContactsDescription = meta.syncContactsDescription,
- syncContactsTitle = meta.syncContactsTitle,
- syncSmsDescription = meta.syncSmsDescription,
- syncSmsTitle = meta.syncSmsTitle,
triggerDistance = meta.triggerDistance.toDouble(),
trueWirelessImageUrlCase = meta.trueWirelessImageUrlCase,
trueWirelessImageUrlLeftBud = meta.trueWirelessImageUrlLeftBud,
@@ -175,31 +161,21 @@
fun toFastPairDeviceMetadata(): FastPairDeviceMetadata {
return FastPairDeviceMetadata.Builder()
- .setAssistantSetupHalfSheet(assistantSetupHalfSheet)
- .setAssistantSetupNotification(assistantSetupNotification)
.setBleTxPower(bleTxPower)
- .setConfirmPinDescription(confirmPinDescription)
- .setConfirmPinTitle(confirmPinTitle)
.setConnectSuccessCompanionAppInstalled(compAppInstalled)
.setConnectSuccessCompanionAppNotInstalled(comAppNotIns)
.setDeviceType(deviceType)
.setDownloadCompanionAppDescription(downloadComApp)
.setFailConnectGoToSettingsDescription(failConnectDes)
- .setFastPairTvConnectDeviceNoAccountDescription(accDes)
.setImageUrl(imageUrl)
.setInitialNotificationDescription(initNotification)
.setInitialNotificationDescriptionNoAccount(initNoAccount)
.setInitialPairingDescription(initialPairingDescription)
.setIntentUri(intentUri)
- .setLocale(locale)
.setName(name)
.setOpenCompanionAppDescription(openCompanionAppDescription)
.setRetroactivePairingDescription(retroactivePairingDes)
.setSubsequentPairingDescription(subsequentPairingDescription)
- .setSyncContactsDescription(syncContactsDescription)
- .setSyncContactsTitle(syncContactsTitle)
- .setSyncSmsDescription(syncSmsDescription)
- .setSyncSmsTitle(syncSmsTitle)
.setTriggerDistance(triggerDistance.toFloat())
.setTrueWirelessImageUrlCase(trueWirelessImageUrlCase)
.setTrueWirelessImageUrlLeftBud(trueWirelessImageUrlLeftBud)
@@ -216,24 +192,15 @@
@SerializedName("action_url") val actionUrl: String?,
@SerializedName("action_url_type") val actionUrlType: Int,
@SerializedName("app_name") val appName: String?,
- @SerializedName("attachment_type") val attachmentType: Int,
@SerializedName("authentication_public_key_secp256r1") val authenticationPublicKey: String?,
- @SerializedName("ble_record_bytes") val bleRecordBytes: String?,
- @SerializedName("debug_category") val debugCategory: Int,
- @SerializedName("debug_message") val debugMessage: String?,
@SerializedName("description") val description: String?,
@SerializedName("device_name") val deviceName: String?,
@SerializedName("display_url") val displayUrl: String?,
- @SerializedName("entity_id") val entityId: String?,
- @SerializedName("feature_graphic_url") val featureGraphicUrl: String?,
@SerializedName("first_observation_timestamp_millis") val firstObservationMs: Long,
- @SerializedName("group_id") val groupId: String?,
@SerializedName("icon_fife_url") val iconFfeUrl: String?,
@SerializedName("icon_png") val iconPng: String?,
@SerializedName("id") val id: String?,
@SerializedName("last_observation_timestamp_millis") val lastObservationMs: Long,
- @SerializedName("last_user_experience") val lastUserExperience: Int,
- @SerializedName("lost_millis") val lostMillis: Long,
@SerializedName("mac_address") val macAddress: String?,
@SerializedName("package_name") val packageName: String?,
@SerializedName("pending_app_install_timestamp_millis") val pendingAppInstallMs: Long,
@@ -241,31 +208,21 @@
@SerializedName("state") val state: Int,
@SerializedName("title") val title: String?,
@SerializedName("trigger_id") val triggerId: String?,
- @SerializedName("tx_power") val txPower: Int,
- @SerializedName("type") val type: Int
+ @SerializedName("tx_power") val txPower: Int
) {
constructor(item: FastPairDiscoveryItem) : this(
actionUrl = item.actionUrl,
actionUrlType = item.actionUrlType,
appName = item.appName,
- attachmentType = item.attachmentType,
authenticationPublicKey = item.authenticationPublicKeySecp256r1?.base64Encode(),
- bleRecordBytes = item.bleRecordBytes?.base64Encode(),
- debugCategory = item.debugCategory,
- debugMessage = item.debugMessage,
description = item.description,
deviceName = item.deviceName,
displayUrl = item.displayUrl,
- entityId = item.entityId,
- featureGraphicUrl = item.featureGraphicUrl,
firstObservationMs = item.firstObservationTimestampMillis,
- groupId = item.groupId,
iconFfeUrl = item.iconFfeUrl,
iconPng = item.iconPng?.base64Encode(),
id = item.id,
lastObservationMs = item.lastObservationTimestampMillis,
- lastUserExperience = item.lastUserExperience,
- lostMillis = item.lostMillis,
macAddress = item.macAddress,
packageName = item.packageName,
pendingAppInstallMs = item.pendingAppInstallTimestampMillis,
@@ -273,8 +230,7 @@
state = item.state,
title = item.title,
triggerId = item.triggerId,
- txPower = item.txPower,
- type = item.type
+ txPower = item.txPower
)
fun toFastPairDiscoveryItem(): FastPairDiscoveryItem {
@@ -282,24 +238,15 @@
.setActionUrl(actionUrl)
.setActionUrlType(actionUrlType)
.setAppName(appName)
- .setAttachmentType(attachmentType)
.setAuthenticationPublicKeySecp256r1(authenticationPublicKey?.base64Decode())
- .setBleRecordBytes(bleRecordBytes?.base64Decode())
- .setDebugCategory(debugCategory)
- .setDebugMessage(debugMessage)
.setDescription(description)
.setDeviceName(deviceName)
.setDisplayUrl(displayUrl)
- .setEntityId(entityId)
- .setFeatureGraphicUrl(featureGraphicUrl)
.setFirstObservationTimestampMillis(firstObservationMs)
- .setGroupId(groupId)
.setIconFfeUrl(iconFfeUrl)
.setIconPng(iconPng?.base64Decode())
.setId(id)
.setLastObservationTimestampMillis(lastObservationMs)
- .setLastUserExperience(lastUserExperience)
- .setLostMillis(lostMillis)
.setMacAddress(macAddress)
.setPackageName(packageName)
.setPendingAppInstallTimestampMillis(pendingAppInstallMs)
@@ -308,7 +255,6 @@
.setTitle(title)
.setTriggerId(triggerId)
.setTxPower(txPower)
- .setType(type)
.build()
}
}
diff --git a/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/src/android/nearby/fastpair/seeker/data/FastPairTestDataManager.kt b/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/src/android/nearby/fastpair/seeker/data/FastPairTestDataManager.kt
index f226789..e924da1 100644
--- a/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/src/android/nearby/fastpair/seeker/data/FastPairTestDataManager.kt
+++ b/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/src/android/nearby/fastpair/seeker/data/FastPairTestDataManager.kt
@@ -72,7 +72,7 @@
ACTION_SEND_ACCOUNT_KEY_DEVICE_METADATA -> {
Log.d(TAG, "ACTION_SEND_ACCOUNT_KEY_DEVICE_METADATA received!")
val json = intent.getStringExtra(DATA_JSON_STRING_KEY)!!
- testDataCache.putAccountKeyDeviceMetadata(json)
+ testDataCache.putAccountKeyDeviceMetadataJsonArray(json)
}
ACTION_RESET_TEST_DATA_CACHE -> {
Log.d(TAG, "ACTION_RESET_TEST_DATA_CACHE received!")
diff --git a/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/src/android/nearby/fastpair/seeker/dataprovider/FastPairTestDataProviderService.kt b/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/src/android/nearby/fastpair/seeker/dataprovider/FastPairTestDataProviderService.kt
index 3f5a803..aec1379 100644
--- a/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/src/android/nearby/fastpair/seeker/dataprovider/FastPairTestDataProviderService.kt
+++ b/nearby/tests/multidevices/clients/test_service/fastpair_seeker_data_provider/src/android/nearby/fastpair/seeker/dataprovider/FastPairTestDataProviderService.kt
@@ -20,7 +20,10 @@
import android.content.IntentFilter
import android.nearby.FastPairDataProviderService
import android.nearby.FastPairEligibleAccount
-import android.nearby.fastpair.seeker.*
+import android.nearby.fastpair.seeker.ACTION_RESET_TEST_DATA_CACHE
+import android.nearby.fastpair.seeker.ACTION_SEND_ACCOUNT_KEY_DEVICE_METADATA
+import android.nearby.fastpair.seeker.ACTION_SEND_ANTISPOOF_KEY_DEVICE_METADATA
+import android.nearby.fastpair.seeker.FAKE_TEST_ACCOUNT_NAME
import android.nearby.fastpair.seeker.data.FastPairTestDataManager
import android.util.Log
@@ -58,7 +61,9 @@
val fastPairAntispoofKeyDeviceMetadata =
testDataManager.testDataCache.getAntispoofKeyDeviceMetadata(requestedModelId)
if (fastPairAntispoofKeyDeviceMetadata != null) {
- callback.onFastPairAntispoofKeyDeviceMetadataReceived(fastPairAntispoofKeyDeviceMetadata)
+ callback.onFastPairAntispoofKeyDeviceMetadataReceived(
+ fastPairAntispoofKeyDeviceMetadata
+ )
} else {
Log.d(TAG, "No metadata available for $requestedModelId!")
callback.onError(ERROR_CODE_BAD_REQUEST, "No metadata available for $requestedModelId")
@@ -91,7 +96,8 @@
}
override fun onManageFastPairAccount(
- request: FastPairManageAccountRequest, callback: FastPairManageActionCallback
+ request: FastPairManageAccountRequest,
+ callback: FastPairManageActionCallback
) {
val requestedAccount = request.account
val requestType = request.requestType
@@ -101,19 +107,18 @@
}
override fun onManageFastPairAccountDevice(
- request: FastPairManageAccountDeviceRequest, callback: FastPairManageActionCallback
+ request: FastPairManageAccountDeviceRequest,
+ callback: FastPairManageActionCallback
) {
val requestedAccount = request.account
val requestType = request.requestType
val requestTypeString = if (requestType == MANAGE_REQUEST_ADD) "Add" else "Remove"
- val requestedBleAddress = request.bleAddress
val requestedAccountKeyDeviceMetadata = request.accountKeyDeviceMetadata
Log.d(
TAG,
"onManageFastPairAccountDevice(requestedAccount: $requestedAccount, " +
"requestType: $requestTypeString,"
)
- Log.d(TAG, "requestedBleAddress: $requestedBleAddress,")
val requestedAccountKeyDeviceMetadataInJson =
testDataManager.writeAccountKeyDeviceMetadata(requestedAccountKeyDeviceMetadata)
@@ -128,7 +133,7 @@
FastPairEligibleAccount.Builder()
.setAccount(Account(FAKE_TEST_ACCOUNT_NAME, "FakeTestAccount"))
.setOptIn(true)
- .build(),
+ .build()
)
private fun ByteArray.bytesToStringLowerCase(): String =
diff --git a/nearby/tests/multidevices/clients/test_support/fastpair_provider/Android.bp b/nearby/tests/multidevices/clients/test_support/fastpair_provider/Android.bp
index 920834a..e01c436 100644
--- a/nearby/tests/multidevices/clients/test_support/fastpair_provider/Android.bp
+++ b/nearby/tests/multidevices/clients/test_support/fastpair_provider/Android.bp
@@ -22,7 +22,16 @@
"src/**/*.java",
"src/**/*.kt",
],
- sdk_version: "test_current",
+ sdk_version: "core_platform",
+ libs: [
+ // order matters: classes in framework-bluetooth are resolved before framework, meaning
+ // @hide APIs in framework-bluetooth are resolved before @SystemApi stubs in framework
+ "framework-bluetooth.impl",
+ "framework",
+
+ // if sdk_version="" this gets automatically included, but here we need to add manually.
+ "framework-res",
+ ],
static_libs: [
"NearbyFastPairProviderLiteProtos",
"androidx.test.core",
diff --git a/nearby/tests/multidevices/clients/test_support/fastpair_provider/simulator_app/Android.bp b/nearby/tests/multidevices/clients/test_support/fastpair_provider/simulator_app/Android.bp
index 79c5007..87d352f 100644
--- a/nearby/tests/multidevices/clients/test_support/fastpair_provider/simulator_app/Android.bp
+++ b/nearby/tests/multidevices/clients/test_support/fastpair_provider/simulator_app/Android.bp
@@ -16,9 +16,20 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
+// Build and install NearbyFastPairProviderSimulatorApp to your phone:
+// m NearbyFastPairProviderSimulatorApp
+// adb root
+// adb remount && adb reboot (make first time remount work)
+//
+// adb root
+// adb remount
+// adb push ${ANDROID_PRODUCT_OUT}/system/app/NearbyFastPairProviderSimulatorApp /system/app/
+// adb reboot
android_app {
name: "NearbyFastPairProviderSimulatorApp",
sdk_version: "test_current",
+ // Sign with "platform" certificate for accessing Bluetooth @SystemAPI
+ certificate: "platform",
static_libs: ["NearbyFastPairProviderSimulatorLib"],
optimize: {
enabled: true,
diff --git a/nearby/tests/multidevices/clients/test_support/fastpair_provider/simulator_app/proguard.flags b/nearby/tests/multidevices/clients/test_support/fastpair_provider/simulator_app/proguard.flags
index 28680b3..0827c60 100644
--- a/nearby/tests/multidevices/clients/test_support/fastpair_provider/simulator_app/proguard.flags
+++ b/nearby/tests/multidevices/clients/test_support/fastpair_provider/simulator_app/proguard.flags
@@ -1,5 +1,5 @@
-# Keep simulator reflection callback.
--keep class android.nearby.fastpair.provider.** {
+# Keep AdvertisingSetCallback#onOwnAddressRead callback.
+-keep class * extends android.bluetooth.le.AdvertisingSetCallback {
*;
}
diff --git a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/FastPairSimulator.java b/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/FastPairSimulator.java
index 232e84b..0d5563e 100644
--- a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/FastPairSimulator.java
+++ b/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/FastPairSimulator.java
@@ -107,8 +107,6 @@
import com.android.server.nearby.common.bluetooth.fastpair.Ltv;
import com.android.server.nearby.common.bluetooth.fastpair.MessageStreamHmacEncoder;
import com.android.server.nearby.common.bluetooth.fastpair.NamingEncoder;
-import com.android.server.nearby.common.bluetooth.fastpair.Reflect;
-import com.android.server.nearby.common.bluetooth.fastpair.ReflectionException;
import com.google.common.base.Ascii;
import com.google.common.primitives.Bytes;
@@ -185,15 +183,6 @@
private static final long ADVERTISING_REFRESH_DELAY_1_MIN = TimeUnit.MINUTES.toMillis(1);
- /** The user will be prompted to accept or deny the incoming pairing request */
- public static final int PAIRING_VARIANT_CONSENT = 3;
-
- /**
- * The user will be prompted to enter the passkey displayed on remote device. This is used for
- * Bluetooth 2.1 pairing.
- */
- public static final int PAIRING_VARIANT_DISPLAY_PASSKEY = 4;
-
/**
* The size of account key filter in bytes is (1.2*n + 3), n represents the size of account key,
* see https://developers.google.com/nearby/fast-pair/spec#advertising_when_not_discoverable.
@@ -299,7 +288,7 @@
// the passkey later over GATT.
mLocalPasskey = key;
checkPasskey();
- } else if (variant == PAIRING_VARIANT_DISPLAY_PASSKEY) {
+ } else if (variant == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY) {
if (mPasskeyEventCallback != null) {
mPasskeyEventCallback.onPasskeyRequested(
FastPairSimulator.this::enterPassKey);
@@ -307,7 +296,7 @@
mLogger.log("passkeyEventCallback is not set!");
enterPassKey(key);
}
- } else if (variant == PAIRING_VARIANT_CONSENT) {
+ } else if (variant == BluetoothDevice.PAIRING_VARIANT_CONSENT) {
setPasskeyConfirmation(true);
} else if (variant == BluetoothDevice.PAIRING_VARIANT_PIN) {
@@ -1969,14 +1958,7 @@
public void enterPassKey(int passkey) {
mLogger.log("enterPassKey called with passkey %d.", passkey);
- try {
- boolean result =
- (Boolean) Reflect.on(mPairingDevice).withMethod("setPasskey", int.class).get(
- passkey);
- mLogger.log("enterPassKey called with result %b", result);
- } catch (ReflectionException e) {
- mLogger.log("enterPassKey meet Exception %s.", e.getMessage());
- }
+ mPairingDevice.setPairingConfirmation(true);
}
private void checkPasskey() {
@@ -2290,19 +2272,11 @@
}
public void disconnect(BluetoothProfile profile, BluetoothDevice device) {
- try {
- Reflect.on(profile).withMethod("disconnect", BluetoothDevice.class).invoke(device);
- } catch (ReflectionException e) {
- mLogger.log(e, "Error disconnecting device=%s from profile=%s", device, profile);
- }
+ device.disconnect();
}
public void removeBond(BluetoothDevice device) {
- try {
- Reflect.on(device).withMethod("removeBond").invoke();
- } catch (ReflectionException e) {
- mLogger.log(e, "Error removing bond for device=%s", device);
- }
+ device.removeBond();
}
public void resetAccountKeys() {
diff --git a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/OreoFastPairAdvertiser.java b/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/OreoFastPairAdvertiser.java
index bb77c11..bc0cdfe 100644
--- a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/OreoFastPairAdvertiser.java
+++ b/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/OreoFastPairAdvertiser.java
@@ -18,7 +18,6 @@
import static com.google.common.io.BaseEncoding.base16;
-import android.annotation.TargetApi;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.le.AdvertiseData;
import android.bluetooth.le.AdvertiseSettings;
@@ -27,21 +26,17 @@
import android.bluetooth.le.AdvertisingSetParameters;
import android.bluetooth.le.BluetoothLeAdvertiser;
import android.nearby.fastpair.provider.utils.Logger;
-import android.os.Build.VERSION_CODES;
import android.os.ParcelUuid;
import androidx.annotation.Nullable;
import com.android.server.nearby.common.bluetooth.fastpair.Constants.FastPairService;
-import com.android.server.nearby.common.bluetooth.fastpair.Reflect;
-import com.android.server.nearby.common.bluetooth.fastpair.ReflectionException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
/** Fast Pair advertiser taking advantage of new Android Oreo advertising features. */
-@TargetApi(VERSION_CODES.O)
public final class OreoFastPairAdvertiser implements FastPairAdvertiser {
private static final String TAG = "OreoFastPairAdvertiser";
private final Logger mLogger = new Logger(TAG);
@@ -63,13 +58,7 @@
mLogger.log("Advertising succeeded, advertising at %s dBm", txPower);
simulator.setIsAdvertising(true);
mAdvertisingSet = set;
-
- try {
- // Requires custom Android build, see callback below.
- Reflect.on(set).withMethod("getOwnAddress").invoke();
- } catch (ReflectionException e) {
- mLogger.log(e, "Error calling getOwnAddress for AdvertisingSet");
- }
+ mAdvertisingSet.getOwnAddress();
} else {
mLogger.log(
new IllegalStateException(),
@@ -88,7 +77,8 @@
}
}
- // Called via reflection with AdvertisingSet.getOwnAddress().
+ // Callback for AdvertisingSet.getOwnAddress().
+ @Override
public void onOwnAddressRead(
AdvertisingSet set, int addressType, String address) {
if (!address.equals(simulator.getBleAddress())) {
@@ -108,12 +98,7 @@
public void startAdvertising(@Nullable byte[] serviceData) {
// To be informed that BLE address is rotated, we need to polling query it asynchronously.
if (mAdvertisingSet != null) {
- try {
- // Requires custom Android build, see callback: onOwnAddressRead.
- Reflect.on(mAdvertisingSet).withMethod("getOwnAddress").invoke();
- } catch (ReflectionException ignored) {
- // Ignore it due to user already knows it when setting advertisingSet.
- }
+ mAdvertisingSet.getOwnAddress();
}
if (mSimulator.isDestroyed()) {
diff --git a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/bluetooth/BluetoothController.kt b/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/bluetooth/BluetoothController.kt
index 6a3e59e..0cc0c92 100644
--- a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/bluetooth/BluetoothController.kt
+++ b/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/bluetooth/BluetoothController.kt
@@ -26,15 +26,13 @@
import android.content.IntentFilter
import android.nearby.fastpair.provider.FastPairSimulator
import android.nearby.fastpair.provider.utils.Logger
-import android.nearby.fastpair.provider.utils.Reflect
-import android.nearby.fastpair.provider.utils.ReflectionException
import android.os.SystemClock
import android.provider.Settings
/** Controls the local Bluetooth adapter for Fast Pair testing. */
class BluetoothController(
private val context: Context,
- private val listener: EventListener,
+ private val listener: EventListener
) : BroadcastReceiver() {
private val mLogger = Logger(TAG)
private val bluetoothAdapter: BluetoothAdapter =
@@ -67,23 +65,10 @@
* ```
*/
fun setIoCapability(ioCapabilityClassic: Int, ioCapabilityBLE: Int) {
- try {
- Reflect.on(bluetoothAdapter)
- .withMethod("setIoCapability", Int::class.javaPrimitiveType)[
- ioCapabilityClassic]
- } catch (e: ReflectionException) {
- mLogger.log(e, "Error setIoCapability to %s: %s", ioCapabilityClassic)
- }
- try {
- Reflect.on(bluetoothAdapter)
- .withMethod("setLeIoCapability", Int::class.javaPrimitiveType)[
- ioCapabilityBLE]
- } catch (e: ReflectionException) {
- mLogger.log(e, "Error setLeIoCapability to %s: %s", ioCapabilityBLE)
- }
+ bluetoothAdapter.ioCapability = ioCapabilityClassic
+ bluetoothAdapter.leIoCapability = ioCapabilityBLE
// Toggling airplane mode on/off to restart Bluetooth stack and reset the BLE.
- // Since it also increases reliability, we will do so even if ReflectionException is caught.
try {
Settings.Global.putInt(
context.contentResolver,
@@ -165,7 +150,7 @@
override fun onServiceDisconnected(profile: Int) {}
},
- BLUETOOTH_PROFILE_A2DP_SINK
+ BluetoothProfile.A2DP_SINK
)
}
@@ -204,7 +189,8 @@
else -> remoteDevice
}
mLogger.log(
- "ACTION_BOND_STATE_CHANGED, the bound state of the remote device (%s) change to %s.",
+ "ACTION_BOND_STATE_CHANGED, the bound state of " +
+ "the remote device (%s) change to %s.",
remoteDevice?.remoteDeviceToString(),
bondState.bondStateToString()
)
@@ -284,9 +270,6 @@
companion object {
private const val TAG = "BluetoothController"
- /** Hidden SystemApi field in [BluetoothProfile] interface. */
- private const val BLUETOOTH_PROFILE_A2DP_SINK = 11
-
private const val TURN_AIRPLANE_MODE_OFF = 0
private const val TURN_AIRPLANE_MODE_ON = 1
}
diff --git a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/utils/Reflect.java b/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/utils/Reflect.java
deleted file mode 100644
index 5ae5310..0000000
--- a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/utils/Reflect.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2022 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.fastpair.provider.utils;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Utilities for calling methods using reflection. The main benefit of using this helper is to avoid
- * complications around exception handling when calling methods reflectively. It's not safe to use
- * Java 8's multicatch on such exceptions, because the java compiler converts multicatch into
- * ReflectiveOperationException in some instances, which doesn't work on older sdk versions.
- * Instead, use these utilities and catch ReflectionException.
- *
- * <p>Example usage:
- *
- * <pre>{@code
- * try {
- * Reflect.on(btAdapter)
- * .withMethod("setScanMode", int.class)
- * .invoke(BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE)
- * } catch (ReflectionException e) { }
- * }</pre>
- */
-public final class Reflect {
- private final Object mTargetObject;
-
- private Reflect(Object targetObject) {
- this.mTargetObject = targetObject;
- }
-
- /** Creates an instance of this helper to invoke methods on the given target object. */
- public static Reflect on(Object targetObject) {
- return new Reflect(targetObject);
- }
-
- /** Finds a method with the given name and parameter types. */
- public ReflectionMethod withMethod(String methodName, Class<?>... paramTypes)
- throws ReflectionException {
- try {
- return new ReflectionMethod(mTargetObject.getClass().getMethod(methodName, paramTypes));
- } catch (NoSuchMethodException e) {
- throw new ReflectionException(e);
- }
- }
-
- /** Represents an invokable method found reflectively. */
- public final class ReflectionMethod {
- private final Method mMethod;
-
- private ReflectionMethod(Method method) {
- this.mMethod = method;
- }
-
- /**
- * Invokes this instance method with the given parameters. The called method does not return
- * a value.
- */
- public void invoke(Object... parameters) throws ReflectionException {
- try {
- mMethod.invoke(mTargetObject, parameters);
- } catch (IllegalAccessException e) {
- throw new ReflectionException(e);
- } catch (InvocationTargetException e) {
- throw new ReflectionException(e);
- }
- }
-
- /**
- * Invokes this instance method with the given parameters. The called method returns a non
- * null
- * value.
- */
- public Object get(Object... parameters) throws ReflectionException {
- Object value;
- try {
- value = mMethod.invoke(mTargetObject, parameters);
- } catch (IllegalAccessException e) {
- throw new ReflectionException(e);
- } catch (InvocationTargetException e) {
- throw new ReflectionException(e);
- }
- if (value == null) {
- throw new ReflectionException(new NullPointerException());
- }
- return value;
- }
- }
-}
diff --git a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/utils/ReflectionException.java b/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/utils/ReflectionException.java
deleted file mode 100644
index 959fd11..0000000
--- a/nearby/tests/multidevices/clients/test_support/fastpair_provider/src/android/nearby/fastpair/provider/utils/ReflectionException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2022 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.fastpair.provider.utils;
-
-/**
- * An exception thrown during a reflection operation. Like ReflectiveOperationException, except
- * compatible on older API versions.
- */
-public final class ReflectionException extends Exception {
- public ReflectionException(Throwable cause) {
- super(cause.getMessage(), cause);
- }
-}
diff --git a/nearby/tests/multidevices/host/initial_pairing_test.py b/nearby/tests/multidevices/host/initial_pairing_test.py
new file mode 100644
index 0000000..1a49045
--- /dev/null
+++ b/nearby/tests/multidevices/host/initial_pairing_test.py
@@ -0,0 +1,62 @@
+# Copyright (C) 2022 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.
+
+"""CTS-V Nearby Mainline Fast Pair end-to-end test case: initial pairing test."""
+
+from test_helper import constants
+from test_helper import fast_pair_base_test
+
+# The model ID to simulate on provider side.
+PROVIDER_SIMULATOR_MODEL_ID = constants.DEFAULT_MODEL_ID
+# The public key to simulate as registered headsets.
+PROVIDER_SIMULATOR_ANTI_SPOOFING_KEY = constants.DEFAULT_ANTI_SPOOFING_KEY
+# The anti-spoof key device metadata JSON file for data provider at seeker side.
+PROVIDER_SIMULATOR_KDM_JSON_FILE = constants.DEFAULT_KDM_JSON_FILE
+
+# Time in seconds for events waiting.
+SETUP_TIMEOUT_SEC = constants.SETUP_TIMEOUT_SEC
+BECOME_DISCOVERABLE_TIMEOUT_SEC = constants.BECOME_DISCOVERABLE_TIMEOUT_SEC
+START_ADVERTISING_TIMEOUT_SEC = constants.START_ADVERTISING_TIMEOUT_SEC
+HALF_SHEET_POPUP_TIMEOUT_SEC = constants.HALF_SHEET_POPUP_TIMEOUT_SEC
+MANAGE_ACCOUNT_DEVICE_TIMEOUT_SEC = constants.AVERAGE_PAIRING_TIMEOUT_SEC * 2
+
+
+class InitialPairingTest(fast_pair_base_test.FastPairBaseTest):
+ """Fast Pair initial pairing test."""
+
+ def setup_test(self) -> None:
+ super().setup_test()
+ self._provider.start_model_id_advertising(PROVIDER_SIMULATOR_MODEL_ID,
+ PROVIDER_SIMULATOR_ANTI_SPOOFING_KEY)
+ self._provider.wait_for_discoverable_mode(BECOME_DISCOVERABLE_TIMEOUT_SEC)
+ self._provider.wait_for_advertising_start(START_ADVERTISING_TIMEOUT_SEC)
+ self._seeker.put_anti_spoof_key_device_metadata(PROVIDER_SIMULATOR_MODEL_ID,
+ PROVIDER_SIMULATOR_KDM_JSON_FILE)
+ self._seeker.set_fast_pair_scan_enabled(True)
+
+ # TODO(b/214015364): Remove Bluetooth bound on both sides ("Forget device").
+ def teardown_test(self) -> None:
+ self._seeker.set_fast_pair_scan_enabled(False)
+ self._provider.teardown_provider_simulator()
+ self._seeker.dismiss_halfsheet()
+ super().teardown_test()
+
+ def test_seeker_initial_pair_provider(self) -> None:
+ self._seeker.wait_and_assert_halfsheet_showed(
+ timeout_seconds=HALF_SHEET_POPUP_TIMEOUT_SEC,
+ expected_model_id=PROVIDER_SIMULATOR_MODEL_ID)
+ self._seeker.start_pairing()
+ self._seeker.wait_and_assert_account_device(
+ get_account_key_from_provider=self._provider.get_latest_received_account_key,
+ timeout_seconds=MANAGE_ACCOUNT_DEVICE_TIMEOUT_SEC)
diff --git a/nearby/tests/multidevices/host/suite_main.py b/nearby/tests/multidevices/host/suite_main.py
index 406a4f0..4f5d48c 100644
--- a/nearby/tests/multidevices/host/suite_main.py
+++ b/nearby/tests/multidevices/host/suite_main.py
@@ -19,6 +19,7 @@
from mobly import suite_runner
+import initial_pairing_test
import seeker_discover_provider_test
import seeker_show_halfsheet_test
@@ -26,6 +27,7 @@
_TEST_CLASSES_LIST = [
seeker_discover_provider_test.SeekerDiscoverProviderTest,
seeker_show_halfsheet_test.SeekerShowHalfSheetTest,
+ initial_pairing_test.InitialPairingTest,
]
diff --git a/nearby/tests/multidevices/host/test_data/fastpair/pixelbuds-a_account_devicemeta_json.txt b/nearby/tests/multidevices/host/test_data/fastpair/pixelbuds-a_account_devicemeta_json.txt
index 6be58df..d3deb40 100644
--- a/nearby/tests/multidevices/host/test_data/fastpair/pixelbuds-a_account_devicemeta_json.txt
+++ b/nearby/tests/multidevices/host/test_data/fastpair/pixelbuds-a_account_devicemeta_json.txt
@@ -19,20 +19,10 @@
"subsequent_pairing_description": "Connect %s to this phone",
"retroactive_pairing_description": "Save device to %s for faster pairing to your other devices",
"wait_launch_companion_app_description": "This will take a few moments",
- "fail_connect_go_to_settings_description": "Try manually pairing to the device by going to Settings",
- "confirm_pin_title": "",
- "confirm_pin_description": "",
- "sync_contacts_title": "",
- "sync_contacts_description": "",
- "sync_sms_title": "",
- "sync_sms_description": "",
- "assistant_setup_half_sheet": "Get hands-free help on the go from Google Assistant",
- "assistant_setup_notification": "Tap to set up your Google Assistant",
- "fast_pair_tv_connect_device_no_account_description": "Select connect to pair your %s with this device"
+ "fail_connect_go_to_settings_description": "Try manually pairing to the device by going to Settings"
},
"fast_pair_discovery_item": {
"id": "",
- "type": 6,
"mac_address": "",
"action_url": "intent:#Intent;action=com.google.android.gms.nearby.discovery%3AACTION_MAGIC_PAIR;package=com.google.android.gms;component=com.google.android.gms\/.nearby.discovery.service.DiscoveryService;S.com.google.android.gms.nearby.discovery%3AEXTRA_COMPANION_APP=com.google.android.apps.wearables.maestro.companion;end",
"device_name": "",
@@ -47,19 +37,10 @@
"pending_app_install_timestamp_millis": 0,
"tx_power": 0,
"app_name": "",
- "group_id": "",
- "attachment_type": 0,
"package_name": "",
- "feature_graphic_url": "",
"trigger_id": "",
"icon_png": "",
"icon_fife_url": "https:\/\/lh3.googleusercontent.com\/2PffmZiopo2AjT8sshX0Se3jV-91cp4yOCIay2bBvZqKoKGVy5B4uyzdHsde6UrUSGaoCqV-h4edd5ZljA4oSGc",
- "debug_message": "",
- "debug_category": 0,
- "lost_millis": 0,
- "last_user_experience": 0,
- "ble_record_bytes": "",
- "entity_id": "",
"authentication_public_key_secp256r1": "z+grhW8lWVA34JUQhXOxMrk1WqVy+VpEDd2K+01ZJvS6KdV0OUg7FRMzq+ITuOqKO\/2TIRKEAEfMKdyk2Ob1Vw=="
}
}
diff --git a/nearby/tests/multidevices/host/test_data/fastpair/pixelbuds-a_antispoofkey_devicemeta_json.txt b/nearby/tests/multidevices/host/test_data/fastpair/pixelbuds-a_antispoofkey_devicemeta_json.txt
index c03d000..3611b03 100644
--- a/nearby/tests/multidevices/host/test_data/fastpair/pixelbuds-a_antispoofkey_devicemeta_json.txt
+++ b/nearby/tests/multidevices/host/test_data/fastpair/pixelbuds-a_antispoofkey_devicemeta_json.txt
@@ -10,7 +10,6 @@
"left_bud_url": "https:\/\/lh3.googleusercontent.com\/O8SVJ5E7CXUkpkym7ibZbp6wypuO7HaTFcslT_FjmEzJX4KHoIY_kzLTdK2kwJXiDBgg8cC__sG-JJ5aVnQtFjQ",
"right_bud_url": "https:\/\/lh3.googleusercontent.com\/X_FsRmEKH_fgKzvopyrlyWJAdczRel42Tih7p9-e-U48gBTaggGVQx70K27TzlqIaqYVuaNpTnGoUsKIgiy4WA",
"case_url": "https:\/\/lh3.googleusercontent.com\/mNZ7CGplQSpZhoY79jXDQU4B65eY2f0SndnYZLk1PSm8zKTYeRU7REmrLL_pptD6HpVI2F_oQ6xhhtZKOvB8EQ",
- "locale": "en-US",
"initial_notification_description": "Tap to pair. Earbuds will be tied to %s",
"initial_notification_description_no_account": "Tap to pair with this device",
"open_companion_app_description": "Tap to finish setup",
@@ -24,15 +23,6 @@
"subsequent_pairing_description": "Connect %s to this phone",
"retroactive_pairing_description": "Save device to %s for faster pairing to your other devices",
"wait_launch_companion_app_description": "This will take a few moments",
- "fail_connect_go_to_settings_description": "Try manually pairing to the device by going to Settings",
- "confirm_pin_title": "",
- "confirm_pin_description": "",
- "sync_contacts_title": "",
- "sync_contacts_description": "",
- "sync_sms_title": "",
- "sync_sms_description": "",
- "assistant_setup_half_sheet": "Get hands-free help on the go from Google Assistant",
- "assistant_setup_notification": "Tap to set up your Google Assistant",
- "fast_pair_tv_connect_device_no_account_description": "Select connect to pair your %s with this device"
+ "fail_connect_go_to_settings_description": "Try manually pairing to the device by going to Settings"
}
}
\ No newline at end of file
diff --git a/nearby/tests/multidevices/host/test_data/fastpair/simulator_account_devicemeta_json.txt b/nearby/tests/multidevices/host/test_data/fastpair/simulator_account_devicemeta_json.txt
index 392c443..ed60860 100644
--- a/nearby/tests/multidevices/host/test_data/fastpair/simulator_account_devicemeta_json.txt
+++ b/nearby/tests/multidevices/host/test_data/fastpair/simulator_account_devicemeta_json.txt
@@ -3,17 +3,12 @@
"account_key": "BPy5AaSyMfrFvMNgr6f7GA==",
"sha256_account_key_public_address": "jNGRz+Ni6ZuLd8hVF3lmGoJnF5byXBUyVi9CmnrF1so=",
"fast_pair_device_metadata": {
- "assistant_setup_half_sheet": "Get hands-free help on the go from Google Assistant",
- "assistant_setup_notification": "Tap to set up your Google Assistant",
"ble_tx_power": 0,
"case_url": "",
- "confirm_pin_description": "",
- "confirm_pin_title": "",
"connect_success_companion_app_installed": "Your device is ready to be set up",
"connect_success_companion_app_not_installed": "Download the device app on Google Play to see all available features",
"device_type": 0,
"fail_connect_go_to_settings_description": "Try manually pairing to the device by going to Settings",
- "fast_pair_tv_connect_device_no_account_description": "Select connect to pair your %s with this device",
"image_url": "https://lh3.googleusercontent.com/2PffmZiopo2AjT8sshX0Se3jV-91cp4yOCIay2bBvZqKoKGVy5B4uyzdHsde6UrUSGaoCqV-h4edd5ZljA4oSGc",
"initial_notification_description": "Tap to pair. Earbuds will be tied to %s",
"initial_notification_description_no_account": "Tap to pair with this device",
@@ -23,10 +18,6 @@
"retroactive_pairing_description": "Save device to %s for faster pairing to your other devices",
"right_bud_url": "",
"subsequent_pairing_description": "Connect %s to this phone",
- "sync_contacts_description": "",
- "sync_contacts_title": "",
- "sync_sms_description": "",
- "sync_sms_title": "",
"trigger_distance": 0,
"wait_launch_companion_app_description": "This will take a few moments"
},
@@ -34,24 +25,15 @@
"action_url": "intent:#Intent;action=com.google.android.gms.nearby.discovery%3AACTION_MAGIC_PAIR;package=com.google.android.gms;component=com.google.android.gms/.nearby.discovery.service.DiscoveryService;S.com.google.android.gms.nearby.discovery%3AEXTRA_COMPANION_APP=com.google.android.apps.wearables.maestro.companion;end",
"action_url_type": 2,
"app_name": "",
- "attachment_type": 0,
"authentication_public_key_secp256r1": "z+grhW8lWVA34JUQhXOxMrk1WqVy+VpEDd2K+01ZJvS6KdV0OUg7FRMzq+ITuOqKO/2TIRKEAEfMKdyk2Ob1Vw==",
- "ble_record_bytes": "",
- "debug_category": 0,
- "debug_message": "",
"description": "Tap to pair with this device",
"device_name": "",
"display_url": "",
- "entity_id": "",
- "feature_graphic_url": "",
"first_observation_timestamp_millis": 0,
- "group_id": "",
"icon_fife_url": "https://lh3.googleusercontent.com/2PffmZiopo2AjT8sshX0Se3jV-91cp4yOCIay2bBvZqKoKGVy5B4uyzdHsde6UrUSGaoCqV-h4edd5ZljA4oSGc",
"icon_png": "",
"id": "",
"last_observation_timestamp_millis": 0,
- "last_user_experience": 0,
- "lost_millis": 0,
"mac_address": "",
"package_name": "",
"pending_app_install_timestamp_millis": 0,
@@ -59,8 +41,7 @@
"state": 1,
"title": "Pixel Buds A-Series",
"trigger_id": "",
- "tx_power": 0,
- "type": 6
+ "tx_power": 0
}
}
]
\ No newline at end of file
diff --git a/nearby/tests/multidevices/host/test_data/fastpair/simulator_antispoofkey_devicemeta_json.txt b/nearby/tests/multidevices/host/test_data/fastpair/simulator_antispoofkey_devicemeta_json.txt
index 7cb29f4..fc9706a 100644
--- a/nearby/tests/multidevices/host/test_data/fastpair/simulator_antispoofkey_devicemeta_json.txt
+++ b/nearby/tests/multidevices/host/test_data/fastpair/simulator_antispoofkey_devicemeta_json.txt
@@ -1,34 +1,24 @@
{
"anti_spoofing_public_key_str": "sjp\/AOS7+VnTCaueeWorjdeJ8Nc32EOmpe\/QRhzY9+cMNELU1QA3jzgvUXdWW73nl6+EN01eXtLBu2Fw9CGmfA==",
"fast_pair_device_metadata": {
- "assistant_setup_half_sheet": "Get hands-free help on the go from Google Assistant",
- "assistant_setup_notification": "Tap to set up your Google Assistant",
"ble_tx_power": -10,
"case_url": "https://lh3.googleusercontent.com/mNZ7CGplQSpZhoY79jXDQU4B65eY2f0SndnYZLk1PSm8zKTYeRU7REmrLL_pptD6HpVI2F_oQ6xhhtZKOvB8EQ",
- "confirm_pin_description": "",
- "confirm_pin_title": "",
"connect_success_companion_app_installed": "Your device is ready to be set up",
"connect_success_companion_app_not_installed": "Download the device app on Google Play to see all available features",
"device_type": 7,
"download_companion_app_description": "Tap to download device app on Google Play and see all features",
"fail_connect_go_to_settings_description": "Try manually pairing to the device by going to Settings",
- "fast_pair_tv_connect_device_no_account_description": "Select connect to pair your %s with this device",
"image_url": "https://lh3.googleusercontent.com/THpAzISZGa5F86cMsBcTPhRWefBPc5dorBxWdOPCGvbFg6ZMHUjFuE-4kbLuoLoIMHf3Fd8jUvvcxnjp_Q",
"initial_notification_description": "Tap to pair. Earbuds will be tied to %s",
"initial_notification_description_no_account": "Tap to pair with this device",
"initial_pairing_description": "%s will appear on devices linked with %s",
"intent_uri": "intent:#Intent;action=com.google.android.gms.nearby.discovery%3AACTION_MAGIC_PAIR;package=com.google.android.gms;component=com.google.android.gms/.nearby.discovery.service.DiscoveryService;S.com.google.android.gms.nearby.discovery%3AEXTRA_COMPANION_APP=com.google.android.testapp;end",
"left_bud_url": "https://lh3.googleusercontent.com/O8SVJ5E7CXUkpkym7ibZbp6wypuO7HaTFcslT_FjmEzJX4KHoIY_kzLTdK2kwJXiDBgg8cC__sG-JJ5aVnQtFjQ",
- "locale": "en-US",
"name": "Fast Pair Provider Simulator",
"open_companion_app_description": "Tap to finish setup",
"retroactive_pairing_description": "Save device to %s for faster pairing to your other devices",
"right_bud_url": "https://lh3.googleusercontent.com/X_FsRmEKH_fgKzvopyrlyWJAdczRel42Tih7p9-e-U48gBTaggGVQx70K27TzlqIaqYVuaNpTnGoUsKIgiy4WA",
"subsequent_pairing_description": "Connect %s to this phone",
- "sync_contacts_description": "",
- "sync_contacts_title": "",
- "sync_sms_description": "",
- "sync_sms_title": "",
"trigger_distance": 0.6000000238418579,
"unable_to_connect_description": "Try manually pairing to the device",
"unable_to_connect_title": "Unable to connect",
diff --git a/nearby/tests/multidevices/host/test_helper/constants.py b/nearby/tests/multidevices/host/test_helper/constants.py
index 646b428..342be8f 100644
--- a/nearby/tests/multidevices/host/test_helper/constants.py
+++ b/nearby/tests/multidevices/host/test_helper/constants.py
@@ -21,12 +21,14 @@
# Default anti-spoof Key Device Metadata JSON file for data provider at seeker side.
DEFAULT_KDM_JSON_FILE = 'simulator_antispoofkey_devicemeta_json.txt'
-# Time in seconds for events waiting.
+# Time in seconds for events waiting according to Fast Pair certification guidelines:
+# https://developers.google.com/nearby/fast-pair/certification-guideline
SETUP_TIMEOUT_SEC = 5
BECOME_DISCOVERABLE_TIMEOUT_SEC = 10
START_ADVERTISING_TIMEOUT_SEC = 5
-SCAN_TIMEOUT_SEC = 30
-HALF_SHEET_POPUP_TIMEOUT_SEC = 30
+SCAN_TIMEOUT_SEC = 5
+HALF_SHEET_POPUP_TIMEOUT_SEC = 5
+AVERAGE_PAIRING_TIMEOUT_SEC = 12
# The phone to simulate Fast Pair provider (like headphone) needs changes in Android system:
# 1. System permission check removal
diff --git a/nearby/tests/multidevices/host/test_helper/fast_pair_provider_simulator.py b/nearby/tests/multidevices/host/test_helper/fast_pair_provider_simulator.py
index 8a98112..d6484fb 100644
--- a/nearby/tests/multidevices/host/test_helper/fast_pair_provider_simulator.py
+++ b/nearby/tests/multidevices/host/test_helper/fast_pair_provider_simulator.py
@@ -18,6 +18,7 @@
from mobly.controllers import android_device
from mobly.controllers.android_device_lib import snippet_event
import retry
+from typing import Optional
from test_helper import event_helper
@@ -179,3 +180,11 @@
on_received=_on_advertising_mode_change_event_received,
on_waiting=_on_advertising_mode_change_event_waiting,
on_missed=_on_advertising_mode_change_event_missed)
+
+ def get_latest_received_account_key(self) -> Optional[str]:
+ """Gets the latest account key received on the provider side.
+
+ Returns:
+ The account key received at provider side.
+ """
+ return self._ad.fp.getLatestReceivedAccountKey()
diff --git a/nearby/tests/multidevices/host/test_helper/fast_pair_seeker.py b/nearby/tests/multidevices/host/test_helper/fast_pair_seeker.py
index cfdb966..64fc2f2 100644
--- a/nearby/tests/multidevices/host/test_helper/fast_pair_seeker.py
+++ b/nearby/tests/multidevices/host/test_helper/fast_pair_seeker.py
@@ -14,6 +14,9 @@
"""Fast Pair seeker role."""
+import json
+from typing import Callable, Optional
+
from mobly import asserts
from mobly.controllers import android_device
from mobly.controllers.android_device_lib import snippet_event
@@ -26,10 +29,12 @@
# Events reported from the seeker snippet.
ON_PROVIDER_FOUND_EVENT = 'onDiscovered'
+ON_MANAGE_ACCOUNT_DEVICE_EVENT = 'onManageAccountDevice'
# Abbreviations for common use type.
AndroidDevice = android_device.AndroidDevice
JsonObject = utils.JsonObject
+ProviderAccountKeyCallable = Callable[[], Optional[str]]
SnippetEvent = snippet_event.SnippetEvent
wait_for_event = event_helper.wait_callback_event
@@ -41,6 +46,7 @@
self._ad = ad
self._ad.debug_tag = 'MainlineFastPairSeeker'
self._scan_result_callback = None
+ self._pairing_result_callback = None
def load_snippet(self) -> None:
"""Starts the seeker snippet and connects.
@@ -58,18 +64,6 @@
"""Stops the Fast Pair seeker scanning."""
self._ad.fp.stopScan()
- def start_pair(self, model_id: str, address: str) -> None:
- """Starts the Fast Pair seeker pairing.
-
- Args:
- model_id: A 3-byte hex string for seeker side to recognize the provider
- device (ex: 0x00000C).
- address: The BLE mac address of the Fast Pair provider.
- """
- self._ad.log.info('Before calling startPairing')
- self._ad.fp.startPairing(model_id, address)
- self._ad.log.info('After calling startPairing')
-
def wait_and_assert_provider_found(self, timeout_seconds: int,
expected_model_id: str,
expected_ble_mac_address: str) -> None:
@@ -137,8 +131,8 @@
Args:
timeout_seconds: The number of seconds to wait before giving up.
- expected_model_id: The expected model ID of the remote Fast Pair provider
- device.
+ expected_model_id: A 3-byte hex string for seeker side to recognize
+ the remote provider device (ex: 0x00000c).
"""
self._ad.log.info('Waits and asserts the half sheet showed for model id "%s".',
expected_model_id)
@@ -147,3 +141,46 @@
def dismiss_halfsheet(self) -> None:
"""Dismisses the half sheet UI if showed."""
self._ad.fp.dismissHalfSheet()
+
+ def start_pairing(self) -> None:
+ """Starts pairing the provider via "Connect" button on half sheet UI."""
+ self._pairing_result_callback = self._ad.fp.startPairing()
+
+ def wait_and_assert_account_device(
+ self, timeout_seconds: int,
+ get_account_key_from_provider: ProviderAccountKeyCallable) -> None:
+ """Waits and asserts the onHalfSheetShowed event from the seeker.
+
+ Args:
+ timeout_seconds: The number of seconds to wait before giving up.
+ get_account_key_from_provider: The callable to get expected account key from the provider
+ side.
+ """
+
+ def _on_manage_account_device_event_received(manage_account_device_event: SnippetEvent,
+ elapsed_time: int) -> bool:
+ account_key_json_str = manage_account_device_event.data['accountDeviceJsonString']
+ account_key_from_seeker = json.loads(account_key_json_str)['account_key']
+ account_key_from_provider = get_account_key_from_provider()
+ self._ad.log.info('Seeker add an account device with account key "%s" in %d seconds.',
+ account_key_from_seeker, elapsed_time)
+ self._ad.log.info('The latest provider side account key is "%s".',
+ account_key_from_provider)
+ return account_key_from_seeker == account_key_from_provider
+
+ def _on_manage_account_device_event_waiting(elapsed_time: int) -> None:
+ self._ad.log.info(
+ 'Still waiting "%s" event callback from seeker side '
+ 'after %d seconds...', ON_MANAGE_ACCOUNT_DEVICE_EVENT, elapsed_time)
+
+ def _on_manage_account_device_event_missed() -> None:
+ asserts.fail(f'Timed out after {timeout_seconds} seconds waiting for '
+ f'the specific "{ON_MANAGE_ACCOUNT_DEVICE_EVENT}" event.')
+
+ wait_for_event(
+ callback_event_handler=self._pairing_result_callback,
+ event_name=ON_MANAGE_ACCOUNT_DEVICE_EVENT,
+ timeout_seconds=timeout_seconds,
+ on_received=_on_manage_account_device_event_received,
+ on_waiting=_on_manage_account_device_event_waiting,
+ on_missed=_on_manage_account_device_event_missed)
diff --git a/nearby/tests/unit/src/android/nearby/ScanRequestTest.java b/nearby/tests/unit/src/android/nearby/ScanRequestTest.java
index 020f6d6..a45d8bb 100644
--- a/nearby/tests/unit/src/android/nearby/ScanRequestTest.java
+++ b/nearby/tests/unit/src/android/nearby/ScanRequestTest.java
@@ -18,10 +18,8 @@
import static android.nearby.ScanRequest.SCAN_MODE_BALANCED;
import static android.nearby.ScanRequest.SCAN_MODE_LOW_POWER;
-import static android.nearby.ScanRequest.SCAN_TYPE_EXPOSURE_NOTIFICATION;
import static android.nearby.ScanRequest.SCAN_TYPE_FAST_PAIR;
import static android.nearby.ScanRequest.SCAN_TYPE_NEARBY_PRESENCE;
-import static android.nearby.ScanRequest.SCAN_TYPE_NEARBY_SHARE;
import static com.google.common.truth.Truth.assertThat;
@@ -82,7 +80,7 @@
public void testSetWorkSource() {
WorkSource workSource = getWorkSource();
ScanRequest request = new ScanRequest.Builder()
- .setScanType(SCAN_TYPE_NEARBY_SHARE)
+ .setScanType(SCAN_TYPE_FAST_PAIR)
.setWorkSource(workSource)
.build();
@@ -93,7 +91,7 @@
@Test
public void testSetWorkSource_nullValue() {
ScanRequest request = new ScanRequest.Builder()
- .setScanType(SCAN_TYPE_EXPOSURE_NOTIFICATION)
+ .setScanType(SCAN_TYPE_FAST_PAIR)
.setWorkSource(null)
.build();
@@ -106,14 +104,14 @@
public void testToString() {
WorkSource workSource = getWorkSource();
ScanRequest request = new ScanRequest.Builder()
- .setScanType(SCAN_TYPE_NEARBY_SHARE)
+ .setScanType(SCAN_TYPE_FAST_PAIR)
.setScanMode(SCAN_MODE_BALANCED)
.setBleEnabled(true)
.setWorkSource(workSource)
.build();
assertThat(request.toString()).isEqualTo(
- "Request[scanType=2, scanMode=SCAN_MODE_BALANCED, "
+ "Request[scanType=1, scanMode=SCAN_MODE_BALANCED, "
+ "enableBle=true, workSource=WorkSource{1001 android.nearby.tests}, "
+ "scanFilters=[]]");
}
diff --git a/nearby/tests/unit/src/com/android/server/nearby/common/ble/util/RangingUtilsTest.java b/nearby/tests/unit/src/com/android/server/nearby/common/ble/util/RangingUtilsTest.java
index 2926015..ebe72b3 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/common/ble/util/RangingUtilsTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/common/ble/util/RangingUtilsTest.java
@@ -32,17 +32,14 @@
public void distanceFromRssi_getCorrectValue() {
// Distance expected to be 1.0 meters based on an RSSI/TxPower of -41dBm
// Using params: int rssi (dBm), int calibratedTxPower (dBm)
- double distance = RangingUtils.distanceFromRssi(-41, -41);
+ double distance = RangingUtils.distanceFromRssiAndTxPower(-82, -41);
assertThat(distance).isWithin(DELTA).of(1.0);
- double distance2 = RangingUtils.distanceFromRssi(-70, -50);
+ double distance2 = RangingUtils.distanceFromRssiAndTxPower(-111, -50);
assertThat(distance2).isWithin(DELTA).of(10.0);
- // testing that the double values are not casted to integers
- double distance3 = RangingUtils.distanceFromRssi(-67, -77);
- assertThat(distance3).isWithin(DELTA).of(0.31622776601683794);
-
- double distance4 = RangingUtils.distanceFromRssi(-50, -70);
+ //rssi txpower
+ double distance4 = RangingUtils.distanceFromRssiAndTxPower(-50, -29);
assertThat(distance4).isWithin(DELTA).of(0.1);
}
@@ -50,8 +47,17 @@
public void testRssiFromDistance() {
// RSSI expected at 1 meter based on the calibrated tx field of -41dBm
// Using params: distance (m), int calibratedTxPower (dBm),
- int rssi = RangingUtils.rssiFromDistance(1.0, -41);
+ int rssi = RangingUtils.rssiFromTargetDistance(1.0, -41);
- assertThat(rssi).isEqualTo(-41);
+ assertThat(rssi).isEqualTo(-82);
+ }
+
+ @Test
+ public void testOutOfRange() {
+ double distance = RangingUtils.distanceFromRssiAndTxPower(-200, -41);
+ assertThat(distance).isWithin(DELTA).of(177.82794);
+
+ distance = RangingUtils.distanceFromRssiAndTxPower(200, -41);
+ assertThat(distance).isWithin(DELTA).of(0);
}
}
diff --git a/nearby/tests/unit/src/com/android/server/nearby/fastpair/FastPairAdvHandlerTest.java b/nearby/tests/unit/src/com/android/server/nearby/fastpair/FastPairAdvHandlerTest.java
new file mode 100644
index 0000000..346a961
--- /dev/null
+++ b/nearby/tests/unit/src/com/android/server/nearby/fastpair/FastPairAdvHandlerTest.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2022 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 com.android.server.nearby.fastpair;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.nearby.FastPairDevice;
+
+import com.android.server.nearby.common.locator.LocatorContextWrapper;
+import com.android.server.nearby.fastpair.halfsheet.FastPairHalfSheetManager;
+import com.android.server.nearby.fastpair.notification.FastPairNotificationManager;
+import com.android.server.nearby.provider.FastPairDataProvider;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import service.proto.Rpcs;
+
+public class FastPairAdvHandlerTest {
+ @Mock
+ private Context mContext;
+ @Mock
+ private FastPairDataProvider mFastPairDataProvider;
+ @Mock
+ private FastPairHalfSheetManager mFastPairHalfSheetManager;
+ @Mock
+ private FastPairNotificationManager mFastPairNotificationManager;
+ private static final String BLUETOOTH_ADDRESS = "AA:BB:CC:DD";
+ private static final int CLOSE_RSSI = -80;
+ private static final int FAR_AWAY_RSSI = -120;
+ private static final int TX_POWER = -70;
+ private static final byte[] INITIAL_BYTE_ARRAY = new byte[]{0x01, 0x02, 0x03};
+
+ LocatorContextWrapper mLocatorContextWrapper;
+ FastPairAdvHandler mFastPairAdvHandler;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ mLocatorContextWrapper = new LocatorContextWrapper(mContext);
+ mLocatorContextWrapper.getLocator().overrideBindingForTest(
+ FastPairHalfSheetManager.class, mFastPairHalfSheetManager
+ );
+ mLocatorContextWrapper.getLocator().overrideBindingForTest(
+ FastPairNotificationManager.class, mFastPairNotificationManager
+ );
+ when(mFastPairDataProvider.loadFastPairAntispoofKeyDeviceMetadata(any()))
+ .thenReturn(Rpcs.GetObservedDeviceResponse.getDefaultInstance());
+ mFastPairAdvHandler = new FastPairAdvHandler(mLocatorContextWrapper, mFastPairDataProvider);
+ }
+
+ @Test
+ public void testInitialBroadcast() {
+ FastPairDevice fastPairDevice = new FastPairDevice.Builder()
+ .setData(INITIAL_BYTE_ARRAY)
+ .setBluetoothAddress(BLUETOOTH_ADDRESS)
+ .setRssi(CLOSE_RSSI)
+ .setTxPower(TX_POWER)
+ .build();
+
+ mFastPairAdvHandler.handleBroadcast(fastPairDevice);
+
+ verify(mFastPairHalfSheetManager).showHalfSheet(any());
+ }
+
+ @Test
+ public void testInitialBroadcast_farAway_notShowHalfSheet() {
+ FastPairDevice fastPairDevice = new FastPairDevice.Builder()
+ .setData(INITIAL_BYTE_ARRAY)
+ .setBluetoothAddress(BLUETOOTH_ADDRESS)
+ .setRssi(FAR_AWAY_RSSI)
+ .setTxPower(TX_POWER)
+ .build();
+
+ mFastPairAdvHandler.handleBroadcast(fastPairDevice);
+
+ verify(mFastPairHalfSheetManager, never()).showHalfSheet(any());
+ }
+
+ @Test
+ public void testSubsequentBroadcast() {
+ byte[] fastPairRecordWithBloomFilter =
+ new byte[]{
+ (byte) 0x02,
+ (byte) 0x01,
+ (byte) 0x02, // Flags
+ (byte) 0x02,
+ (byte) 0x0A,
+ (byte) 0xEB, // Tx Power (-20)
+ (byte) 0x0B,
+ (byte) 0x16,
+ (byte) 0x2C,
+ (byte) 0xFE, // FastPair Service Data
+ (byte) 0x00, // Flags (model ID length = 3)
+ (byte) 0x40, // Account key hash flags (length = 4, type = 0)
+ (byte) 0x11,
+ (byte) 0x22,
+ (byte) 0x33,
+ (byte) 0x44, // Account key hash (0x11223344)
+ (byte) 0x11, // Account key salt flags (length = 1, type = 1)
+ (byte) 0x55, // Account key salt
+ };
+ FastPairDevice fastPairDevice = new FastPairDevice.Builder()
+ .setData(fastPairRecordWithBloomFilter)
+ .setBluetoothAddress(BLUETOOTH_ADDRESS)
+ .setRssi(CLOSE_RSSI)
+ .setTxPower(TX_POWER)
+ .build();
+
+ mFastPairAdvHandler.handleBroadcast(fastPairDevice);
+
+ verify(mFastPairHalfSheetManager, never()).showHalfSheet(any());
+ }
+}
diff --git a/nearby/tests/unit/src/com/android/server/nearby/fastpair/testing/FakeDiscoveryItems.java b/nearby/tests/unit/src/com/android/server/nearby/fastpair/testing/FakeDiscoveryItems.java
index aa7e6f6..c406e47 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/fastpair/testing/FakeDiscoveryItems.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/fastpair/testing/FakeDiscoveryItems.java
@@ -42,7 +42,6 @@
item.setState(Cache.StoredDiscoveryItem.State.STATE_ENABLED);
item.setId(FAST_PAIR_ID);
item.setDescription(DEFAULT_DESCRIPITON);
- item.setType(Cache.NearbyType.NEARBY_DEVICE);
item.setTriggerId(triggerId);
item.setMacAddress(DEFAULT_MAC_ADDRESS);
item.setFirstObservationTimestampMillis(DEFAULT_TIMESTAMP);
diff --git a/nearby/tests/unit/src/com/android/server/nearby/metrics/NearbyMetricsTest.java b/nearby/tests/unit/src/com/android/server/nearby/metrics/NearbyMetricsTest.java
index c4d1ee2..91962ce 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/metrics/NearbyMetricsTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/metrics/NearbyMetricsTest.java
@@ -17,7 +17,7 @@
package com.android.server.nearby.metrics;
import static android.nearby.ScanRequest.SCAN_MODE_BALANCED;
-import static android.nearby.ScanRequest.SCAN_TYPE_NEARBY_SHARE;
+import static android.nearby.ScanRequest.SCAN_TYPE_FAST_PAIR;
import android.nearby.NearbyDeviceParcelable;
import android.nearby.PublicCredential;
@@ -59,7 +59,7 @@
private final ScanRequest.Builder mScanRequestBuilder =
new ScanRequest.Builder()
.setScanMode(SCAN_MODE_BALANCED)
- .setScanType(SCAN_TYPE_NEARBY_SHARE);
+ .setScanType(SCAN_TYPE_FAST_PAIR);
private final ScanRequest mScanRequest = mScanRequestBuilder.setWorkSource(mWorkSource).build();
private final ScanRequest mScanRequestWithEmptyWorkSource =
mScanRequestBuilder.setWorkSource(mEmptyWorkSource).build();
@@ -103,7 +103,7 @@
SESSION_ID,
NearbyStatsLog
.NEARBY_DEVICE_SCAN_STATE_CHANGED__SCAN_STATE__NEARBY_SCAN_STATE_STARTED,
- SCAN_TYPE_NEARBY_SHARE,
+ SCAN_TYPE_FAST_PAIR,
0,
0,
"",
@@ -119,7 +119,7 @@
SESSION_ID,
NearbyStatsLog
.NEARBY_DEVICE_SCAN_STATE_CHANGED__SCAN_STATE__NEARBY_SCAN_STATE_STARTED,
- SCAN_TYPE_NEARBY_SHARE,
+ SCAN_TYPE_FAST_PAIR,
0,
0,
"",
@@ -135,7 +135,7 @@
SESSION_ID,
NearbyStatsLog
.NEARBY_DEVICE_SCAN_STATE_CHANGED__SCAN_STATE__NEARBY_SCAN_STATE_STOPPED,
- SCAN_TYPE_NEARBY_SHARE,
+ SCAN_TYPE_FAST_PAIR,
0,
0,
"",
@@ -151,7 +151,7 @@
SESSION_ID,
NearbyStatsLog
.NEARBY_DEVICE_SCAN_STATE_CHANGED__SCAN_STATE__NEARBY_SCAN_STATE_STOPPED,
- SCAN_TYPE_NEARBY_SHARE,
+ SCAN_TYPE_FAST_PAIR,
0,
0,
"",
@@ -167,7 +167,7 @@
SESSION_ID,
NearbyStatsLog
.NEARBY_DEVICE_SCAN_STATE_CHANGED__SCAN_STATE__NEARBY_SCAN_STATE_DISCOVERED,
- SCAN_TYPE_NEARBY_SHARE,
+ SCAN_TYPE_FAST_PAIR,
SCAN_MEDIUM,
RSSI,
FAST_PAIR_MODEL_ID,
@@ -184,7 +184,7 @@
SESSION_ID,
NearbyStatsLog
.NEARBY_DEVICE_SCAN_STATE_CHANGED__SCAN_STATE__NEARBY_SCAN_STATE_DISCOVERED,
- SCAN_TYPE_NEARBY_SHARE,
+ SCAN_TYPE_FAST_PAIR,
SCAN_MEDIUM,
RSSI,
FAST_PAIR_MODEL_ID,
diff --git a/nearby/tests/unit/src/com/android/server/nearby/provider/UtilsTest.java b/nearby/tests/unit/src/com/android/server/nearby/provider/UtilsTest.java
index 205d5c2..eeea319 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/provider/UtilsTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/provider/UtilsTest.java
@@ -310,13 +310,6 @@
private static void ensureHappyPathAsExpected(FastPairDeviceMetadataParcel metadataParcel) {
assertThat(metadataParcel).isNotNull();
- assertThat(metadataParcel.assistantSetupHalfSheet).isEqualTo(ASSISTANT_SETUP_HALFSHEET);
- assertThat(metadataParcel.assistantSetupNotification).isEqualTo(
- ASSISTANT_SETUP_NOTIFICATION);
-
-
- assertThat(metadataParcel.confirmPinDescription).isEqualTo(CONFIRM_PIN_DESCRIPTION);
- assertThat(metadataParcel.confirmPinTitle).isEqualTo(CONFIRM_PIN_TITLE);
assertThat(metadataParcel.connectSuccessCompanionAppInstalled).isEqualTo(
CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
assertThat(metadataParcel.connectSuccessCompanionAppNotInstalled).isEqualTo(
@@ -326,8 +319,6 @@
assertThat(metadataParcel.failConnectGoToSettingsDescription).isEqualTo(
FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
- assertThat(metadataParcel.fastPairTvConnectDeviceNoAccountDescription).isEqualTo(
- FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
assertThat(metadataParcel.initialNotificationDescription).isEqualTo(
INITIAL_NOTIFICATION_DESCRIPTION);
@@ -341,10 +332,6 @@
assertThat(metadataParcel.subsequentPairingDescription).isEqualTo(
SUBSEQUENT_PAIRING_DESCRIPTION);
- assertThat(metadataParcel.syncContactsDescription).isEqualTo(SYNC_CONTACT_DESCRPTION);
- assertThat(metadataParcel.syncContactsTitle).isEqualTo(SYNC_CONTACTS_TITLE);
- assertThat(metadataParcel.syncSmsDescription).isEqualTo(SYNC_SMS_DESCRIPTION);
- assertThat(metadataParcel.syncSmsTitle).isEqualTo(SYNC_SMS_TITLE);
assertThat(metadataParcel.trueWirelessImageUrlCase).isEqualTo(TRUE_WIRELESS_IMAGE_URL_CASE);
assertThat(metadataParcel.trueWirelessImageUrlLeftBud).isEqualTo(
@@ -378,27 +365,18 @@
assertThat(itemParcel.actionUrl).isEqualTo(ACTION_URL);
assertThat(itemParcel.actionUrlType).isEqualTo(ACTION_URL_TYPE);
assertThat(itemParcel.appName).isEqualTo(APP_NAME);
- assertThat(itemParcel.attachmentType).isEqualTo(ATTACHMENT_TYPE);
assertThat(itemParcel.authenticationPublicKeySecp256r1)
.isEqualTo(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1);
- assertThat(itemParcel.bleRecordBytes).isEqualTo(BLE_RECORD_BYTES);
- assertThat(itemParcel.debugCategory).isEqualTo(DEBUG_CATEGORY);
- assertThat(itemParcel.debugMessage).isEqualTo(DEBUG_MESSAGE);
assertThat(itemParcel.description).isEqualTo(DESCRIPTION);
assertThat(itemParcel.deviceName).isEqualTo(DEVICE_NAME);
assertThat(itemParcel.displayUrl).isEqualTo(DISPLAY_URL);
- assertThat(itemParcel.entityId).isEqualTo(ENTITY_ID);
- assertThat(itemParcel.featureGraphicUrl).isEqualTo(FEATURE_GRAPHIC_URL);
assertThat(itemParcel.firstObservationTimestampMillis)
.isEqualTo(FIRST_OBSERVATION_TIMESTAMP_MILLIS);
- assertThat(itemParcel.groupId).isEqualTo(GROUP_ID);
assertThat(itemParcel.iconFifeUrl).isEqualTo(ICON_FIFE_URL);
assertThat(itemParcel.iconPng).isEqualTo(ICON_PNG);
assertThat(itemParcel.id).isEqualTo(ID);
assertThat(itemParcel.lastObservationTimestampMillis)
.isEqualTo(LAST_OBSERVATION_TIMESTAMP_MILLIS);
- assertThat(itemParcel.lastUserExperience).isEqualTo(LAST_USER_EXPERIENCE);
- assertThat(itemParcel.lostMillis).isEqualTo(LOST_MILLIS);
assertThat(itemParcel.macAddress).isEqualTo(MAC_ADDRESS);
assertThat(itemParcel.packageName).isEqualTo(PACKAGE_NAME);
assertThat(itemParcel.pendingAppInstallTimestampMillis)
@@ -408,7 +386,6 @@
assertThat(itemParcel.title).isEqualTo(TITLE);
assertThat(itemParcel.triggerId).isEqualTo(TRIGGER_ID);
assertThat(itemParcel.txPower).isEqualTo(TX_POWER);
- assertThat(itemParcel.type).isEqualTo(TYPE);
}
private static FastPairEligibleAccountParcel genHappyPathFastPairEligibleAccountParcel() {
@@ -461,19 +438,13 @@
private static FastPairDeviceMetadataParcel genHappyPathFastPairDeviceMetadataParcel() {
FastPairDeviceMetadataParcel parcel = new FastPairDeviceMetadataParcel();
- parcel.assistantSetupHalfSheet = ASSISTANT_SETUP_HALFSHEET;
- parcel.assistantSetupNotification = ASSISTANT_SETUP_NOTIFICATION;
parcel.bleTxPower = BLE_TX_POWER;
- parcel.confirmPinDescription = CONFIRM_PIN_DESCRIPTION;
- parcel.confirmPinTitle = CONFIRM_PIN_TITLE;
parcel.connectSuccessCompanionAppInstalled = CONNECT_SUCCESS_COMPANION_APP_INSTALLED;
parcel.connectSuccessCompanionAppNotInstalled =
CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED;
parcel.deviceType = DEVICE_TYPE;
parcel.downloadCompanionAppDescription = DOWNLOAD_COMPANION_APP_DESCRIPTION;
parcel.failConnectGoToSettingsDescription = FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION;
- parcel.fastPairTvConnectDeviceNoAccountDescription =
- FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION;
parcel.image = IMAGE;
parcel.imageUrl = IMAGE_URL;
parcel.initialNotificationDescription = INITIAL_NOTIFICATION_DESCRIPTION;
@@ -481,15 +452,10 @@
INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT;
parcel.initialPairingDescription = INITIAL_PAIRING_DESCRIPTION;
parcel.intentUri = INTENT_URI;
- parcel.locale = LOCALE;
parcel.name = NAME;
parcel.openCompanionAppDescription = OPEN_COMPANION_APP_DESCRIPTION;
parcel.retroactivePairingDescription = RETRO_ACTIVE_PAIRING_DESCRIPTION;
parcel.subsequentPairingDescription = SUBSEQUENT_PAIRING_DESCRIPTION;
- parcel.syncContactsDescription = SYNC_CONTACT_DESCRPTION;
- parcel.syncContactsTitle = SYNC_CONTACTS_TITLE;
- parcel.syncSmsDescription = SYNC_SMS_DESCRIPTION;
- parcel.syncSmsTitle = SYNC_SMS_TITLE;
parcel.triggerDistance = TRIGGER_DISTANCE;
parcel.trueWirelessImageUrlCase = TRUE_WIRELESS_IMAGE_URL_CASE;
parcel.trueWirelessImageUrlLeftBud = TRUE_WIRELESS_IMAGE_URL_LEFT_BUD;
@@ -508,30 +474,18 @@
storedDiscoveryItemBuilder.setActionUrl(ACTION_URL);
storedDiscoveryItemBuilder.setActionUrlType(Cache.ResolvedUrlType.WEBPAGE);
storedDiscoveryItemBuilder.setAppName(APP_NAME);
- storedDiscoveryItemBuilder.setAttachmentType(
- Cache.DiscoveryAttachmentType.DISCOVERY_ATTACHMENT_TYPE_NORMAL);
storedDiscoveryItemBuilder.setAuthenticationPublicKeySecp256R1(
ByteString.copyFrom(AUTHENTICATION_PUBLIC_KEY_SEC_P256R1));
- storedDiscoveryItemBuilder.setBleRecordBytes(ByteString.copyFrom(BLE_RECORD_BYTES));
- storedDiscoveryItemBuilder.setDebugCategory(
- Cache.StoredDiscoveryItem.DebugMessageCategory.STATUS_VALID_NOTIFICATION);
- storedDiscoveryItemBuilder.setDebugMessage(DEBUG_MESSAGE);
storedDiscoveryItemBuilder.setDescription(DESCRIPTION);
storedDiscoveryItemBuilder.setDeviceName(DEVICE_NAME);
storedDiscoveryItemBuilder.setDisplayUrl(DISPLAY_URL);
- storedDiscoveryItemBuilder.setEntityId(ENTITY_ID);
- storedDiscoveryItemBuilder.setFeatureGraphicUrl(FEATURE_GRAPHIC_URL);
storedDiscoveryItemBuilder.setFirstObservationTimestampMillis(
FIRST_OBSERVATION_TIMESTAMP_MILLIS);
- storedDiscoveryItemBuilder.setGroupId(GROUP_ID);
storedDiscoveryItemBuilder.setIconFifeUrl(ICON_FIFE_URL);
storedDiscoveryItemBuilder.setIconPng(ByteString.copyFrom(ICON_PNG));
storedDiscoveryItemBuilder.setId(ID);
storedDiscoveryItemBuilder.setLastObservationTimestampMillis(
LAST_OBSERVATION_TIMESTAMP_MILLIS);
- storedDiscoveryItemBuilder.setLastUserExperience(
- Cache.StoredDiscoveryItem.ExperienceType.EXPERIENCE_GOOD);
- storedDiscoveryItemBuilder.setLostMillis(LOST_MILLIS);
storedDiscoveryItemBuilder.setMacAddress(MAC_ADDRESS);
storedDiscoveryItemBuilder.setPackageName(PACKAGE_NAME);
storedDiscoveryItemBuilder.setPendingAppInstallTimestampMillis(
@@ -541,21 +495,14 @@
storedDiscoveryItemBuilder.setTitle(TITLE);
storedDiscoveryItemBuilder.setTriggerId(TRIGGER_ID);
storedDiscoveryItemBuilder.setTxPower(TX_POWER);
- storedDiscoveryItemBuilder.setType(Cache.NearbyType.NEARBY_PROXIMITY_BEACON);
FastPairStrings.Builder stringsBuilder = FastPairStrings.newBuilder();
- stringsBuilder.setAssistantHalfSheetDescription(ASSISTANT_SETUP_HALFSHEET);
- stringsBuilder.setAssistantNotificationDescription(ASSISTANT_SETUP_NOTIFICATION);
- stringsBuilder.setConfirmPinDescription(CONFIRM_PIN_DESCRIPTION);
- stringsBuilder.setConfirmPinTitle(CONFIRM_PIN_TITLE);
stringsBuilder.setPairingFinishedCompanionAppInstalled(
CONNECT_SUCCESS_COMPANION_APP_INSTALLED);
stringsBuilder.setPairingFinishedCompanionAppNotInstalled(
CONNECT_SUCCESS_COMPANION_APP_NOT_INSTALLED);
stringsBuilder.setPairingFailDescription(
FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION);
- stringsBuilder.setFastPairTvConnectDeviceNoAccountDescription(
- FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
stringsBuilder.setTapToPairWithAccount(
INITIAL_NOTIFICATION_DESCRIPTION);
stringsBuilder.setTapToPairWithoutAccount(
@@ -563,10 +510,6 @@
stringsBuilder.setInitialPairingDescription(INITIAL_PAIRING_DESCRIPTION);
stringsBuilder.setRetroactivePairingDescription(RETRO_ACTIVE_PAIRING_DESCRIPTION);
stringsBuilder.setSubsequentPairingDescription(SUBSEQUENT_PAIRING_DESCRIPTION);
- stringsBuilder.setSyncContactsDescription(SYNC_CONTACT_DESCRPTION);
- stringsBuilder.setSyncContactsTitle(SYNC_CONTACTS_TITLE);
- stringsBuilder.setSyncSmsDescription(SYNC_SMS_DESCRIPTION);
- stringsBuilder.setSyncSmsTitle(SYNC_SMS_TITLE);
stringsBuilder.setWaitAppLaunchDescription(WAIT_LAUNCH_COMPANION_APP_DESCRIPTION);
storedDiscoveryItemBuilder.setFastPairStrings(stringsBuilder.build());
@@ -606,24 +549,15 @@
parcel.actionUrl = ACTION_URL;
parcel.actionUrlType = ACTION_URL_TYPE;
parcel.appName = APP_NAME;
- parcel.attachmentType = ATTACHMENT_TYPE;
parcel.authenticationPublicKeySecp256r1 = AUTHENTICATION_PUBLIC_KEY_SEC_P256R1;
- parcel.bleRecordBytes = BLE_RECORD_BYTES;
- parcel.debugCategory = DEBUG_CATEGORY;
- parcel.debugMessage = DEBUG_MESSAGE;
parcel.description = DESCRIPTION;
parcel.deviceName = DEVICE_NAME;
parcel.displayUrl = DISPLAY_URL;
- parcel.entityId = ENTITY_ID;
- parcel.featureGraphicUrl = FEATURE_GRAPHIC_URL;
parcel.firstObservationTimestampMillis = FIRST_OBSERVATION_TIMESTAMP_MILLIS;
- parcel.groupId = GROUP_ID;
parcel.iconFifeUrl = ICON_FIFE_URL;
parcel.iconPng = ICON_PNG;
parcel.id = ID;
parcel.lastObservationTimestampMillis = LAST_OBSERVATION_TIMESTAMP_MILLIS;
- parcel.lastUserExperience = LAST_USER_EXPERIENCE;
- parcel.lostMillis = LOST_MILLIS;
parcel.macAddress = MAC_ADDRESS;
parcel.packageName = PACKAGE_NAME;
parcel.pendingAppInstallTimestampMillis = PENDING_APP_INSTALL_TIMESTAMP_MILLIS;
@@ -632,7 +566,6 @@
parcel.title = TITLE;
parcel.triggerId = TRIGGER_ID;
parcel.txPower = TX_POWER;
- parcel.type = TYPE;
return parcel;
}
@@ -659,10 +592,6 @@
.setDevice(deviceBuilder.build())
.setImage(ByteString.copyFrom(IMAGE))
.setStrings(Rpcs.ObservedDeviceStrings.newBuilder()
- .setAssistantSetupHalfSheet(ASSISTANT_SETUP_HALFSHEET)
- .setAssistantSetupNotification(ASSISTANT_SETUP_NOTIFICATION)
- .setConfirmPinDescription(CONFIRM_PIN_DESCRIPTION)
- .setConfirmPinTitle(CONFIRM_PIN_TITLE)
.setConnectSuccessCompanionAppInstalled(
CONNECT_SUCCESS_COMPANION_APP_INSTALLED)
.setConnectSuccessCompanionAppNotInstalled(
@@ -671,29 +600,18 @@
DOWNLOAD_COMPANION_APP_DESCRIPTION)
.setFailConnectGoToSettingsDescription(
FAIL_CONNECT_GOTO_SETTINGS_DESCRIPTION)
- .setFastPairTvConnectDeviceNoAccountDescription(
- FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION)
.setInitialNotificationDescription(
INITIAL_NOTIFICATION_DESCRIPTION)
.setInitialNotificationDescriptionNoAccount(
INITIAL_NOTIFICATION_DESCRIPTION_NO_ACCOUNT)
.setInitialPairingDescription(
INITIAL_PAIRING_DESCRIPTION)
- .setLocale(LOCALE)
.setOpenCompanionAppDescription(
OPEN_COMPANION_APP_DESCRIPTION)
.setRetroactivePairingDescription(
RETRO_ACTIVE_PAIRING_DESCRIPTION)
.setSubsequentPairingDescription(
SUBSEQUENT_PAIRING_DESCRIPTION)
- .setSyncContactsDescription(
- SYNC_CONTACT_DESCRPTION)
- .setSyncContactsTitle(
- SYNC_CONTACTS_TITLE)
- .setSyncSmsDescription(
- SYNC_SMS_DESCRIPTION)
- .setSyncSmsTitle(
- SYNC_SMS_TITLE)
.setUnableToConnectDescription(
UNABLE_TO_CONNECT_DESCRIPTION)
.setUnableToConnectTitle(
diff --git a/nearby/tests/unit/src/com/android/server/nearby/util/DataUtilsTest.java b/nearby/tests/unit/src/com/android/server/nearby/util/DataUtilsTest.java
index 9152c07..f098600 100644
--- a/nearby/tests/unit/src/com/android/server/nearby/util/DataUtilsTest.java
+++ b/nearby/tests/unit/src/com/android/server/nearby/util/DataUtilsTest.java
@@ -92,12 +92,6 @@
.isEqualTo(MESSAGE_WAIT_LAUNCH_COMPANION_APP_DESCRIPTION);
assertThat(strings.getPairingFailDescription())
.isEqualTo(MESSAGE_FAIL_CONNECT_DESCRIPTION);
- assertThat(strings.getAssistantHalfSheetDescription())
- .isEqualTo(MESSAGE_ASSISTANT_HALF_SHEET_DESCRIPTION);
- assertThat(strings.getAssistantNotificationDescription())
- .isEqualTo(MESSAGE_ASSISTANT_NOTIFICATION_DESCRIPTION);
- assertThat(strings.getFastPairTvConnectDeviceNoAccountDescription())
- .isEqualTo(MESSAGE_FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION);
}
@Test
@@ -124,10 +118,7 @@
+ "subsequentPairingDescription=message 6, "
+ "retroactivePairingDescription=message 7, "
+ "waitAppLaunchDescription=message 8, "
- + "pairingFailDescription=message 9, "
- + "assistantHalfSheetDescription=message 11, "
- + "assistantNotificationDescription=message 12, "
- + "fastPairTvConnectDeviceNoAccountDescription=message 10]");
+ + "pairingFailDescription=message 9]");
}
private static GetObservedDeviceResponse createObservedDeviceResponse() {
@@ -168,13 +159,7 @@
.setWaitLaunchCompanionAppDescription(
MESSAGE_WAIT_LAUNCH_COMPANION_APP_DESCRIPTION)
.setFailConnectGoToSettingsDescription(
- MESSAGE_FAIL_CONNECT_DESCRIPTION)
- .setAssistantSetupHalfSheet(
- MESSAGE_ASSISTANT_HALF_SHEET_DESCRIPTION)
- .setAssistantSetupNotification(
- MESSAGE_ASSISTANT_NOTIFICATION_DESCRIPTION)
- .setFastPairTvConnectDeviceNoAccountDescription(
- MESSAGE_FAST_PAIR_TV_CONNECT_DEVICE_NO_ACCOUNT_DESCRIPTION))
+ MESSAGE_FAIL_CONNECT_DESCRIPTION))
.build();
}
}
diff --git a/service/src/com/android/server/ConnectivityService.java b/service/src/com/android/server/ConnectivityService.java
index b4cc41a..0528f29 100644
--- a/service/src/com/android/server/ConnectivityService.java
+++ b/service/src/com/android/server/ConnectivityService.java
@@ -2238,6 +2238,13 @@
callingAttributionTag);
}
+ private void redactUnderlyingNetworksForCapabilities(NetworkCapabilities nc, int pid, int uid) {
+ if (nc.getUnderlyingNetworks() != null
+ && !checkNetworkFactoryOrSettingsPermission(pid, uid)) {
+ nc.setUnderlyingNetworks(null);
+ }
+ }
+
@VisibleForTesting
NetworkCapabilities networkCapabilitiesRestrictedForCallerPermissions(
NetworkCapabilities nc, int callerPid, int callerUid) {
@@ -2250,8 +2257,6 @@
if (!checkSettingsPermission(callerPid, callerUid)) {
newNc.setUids(null);
newNc.setSSID(null);
- // TODO: Processes holding NETWORK_FACTORY should be able to see the underlying networks
- newNc.setUnderlyingNetworks(null);
}
if (newNc.getNetworkSpecifier() != null) {
newNc.setNetworkSpecifier(newNc.getNetworkSpecifier().redact());
@@ -2265,6 +2270,7 @@
newNc.setAllowedUids(new ArraySet<>());
newNc.setSubscriptionIds(Collections.emptySet());
}
+ redactUnderlyingNetworksForCapabilities(newNc, callerPid, callerUid);
return newNc;
}
@@ -2877,6 +2883,15 @@
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK);
}
+ private boolean checkNetworkFactoryOrSettingsPermission(int pid, int uid) {
+ return PERMISSION_GRANTED == mContext.checkPermission(
+ android.Manifest.permission.NETWORK_FACTORY, pid, uid)
+ || PERMISSION_GRANTED == mContext.checkPermission(
+ android.Manifest.permission.NETWORK_SETTINGS, pid, uid)
+ || PERMISSION_GRANTED == mContext.checkPermission(
+ NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, pid, uid);
+ }
+
private boolean checkSettingsPermission() {
return checkAnyPermissionOf(
android.Manifest.permission.NETWORK_SETTINGS,
diff --git a/service/src/com/android/server/connectivity/FullScore.java b/service/src/com/android/server/connectivity/FullScore.java
index 799f46b..b13ba93 100644
--- a/service/src/com/android/server/connectivity/FullScore.java
+++ b/service/src/com/android/server/connectivity/FullScore.java
@@ -29,6 +29,7 @@
import android.net.NetworkCapabilities;
import android.net.NetworkScore;
import android.net.NetworkScore.KeepConnectedReason;
+import android.util.Log;
import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting;
@@ -46,6 +47,8 @@
* they are handling a score that had the CS-managed bits set.
*/
public class FullScore {
+ private static final String TAG = FullScore.class.getSimpleName();
+
// This will be removed soon. Do *NOT* depend on it for any new code that is not part of
// a migration.
private final int mLegacyInt;
@@ -126,7 +129,15 @@
@VisibleForTesting
static @NonNull String policyNameOf(final int policy) {
final String name = sMessageNames.get(policy);
- if (name == null) throw new IllegalArgumentException("Unknown policy: " + policy);
+ if (name == null) {
+ // Don't throw here because name might be null due to proguard stripping out the
+ // POLICY_* constants, potentially causing a crash only on user builds because proguard
+ // does not run on userdebug builds.
+ // TODO: make MessageUtils safer by not returning the array and instead storing it
+ // internally and providing a getter (that does not throw) for individual values.
+ Log.wtf(TAG, "Unknown policy: " + policy);
+ return Integer.toString(policy);
+ }
return name.substring("POLICY_".length());
}
diff --git a/tests/cts/net/src/android/net/cts/Ikev2VpnTest.java b/tests/cts/net/src/android/net/cts/Ikev2VpnTest.java
index 6e9f0cd..9fa146f 100644
--- a/tests/cts/net/src/android/net/cts/Ikev2VpnTest.java
+++ b/tests/cts/net/src/android/net/cts/Ikev2VpnTest.java
@@ -17,15 +17,16 @@
package android.net.cts;
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
+import static android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED;
import static android.net.NetworkCapabilities.TRANSPORT_VPN;
import static android.net.cts.util.CtsNetUtils.TestNetworkCallback;
import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;
+import static com.android.testutils.TestableNetworkCallbackKt.anyNetwork;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -40,7 +41,6 @@
import android.net.Ikev2VpnProfile;
import android.net.IpSecAlgorithm;
import android.net.Network;
-import android.net.NetworkCapabilities;
import android.net.NetworkRequest;
import android.net.ProxyInfo;
import android.net.TestNetworkInterface;
@@ -53,8 +53,14 @@
import androidx.test.InstrumentationRegistry;
import com.android.internal.util.HexDump;
+import com.android.networkstack.apishim.Ikev2VpnProfileBuilderShimImpl;
+import com.android.networkstack.apishim.Ikev2VpnProfileShimImpl;
+import com.android.networkstack.apishim.common.Ikev2VpnProfileShim;
+import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
import com.android.testutils.DevSdkIgnoreRule.IgnoreUpTo;
import com.android.testutils.DevSdkIgnoreRunner;
+import com.android.testutils.RecorderCallback.CallbackEntry;
+import com.android.testutils.TestableNetworkCallback;
import org.bouncycastle.x509.X509V1CertificateGenerator;
import org.junit.After;
@@ -167,6 +173,7 @@
private static final VpnManager sVpnMgr =
(VpnManager) sContext.getSystemService(Context.VPN_MANAGEMENT_SERVICE);
private static final CtsNetUtils mCtsNetUtils = new CtsNetUtils(sContext);
+ private static final long TIMEOUT_MS = 15_000;
private final X509Certificate mServerRootCa;
private final CertificateAndKey mUserCertKey;
@@ -197,31 +204,32 @@
}, Manifest.permission.MANAGE_TEST_NETWORKS);
}
- private Ikev2VpnProfile buildIkev2VpnProfileCommon(
- Ikev2VpnProfile.Builder builder, boolean isRestrictedToTestNetworks) throws Exception {
+ private Ikev2VpnProfile buildIkev2VpnProfileCommon(@NonNull Ikev2VpnProfile.Builder builder,
+ boolean isRestrictedToTestNetworks,
+ boolean requiresValidation) throws Exception {
if (isRestrictedToTestNetworks) {
builder.restrictToTestNetworks();
}
- return builder.setBypassable(true)
+ builder.setBypassable(true)
.setAllowedAlgorithms(TEST_ALLOWED_ALGORITHMS)
.setProxy(TEST_PROXY_INFO)
.setMaxMtu(TEST_MTU)
- .setMetered(false)
- .build();
+ .setMetered(false);
+ if (TestUtils.shouldTestTApis()) {
+ Ikev2VpnProfileBuilderShimImpl.newInstance().setRequiresInternetValidation(
+ builder, requiresValidation);
+ }
+ return builder.build();
}
- private Ikev2VpnProfile buildIkev2VpnProfilePsk(boolean isRestrictedToTestNetworks)
- throws Exception {
- return buildIkev2VpnProfilePsk(TEST_SERVER_ADDR_V6, isRestrictedToTestNetworks);
- }
-
- private Ikev2VpnProfile buildIkev2VpnProfilePsk(
- String remote, boolean isRestrictedToTestNetworks) throws Exception {
+ private Ikev2VpnProfile buildIkev2VpnProfilePsk(@NonNull String remote,
+ boolean isRestrictedToTestNetworks, boolean requiresValidation) throws Exception {
final Ikev2VpnProfile.Builder builder =
new Ikev2VpnProfile.Builder(remote, TEST_IDENTITY).setAuthPsk(TEST_PSK);
- return buildIkev2VpnProfileCommon(builder, isRestrictedToTestNetworks);
+ return buildIkev2VpnProfileCommon(builder, isRestrictedToTestNetworks,
+ requiresValidation);
}
private Ikev2VpnProfile buildIkev2VpnProfileUsernamePassword(boolean isRestrictedToTestNetworks)
@@ -230,7 +238,8 @@
new Ikev2VpnProfile.Builder(TEST_SERVER_ADDR_V6, TEST_IDENTITY)
.setAuthUsernamePassword(TEST_USER, TEST_PASSWORD, mServerRootCa);
- return buildIkev2VpnProfileCommon(builder, isRestrictedToTestNetworks);
+ return buildIkev2VpnProfileCommon(builder, isRestrictedToTestNetworks,
+ false /* requiresValidation */);
}
private Ikev2VpnProfile buildIkev2VpnProfileDigitalSignature(boolean isRestrictedToTestNetworks)
@@ -240,7 +249,8 @@
.setAuthDigitalSignature(
mUserCertKey.cert, mUserCertKey.key, mServerRootCa);
- return buildIkev2VpnProfileCommon(builder, isRestrictedToTestNetworks);
+ return buildIkev2VpnProfileCommon(builder, isRestrictedToTestNetworks,
+ false /* requiresValidation */);
}
private void checkBasicIkev2VpnProfile(@NonNull Ikev2VpnProfile profile) throws Exception {
@@ -254,12 +264,11 @@
assertFalse(profile.isRestrictedToTestNetworks());
}
- @Test
- public void testBuildIkev2VpnProfilePsk() throws Exception {
+ public void doTestBuildIkev2VpnProfilePsk(final boolean requiresValidation) throws Exception {
assumeTrue(mCtsNetUtils.hasIpsecTunnelsFeature());
- final Ikev2VpnProfile profile =
- buildIkev2VpnProfilePsk(false /* isRestrictedToTestNetworks */);
+ final Ikev2VpnProfile profile = buildIkev2VpnProfilePsk(TEST_SERVER_ADDR_V6,
+ false /* isRestrictedToTestNetworks */, requiresValidation);
checkBasicIkev2VpnProfile(profile);
assertArrayEquals(TEST_PSK, profile.getPresharedKey());
@@ -270,6 +279,22 @@
assertNull(profile.getServerRootCaCert());
assertNull(profile.getRsaPrivateKey());
assertNull(profile.getUserCert());
+ final Ikev2VpnProfileShim<Ikev2VpnProfile> shim = Ikev2VpnProfileShimImpl.newInstance();
+ if (TestUtils.shouldTestTApis()) {
+ assertEquals(requiresValidation, shim.isInternetValidationRequired(profile));
+ } else {
+ try {
+ shim.isInternetValidationRequired(profile);
+ fail("Only supported from API level 33");
+ } catch (UnsupportedApiLevelException expected) {
+ }
+ }
+ }
+
+ @Test
+ public void testBuildIkev2VpnProfilePsk() throws Exception {
+ doTestBuildIkev2VpnProfilePsk(true /* requiresValidation */);
+ doTestBuildIkev2VpnProfilePsk(false /* requiresValidation */);
}
@Test
@@ -316,8 +341,8 @@
setAppop(AppOpsManager.OP_ACTIVATE_VPN, hasActivateVpn);
setAppop(AppOpsManager.OP_ACTIVATE_PLATFORM_VPN, hasActivatePlatformVpn);
- final Ikev2VpnProfile profile =
- buildIkev2VpnProfilePsk(false /* isRestrictedToTestNetworks */);
+ final Ikev2VpnProfile profile = buildIkev2VpnProfilePsk(TEST_SERVER_ADDR_V6,
+ false /* isRestrictedToTestNetworks */, false /* requiresValidation */);
final Intent intent = sVpnMgr.provisionVpnProfile(profile);
assertEquals(expectIntent, intent != null);
}
@@ -360,8 +385,8 @@
setAppop(AppOpsManager.OP_ACTIVATE_PLATFORM_VPN, true);
- final Ikev2VpnProfile profile =
- buildIkev2VpnProfilePsk(false /* isRestrictedToTestNetworks */);
+ final Ikev2VpnProfile profile = buildIkev2VpnProfilePsk(TEST_SERVER_ADDR_V6,
+ false /* isRestrictedToTestNetworks */, false /* requiresValidation */);
assertNull(sVpnMgr.provisionVpnProfile(profile));
// Verify that deleting the profile works (even without the appop)
@@ -394,7 +419,8 @@
}
}
- private void checkStartStopVpnProfileBuildsNetworks(IkeTunUtils tunUtils, boolean testIpv6)
+ private void checkStartStopVpnProfileBuildsNetworks(@NonNull IkeTunUtils tunUtils,
+ boolean testIpv6, boolean requiresValidation)
throws Exception {
String serverAddr = testIpv6 ? TEST_SERVER_ADDR_V6 : TEST_SERVER_ADDR_V4;
String initResp = testIpv6 ? SUCCESSFUL_IKE_INIT_RESP_V6 : SUCCESSFUL_IKE_INIT_RESP_V4;
@@ -404,10 +430,15 @@
// Requires MANAGE_TEST_NETWORKS to provision a test-mode profile.
mCtsNetUtils.setAppopPrivileged(AppOpsManager.OP_ACTIVATE_PLATFORM_VPN, true);
- final Ikev2VpnProfile profile =
- buildIkev2VpnProfilePsk(serverAddr, true /* isRestrictedToTestNetworks */);
+ final Ikev2VpnProfile profile = buildIkev2VpnProfilePsk(serverAddr,
+ true /* isRestrictedToTestNetworks */, requiresValidation);
assertNull(sVpnMgr.provisionVpnProfile(profile));
+ final TestableNetworkCallback cb = new TestableNetworkCallback(TIMEOUT_MS);
+ final NetworkRequest nr = new NetworkRequest.Builder()
+ .clearCapabilities().addTransportType(TRANSPORT_VPN).build();
+ sCM.registerNetworkCallback(nr, cb);
+
sVpnMgr.startProvisionedVpnProfile();
// Inject IKE negotiation
@@ -418,35 +449,49 @@
HexDump.hexStringToByteArray(authResp));
// Verify the VPN network came up
- final NetworkRequest nr = new NetworkRequest.Builder()
- .clearCapabilities().addTransportType(TRANSPORT_VPN).build();
+ final Network vpnNetwork = cb.expectCallback(CallbackEntry.AVAILABLE, anyNetwork())
+ .getNetwork();
- final TestNetworkCallback cb = new TestNetworkCallback();
- sCM.requestNetwork(nr, cb);
- cb.waitForAvailable();
- final Network vpnNetwork = cb.currentNetwork;
- assertNotNull(vpnNetwork);
+ cb.expectCapabilitiesThat(vpnNetwork, TIMEOUT_MS, caps -> caps.hasTransport(TRANSPORT_VPN)
+ && caps.hasCapability(NET_CAPABILITY_INTERNET)
+ && !caps.hasCapability(NET_CAPABILITY_VALIDATED)
+ && Process.myUid() == caps.getOwnerUid());
+ cb.expectCallback(CallbackEntry.LINK_PROPERTIES_CHANGED, vpnNetwork);
+ cb.expectCallback(CallbackEntry.BLOCKED_STATUS, vpnNetwork);
- final NetworkCapabilities caps = sCM.getNetworkCapabilities(vpnNetwork);
- assertTrue(caps.hasTransport(TRANSPORT_VPN));
- assertTrue(caps.hasCapability(NET_CAPABILITY_INTERNET));
- assertEquals(Process.myUid(), caps.getOwnerUid());
+ // A VPN that requires validation is initially not validated, while one that doesn't
+ // immediately validate automatically. Because this VPN can't actually access Internet,
+ // the VPN only validates if it doesn't require validation. If the VPN requires validation
+ // but unexpectedly sends this callback, expecting LOST below will fail because the next
+ // callback will be the validated capabilities instead.
+ // In S and below, |requiresValidation| is ignored, so this callback is always sent
+ // regardless of its value.
+ if (!requiresValidation || !TestUtils.shouldTestTApis()) {
+ cb.eventuallyExpect(CallbackEntry.NETWORK_CAPS_UPDATED, TIMEOUT_MS,
+ entry -> ((CallbackEntry.CapabilitiesChanged) entry).getCaps()
+ .hasCapability(NET_CAPABILITY_VALIDATED));
+ }
sVpnMgr.stopProvisionedVpnProfile();
- cb.waitForLost();
- assertEquals(vpnNetwork, cb.lastLostNetwork);
+ // Using expectCallback may cause the test to be flaky since test may receive other
+ // callbacks such as linkproperties change.
+ cb.eventuallyExpect(CallbackEntry.LOST, TIMEOUT_MS,
+ lost -> vpnNetwork.equals(lost.getNetwork()));
}
private class VerifyStartStopVpnProfileTest implements TestNetworkRunnable.Test {
private final boolean mTestIpv6Only;
+ private final boolean mRequiresValidation;
/**
* Constructs the test
*
* @param testIpv6Only if true, builds a IPv6-only test; otherwise builds a IPv4-only test
+ * @param requiresValidation whether this VPN should request platform validation
*/
- VerifyStartStopVpnProfileTest(boolean testIpv6Only) {
+ VerifyStartStopVpnProfileTest(boolean testIpv6Only, boolean requiresValidation) {
mTestIpv6Only = testIpv6Only;
+ mRequiresValidation = requiresValidation;
}
@Override
@@ -454,7 +499,8 @@
throws Exception {
final IkeTunUtils tunUtils = new IkeTunUtils(testIface.getFileDescriptor());
- checkStartStopVpnProfileBuildsNetworks(tunUtils, mTestIpv6Only);
+ checkStartStopVpnProfileBuildsNetworks(
+ tunUtils, mTestIpv6Only, mRequiresValidation);
}
@Override
@@ -478,7 +524,10 @@
// Requires shell permission to update appops.
runWithShellPermissionIdentity(
- new TestNetworkRunnable(new VerifyStartStopVpnProfileTest(false)));
+ new TestNetworkRunnable(new VerifyStartStopVpnProfileTest(false, false)));
+
+ runWithShellPermissionIdentity(
+ new TestNetworkRunnable(new VerifyStartStopVpnProfileTest(false, true)));
}
@Test
@@ -487,7 +536,9 @@
// Requires shell permission to update appops.
runWithShellPermissionIdentity(
- new TestNetworkRunnable(new VerifyStartStopVpnProfileTest(true)));
+ new TestNetworkRunnable(new VerifyStartStopVpnProfileTest(true, false)));
+ runWithShellPermissionIdentity(
+ new TestNetworkRunnable(new VerifyStartStopVpnProfileTest(true, true)));
}
private static class CertificateAndKey {
diff --git a/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt b/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt
index f007b83..0504973 100644
--- a/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt
+++ b/tests/cts/net/src/android/net/cts/NetworkAgentTest.kt
@@ -72,6 +72,7 @@
import android.os.HandlerThread
import android.os.Message
import android.os.SystemClock
+import android.platform.test.annotations.AppModeFull
import android.telephony.TelephonyManager
import android.telephony.data.EpsBearerQosSessionAttributes
import android.util.DebugUtils.valueToString
@@ -106,7 +107,6 @@
import com.android.testutils.TestableNetworkCallback
import com.android.testutils.assertThrows
import org.junit.After
-import org.junit.Assume.assumeFalse
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -946,11 +946,9 @@
return Pair(agent, qosTestSocket!!)
}
+ @AppModeFull(reason = "Instant apps don't have permission to bind sockets.")
@Test
fun testQosCallbackRegisterWithUnregister() {
- // Instant apps can't bind sockets to localhost
- // TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
- assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting()
val qosCallback = TestableQosCallback()
@@ -975,11 +973,9 @@
}
}
+ @AppModeFull(reason = "Instant apps don't have permission to bind sockets.")
@Test
fun testQosCallbackOnQosSession() {
- // Instant apps can't bind sockets to localhost
- // TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
- assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting()
val qosCallback = TestableQosCallback()
Executors.newSingleThreadExecutor().let { executor ->
@@ -1023,11 +1019,9 @@
}
}
+ @AppModeFull(reason = "Instant apps don't have permission to bind sockets.")
@Test
fun testQosCallbackOnError() {
- // Instant apps can't bind sockets to localhost
- // TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
- assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting()
val qosCallback = TestableQosCallback()
Executors.newSingleThreadExecutor().let { executor ->
@@ -1064,11 +1058,9 @@
}
}
+ @AppModeFull(reason = "Instant apps don't have permission to bind sockets.")
@Test
fun testQosCallbackIdsAreMappedCorrectly() {
- // Instant apps can't bind sockets to localhost
- // TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
- assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting()
val qosCallback1 = TestableQosCallback()
val qosCallback2 = TestableQosCallback()
@@ -1107,11 +1099,9 @@
}
}
+ @AppModeFull(reason = "Instant apps don't have permission to bind sockets.")
@Test
fun testQosCallbackWhenNetworkReleased() {
- // Instant apps can't bind sockets to localhost
- // TODO: use @AppModeFull when supported by DevSdkIgnoreRunner
- assumeFalse(realContext.packageManager.isInstantApp())
val (agent, socket) = setupForQosCallbackTesting()
Executors.newSingleThreadExecutor().let { executor ->
try {
@@ -1151,6 +1141,7 @@
)
}
+ @AppModeFull(reason = "Instant apps don't have permission to bind sockets.")
@Test
fun testUnregisterAfterReplacement() {
// Keeps an eye on all test networks.
diff --git a/tests/cts/net/src/android/net/cts/TestUtils.java b/tests/cts/net/src/android/net/cts/TestUtils.java
index c1100b1..001aa01 100644
--- a/tests/cts/net/src/android/net/cts/TestUtils.java
+++ b/tests/cts/net/src/android/net/cts/TestUtils.java
@@ -16,6 +16,8 @@
package android.net.cts;
+import static com.android.testutils.DevSdkIgnoreRuleKt.SC_V2;
+
import android.os.Build;
import com.android.modules.utils.build.SdkLevel;
@@ -33,4 +35,13 @@
public static boolean shouldTestSApis() {
return SdkLevel.isAtLeastS() && ConstantsShim.VERSION > Build.VERSION_CODES.R;
}
+
+ /**
+ * Whether to test T+ APIs. This requires a) that the test be running on an S+ device, and
+ * b) that the code be compiled against shims new enough to access these APIs.
+ */
+ public static boolean shouldTestTApis() {
+ // TODO: replace SC_V2 with Build.VERSION_CODES.S_V2 when it's available in mainline branch.
+ return SdkLevel.isAtLeastT() && ConstantsShim.VERSION > SC_V2;
+ }
}
diff --git a/tests/integration/util/com/android/server/NetworkAgentWrapper.java b/tests/integration/util/com/android/server/NetworkAgentWrapper.java
index 365c0cf..2763f5a 100644
--- a/tests/integration/util/com/android/server/NetworkAgentWrapper.java
+++ b/tests/integration/util/com/android/server/NetworkAgentWrapper.java
@@ -343,6 +343,10 @@
return mNetworkAgent;
}
+ public NetworkAgentConfig getNetworkAgentConfig() {
+ return mNetworkAgentConfig;
+ }
+
public NetworkCapabilities getNetworkCapabilities() {
return mNetworkCapabilities;
}
diff --git a/tests/unit/java/com/android/server/ConnectivityServiceTest.java b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
index 025b28c..4c76803 100644
--- a/tests/unit/java/com/android/server/ConnectivityServiceTest.java
+++ b/tests/unit/java/com/android/server/ConnectivityServiceTest.java
@@ -337,6 +337,7 @@
import com.android.net.module.util.ArrayTrackRecord;
import com.android.net.module.util.CollectionUtils;
import com.android.net.module.util.LocationPermissionChecker;
+import com.android.networkstack.apishim.NetworkAgentConfigShimImpl;
import com.android.server.ConnectivityService.ConnectivityDiagnosticsCallbackInfo;
import com.android.server.ConnectivityService.NetworkRequestInfo;
import com.android.server.ConnectivityServiceTest.ConnectivityServiceDependencies.ReportedInterfaces;
@@ -1373,6 +1374,10 @@
return (mMockNetworkAgent == null) ? null : mMockNetworkAgent.getNetwork();
}
+ public NetworkAgentConfig getNetworkAgentConfig() {
+ return null == mMockNetworkAgent ? null : mMockNetworkAgent.getNetworkAgentConfig();
+ }
+
@Override
public int getActiveVpnType() {
return mVpnType;
@@ -2936,6 +2941,7 @@
@Test
public void testRequiresValidation() {
assertTrue(NetworkMonitorUtils.isValidationRequired(
+ NetworkAgentConfigShimImpl.newInstance(null),
mCm.getDefaultRequest().networkCapabilities));
}
@@ -7933,6 +7939,7 @@
// VPN networks do not satisfy the default request and are automatically validated
// by NetworkMonitor
assertFalse(NetworkMonitorUtils.isValidationRequired(
+ NetworkAgentConfigShimImpl.newInstance(mMockVpn.getNetworkAgentConfig()),
mMockVpn.getAgent().getNetworkCapabilities()));
mMockVpn.getAgent().setNetworkValid(false /* isStrictMode */);
@@ -8083,6 +8090,7 @@
assertTrue(nc.hasCapability(NET_CAPABILITY_INTERNET));
assertFalse(NetworkMonitorUtils.isValidationRequired(
+ NetworkAgentConfigShimImpl.newInstance(mMockVpn.getNetworkAgentConfig()),
mMockVpn.getAgent().getNetworkCapabilities()));
assertTrue(NetworkMonitorUtils.isPrivateDnsValidationRequired(
mMockVpn.getAgent().getNetworkCapabilities()));
diff --git a/tests/unit/java/com/android/server/connectivity/FullScoreTest.kt b/tests/unit/java/com/android/server/connectivity/FullScoreTest.kt
index e7f6245..c03a9cd 100644
--- a/tests/unit/java/com/android/server/connectivity/FullScoreTest.kt
+++ b/tests/unit/java/com/android/server/connectivity/FullScoreTest.kt
@@ -22,6 +22,7 @@
import android.os.Build
import android.text.TextUtils
import android.util.ArraySet
+import android.util.Log
import androidx.test.filters.SmallTest
import com.android.server.connectivity.FullScore.MAX_CS_MANAGED_POLICY
import com.android.server.connectivity.FullScore.POLICY_ACCEPT_UNVALIDATED
@@ -32,11 +33,12 @@
import com.android.server.connectivity.FullScore.POLICY_IS_VPN
import com.android.testutils.DevSdkIgnoreRule
import com.android.testutils.DevSdkIgnoreRunner
+import org.junit.After
+import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import kotlin.reflect.full.staticProperties
import kotlin.test.assertEquals
-import kotlin.test.assertFailsWith
import kotlin.test.assertFalse
import kotlin.test.assertTrue
@@ -63,6 +65,23 @@
return mixInScore(nc, nac, validated, false /* yieldToBadWifi */, destroyed)
}
+ private val TAG = this::class.simpleName
+
+ private var wtfHandler: Log.TerribleFailureHandler? = null
+
+ @Before
+ fun setUp() {
+ // policyNameOf will call Log.wtf if passed an invalid policy.
+ wtfHandler = Log.setWtfHandler() { tagString, what, system ->
+ Log.d(TAG, "WTF captured, ignoring: $tagString $what")
+ }
+ }
+
+ @After
+ fun tearDown() {
+ Log.setWtfHandler(wtfHandler)
+ }
+
@Test
fun testGetLegacyInt() {
val ns = FullScore(50, 0L /* policy */, KEEP_CONNECTED_NONE)
@@ -101,10 +120,9 @@
assertFalse(foundNames.contains(name))
foundNames.add(name)
}
- assertFailsWith<IllegalArgumentException> {
- FullScore.policyNameOf(MAX_CS_MANAGED_POLICY + 1)
- }
assertEquals("IS_UNMETERED", FullScore.policyNameOf(POLICY_IS_UNMETERED))
+ val invalidPolicy = MAX_CS_MANAGED_POLICY + 1
+ assertEquals(Integer.toString(invalidPolicy), FullScore.policyNameOf(invalidPolicy))
}
fun getAllPolicies() = Regex("POLICY_.*").let { nameRegex ->