Commit 27589723 authored by Mygod's avatar Mygod

Fix leaks after service switches

parent 24bd70a4
......@@ -27,10 +27,7 @@ import android.content.Intent
* Shadowsocks service at its minimum.
*/
class ProxyService : Service(), BaseService.Interface {
init {
BaseService.register(this)
}
override val data = BaseService.Data(this)
override val tag: String get() = "ShadowsocksProxyService"
override fun createNotification(profileName: String): ServiceNotification =
ServiceNotification(this, profileName, "service-proxy", true)
......@@ -39,7 +36,7 @@ class ProxyService : Service(), BaseService.Interface {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int =
super<BaseService.Interface>.onStartCommand(intent, flags, startId)
override fun onDestroy() {
super<Service>.onDestroy()
super<BaseService.Interface>.onDestroy()
super.onDestroy()
data.binder.close()
}
}
......@@ -27,10 +27,7 @@ import com.github.shadowsocks.preference.DataStore
import java.io.File
class TransproxyService : Service(), LocalDnsService.Interface {
init {
BaseService.register(this)
}
override val data = BaseService.Data(this)
override val tag: String get() = "ShadowsocksTransproxyService"
override fun createNotification(profileName: String): ServiceNotification =
ServiceNotification(this, profileName, "service-transproxy", true)
......@@ -79,7 +76,7 @@ redsocks {
}
override fun onDestroy() {
super<Service>.onDestroy()
super<LocalDnsService.Interface>.onDestroy()
super.onDestroy()
data.binder.close()
}
}
......@@ -108,10 +108,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
override fun getLocalizedMessage() = getString(R.string.reboot_required)
}
init {
BaseService.register(this)
}
override val data = BaseService.Data(this)
override val tag: String get() = "ShadowsocksVpnService"
override fun createNotification(profileName: String): ServiceNotification =
ServiceNotification(this, profileName, "service-vpn")
......@@ -282,7 +279,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
}
override fun onDestroy() {
super<BaseVpnService>.onDestroy()
super<LocalDnsService.Interface>.onDestroy()
super.onDestroy()
data.binder.close()
}
}
Markdown is supported
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