Refine code style
This commit is contained in:
@@ -85,7 +85,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, VpnMonitor.Ca
|
|||||||
else -> Log.w(TAG, "Unexpected groups: $it")
|
else -> Log.w(TAG, "Unexpected groups: $it")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e: Exception) {
|
} catch (e: ReflectiveOperationException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
Toast.makeText(this@RepeaterService, e.message, Toast.LENGTH_LONG).show()
|
Toast.makeText(this@RepeaterService, e.message, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,13 +179,12 @@ class TetheringFragment : Fragment(), ServiceConnection {
|
|||||||
/**
|
/**
|
||||||
* Based on: https://android.googlesource.com/platform/packages/apps/Settings/+/78d5efd/src/com/android/settings/TetherSettings.java
|
* Based on: https://android.googlesource.com/platform/packages/apps/Settings/+/78d5efd/src/com/android/settings/TetherSettings.java
|
||||||
*/
|
*/
|
||||||
fun isStarted(type: TetherType, enabledTypes: Set<TetherType> = this.enabledTypes): Boolean {
|
fun isStarted(type: TetherType, enabledTypes: Set<TetherType> = this.enabledTypes) =
|
||||||
return if (type == TetherType.BLUETOOTH) {
|
if (type == TetherType.BLUETOOTH) {
|
||||||
val pan = pan
|
val pan = pan
|
||||||
BluetoothAdapter.getDefaultAdapter()?.state == BluetoothAdapter.STATE_ON && pan != null &&
|
BluetoothAdapter.getDefaultAdapter()?.state == BluetoothAdapter.STATE_ON && pan != null &&
|
||||||
isTetheringOn.invoke(pan) as Boolean
|
isTetheringOn.invoke(pan) as Boolean
|
||||||
} else enabledTypes.contains(type)
|
} else enabledTypes.contains(type)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
class TetheredInterface(val name: String, lookup: Map<String, NetworkInterface>) : Comparable<TetheredInterface> {
|
class TetheredInterface(val name: String, lookup: Map<String, NetworkInterface>) : Comparable<TetheredInterface> {
|
||||||
val addresses = lookup[name]?.formatAddresses() ?: ""
|
val addresses = lookup[name]?.formatAddresses() ?: ""
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package be.mygod.vpnhotspot.net
|
package be.mygod.vpnhotspot.net
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.Network
|
import android.net.Network
|
||||||
import android.net.NetworkCapabilities
|
import android.net.NetworkCapabilities
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class P2pSupplicantConfiguration {
|
|||||||
fun readPsk(): String? {
|
fun readPsk(): String? {
|
||||||
return try {
|
return try {
|
||||||
pskParser.findAll(content ?: return null).single().groupValues[1]
|
pskParser.findAll(content ?: return null).single().groupValues[1]
|
||||||
} catch (e: Exception) {
|
} catch (e: RuntimeException) {
|
||||||
Log.w(TAG, content)
|
Log.w(TAG, content)
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
Toast.makeText(app, e.message, Toast.LENGTH_LONG).show()
|
Toast.makeText(app, e.message, Toast.LENGTH_LONG).show()
|
||||||
|
|||||||
Reference in New Issue
Block a user