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

Commit 2fad09a8 authored by Yiyi Shen's avatar Yiyi Shen
Browse files

[Audiosharing] Catch addSource exception when BT off

Test: atest
Flag: com.android.settingslib.flags.enable_le_audio_sharing
Bug: 305620450
Change-Id: I64ce9cee0edcee6592d28e98d32f607feb8f715f
parent ef8c6a24
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -151,7 +151,19 @@ public class LocalBluetoothLeBroadcastAssistant implements LocalBluetoothProfile
            Log.d(TAG, "The BluetoothLeBroadcastAssistant is null");
            return;
        }
        try {
            mService.addSource(sink, metadata, isGroupOp);
        } catch (IllegalStateException e) {
            // BT will check callback registration before add source.
            // If it throw callback exception when bt is disabled, then the failure is intended,
            // just catch it here.
            BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
            if (adapter != null && adapter.isEnabled()) {
                throw e;
            } else {
                Log.d(TAG, "Catch addSource failure when bt is disabled: " + e);
            }
        }
    }

    /**