@@ -21,6 +21,7 @@ import com.wireguard.android.Application
21
21
import com.wireguard.android.BuildConfig
22
22
import com.wireguard.android.activity.MainActivity
23
23
import com.wireguard.android.util.UserKnobs
24
+ import com.wireguard.android.util.applicationScope
24
25
import kotlinx.coroutines.CoroutineScope
25
26
import kotlinx.coroutines.Dispatchers
26
27
import kotlinx.coroutines.Job
@@ -76,7 +77,7 @@ object Updater {
76
77
object Complete : Progress()
77
78
class Available (val version : String ) : Progress() {
78
79
fun update () {
79
- Application .getCoroutineScope() .launch {
80
+ applicationScope .launch {
80
81
UserKnobs .setUpdaterNewerVersionConsented(version)
81
82
}
82
83
}
@@ -100,7 +101,7 @@ object Updater {
100
101
}
101
102
102
103
fun markAsDone () {
103
- Application .getCoroutineScope() .launch {
104
+ applicationScope .launch {
104
105
if (installerActive())
105
106
return @launch
106
107
delay(7 .seconds)
@@ -333,13 +334,13 @@ object Updater {
333
334
PackageInstaller .STATUS_PENDING_USER_ACTION -> {
334
335
val id = intent.getIntExtra(PackageInstaller .EXTRA_SESSION_ID , 0 )
335
336
val userIntervention = IntentCompat .getParcelableExtra(intent, Intent .EXTRA_INTENT , Intent ::class .java)!!
336
- Application .getCoroutineScope() .launch {
337
+ applicationScope .launch {
337
338
emitProgress(Progress .NeedsUserIntervention (userIntervention, id))
338
339
}
339
340
}
340
341
341
342
PackageInstaller .STATUS_SUCCESS -> {
342
- Application .getCoroutineScope() .launch {
343
+ applicationScope .launch {
343
344
emitProgress(Progress .Complete )
344
345
}
345
346
context.applicationContext.unregisterReceiver(this )
@@ -352,7 +353,7 @@ object Updater {
352
353
} catch (_: SecurityException ) {
353
354
}
354
355
val message = intent.getStringExtra(PackageInstaller .EXTRA_STATUS_MESSAGE ) ? : " Installation error $status "
355
- Application .getCoroutineScope() .launch {
356
+ applicationScope .launch {
356
357
val e = Exception (message)
357
358
Log .e(TAG , " Update failure" , e)
358
359
emitProgress(Progress .Failure (e))
@@ -414,14 +415,14 @@ object Updater {
414
415
UserKnobs .updaterNewerVersionConsented.firstOrNull()?.let { Version (it) > CURRENT_VERSION } != true
415
416
)
416
417
emitProgress(Progress .Available (ver))
417
- }.launchIn(Application .getCoroutineScope() )
418
+ }.launchIn(applicationScope )
418
419
419
420
UserKnobs .updaterNewerVersionConsented.onEach { ver ->
420
421
if (ver != null && Version (ver) > CURRENT_VERSION )
421
422
updaterScope.launch {
422
423
downloadAndUpdateWrapErrors()
423
424
}
424
- }.launchIn(Application .getCoroutineScope() )
425
+ }.launchIn(applicationScope )
425
426
}
426
427
427
428
class AppUpdatedReceiver : BroadcastReceiver () {
0 commit comments