Reset pendingCallback on failure
This commit is contained in:
@@ -125,8 +125,7 @@ class BluetoothTethering(context: Context, val stateListener: () -> Unit) :
|
|||||||
*/
|
*/
|
||||||
@RequiresApi(24)
|
@RequiresApi(24)
|
||||||
fun start(callback: TetheringManager.StartTetheringCallback) {
|
fun start(callback: TetheringManager.StartTetheringCallback) {
|
||||||
if (pendingCallback != null) return
|
if (pendingCallback == null) try {
|
||||||
try {
|
|
||||||
if (adapter?.state == BluetoothAdapter.STATE_OFF) {
|
if (adapter?.state == BluetoothAdapter.STATE_OFF) {
|
||||||
registerBluetoothStateListener(BluetoothTethering)
|
registerBluetoothStateListener(BluetoothTethering)
|
||||||
pendingCallback = callback
|
pendingCallback = callback
|
||||||
@@ -134,6 +133,7 @@ class BluetoothTethering(context: Context, val stateListener: () -> Unit) :
|
|||||||
} else TetheringManager.startTethering(TetheringManager.TETHERING_BLUETOOTH, true, callback)
|
} else TetheringManager.startTethering(TetheringManager.TETHERING_BLUETOOTH, true, callback)
|
||||||
} catch (e: SecurityException) {
|
} catch (e: SecurityException) {
|
||||||
SmartSnackbar.make(e.readableMessage).shortToast().show()
|
SmartSnackbar.make(e.readableMessage).shortToast().show()
|
||||||
|
pendingCallback = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@RequiresApi(24)
|
@RequiresApi(24)
|
||||||
|
|||||||
Reference in New Issue
Block a user