diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt index 49d3cba0..5f5fcee5 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt @@ -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() diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt index 4938d4f9..bba9723b 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt @@ -86,10 +86,13 @@ object TetheringManager { const val EXTRA_ERRORED_TETHER = "erroredArray" /** Tethering offload status is stopped. */ + @RequiresApi(30) const val TETHER_HARDWARE_OFFLOAD_STOPPED = 0 /** Tethering offload status is started. */ + @RequiresApi(30) const val TETHER_HARDWARE_OFFLOAD_STARTED = 1 /** Fail to start tethering offload. */ + @RequiresApi(30) const val TETHER_HARDWARE_OFFLOAD_FAILED = 2 // tethering types supported by enableTetheringInternal: https://android.googlesource.com/platform/frameworks/base/+/5d36f01/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java#549