Refine code style
This commit is contained in:
@@ -3,16 +3,13 @@ plugins {
|
||||
}
|
||||
|
||||
buildscript {
|
||||
val kotlinVersion = "1.4.0"
|
||||
extra.set("kotlinVersion", kotlinVersion)
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath(kotlin("gradle-plugin", kotlinVersion))
|
||||
classpath(kotlin("gradle-plugin", "1.4.0"))
|
||||
classpath("com.android.tools.build:gradle:4.1.0-rc01")
|
||||
classpath("com.google.firebase:firebase-crashlytics-gradle:2.2.0")
|
||||
classpath("com.google.android.gms:oss-licenses-plugin:0.10.2")
|
||||
|
||||
@@ -72,7 +72,6 @@ dependencies {
|
||||
|
||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.0.10")
|
||||
kapt("androidx.room:room-compiler:$roomVersion")
|
||||
implementation(kotlin("stdlib-jdk8", rootProject.extra.get("kotlinVersion").toString()))
|
||||
implementation("androidx.appcompat:appcompat:1.3.0-alpha01") // https://issuetracker.google.com/issues/151603528
|
||||
implementation("androidx.browser:browser:1.2.0")
|
||||
implementation("androidx.core:core-ktx:1.3.1")
|
||||
|
||||
@@ -372,9 +372,7 @@ class RootServer {
|
||||
write(bytes)
|
||||
} catch (_: NotSerializableException) {
|
||||
writeByte(EX_GENERIC)
|
||||
writeUTF(StringWriter().also {
|
||||
e.printStackTrace(PrintWriter(it))
|
||||
}.toString())
|
||||
writeUTF(e.stackTraceToString())
|
||||
}
|
||||
flush()
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import kotlinx.android.parcel.Parcelize
|
||||
|
||||
class NoShellException(cause: Throwable) : Exception("Root missing", cause)
|
||||
|
||||
val currentInstructionSet by lazy {
|
||||
internal val currentInstructionSet by lazy {
|
||||
val classVMRuntime = Class.forName("dalvik.system.VMRuntime")
|
||||
val runtime = classVMRuntime.getDeclaredMethod("getRuntime").invoke(null)
|
||||
classVMRuntime.getDeclaredMethod("getCurrentInstructionSet").invoke(runtime) as String
|
||||
@@ -20,12 +20,12 @@ val currentInstructionSet by lazy {
|
||||
|
||||
private val classSystemProperties by lazy { Class.forName("android.os.SystemProperties") }
|
||||
@get:RequiresApi(26)
|
||||
val isVndkLite by lazy {
|
||||
internal val isVndkLite by lazy {
|
||||
classSystemProperties.getDeclaredMethod("getBoolean", String::class.java, Boolean::class.java).invoke(null,
|
||||
"ro.vndk.lite", false) as Boolean
|
||||
}
|
||||
@get:RequiresApi(26)
|
||||
val vndkVersion by lazy {
|
||||
internal val vndkVersion by lazy {
|
||||
classSystemProperties.getDeclaredMethod("get", String::class.java, String::class.java).invoke(null,
|
||||
"ro.vndk.version", "") as String
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
|
||||
p.writeString(passphrase)
|
||||
extras.forEach(p::writeInt)
|
||||
p.setDataPosition(0)
|
||||
p.readParcelable<WifiP2pConfig>(javaClass.classLoader)
|
||||
p.readParcelable(javaClass.classLoader)
|
||||
}
|
||||
}, listener)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class TetheringService : IpNeighbourMonitoringService(), TetheringManager.Tether
|
||||
fun monitored(iface: String) = downstreams[iface]?.monitor
|
||||
}
|
||||
|
||||
private inner class Downstream(caller: Any, downstream: String, var monitor: Boolean = false) :
|
||||
private class Downstream(caller: Any, downstream: String, var monitor: Boolean = false) :
|
||||
RoutingManager(caller, downstream) {
|
||||
override fun Routing.configure() {
|
||||
forward()
|
||||
|
||||
@@ -97,7 +97,7 @@ data class IpNeighbour(val ip: InetAddress, val dev: String, val lladdr: MacAddr
|
||||
devs.map { IpNeighbour(ip, it, lladdr, state) }
|
||||
} catch (e: Exception) {
|
||||
Timber.w(IllegalArgumentException("Unable to parse line: $line", e))
|
||||
emptyList<IpNeighbour>()
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,4 +138,5 @@ data class IpNeighbour(val ip: InetAddress, val dev: String, val lladdr: MacAddr
|
||||
data class IpDev(val ip: InetAddress, val dev: String) {
|
||||
override fun toString() = "$ip%$dev"
|
||||
}
|
||||
@Suppress("FunctionName")
|
||||
fun IpDev(neighbour: IpNeighbour) = IpDev(neighbour.ip, neighbour.dev)
|
||||
|
||||
@@ -48,7 +48,7 @@ enum class TetherType(@DrawableRes val icon: Int) {
|
||||
second.getStringArray(it).filterNotNull().map { it.toPattern() }
|
||||
} catch (_: Resources.NotFoundException) {
|
||||
Timber.w(Exception("$name not found"))
|
||||
emptyList<Pattern>()
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import kotlinx.coroutines.channels.produce
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.InterruptedIOException
|
||||
import java.util.concurrent.Executor
|
||||
|
||||
fun ProcessBuilder.fixPath(redirect: Boolean = false) = apply {
|
||||
environment().compute("PATH") { _, value ->
|
||||
@@ -141,7 +140,7 @@ data class StartTethering(private val type: Int,
|
||||
future.complete(error!!)
|
||||
}
|
||||
}
|
||||
TetheringManager.startTethering(type, true, showProvisioningUi, Executor {
|
||||
TetheringManager.startTethering(type, true, showProvisioningUi, {
|
||||
GlobalScope.launch(Dispatchers.Unconfined) { it.run() }
|
||||
}, TetheringManager.proxy(callback))
|
||||
return future.await()?.let { ParcelableInt(it) }
|
||||
|
||||
@@ -15,7 +15,6 @@ import kotlinx.coroutines.channels.ReceiveChannel
|
||||
import kotlinx.coroutines.channels.consumeEach
|
||||
import kotlinx.coroutines.channels.produce
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.Executor
|
||||
|
||||
object WifiApCommands {
|
||||
@RequiresApi(28)
|
||||
@@ -90,7 +89,7 @@ object WifiApCommands {
|
||||
@RequiresApi(30)
|
||||
override fun onBlockedClientConnecting(client: MacAddress, blockedReason: Int) =
|
||||
push(SoftApCallbackParcel.OnBlockedClientConnecting(client, blockedReason))
|
||||
}, Executor {
|
||||
}) {
|
||||
scope.launch {
|
||||
try {
|
||||
it.run()
|
||||
@@ -98,7 +97,7 @@ object WifiApCommands {
|
||||
finish.completeExceptionally(e)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
try {
|
||||
finish.await()
|
||||
} finally {
|
||||
|
||||
@@ -163,6 +163,7 @@ fun InvocationHandler.callSuper(interfaceClass: Class<*>, proxy: Any, method: Me
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("FunctionName")
|
||||
fun if_nametoindex(ifname: String) = if (Build.VERSION.SDK_INT >= 26) {
|
||||
Os.if_nametoindex(ifname)
|
||||
} else try {
|
||||
|
||||
Reference in New Issue
Block a user