Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93fde650 authored by changbetty's avatar changbetty Committed by Betty Chang
Browse files

[LE Audio] Add try catch for bluetooth device address fail

Bug: 263554347
Bug: 265281156
Bug: 248409874
Test: manual test
Change-Id: Ic200406e35793831841a75311923d86be423c0d8
parent bdf9aaf0
Loading
Loading
Loading
Loading
+22 −17
Original line number Diff line number Diff line
@@ -261,10 +261,12 @@ public class LocalBluetoothLeBroadcastMetadata {
        Pattern pattern = Pattern.compile(PATTERN_BT_BROADCAST_METADATA);
        Matcher match = pattern.matcher(qrCodeString);
        if (match.find()) {
            try {
                mSourceAddressType = Integer.parseInt(match.group(MATCH_INDEX_ADDRESS_TYPE));
                mSourceDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(
                    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));
                mPaSyncInterval = Integer.parseInt(match.group(MATCH_INDEX_SYNC_INTERVAL));
                mIsEncrypted = Boolean.valueOf(match.group(MATCH_INDEX_IS_ENCRYPTED));
@@ -296,10 +298,13 @@ public class LocalBluetoothLeBroadcastMetadata {
                    .setPresentationDelayMicros(mPresentationDelayMicros)
                    .addSubgroup(mSubgroup)
                    .build();
            } catch (IllegalArgumentException e) {
                Log.d(TAG, "IllegalArgumentException when convert : " + e);
                return null;
            }
        } else {
            if (DEBUG) {
                Log.d(TAG,
                        "The match fail, can not convert it to BluetoothLeBroadcastMetadata.");
                Log.d(TAG, "The match fail, can not convert it to BluetoothLeBroadcastMetadata.");
            }
            return null;
        }