Warn when offload is verified to be started
This commit is contained in:
@@ -1,13 +1,17 @@
|
|||||||
package be.mygod.vpnhotspot
|
package be.mygod.vpnhotspot
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.net.Routing
|
import be.mygod.vpnhotspot.net.Routing
|
||||||
import be.mygod.vpnhotspot.net.TetherType
|
import be.mygod.vpnhotspot.net.TetherType
|
||||||
import be.mygod.vpnhotspot.net.TetheringManager
|
import be.mygod.vpnhotspot.net.TetheringManager
|
||||||
import be.mygod.vpnhotspot.net.monitor.IpNeighbourMonitor
|
import be.mygod.vpnhotspot.net.monitor.IpNeighbourMonitor
|
||||||
import be.mygod.vpnhotspot.util.Event0
|
import be.mygod.vpnhotspot.util.Event0
|
||||||
|
import be.mygod.vpnhotspot.widget.SmartSnackbar
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
import timber.log.Timber
|
||||||
|
import java.lang.IllegalStateException
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
class TetheringService : IpNeighbourMonitoringService(), TetheringManager.TetheringEventCallback, CoroutineScope {
|
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() {
|
private fun onDownstreamsChangedLocked() {
|
||||||
if (downstreams.isEmpty()) {
|
if (downstreams.isEmpty()) {
|
||||||
unregisterReceiver()
|
unregisterReceiver()
|
||||||
|
|||||||
@@ -86,10 +86,13 @@ object TetheringManager {
|
|||||||
const val EXTRA_ERRORED_TETHER = "erroredArray"
|
const val EXTRA_ERRORED_TETHER = "erroredArray"
|
||||||
|
|
||||||
/** Tethering offload status is stopped. */
|
/** Tethering offload status is stopped. */
|
||||||
|
@RequiresApi(30)
|
||||||
const val TETHER_HARDWARE_OFFLOAD_STOPPED = 0
|
const val TETHER_HARDWARE_OFFLOAD_STOPPED = 0
|
||||||
/** Tethering offload status is started. */
|
/** Tethering offload status is started. */
|
||||||
|
@RequiresApi(30)
|
||||||
const val TETHER_HARDWARE_OFFLOAD_STARTED = 1
|
const val TETHER_HARDWARE_OFFLOAD_STARTED = 1
|
||||||
/** Fail to start tethering offload. */
|
/** Fail to start tethering offload. */
|
||||||
|
@RequiresApi(30)
|
||||||
const val TETHER_HARDWARE_OFFLOAD_FAILED = 2
|
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
|
// tethering types supported by enableTetheringInternal: https://android.googlesource.com/platform/frameworks/base/+/5d36f01/packages/Tethering/src/com/android/networkstack/tethering/Tethering.java#549
|
||||||
|
|||||||
Reference in New Issue
Block a user