Merge "Catch the exception otherwise if gms core side does not setup correctly system will crush"
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 d3bc9e6..0151543 100644
--- a/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
+++ b/nearby/service/java/com/android/server/nearby/fastpair/FastPairAdvHandler.java
@@ -42,6 +42,7 @@
public class FastPairAdvHandler {
Context mContext;
String mBleAddress;
+ private static final String TAG = "FastPairAdvHandler";
/** The types about how the bloomfilter is processed. */
public enum ProcessBloomFilterType {
@@ -73,17 +74,21 @@
Log.d("FastPairService",
"On discovery model id" + Hex.bytesToStringLowercase(model));
// Use api to get anti spoofing key from model id.
- Rpcs.GetObservedDeviceResponse response =
- FastPairDataProvider.getInstance()
- .loadFastPairAntispoofkeyDeviceMetadata(model);
- ByteString publicKey = response.getDevice().getAntiSpoofingKeyPair().getPublicKey();
- Locator.get(mContext, FastPairHalfSheetManager.class).showHalfSheet(
- Cache.ScanFastPairStoreItem.newBuilder().setAddress(mBleAddress)
- .setAntiSpoofingPublicKey(publicKey)
- .build());
+ try {
+ Rpcs.GetObservedDeviceResponse response =
+ FastPairDataProvider.getInstance()
+ .loadFastPairAntispoofkeyDeviceMetadata(model);
+ ByteString publicKey = response.getDevice().getAntiSpoofingKeyPair().getPublicKey();
+ Locator.get(mContext, FastPairHalfSheetManager.class).showHalfSheet(
+ Cache.ScanFastPairStoreItem.newBuilder().setAddress(mBleAddress)
+ .setAntiSpoofingPublicKey(publicKey)
+ .build());
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "OEM does not construct fast pair data proxy correctly");
+ }
+
} else {
// Start to process bloomfilter
-
}
}
diff --git a/nearby/service/java/com/android/server/nearby/fastpair/FastPairController.java b/nearby/service/java/com/android/server/nearby/fastpair/FastPairController.java
index 6efaae7..cf8cd62 100644
--- a/nearby/service/java/com/android/server/nearby/fastpair/FastPairController.java
+++ b/nearby/service/java/com/android/server/nearby/fastpair/FastPairController.java
@@ -63,6 +63,7 @@
* for pairing control.
*/
public class FastPairController {
+ private static final String TAG = "FastPairController";
private final Context mContext;
private final EventLoop mEventLoop;
private final FastPairCacheManager mFastPairCacheManager;
@@ -132,7 +133,7 @@
item = new DiscoveryItem(mContext,
Cache.StoredDiscoveryItem.parseFrom(discoveryItem));
} catch (InvalidProtocolBufferException e) {
- Log.w("FastPairController",
+ Log.w(TAG,
"Error parsing serialized discovery item with size "
+ discoveryItem.length);
}
@@ -140,8 +141,7 @@
if (item == null || TextUtils.isEmpty(item.getMacAddress())) {
- Log.w("FastPairController",
- "Invalid DiscoveryItem, ignore pairing");
+ Log.w(TAG, "Invalid DiscoveryItem, ignore pairing");
return;
}
@@ -150,7 +150,7 @@
// bug - b/31459521).
if (item.getState() != Cache.StoredDiscoveryItem.State.STATE_ENABLED
&& !isRetroactivePair) {
- Log.d("FastPairController", "Incorrect state, ignore pairing");
+ Log.d(TAG, "Incorrect state, ignore pairing");
return;
}
@@ -193,10 +193,10 @@
@Nullable String companionApp,
PairingProgressHandlerBase pairingProgressHandlerBase) {
if (mIsFastPairing) {
- Log.d("FastPairController", "FastPair: fastpairing, skip pair request");
+ Log.d(TAG, "FastPair: fastpairing, skip pair request");
return;
}
- Log.d("FastPairController", "FastPair: start pair");
+ Log.d(TAG, "FastPair: start pair");
// Hide all "tap to pair" notifications until after the flow completes.
mEventLoop.removeRunnable(mReEnableAllDeviceItemsRunnable);
@@ -243,7 +243,7 @@
if (!mShouldUpload) {
return;
}
- Log.d("FastPairController", "upload device to footprint");
+ Log.d(TAG, "upload device to footprint");
FastPairManager.processBackgroundTask(() -> {
Cache.StoredDiscoveryItem storedDiscoveryItem =
prepareStoredDiscoveryItemForFootprints(discoveryItem);
@@ -257,9 +257,13 @@
new FastPairUploadInfo(storedDiscoveryItem, ByteString.copyFrom(accountKey),
ByteString.copyFrom(hashValue));
// account data place holder here
- FastPairDataProvider.getInstance().optIn(new Account("empty", "empty"));
- FastPairDataProvider.getInstance().upload(
- new Account("empty", "empty"), uploadInfo);
+ try {
+ FastPairDataProvider.getInstance().optIn(new Account("empty", "empty"));
+ FastPairDataProvider.getInstance().upload(
+ new Account("empty", "empty"), uploadInfo);
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "OEM does not construct fast pair data proxy correctly");
+ }
}