diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/AppDataRestoreManager.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/AppDataRestoreManager.kt index 0bf703a42..8d8bb01fb 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/AppDataRestoreManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/AppDataRestoreManager.kt @@ -123,7 +123,8 @@ internal class AppDataRestoreManager( RestoreBackupResult(context.getString(R.string.restore_set_error)) ) } else { - context.startForegroundService(foregroundServiceIntent) + // don't use startForeground(), because we may stop it sooner than the system likes + context.startService(foregroundServiceIntent) } } diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt index d62bb9dbc..48aa99f9d 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/install/ApkRestore.kt @@ -90,7 +90,8 @@ internal class ApkRestore( val i = Intent(context, RestoreService::class.java) val autoRestore = backupStateManager.isAutoRestoreEnabled try { - context.startForegroundService(i) + // don't use startForeground(), because we may stop it sooner than the system likes + context.startService(i) // disable auto-restore before installing apps, if it was enabled before if (autoRestore) backupManager.setAutoRestore(false) reInstallApps(backup, packages.asIterable().reversed()) diff --git a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt index 389bfaf2a..5fae19666 100644 --- a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt +++ b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkBackupRestoreTest.kt @@ -131,7 +131,7 @@ internal class ApkBackupRestoreTest : TransportTest() { // related to starting/stopping service every { strictContext.packageName } returns "org.foo.bar" every { - strictContext.startForegroundService(any()) + strictContext.startService(any()) } returns ComponentName(strictContext, "org.foo.bar.Class") every { strictContext.stopService(any()) } returns true diff --git a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt index 8fcaece16..201824f6c 100644 --- a/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt +++ b/app/src/test/java/com/stevesoltys/seedvault/restore/install/ApkRestoreTest.kt @@ -112,7 +112,7 @@ internal class ApkRestoreTest : TransportTest() { // related to starting/stopping service every { strictContext.packageName } returns "org.foo.bar" every { - strictContext.startForegroundService(any()) + strictContext.startService(any()) } returns ComponentName(strictContext, "org.foo.bar.Class") every { strictContext.stopService(any()) } returns true }