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

Commit f386bb8a authored by Yiyi Shen's avatar Yiyi Shen
Browse files

Only unregister the callback when bt adapter is enabled

Test: manual
Flag: EXEMPT small fix
Bug: 358531727
Change-Id: I3fc2742dc646b54cdf52b86141f25654e9fa3a07
parent da0d38eb
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settingslib.bluetooth

import android.bluetooth.BluetoothAdapter
import android.bluetooth.BluetoothDevice
import android.bluetooth.BluetoothLeBroadcastAssistant
import android.bluetooth.BluetoothLeBroadcastMetadata
@@ -81,5 +82,9 @@ val LocalBluetoothLeBroadcastAssistant.onSourceConnectedOrRemoved: Flow<Unit>
            ConcurrentUtils.DIRECT_EXECUTOR,
            callback,
        )
        awaitClose { unregisterServiceCallBack(callback) }
        awaitClose {
            if (BluetoothAdapter.getDefaultAdapter()?.isEnabled == true) {
                unregisterServiceCallBack(callback)
            }
        }
    }