This commit is contained in:
Your Name
2024-03-05 01:30:47 -06:00
parent fc2268e1fe
commit 2bd9a39328
96 changed files with 13 additions and 8 deletions

View File

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

View File

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