Workaround for using inline class with Parcelize
This commit is contained in:
@@ -10,8 +10,7 @@ import java.nio.ByteOrder
|
||||
/**
|
||||
* Compat support class for [MacAddress].
|
||||
*/
|
||||
@Parcelize
|
||||
inline class MacAddressCompat(val addr: Long) : Parcelable {
|
||||
inline class MacAddressCompat(val addr: Long) {
|
||||
companion object {
|
||||
private const val ETHER_ADDR_LEN = 6
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,8 @@ data class SoftApConfigurationCompat(
|
||||
var band: Int,
|
||||
@RequiresApi(23)
|
||||
var channel: Int,
|
||||
var bssid: MacAddressCompat?,
|
||||
@Deprecated("Workaround for using inline class with Parcelize, use bssid")
|
||||
var bssidAddr: Long?,
|
||||
var maxNumberOfClients: Int,
|
||||
@RequiresApi(28)
|
||||
var shutdownTimeoutMillis: Long,
|
||||
@@ -184,7 +185,7 @@ data class SoftApConfigurationCompat(
|
||||
preSharedKey,
|
||||
if (Build.VERSION.SDK_INT >= 23) apBand.getInt(this) else BAND_ANY, // TODO
|
||||
if (Build.VERSION.SDK_INT >= 23) apChannel.getInt(this) else CH_INVALID, // TODO
|
||||
BSSID?.let { MacAddressCompat.fromString(it) },
|
||||
BSSID?.let { MacAddressCompat.fromString(it) }?.addr,
|
||||
0, // TODO: unsupported field should have @RequiresApi?
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
TetherTimeoutMonitor.timeout.toLong()
|
||||
@@ -204,7 +205,7 @@ data class SoftApConfigurationCompat(
|
||||
passphrase,
|
||||
getBand(this) as Int,
|
||||
getChannel(this) as Int,
|
||||
bssid?.toCompat(),
|
||||
bssid?.toCompat()?.addr,
|
||||
getMaxNumberOfClients(this) as Int,
|
||||
getShutdownTimeoutMillis(this) as Long,
|
||||
isAutoShutdownEnabled(this) as Boolean,
|
||||
@@ -222,6 +223,13 @@ data class SoftApConfigurationCompat(
|
||||
if (Build.VERSION.SDK_INT >= 28) TetherTimeoutMonitor.enabled else false, false, false, null, null)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
var bssid: MacAddressCompat?
|
||||
get() = bssidAddr?.let { MacAddressCompat(it) }
|
||||
set(value) {
|
||||
bssidAddr = value?.addr
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on:
|
||||
* https://android.googlesource.com/platform/packages/apps/Settings/+/android-5.0.0_r1/src/com/android/settings/wifi/WifiApDialog.java#88
|
||||
|
||||
@@ -81,8 +81,8 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
||||
override val ret get() = Arg(arg.configuration.copy(
|
||||
ssid = dialogView.ssid.text.toString(),
|
||||
passphrase = if (dialogView.password.length() != 0) dialogView.password.text.toString() else null,
|
||||
bssid = if (dialogView.bssid.length() != 0) {
|
||||
MacAddressCompat.fromString(dialogView.bssid.toString())
|
||||
bssidAddr = if (dialogView.bssid.length() != 0) {
|
||||
MacAddressCompat.fromString(dialogView.bssid.toString()).addr
|
||||
} else null).apply {
|
||||
if (!arg.p2pMode) {
|
||||
securityType = dialogView.security.selectedItemPosition
|
||||
|
||||
Reference in New Issue
Block a user