Drop support for old Android 12 betas
This commit is contained in:
@@ -8,7 +8,6 @@ import android.os.Build
|
||||
import android.os.Parcelable
|
||||
import android.util.SparseIntArray
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.os.BuildCompat
|
||||
import be.mygod.vpnhotspot.net.MacAddressCompat
|
||||
import be.mygod.vpnhotspot.net.MacAddressCompat.Companion.toCompat
|
||||
import be.mygod.vpnhotspot.net.monitor.TetherTimeoutMonitor
|
||||
@@ -64,7 +63,7 @@ data class SoftApConfigurationCompat(
|
||||
const val BAND_60GHZ = 8
|
||||
const val BAND_LEGACY = BAND_2GHZ or BAND_5GHZ
|
||||
val BAND_TYPES by lazy {
|
||||
if (BuildCompat.isAtLeastS()) try {
|
||||
if (Build.VERSION.SDK_INT >= 31) try {
|
||||
return@lazy UnblockCentral.SoftApConfiguration_BAND_TYPES
|
||||
} catch (e: ReflectiveOperationException) {
|
||||
Timber.w(e)
|
||||
@@ -314,25 +313,26 @@ data class SoftApConfigurationCompat(
|
||||
@RequiresApi(30)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun SoftApConfiguration.toCompat() = SoftApConfigurationCompat(
|
||||
ssid,
|
||||
bssid?.toCompat()?.addr,
|
||||
passphrase,
|
||||
isHiddenSsid,
|
||||
if (BuildCompat.isAtLeastS()) getChannels(this) as SparseIntArray else SparseIntArray(1).also {
|
||||
it.append(getBand(this) as Int, getChannel(this) as Int)
|
||||
},
|
||||
securityType,
|
||||
getMaxNumberOfClients(this) as Int,
|
||||
isAutoShutdownEnabled(this) as Boolean,
|
||||
getShutdownTimeoutMillis(this) as Long,
|
||||
isClientControlByUserEnabled(this) as Boolean,
|
||||
getBlockedClientList(this) as List<MacAddress>,
|
||||
getAllowedClientList(this) as List<MacAddress>,
|
||||
if (BuildCompat.isAtLeastS()) getMacRandomizationSetting(this) as Int else RANDOMIZATION_PERSISTENT,
|
||||
!BuildCompat.isAtLeastS() || isBridgedModeOpportunisticShutdownEnabled(this) as Boolean,
|
||||
!BuildCompat.isAtLeastS() || isIeee80211axEnabled(this) as Boolean,
|
||||
!BuildCompat.isAtLeastS() || isUserConfiguration(this) as Boolean,
|
||||
this)
|
||||
ssid,
|
||||
bssid?.toCompat()?.addr,
|
||||
passphrase,
|
||||
isHiddenSsid,
|
||||
if (Build.VERSION.SDK_INT >= 31) getChannels(this) as SparseIntArray else SparseIntArray(1).also {
|
||||
it.append(getBand(this) as Int, getChannel(this) as Int)
|
||||
},
|
||||
securityType,
|
||||
getMaxNumberOfClients(this) as Int,
|
||||
isAutoShutdownEnabled(this) as Boolean,
|
||||
getShutdownTimeoutMillis(this) as Long,
|
||||
isClientControlByUserEnabled(this) as Boolean,
|
||||
getBlockedClientList(this) as List<MacAddress>,
|
||||
getAllowedClientList(this) as List<MacAddress>,
|
||||
if (Build.VERSION.SDK_INT >= 31) getMacRandomizationSetting(this) as Int else RANDOMIZATION_PERSISTENT,
|
||||
Build.VERSION.SDK_INT < 31 || isBridgedModeOpportunisticShutdownEnabled(this) as Boolean,
|
||||
Build.VERSION.SDK_INT < 31 || isIeee80211axEnabled(this) as Boolean,
|
||||
Build.VERSION.SDK_INT < 31 || isUserConfiguration(this) as Boolean,
|
||||
this,
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@@ -438,7 +438,7 @@ data class SoftApConfigurationCompat(
|
||||
setSsid(builder, ssid)
|
||||
setPassphrase(builder, if (securityType == SoftApConfiguration.SECURITY_TYPE_OPEN) null else passphrase,
|
||||
securityType)
|
||||
if (BuildCompat.isAtLeastS()) setChannels(builder, channels) else {
|
||||
if (Build.VERSION.SDK_INT >= 31) setChannels(builder, channels) else {
|
||||
val (band, channel) = requireSingleBand()
|
||||
if (channel == 0) setBand(builder, band) else setChannel(builder, channel, band)
|
||||
}
|
||||
@@ -450,7 +450,7 @@ data class SoftApConfigurationCompat(
|
||||
setHiddenSsid(builder, isHiddenSsid)
|
||||
setAllowedClientList(builder, allowedClientList)
|
||||
setBlockedClientList(builder, blockedClientList)
|
||||
if (BuildCompat.isAtLeastS()) {
|
||||
if (Build.VERSION.SDK_INT >= 31) {
|
||||
setMacRandomizationSetting(builder, macRandomizationSetting)
|
||||
setBridgedModeOpportunisticShutdownEnabled(builder, isBridgedModeOpportunisticShutdownEnabled)
|
||||
setIeee80211axEnabled(builder, isIeee80211axEnabled)
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.os.BuildCompat
|
||||
import androidx.core.view.isGone
|
||||
import be.mygod.librootkotlinx.toByteArray
|
||||
import be.mygod.librootkotlinx.toParcelable
|
||||
@@ -117,7 +116,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
||||
val channel = (spinner.selectedItem as ChannelOption?)?.channel
|
||||
if (channel != null && channel >= 0) channels.append(band, channel)
|
||||
}
|
||||
if (!arg.p2pMode && BuildCompat.isAtLeastS() && dialogView.bridgedMode.isChecked) {
|
||||
if (!arg.p2pMode && Build.VERSION.SDK_INT >= 31 && dialogView.bridgedMode.isChecked) {
|
||||
this.channels = channels
|
||||
} else optimizeChannels(channels)
|
||||
}
|
||||
@@ -179,7 +178,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
||||
dialogView.band5G.configure(currentChannels5G)
|
||||
if (Build.VERSION.SDK_INT >= 30 && !arg.p2pMode) dialogView.band6G.configure(channels6G)
|
||||
else dialogView.bandWrapper6G.isGone = true
|
||||
if (BuildCompat.isAtLeastS() && !arg.p2pMode) dialogView.band60G.configure(channels60G) else {
|
||||
if (Build.VERSION.SDK_INT >= 31 && !arg.p2pMode) dialogView.band60G.configure(channels60G) else {
|
||||
dialogView.bandWrapper60G.isGone = true
|
||||
dialogView.bridgedMode.isGone = true
|
||||
dialogView.bridgedModeOpportunisticShutdown.isGone = true
|
||||
@@ -193,8 +192,8 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
||||
dialogView.bssid.addTextChangedListener(this@WifiApDialogFragment)
|
||||
if (arg.p2pMode) dialogView.hiddenSsid.isGone = true
|
||||
if (arg.p2pMode && Build.VERSION.SDK_INT >= 29) dialogView.macRandomization.isEnabled = false
|
||||
else if (arg.p2pMode || !BuildCompat.isAtLeastS()) dialogView.macRandomization.isGone = true
|
||||
if (arg.p2pMode || !BuildCompat.isAtLeastS()) {
|
||||
else if (arg.p2pMode || Build.VERSION.SDK_INT < 31) dialogView.macRandomization.isGone = true
|
||||
if (arg.p2pMode || Build.VERSION.SDK_INT < 31) {
|
||||
dialogView.ieee80211ax.isGone = true
|
||||
dialogView.userConfig.isGone = true
|
||||
}
|
||||
@@ -302,7 +301,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
||||
else -> option5G is ChannelOption.Disabled
|
||||
}
|
||||
}
|
||||
Build.VERSION.SDK_INT == 30 && !BuildCompat.isAtLeastS() -> {
|
||||
Build.VERSION.SDK_INT == 30 -> {
|
||||
var expected = 1
|
||||
var set = 0
|
||||
for (s in arrayOf(dialogView.band2G, dialogView.band5G, dialogView.band6G)) when (s.selectedItem) {
|
||||
|
||||
@@ -287,7 +287,7 @@ object WifiApManager {
|
||||
if (noArgs != 1) Timber.w("Unexpected args for $name: ${args?.contentToString()}")
|
||||
val arg = args!![0]
|
||||
if (arg is List<*>) {
|
||||
if (!BuildCompat.isAtLeastS()) Timber.w(Exception("Unexpected onInfoChanged API 31+"))
|
||||
if (Build.VERSION.SDK_INT < 31) Timber.w(Exception("Unexpected onInfoChanged API 31+"))
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
callback.onInfoChanged(arg as List<Parcelable>)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user