@@ -222,7 +222,6 @@ Greylisted/blacklisted APIs or internal constants: (some constants are hardcoded
|
||||
* `Landroid/net/TetheringManager;->EXTRA_ERRORED_TETHER:Ljava/lang/String;,sdk,system-api,test-api`
|
||||
* (since API 24) `Landroid/net/TetheringManager;->TETHERING_BLUETOOTH:I,sdk,system-api,test-api`
|
||||
* (since API 30) `Landroid/net/TetheringManager;->TETHERING_ETHERNET:I,sdk,system-api,test-api`
|
||||
* (since API 30) `Landroid/net/TetheringManager;->TETHERING_NCM:I,sdk,system-api,test-api`
|
||||
* (since API 24) `Landroid/net/TetheringManager;->TETHERING_USB:I,sdk,system-api,test-api`
|
||||
* (since API 24) `Landroid/net/TetheringManager;->TETHERING_WIFI:I,sdk,system-api,test-api`
|
||||
* `Landroid/net/TetheringManager;->TETHER_ERROR_*:I,sdk,system-api,test-api`
|
||||
|
||||
@@ -193,22 +193,6 @@
|
||||
android:name="android.service.quicksettings.TOGGLEABLE_TILE"
|
||||
android:value="true" />
|
||||
</service>
|
||||
<service
|
||||
android:name=".manage.TetheringTileService$Ncm"
|
||||
android:directBootAware="true"
|
||||
android:enabled="@bool/api_ge_30"
|
||||
android:exported="true"
|
||||
android:icon="@drawable/ic_action_settings_ethernet"
|
||||
android:label="@string/tethering_manage_ncm"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
|
||||
tools:targetApi="30">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||
</intent-filter>
|
||||
<meta-data
|
||||
android:name="android.service.quicksettings.TOGGLEABLE_TILE"
|
||||
android:value="true" />
|
||||
</service>
|
||||
<!--suppress DeprecatedClassUsageInspection -->
|
||||
<service
|
||||
android:name=".manage.TetheringTileService$WifiLegacy"
|
||||
|
||||
@@ -18,7 +18,6 @@ abstract class Manager {
|
||||
const val VIEW_TYPE_USB = 3
|
||||
const val VIEW_TYPE_BLUETOOTH = 4
|
||||
const val VIEW_TYPE_ETHERNET = 8
|
||||
const val VIEW_TYPE_NCM = 9
|
||||
const val VIEW_TYPE_WIFI_LEGACY = 5
|
||||
const val VIEW_TYPE_LOCAL_ONLY_HOTSPOT = 6
|
||||
const val VIEW_TYPE_REPEATER = 7
|
||||
@@ -35,7 +34,6 @@ abstract class Manager {
|
||||
VIEW_TYPE_USB,
|
||||
VIEW_TYPE_BLUETOOTH,
|
||||
VIEW_TYPE_ETHERNET,
|
||||
VIEW_TYPE_NCM,
|
||||
VIEW_TYPE_WIFI_LEGACY -> {
|
||||
TetherManager.ViewHolder(ListitemInterfaceBinding.inflate(inflater, parent, false))
|
||||
}
|
||||
|
||||
@@ -90,7 +90,8 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
||||
val data = Data()
|
||||
abstract val title: CharSequence
|
||||
abstract val tetherType: TetherType
|
||||
open val isStarted: Boolean? get() = parent.enabledTypes.contains(tetherType)
|
||||
open val isStarted: Boolean? get() = parent.enabledTypes.contains(tetherType) ||
|
||||
tetherType == TetherType.USB && parent.enabledTypes.contains(TetherType.NCM)
|
||||
protected open val text: CharSequence get() = baseError ?: ""
|
||||
|
||||
protected var baseError: String? = null
|
||||
@@ -126,7 +127,7 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
||||
}
|
||||
|
||||
fun updateErrorMessage(errored: List<String>, lastErrors: Map<String, Int>) {
|
||||
val interested = errored.filter { TetherType.ofInterface(it) == tetherType }
|
||||
val interested = errored.filter { TetherType.ofInterface(it).isA(tetherType) }
|
||||
baseError = if (interested.isEmpty()) null else interested.joinToString("\n") { iface ->
|
||||
"$iface: " + try {
|
||||
TetheringManager.tetherErrorLookup(if (Build.VERSION.SDK_INT < 30) @Suppress("DEPRECATION") {
|
||||
@@ -331,15 +332,6 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
|
||||
override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_ETHERNET, true, this)
|
||||
override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_ETHERNET, this::onException)
|
||||
}
|
||||
@RequiresApi(30)
|
||||
class Ncm(parent: TetheringFragment) : TetherManager(parent) {
|
||||
override val title get() = parent.getString(R.string.tethering_manage_ncm)
|
||||
override val tetherType get() = TetherType.NCM
|
||||
override val type get() = VIEW_TYPE_NCM
|
||||
|
||||
override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_NCM, true, this)
|
||||
override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_NCM, this::onException)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("Not usable since API 26, malfunctioning on API 25")
|
||||
|
||||
@@ -68,9 +68,7 @@ class TetheringFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClick
|
||||
)
|
||||
}
|
||||
@get:RequiresApi(30)
|
||||
private val tetherManagers30 by lazy @TargetApi(30) {
|
||||
listOf(TetherManager.Ethernet(this@TetheringFragment), TetherManager.Ncm(this@TetheringFragment))
|
||||
}
|
||||
private val ethernetManager by lazy @TargetApi(30) { TetherManager.Ethernet(this@TetheringFragment) }
|
||||
private val wifiManagerLegacy by lazy { TetherManager.WifiLegacy(this@TetheringFragment) }
|
||||
|
||||
var activeIfaces = emptyList<String>()
|
||||
@@ -119,8 +117,8 @@ class TetheringFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClick
|
||||
tetherManagers.forEach { it.updateErrorMessage(erroredIfaces, lastErrors) }
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
list.addAll(tetherManagers30)
|
||||
tetherManagers30.forEach { it.updateErrorMessage(erroredIfaces, lastErrors) }
|
||||
list.add(ethernetManager)
|
||||
ethernetManager.updateErrorMessage(erroredIfaces, lastErrors)
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < 26) {
|
||||
list.add(wifiManagerLegacy)
|
||||
|
||||
@@ -36,7 +36,7 @@ sealed class TetheringTileService : IpNeighbourMonitoringTileService(), Tetherin
|
||||
protected abstract val tetherType: TetherType
|
||||
protected open val icon get() = tetherType.icon
|
||||
private var tethered: List<String>? = null
|
||||
protected val interested get() = tethered?.filter { TetherType.ofInterface(it) == tetherType }
|
||||
protected val interested get() = tethered?.filter { TetherType.ofInterface(it).isA(tetherType) }
|
||||
protected var binder: TetheringService.Binder? = null
|
||||
|
||||
private val receiver = broadcastReceiver { _, intent ->
|
||||
@@ -228,14 +228,6 @@ sealed class TetheringTileService : IpNeighbourMonitoringTileService(), Tetherin
|
||||
override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_ETHERNET, true, this)
|
||||
override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_ETHERNET, this::onException)
|
||||
}
|
||||
@RequiresApi(30)
|
||||
class Ncm : TetheringTileService() {
|
||||
override val labelString get() = R.string.tethering_manage_ncm
|
||||
override val tetherType get() = TetherType.NCM
|
||||
|
||||
override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_NCM, true, this)
|
||||
override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_NCM, this::onException)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("Not usable since API 25")
|
||||
|
||||
@@ -28,6 +28,8 @@ enum class TetherType(@DrawableRes val icon: Int) {
|
||||
else -> false
|
||||
}
|
||||
|
||||
fun isA(other: TetherType) = this == other || other == USB && this == NCM
|
||||
|
||||
companion object : TetheringManager.TetheringEventCallback {
|
||||
private lateinit var usbRegexs: List<Pattern>
|
||||
private lateinit var wifiRegexs: List<Pattern>
|
||||
|
||||
@@ -151,13 +151,6 @@ object TetheringManager {
|
||||
*/
|
||||
@RequiresApi(24)
|
||||
const val TETHERING_BLUETOOTH = 2
|
||||
/**
|
||||
* Ncm local tethering type.
|
||||
*
|
||||
* @see startTethering
|
||||
*/
|
||||
@RequiresApi(30)
|
||||
const val TETHERING_NCM = 4
|
||||
/**
|
||||
* Ethernet tethering type.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user