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