Add more logging

This commit is contained in:
Mygod
2018-06-10 20:26:36 +08:00
parent 55e8b684df
commit e2cbe18ea9
18 changed files with 76 additions and 18 deletions

View File

@@ -7,6 +7,7 @@ import android.widget.Toast
import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.util.loggerSu
import be.mygod.vpnhotspot.util.noisySu
import com.crashlytics.android.Crashlytics
import java.io.File
class P2pSupplicantConfiguration {
@@ -34,8 +35,9 @@ class P2pSupplicantConfiguration {
check(result.length in 8..63)
result
} catch (e: RuntimeException) {
Log.w(TAG, content)
Crashlytics.log(Log.WARN, TAG, content)
e.printStackTrace()
Crashlytics.logException(e)
Toast.makeText(app, e.message, Toast.LENGTH_LONG).show()
null
}
@@ -61,7 +63,9 @@ class P2pSupplicantConfiguration {
else -> line // do nothing
})
}
if (ssidFound != 1 || pskFound != 1) Log.w(TAG, "Invalid conf ($ssidFound, $pskFound): $content")
if (ssidFound != 1 || pskFound != 1) {
Crashlytics.log(Log.WARN, TAG, "Invalid conf ($ssidFound, $pskFound): $content")
}
if (ssidFound == 0 || pskFound == 0) return false
// pkill not available on Lollipop. Source: https://android.googlesource.com/platform/system/core/+/master/shell_and_utilities/README.md
return noisySu("cat ${tempFile.absolutePath} > /data/misc/wifi/p2p_supplicant.conf",

View File

@@ -6,6 +6,7 @@ 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 java.lang.reflect.Proxy
import java.util.regex.Pattern
@@ -88,11 +89,11 @@ object WifiP2pManagerHelper {
val proxy = Proxy.newProxyInstance(interfacePersistentGroupInfoListener.classLoader,
arrayOf(interfacePersistentGroupInfoListener), { proxy, method, args ->
if (method.name == "onPersistentGroupInfoAvailable") {
if (args.size != 1) Log.w(TAG, "Unexpected args: $args")
if (args.size != 1) Crashlytics.log(Log.WARN, TAG, "Unexpected args: $args")
listener(getGroupList.invoke(args[0]) as Collection<WifiP2pGroup>)
null
} else {
Log.w(TAG, "Unexpected method, calling super: $method")
Crashlytics.log(Log.WARN, TAG, "Unexpected method, calling super: $method")
ProxyBuilder.callSuper(proxy, method, args)
}
})