Refine code style
This commit is contained in:
@@ -7,7 +7,6 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.pm.ResolveInfo
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.os.Build
|
||||
@@ -173,8 +172,9 @@ 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 @TargetApi(30) {
|
||||
private val instance by lazy {
|
||||
@SuppressLint("WrongConstant") // hidden services are not included in constants as of R preview 4
|
||||
val service = Services.context.getSystemService(TETHERING_SERVICE)
|
||||
service
|
||||
|
||||
@@ -108,41 +108,48 @@ data class SoftApConfigurationCompat(
|
||||
android.net.wifi.WifiConfiguration::class.java.getDeclaredField("apChannel")
|
||||
}
|
||||
|
||||
@delegate:TargetApi(30)
|
||||
@get:RequiresApi(30)
|
||||
private val getAllowedClientList by lazy @TargetApi(30) {
|
||||
private val getAllowedClientList by lazy {
|
||||
SoftApConfiguration::class.java.getDeclaredMethod("getAllowedClientList")
|
||||
}
|
||||
@delegate:TargetApi(30)
|
||||
@get:RequiresApi(30)
|
||||
private val getBand by lazy @TargetApi(30) { SoftApConfiguration::class.java.getDeclaredMethod("getBand") }
|
||||
private val getBand by lazy { SoftApConfiguration::class.java.getDeclaredMethod("getBand") }
|
||||
@delegate:TargetApi(30)
|
||||
@get:RequiresApi(30)
|
||||
private val getBlockedClientList by lazy @TargetApi(30) {
|
||||
private val getBlockedClientList by lazy {
|
||||
SoftApConfiguration::class.java.getDeclaredMethod("getBlockedClientList")
|
||||
}
|
||||
@delegate:TargetApi(30)
|
||||
@get:RequiresApi(30)
|
||||
private val getChannel by lazy @TargetApi(30) {
|
||||
SoftApConfiguration::class.java.getDeclaredMethod("getChannel")
|
||||
}
|
||||
private val getChannel by lazy { SoftApConfiguration::class.java.getDeclaredMethod("getChannel") }
|
||||
@delegate:TargetApi(30)
|
||||
@get:RequiresApi(30)
|
||||
private val getMaxNumberOfClients by lazy @TargetApi(30) {
|
||||
private val getMaxNumberOfClients by lazy {
|
||||
SoftApConfiguration::class.java.getDeclaredMethod("getMaxNumberOfClients")
|
||||
}
|
||||
@delegate:TargetApi(30)
|
||||
@get:RequiresApi(30)
|
||||
private val getShutdownTimeoutMillis by lazy @TargetApi(30) {
|
||||
private val getShutdownTimeoutMillis by lazy {
|
||||
SoftApConfiguration::class.java.getDeclaredMethod("getShutdownTimeoutMillis")
|
||||
}
|
||||
@delegate:TargetApi(30)
|
||||
@get:RequiresApi(30)
|
||||
private val isAutoShutdownEnabled by lazy @TargetApi(30) {
|
||||
private val isAutoShutdownEnabled by lazy {
|
||||
SoftApConfiguration::class.java.getDeclaredMethod("isAutoShutdownEnabled")
|
||||
}
|
||||
@delegate:TargetApi(30)
|
||||
@get:RequiresApi(30)
|
||||
private val isClientControlByUserEnabled by lazy @TargetApi(30) {
|
||||
private val isClientControlByUserEnabled by lazy {
|
||||
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 @TargetApi(30) { classBuilder.getConstructor(SoftApConfiguration::class.java) }
|
||||
private val newBuilder by lazy { classBuilder.getConstructor(SoftApConfiguration::class.java) }
|
||||
@get:RequiresApi(30)
|
||||
private val build by lazy { classBuilder.getDeclaredMethod("build") }
|
||||
@get:RequiresApi(30)
|
||||
@@ -159,10 +166,9 @@ 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 @TargetApi(30) {
|
||||
classBuilder.getDeclaredMethod("setBssid", MacAddress::class.java)
|
||||
}
|
||||
private val setBssid by lazy { classBuilder.getDeclaredMethod("setBssid", MacAddress::class.java) }
|
||||
@get:RequiresApi(30)
|
||||
private val setChannel by lazy {
|
||||
classBuilder.getDeclaredMethod("setChannel", Int::class.java, Int::class.java)
|
||||
|
||||
@@ -19,8 +19,9 @@ 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 @TargetApi(31) { UnblockCentral.getApInstanceIdentifier(clazz) }
|
||||
private val getApInstanceIdentifier by lazy { UnblockCentral.getApInstanceIdentifier(clazz) }
|
||||
@get:RequiresApi(31)
|
||||
private val getAutoShutdownTimeoutMillis by lazy { clazz.getDeclaredMethod("getAutoShutdownTimeoutMillis") }
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package be.mygod.vpnhotspot.net.wifi
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.MacAddress
|
||||
import android.net.wifi.SoftApConfiguration
|
||||
import android.net.wifi.WifiManager
|
||||
import android.os.Build
|
||||
@@ -43,8 +42,9 @@ 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 @TargetApi(30) {
|
||||
private val setSoftApConfiguration by lazy {
|
||||
WifiManager::class.java.getDeclaredMethod("setSoftApConfiguration", SoftApConfiguration::class.java)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@ 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 @TargetApi(31) { UnblockCentral.getApInstanceIdentifier(clazz) }
|
||||
private val getApInstanceIdentifier by lazy { UnblockCentral.getApInstanceIdentifier(clazz) }
|
||||
}
|
||||
|
||||
val macAddress get() = getMacAddress(inner) as MacAddress
|
||||
|
||||
@@ -95,10 +95,10 @@ object WifiP2pManagerHelper {
|
||||
return result.future.await()
|
||||
}
|
||||
|
||||
private val interfacePersistentGroupInfoListener by lazy @SuppressLint("PrivateApi") {
|
||||
private val interfacePersistentGroupInfoListener by lazy {
|
||||
Class.forName("android.net.wifi.p2p.WifiP2pManager\$PersistentGroupInfoListener")
|
||||
}
|
||||
private val getGroupList by lazy @SuppressLint("PrivateApi") {
|
||||
private val getGroupList by lazy {
|
||||
Class.forName("android.net.wifi.p2p.WifiP2pGroupList").getDeclaredMethod("getGroupList")
|
||||
}
|
||||
private val requestPersistentGroupInfo by lazy {
|
||||
@@ -111,7 +111,6 @@ object WifiP2pManagerHelper {
|
||||
* Requires one of NETWORK_SETTING, NETWORK_STACK, or READ_WIFI_CREDENTIAL permission since API 30.
|
||||
*
|
||||
* @param c is the channel created at {@link #initialize}
|
||||
* @param listener for callback when persistent group info list is available. Can be null.
|
||||
*/
|
||||
suspend fun WifiP2pManager.requestPersistentGroupInfo(c: WifiP2pManager.Channel): Collection<WifiP2pGroup> {
|
||||
val result = CompletableDeferred<Collection<WifiP2pGroup>>()
|
||||
|
||||
Reference in New Issue
Block a user