Merge branch 'v2.4' into q-beta

This commit is contained in:
Mygod
2019-05-10 15:14:56 +08:00
3 changed files with 54 additions and 20 deletions

View File

@@ -126,9 +126,6 @@ Undocumented API list:
* (since API 24) [`Landroid/net/ConnectivityManager$OnStartTetheringCallback;->onTetheringFailed()V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#122392)
* (since API 24) [`Landroid/net/ConnectivityManager$OnStartTetheringCallback;->onTetheringStarted()V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#122393)
* (since API 24) [`Landroid/net/ConnectivityManager;->getLastTetherError(Ljava/lang/String;)I,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#122588)
* [`Landroid/net/ConnectivityManager;->getTetherableBluetoothRegexs()[Ljava/lang/String;,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#122608)
* [`Landroid/net/ConnectivityManager;->getTetherableUsbRegexs()[Ljava/lang/String;,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#122610)
* [`Landroid/net/ConnectivityManager;->getTetherableWifiRegexs()[Ljava/lang/String;,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#122611)
* (since API 24) [`Landroid/net/ConnectivityManager;->startTethering(IZLandroid/net/ConnectivityManager$OnStartTetheringCallback;Landroid/os/Handler;)V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#122683)
* (since API 24) [`Landroid/net/ConnectivityManager;->stopTethering(I)V,whitelist`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#122685)
* (since API 23) [`Landroid/net/wifi/WifiConfiguration;->apBand:I,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#131003)
@@ -144,6 +141,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/+/7cb2ccf/appcompat/hiddenapi-flags.csv#134176)
* (prior to API Q) [`Ljava/net/InetAddress;->parseNumericAddress(Ljava/lang/String;)Ljava/net/InetAddress;,core-platform-api,greylist-max-p`](https://android.googlesource.com/platform/prebuilts/runtime/+/7cb2ccf/appcompat/hiddenapi-flags.csv#332821)
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:
* (since API 29) `android.net.wifi.p2p.WifiP2pConfig` needs to be parcelized in a very specific order.

View File

@@ -19,8 +19,8 @@ android {
minSdkVersion 21
targetSdkVersion 28
resConfigs "ru", "zh-rCN"
versionCode 202
versionName "2.4.2"
versionCode 203
versionName "2.4.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {

View File

@@ -1,25 +1,54 @@
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.R
import java.util.regex.Pattern
enum class TetherType(val icon: Int, val isWifi: Boolean = false) {
NONE(R.drawable.ic_device_wifi_tethering),
WIFI_P2P(R.drawable.ic_action_settings_input_antenna, true),
USB(R.drawable.ic_device_usb),
WIFI(R.drawable.ic_device_network_wifi, true),
BLUETOOTH(R.drawable.ic_device_bluetooth);
enum class TetherType {
NONE, WIFI_P2P, USB, WIFI, WIMAX, BLUETOOTH;
val icon get() = when (this) {
USB -> R.drawable.ic_device_usb
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 {
private fun getRegexs(type: String) =
(ConnectivityManager::class.java.getDeclaredMethod("getTetherable${type}Regexs")
.invoke(app.connectivity) as Array<String?>)
.filterNotNull()
.map { it.toPattern() }
private val usbRegexs = getRegexs("Usb")
private val wifiRegexs = getRegexs("Wifi")
private val bluetoothRegexs = getRegexs("Bluetooth")
private val usbRegexs: List<Pattern>
private val wifiRegexs: List<Pattern>
private val wimaxRegexs: List<Pattern>
private val bluetoothRegexs: List<Pattern>
/**
* Source: https://android.googlesource.com/platform/frameworks/base/+/61fa313/core/res/res/values/config.xml#328
*/
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
@@ -30,6 +59,7 @@ enum class TetherType(val icon: Int, val isWifi: Boolean = false) {
wifiRegexs.any { it.matcher(iface).matches() } -> WIFI
usbRegexs.any { it.matcher(iface).matches() } -> USB
bluetoothRegexs.any { it.matcher(iface).matches() } -> BLUETOOTH
wimaxRegexs.any { it.matcher(iface).matches() } -> WIMAX
else -> NONE
}
}