Remove Bluetooth tethering if unsupported

This commit is contained in:
Mygod
2021-07-27 14:53:23 -04:00
parent 5f6e33c852
commit 018682e2f5
4 changed files with 26 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
package be.mygod.vpnhotspot.manage
import android.bluetooth.BluetoothManager
import android.content.ComponentName
import android.content.Context
import android.content.Intent
@@ -11,6 +12,7 @@ import android.service.quicksettings.Tile
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import androidx.core.content.getSystemService
import be.mygod.vpnhotspot.R
import be.mygod.vpnhotspot.TetheringService
import be.mygod.vpnhotspot.net.TetherType
@@ -158,7 +160,9 @@ sealed class TetheringTileService : IpNeighbourMonitoringTileService(), Tetherin
}
override fun onStartListening() {
tethering = BluetoothTethering(this) { updateTile() }
tethering = getSystemService<BluetoothManager>()?.adapter?.let {
BluetoothTethering(this, it) { updateTile() }
}
super.onStartListening()
}
override fun onStopListening() {