Commit f3fc01ac authored by Daniel Wolf's avatar Daniel Wolf
Browse files

Added LeakCanary to the services

parent 509f25fa
......@@ -15,6 +15,8 @@ import com.github.anrwatchdog.ANRWatchDog
import io.sentry.Sentry
import io.sentry.android.AndroidSentryClientFactory
import io.sentry.event.User
import leakcanary.LeakCanary
import leakcanary.LeakSentry
import java.util.*
import kotlin.system.exitProcess
......@@ -96,6 +98,7 @@ class SmokeScreen : Application() {
ANRWatchDog().setANRListener {
log(RuntimeException(it))
}
LeakSentry.refWatcher.watch(this)
}
fun initSentry(forceEnabled: Boolean = false) {
......
......@@ -36,6 +36,7 @@ import com.frostnerd.smokescreen.util.proxy.SmokeProxy
import com.frostnerd.vpntunnelproxy.TrafficStats
import com.frostnerd.vpntunnelproxy.VPNTunnelProxy
import kotlinx.coroutines.*
import leakcanary.LeakSentry
import org.minidns.dnsmessage.DnsMessage
import org.minidns.dnsmessage.Question
import org.minidns.dnsname.DnsName
......@@ -143,6 +144,7 @@ class DnsVpnService : VpnService(), Runnable {
override fun onCreate() {
super.onCreate()
LeakSentry.refWatcher.watch(this, "DnsVpnService")
Thread.setDefaultUncaughtExceptionHandler { t, e ->
log("Encountered an uncaught exception.")
destroy()
......
......@@ -16,6 +16,7 @@ import com.frostnerd.smokescreen.util.Notifications
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import leakcanary.LeakSentry
import java.io.BufferedWriter
import java.io.OutputStreamWriter
import java.io.Serializable
......@@ -50,6 +51,11 @@ class RuleExportService : Service() {
const val BROADCAST_EXPORT_DONE = "com.frostnerd.nebulo.RULE_EXPORT_DONE"
}
override fun onCreate() {
super.onCreate()
LeakSentry.refWatcher.watch(this, "RuleExportService")
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
createNotification()
if (intent?.hasExtra("params") == true) {
......
......@@ -18,6 +18,7 @@ import com.frostnerd.smokescreen.util.Notifications
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import leakcanary.LeakSentry
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
......@@ -67,6 +68,11 @@ class RuleImportService : Service() {
OkHttpClient()
}
override fun onCreate() {
super.onCreate()
LeakSentry.refWatcher.watch(this, "RuleImportService")
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (intent != null && intent.hasExtra("abort")) {
abortImport()
......
......@@ -11,6 +11,7 @@ import android.service.quicksettings.TileService
import androidx.annotation.RequiresApi
import com.frostnerd.general.service.isServiceRunning
import com.frostnerd.smokescreen.R
import leakcanary.LeakSentry
/*
* Copyright (C) 2019 Daniel Wolf (Ch4t4r)
......@@ -39,6 +40,11 @@ fun Context.updateServiceTile() {
@RequiresApi(Build.VERSION_CODES.N)
class StartStopTileService:TileService() {
override fun onCreate() {
super.onCreate()
LeakSentry.refWatcher.watch(this, "StartStopTileService")
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
updateTileState()
return Service.START_STICKY
......
......@@ -8,6 +8,7 @@ import com.frostnerd.smokescreen.R
import com.frostnerd.smokescreen.activity.BackgroundVpnConfigureActivity
import com.frostnerd.smokescreen.log
import com.frostnerd.smokescreen.util.Notifications
import leakcanary.LeakSentry
/*
* Copyright (C) 2019 Daniel Wolf (Ch4t4r)
......@@ -38,6 +39,11 @@ class VpnRestartService : Service() {
return null
}
override fun onCreate() {
super.onCreate()
LeakSentry.refWatcher.watch(this, "VpnRestartService")
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
log("Trying to restart the VPN Service.")
val builder = NotificationCompat.Builder(this, Notifications.servicePersistentNotificationChannel(this))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment