Add shortcut for tether offload

Fix #41.
This commit is contained in:
Mygod
2019-07-11 11:09:24 +08:00
parent 07ce4f4e25
commit 9a69c4006e
8 changed files with 66 additions and 14 deletions

View File

@@ -3,14 +3,13 @@ package be.mygod.vpnhotspot.manage
import android.content.Context
import android.content.Intent
import android.os.Build
import android.provider.Settings
import android.view.View
import androidx.core.os.bundleOf
import androidx.databinding.BaseObservable
import androidx.recyclerview.widget.RecyclerView
import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.DebugHelper
import be.mygod.vpnhotspot.databinding.ListitemManageBinding
import be.mygod.vpnhotspot.net.TetherOffloadManager
object ManageBar : Manager() {
private const val TAG = "ManageBar"
@@ -19,16 +18,7 @@ object ManageBar : Manager() {
private const val SETTINGS_2 = "com.android.settings.TetherSettings"
object Data : BaseObservable() {
/**
* It's hard to change tethering rules with Tethering hardware acceleration enabled for now.
*
* See also:
* android.provider.Settings.Global.TETHER_OFFLOAD_DISABLED
* https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r1/services/core/java/com/android/server/connectivity/tethering/OffloadHardwareInterface.java#45
* https://android.googlesource.com/platform/hardware/qcom/data/ipacfg-mgr/+/master/msm8998/ipacm/src/IPACM_OffloadManager.cpp
*/
val offloadEnabled get() = Build.VERSION.SDK_INT >= 27 && Settings.Global.getInt(app.contentResolver,
"tether_offload_disabled", 0) == 0
val offloadEnabled get() = Build.VERSION.SDK_INT >= 27 && TetherOffloadManager.enabled
}
class ViewHolder(binding: ListitemManageBinding) : RecyclerView.ViewHolder(binding.root), View.OnClickListener {
init {