Update dependencies and refine code style
This commit is contained in:
@@ -62,7 +62,7 @@ abstract class RoutingManager(private val caller: Any, val downstream: String, p
|
||||
fun start() = when (val other = active.putIfAbsentCompat(downstream, this)) {
|
||||
null -> initRouting()
|
||||
this -> true // already started
|
||||
else -> throw IllegalStateException("Double routing detected for $downstream from $caller != ${other.caller}")
|
||||
else -> error("Double routing detected for $downstream from $caller != ${other.caller}")
|
||||
}
|
||||
|
||||
private fun initRouting() = try {
|
||||
|
||||
@@ -59,7 +59,7 @@ open class Client(val mac: Long, val iface: String) {
|
||||
IpNeighbour.State.INCOMPLETE -> R.string.connected_state_incomplete
|
||||
IpNeighbour.State.VALID -> R.string.connected_state_valid
|
||||
IpNeighbour.State.FAILED -> R.string.connected_state_failed
|
||||
else -> throw IllegalStateException("Invalid IpNeighbour.State: $state")
|
||||
else -> error("Invalid IpNeighbour.State: $state")
|
||||
}))
|
||||
}
|
||||
}.trimEnd()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package be.mygod.vpnhotspot.client
|
||||
|
||||
import androidx.emoji.text.EmojiCompat
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
fun emojize(text: CharSequence?): CharSequence? = if (text == null) null else try {
|
||||
EmojiCompat.get().process(text)
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.lang.reflect.InvocationTargetException
|
||||
|
||||
sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
||||
TetheringManager.OnStartTetheringCallback {
|
||||
class ViewHolder(val binding: ListitemInterfaceBinding) : RecyclerView.ViewHolder(binding.root),
|
||||
class ViewHolder(private val binding: ListitemInterfaceBinding) : RecyclerView.ViewHolder(binding.root),
|
||||
View.OnClickListener {
|
||||
init {
|
||||
itemView.updatePaddingRelative(start = itemView.resources.getDimensionPixelOffset(
|
||||
|
||||
@@ -35,7 +35,6 @@ import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import java.lang.IllegalArgumentException
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import java.net.NetworkInterface
|
||||
import java.net.SocketException
|
||||
@@ -195,6 +194,7 @@ class TetheringFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClick
|
||||
CONFIGURE_AP -> if (resultCode == DialogInterface.BUTTON_POSITIVE) try {
|
||||
WifiApManager.configuration = configuration
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Timber.d(e)
|
||||
SmartSnackbar.make(R.string.configuration_rejected).show()
|
||||
} catch (e: InvocationTargetException) {
|
||||
SmartSnackbar.make(e.targetException).show()
|
||||
|
||||
@@ -13,7 +13,6 @@ import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.util.broadcastReceiver
|
||||
import be.mygod.vpnhotspot.util.intentFilter
|
||||
import timber.log.Timber
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
@RequiresApi(28)
|
||||
class TetherTimeoutMonitor(private val context: Context, private val handler: Handler,
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.net.LinkProperties
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import java.lang.UnsupportedOperationException
|
||||
import java.net.InetAddress
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@@ -3,7 +3,6 @@ package be.mygod.vpnhotspot.net.wifi
|
||||
import android.net.wifi.WifiConfiguration
|
||||
import android.net.wifi.WifiManager
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
object WifiApManager {
|
||||
private val getWifiApConfiguration by lazy { WifiManager::class.java.getDeclaredMethod("getWifiApConfiguration") }
|
||||
@@ -13,8 +12,8 @@ object WifiApManager {
|
||||
var configuration: WifiConfiguration
|
||||
get() = getWifiApConfiguration.invoke(app.wifi) as? WifiConfiguration ?: WifiConfiguration()
|
||||
set(value) {
|
||||
if (setWifiApConfiguration.invoke(app.wifi, value) as? Boolean != true) {
|
||||
throw IllegalArgumentException("setWifiApConfiguration failed")
|
||||
require(setWifiApConfiguration.invoke(app.wifi, value) as? Boolean == true) {
|
||||
"setWifiApConfiguration failed"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.net.wifi.p2p.WifiP2pManager
|
||||
import be.mygod.vpnhotspot.DebugHelper
|
||||
import com.android.dx.stock.ProxyBuilder
|
||||
import timber.log.Timber
|
||||
import java.lang.IllegalArgumentException
|
||||
import java.lang.reflect.Proxy
|
||||
|
||||
object WifiP2pManagerHelper {
|
||||
@@ -30,7 +29,7 @@ object WifiP2pManagerHelper {
|
||||
listener: WifiP2pManager.ActionListener) {
|
||||
try {
|
||||
setWifiP2pChannels.invoke(this, c, lc, oc, listener)
|
||||
} catch (e: NoSuchMethodException) {
|
||||
} catch (_: NoSuchMethodException) {
|
||||
DebugHelper.logEvent("NoSuchMethod_setWifiP2pChannels")
|
||||
listener.onFailure(UNSUPPORTED)
|
||||
}
|
||||
@@ -46,7 +45,7 @@ object WifiP2pManagerHelper {
|
||||
try {
|
||||
WifiP2pManager::class.java.getDeclaredMethod("startWps",
|
||||
WifiP2pManager.Channel::class.java, WpsInfo::class.java, WifiP2pManager.ActionListener::class.java)
|
||||
} catch (e: NoSuchMethodException) {
|
||||
} catch (_: NoSuchMethodException) {
|
||||
DebugHelper.logEvent("NoSuchMethod_startWps")
|
||||
null
|
||||
}
|
||||
@@ -69,7 +68,7 @@ object WifiP2pManagerHelper {
|
||||
listener: WifiP2pManager.ActionListener) {
|
||||
try {
|
||||
deletePersistentGroup.invoke(this, c, netId, listener)
|
||||
} catch (e: NoSuchMethodException) {
|
||||
} catch (_: NoSuchMethodException) {
|
||||
DebugHelper.logEvent("NoSuchMethod_deletePersistentGroup")
|
||||
listener.onFailure(UNSUPPORTED)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import be.mygod.vpnhotspot.DebugHelper
|
||||
import be.mygod.vpnhotspot.RepeaterService
|
||||
import be.mygod.vpnhotspot.util.RootSession
|
||||
import java.io.File
|
||||
import java.lang.IllegalStateException
|
||||
|
||||
/**
|
||||
* This parser is based on:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package be.mygod.vpnhotspot.net.wifi.configuration
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.annotation.TargetApi
|
||||
import android.content.ClipData
|
||||
import android.content.DialogInterface
|
||||
@@ -90,6 +91,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
||||
|
||||
override fun AlertDialog.Builder.prepare(listener: DialogInterface.OnClickListener) {
|
||||
val activity = requireActivity()
|
||||
@SuppressLint("InflateParams")
|
||||
dialogView = activity.layoutInflater.inflate(R.layout.dialog_wifi_ap, null)
|
||||
setView(dialogView)
|
||||
if (!arg.readOnly) setPositiveButton(R.string.wifi_save, listener)
|
||||
@@ -103,8 +105,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
||||
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
}
|
||||
onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) =
|
||||
throw IllegalStateException("Must select something")
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) = error("Must select something")
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
dialogView.password_wrapper.isGone = position == WifiConfiguration.KeyMgmt.NONE
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user