Fix more crashes

This commit is contained in:
Mygod
2020-06-26 05:00:17 +08:00
parent debce58375
commit 8f8ede2c8c
3 changed files with 12 additions and 10 deletions

View File

@@ -249,7 +249,7 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
private fun onPersistentGroupsChanged() = launch { private fun onPersistentGroupsChanged() = launch {
val ownerAddress = lastMac?.let(MacAddressCompat.Companion::fromString) ?: try { val ownerAddress = lastMac?.let(MacAddressCompat.Companion::fromString) ?: try {
P2pSupplicantConfiguration().apply { init() }.bssid P2pSupplicantConfiguration().apply { init() }.bssid
} catch (e: RuntimeException) { } catch (e: Exception) {
Timber.d(e) Timber.d(e)
null null
} ?: return@launch } ?: return@launch

View File

@@ -159,7 +159,7 @@ abstract class IpMonitor {
val lines = result.out.lines() val lines = result.out.lines()
if (lines.any { errorMatcher.containsMatchIn(it) }) throw IOException(result.out) if (lines.any { errorMatcher.containsMatchIn(it) }) throw IOException(result.out)
processLines(lines.asSequence()) processLines(lines.asSequence())
} catch (e: RuntimeException) { } catch (e: Exception) {
app.logEvent("ip_su_poll_failure") { param("cause", e.message.toString()) } app.logEvent("ip_su_poll_failure") { param("cause", e.message.toString()) }
Timber.d(e) Timber.d(e)
} }

View File

@@ -84,19 +84,21 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
private var started = false private var started = false
override val ret get() = Arg(generateConfig()) override val ret get() = Arg(generateConfig())
private fun generateConfig(populateBssid: Boolean = true) = base.copy( private fun generateConfig(full: 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).apply { passphrase = if (dialogView.password.length() != 0) dialogView.password.text.toString() 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
} }
val bandOption = dialogView.band.selectedItem as BandOption if (full) {
band = bandOption.band val bandOption = dialogView.band.selectedItem as BandOption
channel = bandOption.channel band = bandOption.band
if (populateBssid) bssid = if (dialogView.bssid.length() != 0) { channel = bandOption.channel
MacAddressCompat.fromString(dialogView.bssid.text.toString()) bssid = if (dialogView.bssid.length() != 0) {
} else null MacAddressCompat.fromString(dialogView.bssid.text.toString())
} else null
}
} }
override fun AlertDialog.Builder.prepare(listener: DialogInterface.OnClickListener) { override fun AlertDialog.Builder.prepare(listener: DialogInterface.OnClickListener) {
@@ -142,7 +144,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
} }
} else dialogView.bandWrapper.isGone = true } else dialogView.bandWrapper.isGone = true
if (!arg.readOnly) dialogView.bssid.addTextChangedListener(this@WifiApDialogFragment) dialogView.bssid.addTextChangedListener(this@WifiApDialogFragment)
if (arg.p2pMode) dialogView.hiddenSsid.isGone = true if (arg.p2pMode) dialogView.hiddenSsid.isGone = true
base = arg.configuration base = arg.configuration
populateFromConfiguration() populateFromConfiguration()