Support driver country code display

This commit is contained in:
Mygod
2022-07-12 21:03:47 -04:00
parent bf856d77d5
commit f4e5e2f834
6 changed files with 20 additions and 0 deletions

View File

@@ -159,6 +159,7 @@ Greylisted/blacklisted APIs or internal constants: (some constants are hardcoded
* (prior to API 30) `Landroid/net/ConnectivityManager;->getLastTetherError(Ljava/lang/String;)I,max-target-r`
* (since API 30) `Landroid/net/ConnectivityModuleConnector;->IN_PROCESS_SUFFIX:Ljava/lang/String;`
* (since API 30) `Landroid/net/TetheringManager$TetheringEventCallback;->onTetherableInterfaceRegexpsChanged(Landroid/net/TetheringManager$TetheringInterfaceRegexps;)V,blocked`
* (since API 33) `Landroid/net/wifi/SoftApCapability;->getCountryCode()Ljava/lang/String;,blocked`
* (since API 31) `Landroid/net/wifi/SoftApConfiguration$Builder;->setUserConfiguration(Z)Landroid/net/wifi/SoftApConfiguration$Builder;,blocked`
* (since API 31) `Landroid/net/wifi/SoftApConfiguration;->BAND_TYPES:[I,blocked`
* (since API 31) `Landroid/net/wifi/SoftApInfo;->getApInstanceIdentifier()Ljava/lang/String;,blocked`

View File

@@ -257,6 +257,9 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
}.filterNotNull()
if (list.isNotEmpty()) result.append(parent.getText(R.string.tethering_manage_wifi_supported_channels)
.format(locale, list.joinToString("; ")))
if (Build.VERSION.SDK_INT >= 33) capability.countryCode?.let {
result.append(parent.getText(R.string.tethering_manage_wifi_country_code).format(locale, it))
}
}
result
} ?: numClients?.let { numClients ->

View File

@@ -3,6 +3,8 @@ package be.mygod.vpnhotspot.net.wifi
import android.os.Parcelable
import androidx.annotation.RequiresApi
import be.mygod.vpnhotspot.util.LongConstantLookup
import be.mygod.vpnhotspot.util.UnblockCentral
import timber.log.Timber
@JvmInline
@RequiresApi(30)
@@ -15,6 +17,8 @@ value class SoftApCapability(val inner: Parcelable) {
private val getSupportedChannelList by lazy {
clazz.getDeclaredMethod("getSupportedChannelList", Int::class.java)
}
@get:RequiresApi(33)
private val getCountryCode by lazy { UnblockCentral.getCountryCode(clazz) }
@RequiresApi(31)
const val SOFTAP_FEATURE_BAND_24G_SUPPORTED = 32L
@@ -38,4 +42,11 @@ value class SoftApCapability(val inner: Parcelable) {
return supportedFeatures
}
fun getSupportedChannelList(band: Int) = getSupportedChannelList(inner, band) as IntArray
@get:RequiresApi(33)
val countryCode: String? get() = try {
getCountryCode(inner) as String?
} catch (e: ReflectiveOperationException) {
Timber.w(e)
null
}
}

View File

@@ -21,6 +21,9 @@ object UnblockCentral {
*/
private val init by lazy { if (needInit) UnblockHelper(app.deviceStorage) }
@RequiresApi(33)
fun getCountryCode(clazz: Class<*>) = init.let { clazz.getDeclaredMethod("getCountryCode") }
@RequiresApi(31)
fun setUserConfiguration(clazz: Class<*>) = init.let {
clazz.getDeclaredMethod("setUserConfiguration", Boolean::class.java)

View File

@@ -72,6 +72,7 @@
<item quantity="other">已连接 %d 个设备</item>
</plurals>
<string name="tethering_manage_wifi_supported_channels">\n支持频道: %s</string>
<string name="tethering_manage_wifi_country_code">\n驱动国家代码%s</string>
<string name="tethering_manage_wifi_feature_ap_mac_randomization">随机接入点 MAC</string>
<string name="tethering_manage_wifi_feature_bridged_ap_concurrency">桥接 AP 并发</string>
<string name="tethering_manage_wifi_feature_sta_ap_concurrency">STA/AP 并发</string>

View File

@@ -86,6 +86,7 @@
<item quantity="other">%1d clients connected</item>
</plurals>
<string name="tethering_manage_wifi_supported_channels">\nSupported channels: %s</string>
<string name="tethering_manage_wifi_country_code">\nDriver country code: %s</string>
<string name="tethering_manage_wifi_feature_ap_mac_randomization">Randomized AP MAC</string>
<string name="tethering_manage_wifi_feature_bridged_ap_concurrency">Bridged AP concurrency</string>
<string name="tethering_manage_wifi_feature_sta_ap_concurrency">STA + AP concurrency</string>