Merge "Add PresenceDevice and ScanFilter for offload scan."
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 87045de..d3bc9e6 100644
--- a/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
+++ b/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
@@ -16,11 +16,13 @@
package com.android.server.nearby.fastpair;
+import android.annotation.Nullable;
import android.content.Context;
import android.nearby.FastPairDevice;
import android.nearby.NearbyDevice;
import android.util.Log;
+import com.android.server.nearby.common.bloomfilter.BloomFilter;
import com.android.server.nearby.common.locator.Locator;
import com.android.server.nearby.fastpair.halfsheet.FastPairHalfSheetManager;
import com.android.server.nearby.provider.FastPairDataProvider;
@@ -29,6 +31,8 @@
import com.google.protobuf.ByteString;
+import java.util.List;
+
import service.proto.Cache;
import service.proto.Rpcs;
@@ -82,4 +86,21 @@
}
}
+
+ /**
+ * Checks the bloom filter to see if any of the devices are recognized and should have a
+ * notification displayed for them. A device is recognized if the account key + salt combination
+ * is inside the bloom filter.
+ */
+ @Nullable
+ static FastPairDevice findRecognizedDevice(
+ List<FastPairDevice> devices, BloomFilter bloomFilter, byte[] salt) {
+ for (FastPairDevice device : devices) {
+ // byte[] rotatedKey = concat(device.getAccountKey().toByteArray(), salt);
+// if (bloomFilter.possiblyContains(rotatedKey)) {
+// return device;
+// }
+ }
+ return null;
+ }
}
diff --git a/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java b/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java
index d59e696..34db620 100644
--- a/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java
+++ b/nearby/service/java/com/android/server/nearby/provider/FastPairDataProvider.java
@@ -20,7 +20,6 @@
import android.annotation.Nullable;
import android.content.Context;
import android.nearby.FastPairDataProviderBase;
-import android.nearby.FastPairDevice;
import android.nearby.aidl.FastPairAntispoofkeyDeviceMetadataRequestParcel;
import android.nearby.aidl.FastPairEligibleAccountsRequestParcel;
import android.nearby.aidl.FastPairManageAccountDeviceRequestParcel;
@@ -34,6 +33,7 @@
import java.util.List;
+import service.proto.Data;
import service.proto.Rpcs;
/**
@@ -51,7 +51,6 @@
* Initializes FastPairDataProvider singleton.
*/
public static synchronized FastPairDataProvider init(Context context) {
-
if (sInstance == null) {
sInstance = new FastPairDataProvider(context);
}
@@ -135,8 +134,9 @@
/**
* Get recognized device from bloom filter.
*/
- public FastPairDevice getRecognizedDevice(BloomFilter bloomFilter, byte[] salt) {
- return new FastPairDevice.Builder().build();
+ public Data.FastPairDeviceWithAccountKey getRecognizedDevice(BloomFilter bloomFilter,
+ byte[] salt) {
+ return Data.FastPairDeviceWithAccountKey.newBuilder().build();
}
/**
diff --git a/nearby/service/proto/src/fastpair/data.proto b/nearby/service/proto/src/fastpair/data.proto
new file mode 100644
index 0000000..37dfac2
--- /dev/null
+++ b/nearby/service/proto/src/fastpair/data.proto
@@ -0,0 +1,25 @@
+syntax = "proto3";
+
+package service.proto;
+
+// A device that has been Fast Paired with.
+message FastPairDeviceWithAccountKey {
+ // The account key which was written to the device after pairing completed.
+ bytes account_key = 1;
+
+ // The stored discovery item which represents the notification that should be
+ // associated with the device. Note, this is stored as a raw byte array
+ // instead of StoredDiscoveryItem because icing only supports proto lite and
+ // StoredDiscoveryItem is handed around as a nano proto in implementation,
+ // which are not compatible with each other.
+ bytes discovery_item_bytes = 3;
+
+ // SHA256 of "account key + headset's public address", this is used to
+ // identify the paired headset. Because of adding account key to generate the
+ // hash value, it makes the information anonymous, even for the same headset,
+ // different accounts have different values.
+ bytes sha256_account_key_public_address = 4;
+
+ // Deprecated fields.
+ reserved 2;
+}