[LE Audio] Add try catch for bluetooth device address fail
Bug: 263554347 Bug: 265281156 Bug: 248409874 Test: manual test Change-Id: Ic200406e35793831841a75311923d86be423c0d8
This commit is contained in:
@@ -261,10 +261,12 @@ public class LocalBluetoothLeBroadcastMetadata {
|
|||||||
Pattern pattern = Pattern.compile(PATTERN_BT_BROADCAST_METADATA);
|
Pattern pattern = Pattern.compile(PATTERN_BT_BROADCAST_METADATA);
|
||||||
Matcher match = pattern.matcher(qrCodeString);
|
Matcher match = pattern.matcher(qrCodeString);
|
||||||
if (match.find()) {
|
if (match.find()) {
|
||||||
|
try {
|
||||||
mSourceAddressType = Integer.parseInt(match.group(MATCH_INDEX_ADDRESS_TYPE));
|
mSourceAddressType = Integer.parseInt(match.group(MATCH_INDEX_ADDRESS_TYPE));
|
||||||
mSourceDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(
|
mSourceDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(
|
||||||
match.group(MATCH_INDEX_DEVICE));
|
match.group(MATCH_INDEX_DEVICE));
|
||||||
mSourceAdvertisingSid = Integer.parseInt(match.group(MATCH_INDEX_ADVERTISING_SID));
|
mSourceAdvertisingSid = Integer.parseInt(
|
||||||
|
match.group(MATCH_INDEX_ADVERTISING_SID));
|
||||||
mBroadcastId = Integer.parseInt(match.group(MATCH_INDEX_BROADCAST_ID));
|
mBroadcastId = Integer.parseInt(match.group(MATCH_INDEX_BROADCAST_ID));
|
||||||
mPaSyncInterval = Integer.parseInt(match.group(MATCH_INDEX_SYNC_INTERVAL));
|
mPaSyncInterval = Integer.parseInt(match.group(MATCH_INDEX_SYNC_INTERVAL));
|
||||||
mIsEncrypted = Boolean.valueOf(match.group(MATCH_INDEX_IS_ENCRYPTED));
|
mIsEncrypted = Boolean.valueOf(match.group(MATCH_INDEX_IS_ENCRYPTED));
|
||||||
@@ -296,10 +298,13 @@ public class LocalBluetoothLeBroadcastMetadata {
|
|||||||
.setPresentationDelayMicros(mPresentationDelayMicros)
|
.setPresentationDelayMicros(mPresentationDelayMicros)
|
||||||
.addSubgroup(mSubgroup)
|
.addSubgroup(mSubgroup)
|
||||||
.build();
|
.build();
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.d(TAG, "IllegalArgumentException when convert : " + e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG,
|
Log.d(TAG, "The match fail, can not convert it to BluetoothLeBroadcastMetadata.");
|
||||||
"The match fail, can not convert it to BluetoothLeBroadcastMetadata.");
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user