Support WiGig tethering

As per: https://android-review.googlesource.com/c/platform/frameworks/base/+/1177323
This commit is contained in:
Mygod
2020-07-01 13:15:47 -04:00
parent a76145c8dc
commit 5e4cebc346
10 changed files with 60 additions and 2 deletions

View File

@@ -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:

View File

@@ -178,6 +178,18 @@
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
<service
android:name=".manage.TetheringTileService$WiGig"
android:directBootAware="true"
android:enabled="@bool/api_ge_30"
android:icon="@drawable/ic_image_flash_on"
android:label="@string/tethering_manage_wigig"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
tools:targetApi="30">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE" />
</intent-filter>
</service>
<!--suppress DeprecatedClassUsageInspection -->
<service
android:name=".manage.TetheringTileService$WifiLegacy"

View File

@@ -19,6 +19,7 @@ abstract class Manager {
const val VIEW_TYPE_BLUETOOTH = 4
const val VIEW_TYPE_ETHERNET = 8
const val VIEW_TYPE_NCM = 9
const val VIEW_TYPE_WIGIG = 10
const val VIEW_TYPE_WIFI_LEGACY = 5
const val VIEW_TYPE_LOCAL_ONLY_HOTSPOT = 6
const val VIEW_TYPE_REPEATER = 7
@@ -36,6 +37,7 @@ abstract class Manager {
VIEW_TYPE_BLUETOOTH,
VIEW_TYPE_ETHERNET,
VIEW_TYPE_NCM,
VIEW_TYPE_WIGIG,
VIEW_TYPE_WIFI_LEGACY -> {
TetherManager.ViewHolder(ListitemInterfaceBinding.inflate(inflater, parent, false))
}

View File

@@ -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")

View File

@@ -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)

View File

@@ -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")

View File

@@ -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<Pattern>
private lateinit var wifiRegexs: List<Pattern>
private var wigigRegexs = emptyList<Pattern>()
private var wifiP2pRegexs = emptyList<Pattern>()
private val wimaxRegexs: List<Pattern>
private lateinit var bluetoothRegexs: List<Pattern>
@@ -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

View File

@@ -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") }

View File

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M7,2v11h3v9l7,-12h-4l4,-8z"/>
</vector>

View File

@@ -65,6 +65,7 @@
<string name="tethering_manage_bluetooth">Bluetooth tethering</string>
<string name="tethering_manage_ethernet">Ethernet tethering</string>
<string name="tethering_manage_ncm">USB tethering (NCM)</string>
<string name="tethering_manage_wigig">WiGig tethering</string>
<string name="connected_state_incomplete">" (connecting)"</string>
<string name="connected_state_valid">" (reachable)"</string>