coroutines: lifecycleScope is by default on Main.immediate
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -28,7 +28,7 @@ class KernelModuleDisablerPreference(context: Context, attrs: AttributeSet?) : P
|
||||
private var state = State.UNKNOWN
|
||||
init {
|
||||
isVisible = false
|
||||
lifecycleScope.launch(Dispatchers.Main.immediate) {
|
||||
lifecycleScope.launch {
|
||||
setState(if (Application.getBackend() is WgQuickBackend) State.ENABLED else State.DISABLED)
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class KernelModuleDisablerPreference(context: Context, attrs: AttributeSet?) : P
|
||||
setState(State.DISABLING)
|
||||
Application.getSharedPreferences().edit().putBoolean("disable_kernel_module", true).commit()
|
||||
}
|
||||
lifecycleScope.launch(Dispatchers.Main.immediate) {
|
||||
lifecycleScope.launch {
|
||||
val observableTunnels = Application.getTunnelManager().getTunnels()
|
||||
val downings = observableTunnels.map { async(SupervisorJob()) { it.setStateAsync(Tunnel.State.DOWN) } }
|
||||
try {
|
||||
|
||||
@@ -30,7 +30,7 @@ class ModuleDownloaderPreference(context: Context, attrs: AttributeSet?) : Prefe
|
||||
@SuppressLint("ApplySharedPref")
|
||||
override fun onClick() {
|
||||
setState(State.WORKING)
|
||||
lifecycleScope.launch(Dispatchers.Main.immediate) {
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
when (withContext(Dispatchers.IO) { Application.getModuleLoader().download() }) {
|
||||
OsConstants.ENOENT -> setState(State.NOTFOUND)
|
||||
|
||||
@@ -27,7 +27,7 @@ class ToolsInstallerPreference(context: Context, attrs: AttributeSet?) : Prefere
|
||||
|
||||
override fun onAttached() {
|
||||
super.onAttached()
|
||||
lifecycleScope.launch(Dispatchers.Main.immediate) {
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
val state = withContext(Dispatchers.IO) { Application.getToolsInstaller().areInstalled() }
|
||||
when {
|
||||
@@ -45,7 +45,7 @@ class ToolsInstallerPreference(context: Context, attrs: AttributeSet?) : Prefere
|
||||
|
||||
override fun onClick() {
|
||||
setState(State.WORKING)
|
||||
lifecycleScope.launch(Dispatchers.Main.immediate) {
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
val result = withContext(Dispatchers.IO) { Application.getToolsInstaller().install() }
|
||||
when {
|
||||
|
||||
@@ -47,7 +47,7 @@ class VersionPreference(context: Context, attrs: AttributeSet?) : Preference(con
|
||||
}
|
||||
|
||||
init {
|
||||
lifecycleScope.launch(Dispatchers.Main.immediate) {
|
||||
lifecycleScope.launch {
|
||||
val backend = Application.getBackend()
|
||||
versionSummary = getContext().getString(R.string.version_summary_checking, getBackendPrettyName(context, backend).toLowerCase(Locale.ENGLISH))
|
||||
notifyChanged()
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.zip.ZipOutputStream
|
||||
class ZipExporterPreference(context: Context, attrs: AttributeSet?) : Preference(context, attrs) {
|
||||
private var exportedFilePath: String? = null
|
||||
private fun exportZip() {
|
||||
lifecycleScope.launch(Dispatchers.Main.immediate) {
|
||||
lifecycleScope.launch {
|
||||
val tunnels = Application.getTunnelManager().getTunnels()
|
||||
try {
|
||||
exportedFilePath = withContext(Dispatchers.IO) {
|
||||
|
||||
Reference in New Issue
Block a user