Hide WPS if unsupported
This commit is contained in:
@@ -39,18 +39,19 @@ object WifiP2pManagerHelper {
|
|||||||
*
|
*
|
||||||
* Source: https://android.googlesource.com/platform/frameworks/base/+/android-4.3_r0.9/wifi/java/android/net/wifi/p2p/WifiP2pManager.java#958
|
* Source: https://android.googlesource.com/platform/frameworks/base/+/android-4.3_r0.9/wifi/java/android/net/wifi/p2p/WifiP2pManager.java#958
|
||||||
*/
|
*/
|
||||||
private val startWps by lazy {
|
@JvmStatic
|
||||||
WifiP2pManager::class.java.getDeclaredMethod("startWps",
|
val startWps by lazy {
|
||||||
WifiP2pManager.Channel::class.java, WpsInfo::class.java, WifiP2pManager.ActionListener::class.java)
|
|
||||||
}
|
|
||||||
fun WifiP2pManager.startWps(c: WifiP2pManager.Channel, wps: WpsInfo, listener: WifiP2pManager.ActionListener) {
|
|
||||||
try {
|
try {
|
||||||
startWps.invoke(this, c, wps, listener)
|
WifiP2pManager::class.java.getDeclaredMethod("startWps",
|
||||||
|
WifiP2pManager.Channel::class.java, WpsInfo::class.java, WifiP2pManager.ActionListener::class.java)
|
||||||
} catch (e: NoSuchMethodException) {
|
} catch (e: NoSuchMethodException) {
|
||||||
DebugHelper.logEvent("NoSuchMethod_startWps")
|
DebugHelper.logEvent("NoSuchMethod_startWps")
|
||||||
listener.onFailure(UNSUPPORTED)
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun WifiP2pManager.startWps(c: WifiP2pManager.Channel, wps: WpsInfo, listener: WifiP2pManager.ActionListener) {
|
||||||
|
startWps!!.invoke(this, c, wps, listener)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available since Android 4.2.
|
* Available since Android 4.2.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
<data>
|
<data>
|
||||||
|
<import type="be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper"/>
|
||||||
<variable
|
<variable
|
||||||
name="data"
|
name="data"
|
||||||
type="be.mygod.vpnhotspot.manage.RepeaterManager.Data"/>
|
type="be.mygod.vpnhotspot.manage.RepeaterManager.Data"/>
|
||||||
@@ -73,7 +74,7 @@
|
|||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:onClick="@{_ -> data.wps()}"
|
android:onClick="@{_ -> data.wps()}"
|
||||||
android:visibility="@{data.serviceStarted}">
|
android:visibility="@{data.serviceStarted && WifiP2pManagerHelper.startWps != null}">
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="40dp"
|
android:layout_width="40dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user