kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
update CompanionDevice Bluetooth bonding
rodzic
875c1542ea
commit
0f3135978c
|
@ -883,7 +883,6 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
deviceManager.associate(
|
deviceManager.associate(
|
||||||
pairingRequest,
|
pairingRequest,
|
||||||
object : CompanionDeviceManager.Callback() {
|
object : CompanionDeviceManager.Callback() {
|
||||||
|
|
||||||
override fun onDeviceFound(chooserLauncher: IntentSender) {
|
override fun onDeviceFound(chooserLauncher: IntentSender) {
|
||||||
debug("Found one device - enabling changeRadioButton")
|
debug("Found one device - enabling changeRadioButton")
|
||||||
binding.changeRadioButton.isEnabled = true
|
binding.changeRadioButton.isEnabled = true
|
||||||
|
@ -914,8 +913,6 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
updateDevicesButtons(devices)
|
updateDevicesButtons(devices)
|
||||||
startCompanionScan()
|
startCompanionScan()
|
||||||
}
|
}
|
||||||
|
|
||||||
startCompanionScan()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
@ -1041,17 +1038,22 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingPermission")
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
if (hasCompanionDeviceApi && myActivity.hasConnectPermission()
|
||||||
&& requestCode == MainActivity.SELECT_DEVICE_REQUEST_CODE
|
&& requestCode == MainActivity.SELECT_DEVICE_REQUEST_CODE
|
||||||
&& resultCode == Activity.RESULT_OK
|
&& resultCode == Activity.RESULT_OK
|
||||||
) {
|
) {
|
||||||
val deviceToPair: BluetoothDevice =
|
val deviceToPair: BluetoothDevice =
|
||||||
data?.getParcelableExtra(CompanionDeviceManager.EXTRA_DEVICE)!!
|
data?.getParcelableExtra(CompanionDeviceManager.EXTRA_DEVICE)!!
|
||||||
if (deviceToPair.bondState != BOND_BONDED) {
|
scanModel.onSelected(
|
||||||
deviceToPair.createBond()
|
myActivity,
|
||||||
}
|
BTScanModel.DeviceListEntry(
|
||||||
scanModel.changeScanSelection(myActivity, "x${deviceToPair.address}")
|
deviceToPair.name,
|
||||||
|
"x${deviceToPair.address}",
|
||||||
|
deviceToPair.bondState == BOND_BONDED
|
||||||
|
)
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue