From 5e4cebc3461b7ee79ecb5236019010005e28d6a3 Mon Sep 17 00:00:00 2001 From: Mygod Date: Wed, 1 Jul 2020 13:15:47 -0400 Subject: [PATCH] Support WiGig tethering As per: https://android-review.googlesource.com/c/platform/frameworks/base/+/1177323 --- README.md | 2 ++ mobile/src/main/AndroidManifest.xml | 12 ++++++++++++ .../main/java/be/mygod/vpnhotspot/manage/Manager.kt | 2 ++ .../java/be/mygod/vpnhotspot/manage/TetherManager.kt | 9 +++++++++ .../be/mygod/vpnhotspot/manage/TetheringFragment.kt | 4 +++- .../mygod/vpnhotspot/manage/TetheringTileService.kt | 8 ++++++++ .../main/java/be/mygod/vpnhotspot/net/TetherType.kt | 6 +++++- .../java/be/mygod/vpnhotspot/net/TetheringManager.kt | 8 ++++++++ mobile/src/main/res/drawable/ic_image_flash_on.xml | 10 ++++++++++ mobile/src/main/res/values/strings.xml | 1 + 10 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 mobile/src/main/res/drawable/ic_image_flash_on.xml diff --git a/README.md b/README.md index b37376cf..36e3710b 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ Greylisted/blacklisted APIs or internal constants: (some constants are hardcoded * [`Landroid/net/ConnectivityManager;->getLastTetherError(Ljava/lang/String;)I,greylist`](https://android.googlesource.com/platform/prebuilts/runtime/+/4601d91/appcompat/hiddenapi-flags.csv#144306) * (since API 30) [`Landroid/net/TetheringManager$TetheringEventCallback;->onTetherableInterfaceRegexpsChanged(Landroid/net/TetheringManager$TetheringInterfaceRegexps;)V,blacklist`](https://android.googlesource.com/platform/prebuilts/runtime/+/4601d91/appcompat/hiddenapi-flags.csv#148899) +* (since API 30) `Landroid/net/TetheringManager;->TETHERING_WIGIG:I` * (prior to API 30) [`Landroid/net/wifi/WifiConfiguration$KeyMgmt;->WPA_PSK_SHA256:I,blacklist`](https://android.googlesource.com/platform/prebuilts/runtime/+/4601d91/appcompat/hiddenapi-flags.csv#153936) * (since API 23, prior to API 30) [`Landroid/net/wifi/WifiConfiguration;->AP_BAND_2GHZ:I,greylist-max-o`](https://android.googlesource.com/platform/prebuilts/runtime/+/4601d91/appcompat/hiddenapi-flags.csv#154057) * (since API 23, prior to API 30) [`Landroid/net/wifi/WifiConfiguration;->AP_BAND_5GHZ:I,greylist-max-o`](https://android.googlesource.com/platform/prebuilts/runtime/+/4601d91/appcompat/hiddenapi-flags.csv#154058) @@ -262,6 +263,7 @@ Nonexported system resources: * (since API 30) `@com.android.networkstack.tethering:array/config_tether_usb_regexs` * (since API 30) `@com.android.networkstack.tethering:array/config_tether_wifi_p2p_regexs` * (since API 30) `@com.android.networkstack.tethering:array/config_tether_wifi_regexs` +* (since API 30) `@com.android.networkstack.tethering:array/config_tether_wigig_regexs` Other: diff --git a/mobile/src/main/AndroidManifest.xml b/mobile/src/main/AndroidManifest.xml index ba67eaf9..2b3ca094 100644 --- a/mobile/src/main/AndroidManifest.xml +++ b/mobile/src/main/AndroidManifest.xml @@ -178,6 +178,18 @@ + + + + + { TetherManager.ViewHolder(ListitemInterfaceBinding.inflate(inflater, parent, false)) } diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt index 4dd00682..8406ef22 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetherManager.kt @@ -184,6 +184,15 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(), override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_NCM, true, this) override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_NCM, this::onException) } + @RequiresApi(30) + class WiGig(parent: TetheringFragment) : TetherManager(parent) { + override val title get() = parent.getString(R.string.tethering_manage_wigig) + override val tetherType get() = TetherType.WIGIG + override val type get() = VIEW_TYPE_WIGIG + + override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_WIGIG, true, this) + override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_WIGIG, this::onException) + } @Suppress("DEPRECATION") @Deprecated("Not usable since API 26, malfunctioning on API 25") diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringFragment.kt index e8a96cc9..b35b707d 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringFragment.kt @@ -52,7 +52,9 @@ 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)) + listOf(TetherManager.Ethernet(this@TetheringFragment), + TetherManager.Ncm(this@TetheringFragment), + TetherManager.WiGig(this@TetheringFragment)) } private val wifiManagerLegacy by lazy @Suppress("Deprecation") { TetherManager.WifiLegacy(this@TetheringFragment) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringTileService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringTileService.kt index d2e2656c..2ced8548 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringTileService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/TetheringTileService.kt @@ -226,6 +226,14 @@ sealed class TetheringTileService : IpNeighbourMonitoringTileService(), Tetherin override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_NCM, true, this) override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_NCM, this::onException) } + @RequiresApi(30) + class WiGig : TetheringTileService() { + override val labelString get() = R.string.tethering_manage_wigig + override val tetherType get() = TetherType.WIGIG + + override fun start() = TetheringManager.startTethering(TetheringManager.TETHERING_WIGIG, true, this) + override fun stop() = TetheringManager.stopTethering(TetheringManager.TETHERING_WIGIG, this::onException) + } @Suppress("DEPRECATION") @Deprecated("Not usable since API 25") diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetherType.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetherType.kt index 05b6c1c5..0c64f6f6 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetherType.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetherType.kt @@ -20,16 +20,18 @@ enum class TetherType(@DrawableRes val icon: Int) { // if you have an issue with these Ethernet icon namings, blame Google NCM(R.drawable.ic_action_settings_ethernet), ETHERNET(R.drawable.ic_content_inbox), + WIGIG(R.drawable.ic_image_flash_on), ; val isWifi get() = when (this) { - WIFI_P2P, WIFI, WIMAX -> true + WIFI_P2P, WIFI, WIMAX, WIGIG -> true else -> false } companion object : TetheringManager.TetheringEventCallback { private lateinit var usbRegexs: List private lateinit var wifiRegexs: List + private var wigigRegexs = emptyList() private var wifiP2pRegexs = emptyList() private val wimaxRegexs: List private lateinit var bluetoothRegexs: List @@ -54,6 +56,7 @@ enum class TetherType(@DrawableRes val icon: Int) { TetheringManager.resolvedService.serviceInfo.applicationInfo) usbRegexs = tethering.getRegexs("config_tether_usb_regexs") wifiRegexs = tethering.getRegexs("config_tether_wifi_regexs") + wigigRegexs = tethering.getRegexs("config_tether_wigig_regexs") wifiP2pRegexs = tethering.getRegexs("config_tether_wifi_p2p_regexs") bluetoothRegexs = tethering.getRegexs("config_tether_bluetooth_regexs") ncmRegexs = tethering.getRegexs("config_tether_ncm_regexs") @@ -100,6 +103,7 @@ enum class TetherType(@DrawableRes val icon: Int) { ofInterfaceImpl(iface, p2pDev) } wifiRegexs.any { it.matcher(iface).matches() } -> WIFI + wigigRegexs.any { it.matcher(iface).matches() } -> WIGIG wifiP2pRegexs.any { it.matcher(iface).matches() } -> WIFI_P2P usbRegexs.any { it.matcher(iface).matches() } -> USB bluetoothRegexs.any { it.matcher(iface).matches() } -> BLUETOOTH diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt index 299ad7a5..5cf3e3d1 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt @@ -153,6 +153,14 @@ object TetheringManager { */ @RequiresApi(30) const val TETHERING_ETHERNET = 5 + /** + * WIGIG tethering type. Use a separate type to prevent + * conflicts with TETHERING_WIFI + * This type is only used internally by the tethering module + * @hide + */ + @RequiresApi(30) + const val TETHERING_WIGIG = 6 @get:RequiresApi(30) private val clazz by lazy { Class.forName("android.net.TetheringManager") } diff --git a/mobile/src/main/res/drawable/ic_image_flash_on.xml b/mobile/src/main/res/drawable/ic_image_flash_on.xml new file mode 100644 index 00000000..168d13a6 --- /dev/null +++ b/mobile/src/main/res/drawable/ic_image_flash_on.xml @@ -0,0 +1,10 @@ + + + diff --git a/mobile/src/main/res/values/strings.xml b/mobile/src/main/res/values/strings.xml index 630da154..2397388f 100644 --- a/mobile/src/main/res/values/strings.xml +++ b/mobile/src/main/res/values/strings.xml @@ -65,6 +65,7 @@ Bluetooth tethering Ethernet tethering USB tethering (NCM) + WiGig tethering " (connecting)" " (reachable)"