Make compatible with F-Droid (#42)
* Make compatible with F-Droid * Fix title bar empty
This commit is contained in:
@@ -4,10 +4,9 @@ import android.net.wifi.WifiConfiguration
|
||||
import android.os.Build
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import android.util.Log
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.util.RootSession
|
||||
import com.crashlytics.android.Crashlytics
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
@@ -16,7 +15,6 @@ class P2pSupplicantConfiguration(private val initContent: String? = null) : Parc
|
||||
override fun createFromParcel(parcel: Parcel) = P2pSupplicantConfiguration(parcel.readString())
|
||||
override fun newArray(size: Int): Array<P2pSupplicantConfiguration?> = arrayOfNulls(size)
|
||||
|
||||
private const val TAG = "P2pSupplicationConf"
|
||||
/**
|
||||
* Format for ssid is much more complicated, therefore we are only trying to find the line and rely on
|
||||
* Android's results instead.
|
||||
@@ -55,9 +53,8 @@ class P2pSupplicantConfiguration(private val initContent: String? = null) : Parc
|
||||
} catch (e: NoSuchElementException) {
|
||||
null
|
||||
} catch (e: RuntimeException) {
|
||||
if (contentDelegate.isInitialized()) Crashlytics.log(Log.WARN, TAG, content)
|
||||
e.printStackTrace()
|
||||
Crashlytics.logException(e)
|
||||
if (contentDelegate.isInitialized()) Timber.w(content)
|
||||
Timber.w(e)
|
||||
null
|
||||
}
|
||||
}
|
||||
@@ -82,9 +79,9 @@ class P2pSupplicantConfiguration(private val initContent: String? = null) : Parc
|
||||
})
|
||||
}
|
||||
if (ssidFound != 1 || pskFound != 1) {
|
||||
Crashlytics.log(Log.WARN, TAG, "Invalid conf ($ssidFound, $pskFound): $content")
|
||||
Timber.w("Invalid conf ($ssidFound, $pskFound): $content")
|
||||
if (ssidFound == 0 || pskFound == 0) throw InvalidConfigurationError()
|
||||
else Crashlytics.logException(InvalidConfigurationError())
|
||||
else Timber.i(InvalidConfigurationError())
|
||||
}
|
||||
// pkill not available on Lollipop. Source: https://android.googlesource.com/platform/system/core/+/master/shell_and_utilities/README.md
|
||||
RootSession.use {
|
||||
|
||||
@@ -4,14 +4,12 @@ import android.annotation.SuppressLint
|
||||
import android.net.wifi.WpsInfo
|
||||
import android.net.wifi.p2p.WifiP2pGroup
|
||||
import android.net.wifi.p2p.WifiP2pManager
|
||||
import android.util.Log
|
||||
import com.android.dx.stock.ProxyBuilder
|
||||
import com.crashlytics.android.Crashlytics
|
||||
import timber.log.Timber
|
||||
import java.lang.reflect.Proxy
|
||||
import java.util.regex.Pattern
|
||||
|
||||
object WifiP2pManagerHelper {
|
||||
private const val TAG = "WifiP2pManagerHelper"
|
||||
const val UNSUPPORTED = -2
|
||||
|
||||
/**
|
||||
@@ -41,8 +39,7 @@ object WifiP2pManagerHelper {
|
||||
try {
|
||||
setWifiP2pChannels.invoke(this, c, lc, oc, listener)
|
||||
} catch (e: NoSuchMethodException) {
|
||||
e.printStackTrace()
|
||||
Crashlytics.logException(e)
|
||||
Timber.w(e)
|
||||
listener.onFailure(UNSUPPORTED)
|
||||
}
|
||||
}
|
||||
@@ -60,8 +57,7 @@ object WifiP2pManagerHelper {
|
||||
try {
|
||||
startWps.invoke(this, c, wps, listener)
|
||||
} catch (e: NoSuchMethodException) {
|
||||
e.printStackTrace()
|
||||
Crashlytics.logException(e)
|
||||
Timber.w(e)
|
||||
listener.onFailure(UNSUPPORTED)
|
||||
}
|
||||
}
|
||||
@@ -80,8 +76,7 @@ object WifiP2pManagerHelper {
|
||||
try {
|
||||
deletePersistentGroup.invoke(this, c, netId, listener)
|
||||
} catch (e: NoSuchMethodException) {
|
||||
e.printStackTrace()
|
||||
Crashlytics.logException(e)
|
||||
Timber.w(e)
|
||||
listener.onFailure(UNSUPPORTED)
|
||||
}
|
||||
}
|
||||
@@ -107,11 +102,11 @@ object WifiP2pManagerHelper {
|
||||
val proxy = Proxy.newProxyInstance(interfacePersistentGroupInfoListener.classLoader,
|
||||
arrayOf(interfacePersistentGroupInfoListener)) { proxy, method, args ->
|
||||
if (method.name == "onPersistentGroupInfoAvailable") {
|
||||
if (args.size != 1) Crashlytics.log(Log.WARN, TAG, "Unexpected args: $args")
|
||||
if (args.size != 1) Timber.w("Unexpected args: $args")
|
||||
listener(getGroupList.invoke(args[0]) as Collection<WifiP2pGroup>)
|
||||
null
|
||||
} else {
|
||||
Crashlytics.log(Log.WARN, TAG, "Unexpected method, calling super: $method")
|
||||
Timber.w("Unexpected method, calling super: $method")
|
||||
ProxyBuilder.callSuper(proxy, method, args)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user