Minor cleanup

This commit is contained in:
arkon
2022-11-27 17:05:04 -05:00
parent 5076ab3049
commit 3480b45098
14 changed files with 74 additions and 91 deletions
@@ -69,14 +69,14 @@ class BackupRestoreService : Service() {
*/
private lateinit var wakeLock: PowerManager.WakeLock
private lateinit var ioScope: CoroutineScope
private lateinit var scope: CoroutineScope
private var restorer: BackupRestorer? = null
private lateinit var notifier: BackupNotifier
override fun onCreate() {
super.onCreate()
ioScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
notifier = BackupNotifier(this)
wakeLock = acquireWakeLock(javaClass.name)
@@ -95,7 +95,7 @@ class BackupRestoreService : Service() {
private fun destroyJob() {
restorer?.job?.cancel()
ioScope.cancel()
scope.cancel()
if (wakeLock.isHeld) {
wakeLock.release()
}
@@ -129,7 +129,7 @@ class BackupRestoreService : Service() {
notifier.showRestoreError(exception.message)
stopSelf(startId)
}
val job = ioScope.launch(handler) {
val job = scope.launch(handler) {
if (restorer?.restoreBackup(uri) == false) {
notifier.showRestoreError(getString(R.string.restoring_backup_canceled))
}