Properly support bridged AP configurations
This commit is contained in:
@@ -28,7 +28,9 @@ data class SoftApConfigurationCompat(
|
|||||||
/**
|
/**
|
||||||
* To read legacy band/channel pair, use [requireSingleBand]. For easy access, see [getChannel].
|
* To read legacy band/channel pair, use [requireSingleBand]. For easy access, see [getChannel].
|
||||||
*
|
*
|
||||||
* You should probably not set or modify this field directly. Use [optimizeChannels] or [setChannel].
|
* You should probably set or modify this field directly only when you want to use bridged AP,
|
||||||
|
* see also [android.net.wifi.WifiManager.isBridgedApConcurrencySupported].
|
||||||
|
* Otherwise, use [optimizeChannels] or [setChannel].
|
||||||
*/
|
*/
|
||||||
@TargetApi(23)
|
@TargetApi(23)
|
||||||
var channels: SparseIntArray = SparseIntArray(1).apply { put(BAND_2GHZ, 0) },
|
var channels: SparseIntArray = SparseIntArray(1).apply { put(BAND_2GHZ, 0) },
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
*/
|
*/
|
||||||
val p2pMode: Boolean = false) : Parcelable
|
val p2pMode: Boolean = false) : Parcelable
|
||||||
|
|
||||||
private open class ChannelOption(val channel: Int = 0, val band: Int = 0) {
|
private open class ChannelOption(val channel: Int = 0, private val band: Int = 0) {
|
||||||
object Disabled : ChannelOption(-1) {
|
object Disabled : ChannelOption(-1) {
|
||||||
override fun toString() = app.getString(R.string.wifi_ap_choose_disabled)
|
override fun toString() = app.getString(R.string.wifi_ap_choose_disabled)
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,9 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
val channel = (spinner.selectedItem as ChannelOption?)?.channel
|
val channel = (spinner.selectedItem as ChannelOption?)?.channel
|
||||||
if (channel != null && channel >= 0) channels.put(band, channel)
|
if (channel != null && channel >= 0) channels.put(band, channel)
|
||||||
}
|
}
|
||||||
optimizeChannels(channels)
|
if (!arg.p2pMode && BuildCompat.isAtLeastS() && dialogView.bridgedMode.isChecked) {
|
||||||
|
this.channels = channels
|
||||||
|
} else optimizeChannels(channels)
|
||||||
}
|
}
|
||||||
bssid = if (dialogView.bssid.length() != 0) {
|
bssid = if (dialogView.bssid.length() != 0) {
|
||||||
MacAddressCompat.fromString(dialogView.bssid.text.toString())
|
MacAddressCompat.fromString(dialogView.bssid.text.toString())
|
||||||
@@ -198,6 +200,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
if (arg.p2pMode && Build.VERSION.SDK_INT >= 29) dialogView.macRandomization.isEnabled = false
|
if (arg.p2pMode && Build.VERSION.SDK_INT >= 29) dialogView.macRandomization.isEnabled = false
|
||||||
else if (arg.p2pMode || !BuildCompat.isAtLeastS()) dialogView.macRandomization.isGone = true
|
else if (arg.p2pMode || !BuildCompat.isAtLeastS()) dialogView.macRandomization.isGone = true
|
||||||
if (arg.p2pMode || !BuildCompat.isAtLeastS()) {
|
if (arg.p2pMode || !BuildCompat.isAtLeastS()) {
|
||||||
|
dialogView.bridgedMode.isGone = true
|
||||||
dialogView.bridgedModeOpportunisticShutdown.isGone = true
|
dialogView.bridgedModeOpportunisticShutdown.isGone = true
|
||||||
dialogView.ieee80211ax.isGone = true
|
dialogView.ieee80211ax.isGone = true
|
||||||
dialogView.userConfig.isGone = true
|
dialogView.userConfig.isGone = true
|
||||||
@@ -214,6 +217,26 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
0
|
0
|
||||||
} else selection
|
} else selection
|
||||||
}
|
}
|
||||||
|
private var userBridgedMode = false
|
||||||
|
private fun setBridgedMode() {
|
||||||
|
var auto = 0
|
||||||
|
var set = 0
|
||||||
|
for (s in arrayOf(dialogView.band2G, dialogView.band5G, dialogView.band6G)) when (s.selectedItem) {
|
||||||
|
is ChannelOption.Auto -> auto = 1
|
||||||
|
!is ChannelOption.Disabled -> ++set
|
||||||
|
}
|
||||||
|
if (auto + set > 1) {
|
||||||
|
if (dialogView.bridgedMode.isEnabled) {
|
||||||
|
userBridgedMode = dialogView.bridgedMode.isChecked
|
||||||
|
dialogView.bridgedMode.isEnabled = false
|
||||||
|
dialogView.bridgedMode.isChecked = true
|
||||||
|
}
|
||||||
|
} else if (!dialogView.bridgedMode.isEnabled) {
|
||||||
|
dialogView.bridgedMode.isEnabled = true
|
||||||
|
dialogView.bridgedMode.isChecked = userBridgedMode
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
private fun populateFromConfiguration() {
|
private fun populateFromConfiguration() {
|
||||||
dialogView.ssid.setText(base.ssid)
|
dialogView.ssid.setText(base.ssid)
|
||||||
if (!arg.p2pMode) dialogView.security.setSelection(base.securityType)
|
if (!arg.p2pMode) dialogView.security.setSelection(base.securityType)
|
||||||
@@ -225,6 +248,9 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
dialogView.band5G.setSelection(locate(SoftApConfigurationCompat.BAND_5GHZ, currentChannels5G))
|
dialogView.band5G.setSelection(locate(SoftApConfigurationCompat.BAND_5GHZ, currentChannels5G))
|
||||||
dialogView.band6G.setSelection(locate(SoftApConfigurationCompat.BAND_6GHZ, channels6G))
|
dialogView.band6G.setSelection(locate(SoftApConfigurationCompat.BAND_6GHZ, channels6G))
|
||||||
dialogView.band60G.setSelection(locate(SoftApConfigurationCompat.BAND_60GHZ, channels60G))
|
dialogView.band60G.setSelection(locate(SoftApConfigurationCompat.BAND_60GHZ, channels60G))
|
||||||
|
userBridgedMode = base.channels.size() > 1
|
||||||
|
dialogView.bridgedMode.isChecked = userBridgedMode
|
||||||
|
setBridgedMode()
|
||||||
}
|
}
|
||||||
dialogView.bssid.setText(base.bssid?.toString())
|
dialogView.bssid.setText(base.bssid?.toString())
|
||||||
dialogView.hiddenSsid.isChecked = base.isHiddenSsid
|
dialogView.hiddenSsid.isChecked = base.isHiddenSsid
|
||||||
@@ -295,6 +321,7 @@ class WifiApDialogFragment : AlertDialogFragment<WifiApDialogFragment.Arg, WifiA
|
|||||||
}
|
}
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
|
setBridgedMode()
|
||||||
dialogView.bssidWrapper.error = null
|
dialogView.bssidWrapper.error = null
|
||||||
val bssidValid = dialogView.bssid.length() == 0 || try {
|
val bssidValid = dialogView.bssid.length() == 0 || try {
|
||||||
MacAddressCompat.fromString(dialogView.bssid.text.toString())
|
MacAddressCompat.fromString(dialogView.bssid.text.toString())
|
||||||
|
|||||||
@@ -195,6 +195,22 @@
|
|||||||
android:minHeight="@dimen/touch_target_min"
|
android:minHeight="@dimen/touch_target_min"
|
||||||
android:prompt="@string/wifi_ap_choose_60G" />
|
android:prompt="@string/wifi_ap_choose_60G" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/bridged_mode"
|
||||||
|
style="@style/wifi_item_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dip"
|
||||||
|
android:minHeight="@dimen/touch_target_min"
|
||||||
|
android:text="@string/wifi_bridged_mode" />
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/bridged_mode_opportunistic_shutdown"
|
||||||
|
style="@style/wifi_item_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dip"
|
||||||
|
android:minHeight="@dimen/touch_target_min"
|
||||||
|
android:text="@string/wifi_bridged_mode_opportunistic_shutdown" />
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/bssid_wrapper"
|
android:id="@+id/bssid_wrapper"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -281,14 +297,6 @@
|
|||||||
style="@style/wifi_item_edit_content"
|
style="@style/wifi_item_edit_content"
|
||||||
android:inputType="textMultiLine|textNoSuggestions" />
|
android:inputType="textMultiLine|textNoSuggestions" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
<Switch
|
|
||||||
android:id="@+id/bridged_mode_opportunistic_shutdown"
|
|
||||||
style="@style/wifi_item_label"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="8dip"
|
|
||||||
android:minHeight="@dimen/touch_target_min"
|
|
||||||
android:text="@string/wifi_bridged_mode_opportunistic_shutdown" />
|
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/ieee_80211ax"
|
android:id="@+id/ieee_80211ax"
|
||||||
style="@style/wifi_item_label"
|
style="@style/wifi_item_label"
|
||||||
|
|||||||
@@ -185,6 +185,7 @@
|
|||||||
<string name="wifi_blocked_list">设备黑名单</string>
|
<string name="wifi_blocked_list">设备黑名单</string>
|
||||||
<string name="wifi_allowed_list">设备白名单</string>
|
<string name="wifi_allowed_list">设备白名单</string>
|
||||||
<string name="wifi_mac_randomization">随机生成 MAC 地址</string>
|
<string name="wifi_mac_randomization">随机生成 MAC 地址</string>
|
||||||
|
<string name="wifi_bridged_mode">启用无线接入点桥接模式</string>
|
||||||
<string name="wifi_bridged_mode_opportunistic_shutdown">启用桥接模式伺机关闭</string>
|
<string name="wifi_bridged_mode_opportunistic_shutdown">启用桥接模式伺机关闭</string>
|
||||||
<string name="wifi_ieee_80211ax">启用 Wi\u2011Fi 6</string>
|
<string name="wifi_ieee_80211ax">启用 Wi\u2011Fi 6</string>
|
||||||
<string name="wifi_user_config">用户提供配置</string>
|
<string name="wifi_user_config">用户提供配置</string>
|
||||||
|
|||||||
@@ -207,7 +207,8 @@
|
|||||||
<string name="wifi_blocked_list">Blocked list of clients</string>
|
<string name="wifi_blocked_list">Blocked list of clients</string>
|
||||||
<string name="wifi_allowed_list">Allowed list of clients</string>
|
<string name="wifi_allowed_list">Allowed list of clients</string>
|
||||||
<string name="wifi_mac_randomization">Use randomized MAC</string>
|
<string name="wifi_mac_randomization">Use randomized MAC</string>
|
||||||
<string name="wifi_bridged_mode_opportunistic_shutdown">Enable bridged mode opportunistic shutdown</string>
|
<string name="wifi_bridged_mode">Enable Bridged Access point (AP) concurrency</string>
|
||||||
|
<string name="wifi_bridged_mode_opportunistic_shutdown">Enable Bridged mode opportunistic shutdown</string>
|
||||||
<string name="wifi_ieee_80211ax">Enable Wi\u2011Fi 6</string>
|
<string name="wifi_ieee_80211ax">Enable Wi\u2011Fi 6</string>
|
||||||
<string name="wifi_user_config">User Supplied Configuration</string>
|
<string name="wifi_user_config">User Supplied Configuration</string>
|
||||||
<string name="wifi_save">Save</string>
|
<string name="wifi_save">Save</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user