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