Clear error when permission is granted
This commit is contained in:
@@ -109,6 +109,7 @@ class BluetoothTethering(context: Context, val stateListener: () -> Unit) :
|
|||||||
private val receiver = broadcastReceiver { _, _ -> stateListener() }
|
private val receiver = broadcastReceiver { _, _ -> stateListener() }
|
||||||
|
|
||||||
fun ensureInit(context: Context) {
|
fun ensureInit(context: Context) {
|
||||||
|
activeFailureCause = null
|
||||||
if (pan == null) try {
|
if (pan == null) try {
|
||||||
pan = pan(context, this)
|
pan = pan(context, this)
|
||||||
} catch (e: ReflectiveOperationException) {
|
} catch (e: ReflectiveOperationException) {
|
||||||
|
|||||||
@@ -297,11 +297,14 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
|||||||
parent.viewLifecycleOwner.lifecycle.addObserver(this)
|
parent.viewLifecycleOwner.lifecycle.addObserver(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ensureInit(context: Context) = tethering.ensureInit(context)
|
fun ensureInit(context: Context) {
|
||||||
|
tethering.ensureInit(context)
|
||||||
|
onTetheringStarted() // force flush
|
||||||
|
}
|
||||||
override fun onResume(owner: LifecycleOwner) {
|
override fun onResume(owner: LifecycleOwner) {
|
||||||
if (!BuildCompat.isAtLeastS() || parent.requireContext().checkSelfPermission(
|
if (!BuildCompat.isAtLeastS() || parent.requireContext().checkSelfPermission(
|
||||||
Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) {
|
Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) {
|
||||||
ensureInit(parent.requireContext())
|
tethering.ensureInit(parent.requireContext())
|
||||||
} else if (parent.shouldShowRequestPermissionRationale(Manifest.permission.BLUETOOTH_CONNECT)) {
|
} else if (parent.shouldShowRequestPermissionRationale(Manifest.permission.BLUETOOTH_CONNECT)) {
|
||||||
parent.requestBluetooth.launch(Manifest.permission.BLUETOOTH_CONNECT)
|
parent.requestBluetooth.launch(Manifest.permission.BLUETOOTH_CONNECT)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user