diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt
index f9507789..f6b5d597 100644
--- a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt
+++ b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt
@@ -122,6 +122,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
WifiP2pManager.P2P_UNSUPPORTED -> getString(R.string.repeater_failure_reason_p2p_unsupported)
WifiP2pManager.BUSY -> getString(R.string.repeater_failure_reason_busy)
WifiP2pManager.NO_SERVICE_REQUESTS -> getString(R.string.repeater_failure_reason_no_service_requests)
+ WifiP2pManagerHelper.UNSUPPORTED -> getString(R.string.repeater_failure_reason_unsupported_operation)
else -> getString(R.string.failure_reason_unknown, reason)
})
Crashlytics.logException(Failure(result))
diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt
index 42cee995..f0eba762 100644
--- a/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt
+++ b/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt
@@ -98,7 +98,7 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
true
}
findPreference("misc.source").setOnPreferenceClickListener {
- customTabsIntent.launchUrl(activity, Uri.parse("https://github.com/Mygod/VPNHotspot"))
+ customTabsIntent.launchUrl(requireActivity(), Uri.parse("https://github.com/Mygod/VPNHotspot"))
true
}
}
diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiP2pManagerHelper.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiP2pManagerHelper.kt
index 83e327bb..62d96d60 100644
--- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiP2pManagerHelper.kt
+++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/WifiP2pManagerHelper.kt
@@ -12,6 +12,7 @@ import java.util.regex.Pattern
object WifiP2pManagerHelper {
private const val TAG = "WifiP2pManagerHelper"
+ const val UNSUPPORTED = -2
/**
* Matches the output of dumpsys wifip2p. This part is available since Android 4.2.
@@ -36,8 +37,14 @@ object WifiP2pManagerHelper {
Int::class.java, Int::class.java, WifiP2pManager.ActionListener::class.java)
}
fun WifiP2pManager.setWifiP2pChannels(c: WifiP2pManager.Channel, lc: Int, oc: Int,
- listener: WifiP2pManager.ActionListener) {
- setWifiP2pChannels.invoke(this, c, lc, oc, listener)
+ listener: WifiP2pManager.ActionListener) {
+ try {
+ setWifiP2pChannels.invoke(this, c, lc, oc, listener)
+ } catch (e: NoSuchMethodException) {
+ e.printStackTrace()
+ Crashlytics.logException(e)
+ listener.onFailure(UNSUPPORTED)
+ }
}
/**
@@ -49,9 +56,14 @@ object WifiP2pManagerHelper {
WifiP2pManager::class.java.getDeclaredMethod("startWps",
WifiP2pManager.Channel::class.java, WpsInfo::class.java, WifiP2pManager.ActionListener::class.java)
}
- fun WifiP2pManager.startWps(c: WifiP2pManager.Channel, wps: WpsInfo,
- listener: WifiP2pManager.ActionListener) {
- startWps.invoke(this, c, wps, listener)
+ fun WifiP2pManager.startWps(c: WifiP2pManager.Channel, wps: WpsInfo, listener: WifiP2pManager.ActionListener) {
+ try {
+ startWps.invoke(this, c, wps, listener)
+ } catch (e: NoSuchMethodException) {
+ e.printStackTrace()
+ Crashlytics.logException(e)
+ listener.onFailure(UNSUPPORTED)
+ }
}
/**
@@ -65,7 +77,13 @@ object WifiP2pManagerHelper {
}
fun WifiP2pManager.deletePersistentGroup(c: WifiP2pManager.Channel, netId: Int,
listener: WifiP2pManager.ActionListener) {
- deletePersistentGroup.invoke(this, c, netId, listener)
+ try {
+ deletePersistentGroup.invoke(this, c, netId, listener)
+ } catch (e: NoSuchMethodException) {
+ e.printStackTrace()
+ Crashlytics.logException(e)
+ listener.onFailure(UNSUPPORTED)
+ }
}
private val interfacePersistentGroupInfoListener by lazy @SuppressLint("PrivateApi") {
diff --git a/mobile/src/main/res/values-zh-rCN/strings.xml b/mobile/src/main/res/values-zh-rCN/strings.xml
index 910f2d7c..a39e4e5a 100644
--- a/mobile/src/main/res/values-zh-rCN/strings.xml
+++ b/mobile/src/main/res/values-zh-rCN/strings.xml
@@ -27,6 +27,7 @@
设备不支持 Wi\u2011Fi 直连
系统忙
未添加服务请求
+ 不支持此操作
临时 WLAN 热点
使用临时热点需要打开位置服务。
diff --git a/mobile/src/main/res/values/strings.xml b/mobile/src/main/res/values/strings.xml
index bd38d224..b70a370a 100644
--- a/mobile/src/main/res/values/strings.xml
+++ b/mobile/src/main/res/values/strings.xml
@@ -38,6 +38,7 @@
Wi\u2011Fi direct unsupported
framework is busy
no service requests added
+ unsupported operation
Temporary Wi\u2011Fi hotspot
Temporary hotspot requires location to be turned on.