wip
This commit is contained in:
@@ -108,6 +108,11 @@ class MyBroadcastReceiver : BroadcastReceiver(), TetheringManager.StartTethering
|
||||
}
|
||||
TetheringManager.startTethering(TetheringManager.TETHERING_WIFI, false, this)
|
||||
// showNotification(context, "Tethering Status", "Wi-Fi tethering started")
|
||||
Intent(context, TetheringService::class.java).apply {
|
||||
putExtra(TetheringService.EXTRA_ADD_INTERFACES, arrayOf("ap_br_wlan2"))
|
||||
context.startForegroundService(this)
|
||||
}
|
||||
// Toast.makeText(context, "Monitoring service called for $iface", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
"WIFI_TETHER_STOP" -> {
|
||||
TetheringManager.stopTethering(TetheringManager.TETHERING_WIFI)
|
||||
@@ -121,7 +126,6 @@ class MyBroadcastReceiver : BroadcastReceiver(), TetheringManager.StartTethering
|
||||
// }
|
||||
// showNotification(context, "Tethering Status", message)
|
||||
if (tetheredInterfaces != null && tetheredInterfaces.isNotEmpty()) {
|
||||
Toast.makeText(context, "Tethering interfaces changed", Toast.LENGTH_SHORT).show()
|
||||
tetheredInterfaces.forEach { iface ->
|
||||
Intent(context, TetheringService::class.java).apply {
|
||||
putExtra(TetheringService.EXTRA_ADD_INTERFACES, arrayOf(iface))
|
||||
|
||||
@@ -69,7 +69,8 @@ class TetheringService : IpNeighbourMonitoringService(), TetheringManager.Tether
|
||||
val toRemove = downstreams.toMutableMap() // make a copy
|
||||
for (iface in interfaces) {
|
||||
val downstream = toRemove.remove(iface) ?: continue
|
||||
if (downstream.monitor && !downstream.start()) downstream.stop()
|
||||
// if (downstream.monitor && !downstream.start()) downstream.stop()
|
||||
if (!downstream.start()) downstream.stop()
|
||||
}
|
||||
for ((iface, downstream) in toRemove) {
|
||||
if (!downstream.monitor) check(downstreams.remove(iface, downstream))
|
||||
|
||||
Reference in New Issue
Block a user