Misc refinements
This commit is contained in:
@@ -140,13 +140,9 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, VpnMonitor.Ca
|
|||||||
}
|
}
|
||||||
App.ACTION_CLEAN_ROUTINGS -> {
|
App.ACTION_CLEAN_ROUTINGS -> {
|
||||||
val routing = routing
|
val routing = routing
|
||||||
try {
|
routing!!.started = false
|
||||||
routing!!.started = false
|
if (status == Status.ACTIVE && !initRouting(upstream!!, routing.downstream, routing.hostAddress))
|
||||||
if (status == Status.ACTIVE && !initRouting(upstream!!, routing.downstream, routing.hostAddress))
|
Toast.makeText(this@RepeaterService, R.string.noisy_su_failure, Toast.LENGTH_SHORT).show()
|
||||||
Toast.makeText(this@RepeaterService, R.string.noisy_su_failure, Toast.LENGTH_SHORT).show()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Toast.makeText(this@RepeaterService, e.message, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +236,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, VpnMonitor.Ca
|
|||||||
if (!initRouting(ifname, routing.downstream, routing.hostAddress))
|
if (!initRouting(ifname, routing.downstream, routing.hostAddress))
|
||||||
Toast.makeText(this, getText(R.string.noisy_su_failure), Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, getText(R.string.noisy_su_failure), Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
else -> throw RuntimeException("RepeaterService is in unexpected state when receiving onAvailable")
|
else -> throw IllegalStateException("RepeaterService is in unexpected state when receiving onAvailable")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override fun onLost(ifname: String) {
|
override fun onLost(ifname: String) {
|
||||||
@@ -273,9 +269,9 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, VpnMonitor.Ca
|
|||||||
debugLog(TAG, "P2P connection changed: $info\n$net\n$group")
|
debugLog(TAG, "P2P connection changed: $info\n$net\n$group")
|
||||||
}
|
}
|
||||||
private fun onGroupCreated(info: WifiP2pInfo, group: WifiP2pGroup) {
|
private fun onGroupCreated(info: WifiP2pInfo, group: WifiP2pGroup) {
|
||||||
val owner = info.groupOwnerAddress
|
if (!info.groupFormed || !info.isGroupOwner) return
|
||||||
val downstream = group.`interface`
|
val owner = info.groupOwnerAddress ?: return
|
||||||
if (!info.groupFormed || !info.isGroupOwner || downstream == null || owner == null) return
|
val downstream = group.`interface` ?: return
|
||||||
receiverRegistered = true
|
receiverRegistered = true
|
||||||
try {
|
try {
|
||||||
if (initRouting(upstream!!, downstream, owner)) doStart(group)
|
if (initRouting(upstream!!, downstream, owner)) doStart(group)
|
||||||
|
|||||||
@@ -30,9 +30,13 @@ fun setImageResource(imageView: ImageView, @DrawableRes resource: Int) = imageVi
|
|||||||
private const val NOISYSU_TAG = "NoisySU"
|
private const val NOISYSU_TAG = "NoisySU"
|
||||||
private const val NOISYSU_SUFFIX = "SUCCESS\n"
|
private const val NOISYSU_SUFFIX = "SUCCESS\n"
|
||||||
fun loggerSu(command: String): String? {
|
fun loggerSu(command: String): String? {
|
||||||
val process = ProcessBuilder("su", "-c", command)
|
val process = try {
|
||||||
.redirectErrorStream(true)
|
ProcessBuilder("su", "-c", command)
|
||||||
.start()
|
.redirectErrorStream(true)
|
||||||
|
.start()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
process.waitFor()
|
process.waitFor()
|
||||||
try {
|
try {
|
||||||
val err = process.errorStream.bufferedReader().readText()
|
val err = process.errorStream.bufferedReader().readText()
|
||||||
|
|||||||
Reference in New Issue
Block a user