Do not update tile state when unsure

This commit is contained in:
Mygod
2018-12-25 12:57:25 +08:00
parent 36b0284573
commit b2534eb2c0
6 changed files with 35 additions and 25 deletions

View File

@@ -24,9 +24,9 @@ class BluetoothTethering(context: Context) : BluetoothProfile.ServiceListener, A
/**
* Based on: https://android.googlesource.com/platform/packages/apps/Settings/+/78d5efd/src/com/android/settings/TetherSettings.java
*/
val active: Boolean get() {
val pan = pan
return adapter?.state == BluetoothAdapter.STATE_ON && pan != null && isTetheringOn.invoke(pan) as Boolean
val active: Boolean? get() {
val pan = pan ?: return null
return adapter?.state == BluetoothAdapter.STATE_ON && isTetheringOn.invoke(pan) as Boolean
}
init {