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

Commit 5b2f1b8b authored by Yiyi Shen's avatar Yiyi Shen Committed by Android (Google) Code Review
Browse files

Merge "[Audiosharing] Catch addSource exception when BT off" into main

parents a4095138 2fad09a8
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);
            }
        }
    }

    /**