[automerge] [DO NOT MERGE] Add DeviceName and account to initial paring description 2p: 6c9d4f0157
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Nearby/+/16943530
Bug: 196262706
Change-Id: I3a086522c0d8611e9ea85608102b874541c1e96f
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 f8d5a62..97eaab2 100644
--- a/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
+++ b/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
@@ -69,6 +69,8 @@
public void handleBroadcast(NearbyDevice device) {
FastPairDevice fastPairDevice = (FastPairDevice) device;
mBleAddress = fastPairDevice.getBluetoothAddress();
+ List<Account> accountList =
+ FastPairDataProvider.getInstance().loadFastPairEligibleAccounts();
if (FastPairDecoder.checkModelId(fastPairDevice.getData())) {
byte[] model = FastPairDecoder.getModelId(fastPairDevice.getData());
Log.d("FastPairService",
@@ -79,16 +81,15 @@
FastPairDataProvider.getInstance()
.loadFastPairAntispoofkeyDeviceMetadata(model);
Locator.get(mContext, FastPairHalfSheetManager.class).showHalfSheet(
- DataUtils.toScanFastPairStoreItem(response, mBleAddress));
+ DataUtils.toScanFastPairStoreItem(
+ response, mBleAddress,
+ accountList.isEmpty() ? null : accountList.get(0).name));
} catch (IllegalStateException e) {
Log.e(TAG, "OEM does not construct fast pair data proxy correctly");
}
-
} else {
// Start to process bloom filter
try {
- List<Account> accountList =
- FastPairDataProvider.getInstance().loadFastPairEligibleAccounts();
Log.d(TAG, "account list size" + accountList.size());
byte[] bloomFilterByteArray = FastPairDecoder
.getBloomFilter(fastPairDevice.getData());
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 ce738c8..bad14bf 100644
--- a/nearby/service/java/com/android/server/nearby/util/DataUtils.java
+++ b/nearby/service/java/com/android/server/nearby/util/DataUtils.java
@@ -17,6 +17,7 @@
package com.android.server.nearby.util;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import service.proto.Cache.ScanFastPairStoreItem;
import service.proto.Cache.StoredDiscoveryItem;
@@ -36,16 +37,18 @@
* Converts a {@link GetObservedDeviceResponse} to a {@link ScanFastPairStoreItem}.
*/
public static ScanFastPairStoreItem toScanFastPairStoreItem(
- GetObservedDeviceResponse observedDeviceResponse, @NonNull String bleAddress) {
+ GetObservedDeviceResponse observedDeviceResponse,
+ @NonNull String bleAddress, @Nullable String account) {
Device device = observedDeviceResponse.getDevice();
+ String deviceName = device.getName();
return ScanFastPairStoreItem.newBuilder()
.setAddress(bleAddress)
.setActionUrl(device.getIntentUri())
- .setDeviceName(device.getName())
+ .setDeviceName(deviceName)
.setIconPng(observedDeviceResponse.getImage())
.setIconFifeUrl(device.getImageUrl())
.setAntiSpoofingPublicKey(device.getAntiSpoofingKeyPair().getPublicKey())
- .setFastPairStrings(getFastPairStrings(observedDeviceResponse))
+ .setFastPairStrings(getFastPairStrings(observedDeviceResponse, deviceName, account))
.build();
}
@@ -76,13 +79,17 @@
+ "]";
}
- private static FastPairStrings getFastPairStrings(GetObservedDeviceResponse response) {
+ private static FastPairStrings getFastPairStrings(GetObservedDeviceResponse response,
+ String deviceName, @Nullable String account) {
ObservedDeviceStrings strings = response.getStrings();
return FastPairStrings.newBuilder()
.setTapToPairWithAccount(strings.getInitialNotificationDescription())
.setTapToPairWithoutAccount(
strings.getInitialNotificationDescriptionNoAccount())
- .setInitialPairingDescription(strings.getInitialPairingDescription())
+ .setInitialPairingDescription(account == null
+ ? strings.getInitialNotificationDescriptionNoAccount()
+ : String.format(strings.getInitialPairingDescription(),
+ deviceName, account))
.setPairingFinishedCompanionAppInstalled(
strings.getConnectSuccessCompanionAppInstalled())
.setPairingFinishedCompanionAppNotInstalled(