Revert "Prefer private API over private system configurations, deprecate WiMAX support"
This reverts commit 7f41850a61.
It turns out this fix causes crash on Android 7.x.
This commit is contained in:
10
README.md
10
README.md
@@ -114,9 +114,6 @@ Undocumented API list:
|
|||||||
* (since API 24) [`Landroid/net/ConnectivityManager$OnStartTetheringCallback;->onTetheringFailed()V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112696)
|
* (since API 24) [`Landroid/net/ConnectivityManager$OnStartTetheringCallback;->onTetheringFailed()V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112696)
|
||||||
* (since API 24) [`Landroid/net/ConnectivityManager$OnStartTetheringCallback;->onTetheringStarted()V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112697)
|
* (since API 24) [`Landroid/net/ConnectivityManager$OnStartTetheringCallback;->onTetheringStarted()V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112697)
|
||||||
* (since API 24) [`Landroid/net/ConnectivityManager;->getLastTetherError(Ljava/lang/String;)I,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112882)
|
* (since API 24) [`Landroid/net/ConnectivityManager;->getLastTetherError(Ljava/lang/String;)I,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112882)
|
||||||
* [`Landroid/net/ConnectivityManager;->getTetherableBluetoothRegexs()[Ljava/lang/String;,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112901)
|
|
||||||
* [`Landroid/net/ConnectivityManager;->getTetherableUsbRegexs()[Ljava/lang/String;,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112903)
|
|
||||||
* [`Landroid/net/ConnectivityManager;->getTetherableWifiRegexs()[Ljava/lang/String;,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112904)
|
|
||||||
* (since API 24) [`Landroid/net/ConnectivityManager;->startTethering(IZLandroid/net/ConnectivityManager$OnStartTetheringCallback;Landroid/os/Handler;)V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112972)
|
* (since API 24) [`Landroid/net/ConnectivityManager;->startTethering(IZLandroid/net/ConnectivityManager$OnStartTetheringCallback;Landroid/os/Handler;)V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112972)
|
||||||
* (since API 24) [`Landroid/net/ConnectivityManager;->stopTethering(I)V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112974)
|
* (since API 24) [`Landroid/net/ConnectivityManager;->stopTethering(I)V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#112974)
|
||||||
* (since API 23) [`Landroid/net/wifi/WifiConfiguration;->apBand:I,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#120723)
|
* (since API 23) [`Landroid/net/wifi/WifiConfiguration;->apBand:I,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#120723)
|
||||||
@@ -132,6 +129,13 @@ Undocumented API list:
|
|||||||
* [`Landroid/net/wifi/p2p/WifiP2pManager;->startWps(Landroid/net/wifi/p2p/WifiP2pManager$Channel;Landroid/net/wifi/WpsInfo;Landroid/net/wifi/p2p/WifiP2pManager$ActionListener;)V,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#123459)
|
* [`Landroid/net/wifi/p2p/WifiP2pManager;->startWps(Landroid/net/wifi/p2p/WifiP2pManager$Channel;Landroid/net/wifi/WpsInfo;Landroid/net/wifi/p2p/WifiP2pManager$ActionListener;)V,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#123459)
|
||||||
* [`Ljava/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress;,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#299587)
|
* [`Ljava/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress;,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#299587)
|
||||||
|
|
||||||
|
Undocumented system configurations:
|
||||||
|
|
||||||
|
* `@android:array/config_tether_usb_regexs`
|
||||||
|
* `@android:array/config_tether_wifi_regexs`
|
||||||
|
* `@android:array/config_tether_wimax_regexs`
|
||||||
|
* `@android:array/config_tether_bluetooth_regexs`
|
||||||
|
|
||||||
Other:
|
Other:
|
||||||
|
|
||||||
* (since API 27) [`Landroid/provider/Settings$Global;->TETHER_OFFLOAD_DISABLED:Ljava/lang/String;,greylist-max-o`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#144760) is assumed to be `"tether_offload_disabled"`.
|
* (since API 27) [`Landroid/provider/Settings$Global;->TETHER_OFFLOAD_DISABLED:Ljava/lang/String;,greylist-max-o`](https://android.googlesource.com/platform/prebuilts/runtime/+/aa21a6e/appcompat/hiddenapi-flags.csv#144760) is assumed to be `"tether_offload_disabled"`.
|
||||||
|
|||||||
@@ -1,25 +1,54 @@
|
|||||||
package be.mygod.vpnhotspot.net
|
package be.mygod.vpnhotspot.net
|
||||||
|
|
||||||
import android.net.ConnectivityManager
|
import android.content.res.Resources
|
||||||
import be.mygod.vpnhotspot.App.Companion.app
|
import be.mygod.vpnhotspot.App.Companion.app
|
||||||
import be.mygod.vpnhotspot.R
|
import be.mygod.vpnhotspot.R
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
enum class TetherType(val icon: Int, val isWifi: Boolean = false) {
|
enum class TetherType {
|
||||||
NONE(R.drawable.ic_device_wifi_tethering),
|
NONE, WIFI_P2P, USB, WIFI, WIMAX, BLUETOOTH;
|
||||||
WIFI_P2P(R.drawable.ic_action_settings_input_antenna, true),
|
|
||||||
USB(R.drawable.ic_device_usb),
|
val icon get() = when (this) {
|
||||||
WIFI(R.drawable.ic_device_network_wifi, true),
|
USB -> R.drawable.ic_device_usb
|
||||||
BLUETOOTH(R.drawable.ic_device_bluetooth);
|
WIFI_P2P -> R.drawable.ic_action_settings_input_antenna
|
||||||
|
WIFI, WIMAX -> R.drawable.ic_device_network_wifi
|
||||||
|
BLUETOOTH -> R.drawable.ic_device_bluetooth
|
||||||
|
else -> R.drawable.ic_device_wifi_tethering
|
||||||
|
}
|
||||||
|
val isWifi get() = when (this) {
|
||||||
|
WIFI_P2P, WIFI, WIMAX -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private fun getRegexs(type: String) =
|
private val usbRegexs: List<Pattern>
|
||||||
(ConnectivityManager::class.java.getDeclaredMethod("getTetherable${type}Regexs")
|
private val wifiRegexs: List<Pattern>
|
||||||
.invoke(app.connectivity) as Array<String?>)
|
private val wimaxRegexs: List<Pattern>
|
||||||
.filterNotNull()
|
private val bluetoothRegexs: List<Pattern>
|
||||||
.map { it.toPattern() }
|
|
||||||
private val usbRegexs = getRegexs("Usb")
|
/**
|
||||||
private val wifiRegexs = getRegexs("Wifi")
|
* Source: https://android.googlesource.com/platform/frameworks/base/+/61fa313/core/res/res/values/config.xml#328
|
||||||
private val bluetoothRegexs = getRegexs("Bluetooth")
|
*/
|
||||||
|
init {
|
||||||
|
val appRes = app.resources
|
||||||
|
val sysRes = Resources.getSystem()
|
||||||
|
usbRegexs = appRes.getStringArray(sysRes
|
||||||
|
.getIdentifier("config_tether_usb_regexs", "array", "android"))
|
||||||
|
.filterNotNull()
|
||||||
|
.map { it.toPattern() }
|
||||||
|
wifiRegexs = appRes.getStringArray(sysRes
|
||||||
|
.getIdentifier("config_tether_wifi_regexs", "array", "android"))
|
||||||
|
.filterNotNull()
|
||||||
|
.map { it.toPattern() }
|
||||||
|
wimaxRegexs = appRes.getStringArray(sysRes
|
||||||
|
.getIdentifier("config_tether_wimax_regexs", "array", "android"))
|
||||||
|
.filterNotNull()
|
||||||
|
.map { it.toPattern() }
|
||||||
|
bluetoothRegexs = appRes.getStringArray(sysRes
|
||||||
|
.getIdentifier("config_tether_bluetooth_regexs", "array", "android"))
|
||||||
|
.filterNotNull()
|
||||||
|
.map { it.toPattern() }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based on: https://android.googlesource.com/platform/frameworks/base/+/0e3d092/services/core/java/com/android/server/connectivity/Tethering.java#311
|
* Based on: https://android.googlesource.com/platform/frameworks/base/+/0e3d092/services/core/java/com/android/server/connectivity/Tethering.java#311
|
||||||
@@ -30,6 +59,7 @@ enum class TetherType(val icon: Int, val isWifi: Boolean = false) {
|
|||||||
wifiRegexs.any { it.matcher(iface).matches() } -> WIFI
|
wifiRegexs.any { it.matcher(iface).matches() } -> WIFI
|
||||||
usbRegexs.any { it.matcher(iface).matches() } -> USB
|
usbRegexs.any { it.matcher(iface).matches() } -> USB
|
||||||
bluetoothRegexs.any { it.matcher(iface).matches() } -> BLUETOOTH
|
bluetoothRegexs.any { it.matcher(iface).matches() } -> BLUETOOTH
|
||||||
|
wimaxRegexs.any { it.matcher(iface).matches() } -> WIMAX
|
||||||
else -> NONE
|
else -> NONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user