Refine code style

This commit is contained in:
Mygod
2018-04-21 23:49:10 -07:00
parent 2615abae2f
commit 2b2639e288
4 changed files with 8 additions and 10 deletions

View File

@@ -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()
} }

View File

@@ -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() ?: ""

View File

@@ -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

View File

@@ -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()