This commit is contained in:
Mygod
2021-05-27 13:59:17 -04:00
parent 2e5e1c1f6e
commit d2f8de24b4
7 changed files with 21 additions and 34 deletions

View File

@@ -172,9 +172,8 @@ object TetheringManager {
@get:RequiresApi(30)
private val clazz by lazy { Class.forName("android.net.TetheringManager") }
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val instance by lazy {
private val instance by lazy @TargetApi(30) {
@SuppressLint("WrongConstant") // hidden services are not included in constants as of R preview 4
val service = Services.context.getSystemService(TETHERING_SERVICE)
service

View File

@@ -108,48 +108,41 @@ data class SoftApConfigurationCompat(
android.net.wifi.WifiConfiguration::class.java.getDeclaredField("apChannel")
}
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val getAllowedClientList by lazy {
private val getAllowedClientList by lazy @TargetApi(30) {
SoftApConfiguration::class.java.getDeclaredMethod("getAllowedClientList")
}
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val getBand by lazy { SoftApConfiguration::class.java.getDeclaredMethod("getBand") }
@delegate:TargetApi(30)
private val getBand by lazy @TargetApi(30) { SoftApConfiguration::class.java.getDeclaredMethod("getBand") }
@get:RequiresApi(30)
private val getBlockedClientList by lazy {
private val getBlockedClientList by lazy @TargetApi(30) {
SoftApConfiguration::class.java.getDeclaredMethod("getBlockedClientList")
}
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val getChannel by lazy { SoftApConfiguration::class.java.getDeclaredMethod("getChannel") }
@delegate:TargetApi(30)
private val getChannel by lazy @TargetApi(30) {
SoftApConfiguration::class.java.getDeclaredMethod("getChannel")
}
@get:RequiresApi(30)
private val getMaxNumberOfClients by lazy {
private val getMaxNumberOfClients by lazy @TargetApi(30) {
SoftApConfiguration::class.java.getDeclaredMethod("getMaxNumberOfClients")
}
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val getShutdownTimeoutMillis by lazy {
private val getShutdownTimeoutMillis by lazy @TargetApi(30) {
SoftApConfiguration::class.java.getDeclaredMethod("getShutdownTimeoutMillis")
}
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val isAutoShutdownEnabled by lazy {
private val isAutoShutdownEnabled by lazy @TargetApi(30) {
SoftApConfiguration::class.java.getDeclaredMethod("isAutoShutdownEnabled")
}
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val isClientControlByUserEnabled by lazy {
private val isClientControlByUserEnabled by lazy @TargetApi(30) {
SoftApConfiguration::class.java.getDeclaredMethod("isClientControlByUserEnabled")
}
@get:RequiresApi(30)
private val classBuilder by lazy { Class.forName("android.net.wifi.SoftApConfiguration\$Builder") }
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val newBuilder by lazy { classBuilder.getConstructor(SoftApConfiguration::class.java) }
private val newBuilder by lazy @TargetApi(30) { classBuilder.getConstructor(SoftApConfiguration::class.java) }
@get:RequiresApi(30)
private val build by lazy { classBuilder.getDeclaredMethod("build") }
@get:RequiresApi(30)
@@ -166,9 +159,10 @@ data class SoftApConfigurationCompat(
private val setBlockedClientList by lazy {
classBuilder.getDeclaredMethod("setBlockedClientList", java.util.List::class.java)
}
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val setBssid by lazy { classBuilder.getDeclaredMethod("setBssid", MacAddress::class.java) }
private val setBssid by lazy @TargetApi(30) {
classBuilder.getDeclaredMethod("setBssid", MacAddress::class.java)
}
@get:RequiresApi(30)
private val setChannel by lazy {
classBuilder.getDeclaredMethod("setChannel", Int::class.java, Int::class.java)

View File

@@ -19,9 +19,8 @@ value class SoftApInfo(val inner: Parcelable) {
private val getBssid by lazy { clazz.getDeclaredMethod("getBssid") }
@get:RequiresApi(31)
private val getWifiStandard by lazy { clazz.getDeclaredMethod("getWifiStandard") }
@delegate:TargetApi(31)
@get:RequiresApi(31)
private val getApInstanceIdentifier by lazy { UnblockCentral.getApInstanceIdentifier(clazz) }
private val getApInstanceIdentifier by lazy @TargetApi(31) { UnblockCentral.getApInstanceIdentifier(clazz) }
@get:RequiresApi(31)
private val getAutoShutdownTimeoutMillis by lazy { clazz.getDeclaredMethod("getAutoShutdownTimeoutMillis") }

View File

@@ -42,9 +42,8 @@ object WifiApManager {
}
@get:RequiresApi(30)
private val getSoftApConfiguration by lazy { WifiManager::class.java.getDeclaredMethod("getSoftApConfiguration") }
@delegate:TargetApi(30)
@get:RequiresApi(30)
private val setSoftApConfiguration by lazy {
private val setSoftApConfiguration by lazy @TargetApi(30) {
WifiManager::class.java.getDeclaredMethod("setSoftApConfiguration", SoftApConfiguration::class.java)
}

View File

@@ -13,9 +13,8 @@ value class WifiClient(val inner: Parcelable) {
companion object {
private val clazz by lazy { Class.forName("android.net.wifi.WifiClient") }
private val getMacAddress by lazy { clazz.getDeclaredMethod("getMacAddress") }
@delegate:TargetApi(31)
@get:RequiresApi(31)
private val getApInstanceIdentifier by lazy { UnblockCentral.getApInstanceIdentifier(clazz) }
private val getApInstanceIdentifier by lazy @TargetApi(31) { UnblockCentral.getApInstanceIdentifier(clazz) }
}
val macAddress get() = getMacAddress(inner) as MacAddress