diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt index 72127da6..80287a5a 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt @@ -50,8 +50,7 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene var persistentSupported = false - @delegate:TargetApi(29) - private val hasP2pValidateName by lazy { + private val hasP2pValidateName by lazy @TargetApi(29) { val array = Build.VERSION.SECURITY_PATCH.split('-', limit = 3) val y = array.getOrNull(0)?.toIntOrNull() val m = array.getOrNull(1)?.toIntOrNull() 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 610ca7c3..c5f0a250 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetheringManager.kt @@ -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 diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt index fe83a470..b6ff123e 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApConfigurationCompat.kt @@ -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) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApInfo.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApInfo.kt index 413260b9..ccec77cf 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApInfo.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/SoftApInfo.kt @@ -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") } diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApManager.kt index 1e3fb1df..f45f537c 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiApManager.kt @@ -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) } diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiClient.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiClient.kt index c14de2b4..57edc1a3 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiClient.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiClient.kt @@ -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 diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt b/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt index 0e6bc5c3..7e6e3ab9 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt @@ -159,8 +159,7 @@ fun NetworkInterface.formatAddresses(macOnly: Boolean = false) = SpannableString } }.trimEnd() -@delegate:SuppressLint("SoonBlockedPrivateApi") -private val parseNumericAddress by lazy { +private val parseNumericAddress by lazy @SuppressLint("SoonBlockedPrivateApi") { InetAddress::class.java.getDeclaredMethod("parseNumericAddress", String::class.java).apply { isAccessible = true } @@ -201,9 +200,8 @@ fun Resources.findIdentifier(name: String, defType: String, defPackage: String, if (alternativePackage != null && it == 0) getIdentifier(name, defType, alternativePackage) else it } -@delegate:TargetApi(26) @get:RequiresApi(26) -private val newLookup by lazy { +private val newLookup by lazy @TargetApi(26) { MethodHandles.Lookup::class.java.getDeclaredConstructor(Class::class.java, Int::class.java).apply { isAccessible = true }