Warn when offload is verified to be started

This commit is contained in:
Mygod
2020-05-28 15:11:45 -04:00
parent 4447dfd86e
commit 547815ffaf
2 changed files with 17 additions and 0 deletions

View File

@@ -1,13 +1,17 @@
package be.mygod.vpnhotspot
import android.content.Intent
import androidx.annotation.RequiresApi
import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.net.Routing
import be.mygod.vpnhotspot.net.TetherType
import be.mygod.vpnhotspot.net.TetheringManager
import be.mygod.vpnhotspot.net.monitor.IpNeighbourMonitor
import be.mygod.vpnhotspot.util.Event0
import be.mygod.vpnhotspot.widget.SmartSnackbar
import kotlinx.coroutines.*
import timber.log.Timber
import java.lang.IllegalStateException
import java.util.concurrent.ConcurrentHashMap
class TetheringService : IpNeighbourMonitoringService(), TetheringManager.TetheringEventCallback, CoroutineScope {
@@ -62,6 +66,16 @@ class TetheringService : IpNeighbourMonitoringService(), TetheringManager.Tether
}
}
@RequiresApi(30)
override fun onOffloadStatusChanged(status: Int) = when (status) {
TetheringManager.TETHER_HARDWARE_OFFLOAD_STOPPED, TetheringManager.TETHER_HARDWARE_OFFLOAD_FAILED -> { }
TetheringManager.TETHER_HARDWARE_OFFLOAD_STARTED -> {
Timber.w("TETHER_HARDWARE_OFFLOAD_STARTED")
SmartSnackbar.make(R.string.tethering_manage_offload_enabled).show()
}
else -> Timber.w(IllegalStateException("Unknown onOffloadStatusChanged $status"))
}
private fun onDownstreamsChangedLocked() {
if (downstreams.isEmpty()) {
unregisterReceiver()