Fix various crashes
This commit is contained in:
@@ -36,7 +36,7 @@ abstract class RoutingManager(private val caller: Any, val downstream: String, p
|
|||||||
for (manager in active.values) manager.routing?.stop()
|
for (manager in active.values) manager.routing?.stop()
|
||||||
try {
|
try {
|
||||||
runBlocking { Routing.clean() }
|
runBlocking { Routing.clean() }
|
||||||
} catch (e: RuntimeException) {
|
} catch (e: Exception) {
|
||||||
Timber.d(e)
|
Timber.d(e)
|
||||||
SmartSnackbar.make(e).show()
|
SmartSnackbar.make(e).show()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -82,12 +82,11 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
private lateinit var bandOptions: MutableList<BandOption>
|
private lateinit var bandOptions: MutableList<BandOption>
|
||||||
private lateinit var base: SoftApConfigurationCompat
|
private lateinit var base: SoftApConfigurationCompat
|
||||||
private var started = false
|
private var started = false
|
||||||
override val ret get() = Arg(base.copy(
|
override val ret get() = Arg(generateConfig())
|
||||||
|
|
||||||
|
private fun generateConfig(populateBssid: Boolean = true) = base.copy(
|
||||||
ssid = dialogView.ssid.text.toString(),
|
ssid = dialogView.ssid.text.toString(),
|
||||||
passphrase = if (dialogView.password.length() != 0) dialogView.password.text.toString() else null,
|
passphrase = if (dialogView.password.length() != 0) dialogView.password.text.toString() else null).apply {
|
||||||
bssidAddr = if (dialogView.bssid.length() != 0) {
|
|
||||||
MacAddressCompat.fromString(dialogView.bssid.text.toString()).addr
|
|
||||||
} else null).apply {
|
|
||||||
if (!arg.p2pMode) {
|
if (!arg.p2pMode) {
|
||||||
securityType = dialogView.security.selectedItemPosition
|
securityType = dialogView.security.selectedItemPosition
|
||||||
isHiddenSsid = dialogView.hiddenSsid.isChecked
|
isHiddenSsid = dialogView.hiddenSsid.isChecked
|
||||||
@@ -95,7 +94,10 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
val bandOption = dialogView.band.selectedItem as BandOption
|
val bandOption = dialogView.band.selectedItem as BandOption
|
||||||
band = bandOption.band
|
band = bandOption.band
|
||||||
channel = bandOption.channel
|
channel = bandOption.channel
|
||||||
})
|
if (populateBssid) bssid = if (dialogView.bssid.length() != 0) {
|
||||||
|
MacAddressCompat.fromString(dialogView.bssid.text.toString())
|
||||||
|
} else null
|
||||||
|
}
|
||||||
|
|
||||||
override fun AlertDialog.Builder.prepare(listener: DialogInterface.OnClickListener) {
|
override fun AlertDialog.Builder.prepare(listener: DialogInterface.OnClickListener) {
|
||||||
val activity = requireActivity()
|
val activity = requireActivity()
|
||||||
@@ -196,6 +198,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
}
|
}
|
||||||
(dialog as? AlertDialog)?.getButton(DialogInterface.BUTTON_POSITIVE)?.isEnabled =
|
(dialog as? AlertDialog)?.getButton(DialogInterface.BUTTON_POSITIVE)?.isEnabled =
|
||||||
ssidLength in 1..32 && passwordValid && bssidValid
|
ssidLength in 1..32 && passwordValid && bssidValid
|
||||||
|
dialogView.toolbar.menu.findItem(android.R.id.copy).isEnabled = bssidValid
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { }
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) { }
|
||||||
@@ -206,7 +209,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
return when (item?.itemId) {
|
return when (item?.itemId) {
|
||||||
android.R.id.copy -> {
|
android.R.id.copy -> {
|
||||||
app.clipboard.setPrimaryClip(ClipData.newPlainText(null,
|
app.clipboard.setPrimaryClip(ClipData.newPlainText(null,
|
||||||
Base64.encodeToString(ret.configuration.toByteArray(), BASE64_FLAGS)))
|
Base64.encodeToString(generateConfig().toByteArray(), BASE64_FLAGS)))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
android.R.id.paste -> try {
|
android.R.id.paste -> try {
|
||||||
@@ -226,13 +229,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
R.id.share_qr -> {
|
R.id.share_qr -> {
|
||||||
val qrString = try {
|
QRCodeDialog().withArg(generateConfig(false).toQrCode()).showAllowingStateLoss(parentFragmentManager)
|
||||||
ret.configuration.toQrCode()
|
|
||||||
} catch (e: IllegalArgumentException) {
|
|
||||||
SmartSnackbar.make(e).show()
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
QRCodeDialog().withArg(qrString).showAllowingStateLoss(parentFragmentManager)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> false
|
else -> false
|
||||||
|
|||||||
Reference in New Issue
Block a user