diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0a79268a..eec0dd80 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -123,6 +123,7 @@ android:name=".restore.RestoreActivity" android:exported="true" android:label="@string/restore_title" + android:launchMode="singleTask" android:permission="com.stevesoltys.seedvault.RESTORE_BACKUP"> 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 2180d140..095fb8c8 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/AppDataRestoreManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/AppDataRestoreManager.kt @@ -210,7 +210,7 @@ internal class AppDataRestoreManager( context.stopService(foregroundServiceIntent) } - fun closeSession() { + private fun closeSession() { session?.endRestoreSession() session = null } @@ -267,6 +267,7 @@ internal class AppDataRestoreManager( val nextChunkIndex = (packageIndex + PACKAGES_PER_CHUNK).coerceAtMost(packages.size) val packageChunk = packages.subList(packageIndex, nextChunkIndex).toTypedArray() packageIndex += packageChunk.size + Log.d(TAG, "restoreNextPackages() with packageIndex=$packageIndex") val token = restorableBackup.token val result = session.restorePackages(token, this, packageChunk, monitor) @@ -309,6 +310,7 @@ internal class AppDataRestoreManager( */ override fun restoreFinished(result: Int) { val chunkIndex = packageIndex / PACKAGES_PER_CHUNK + Log.d(TAG, "restoreFinished($result) with chunkIndex=$chunkIndex") chunkResults[chunkIndex] = result // Restore next chunk if successful and there are more packages to restore. @@ -317,6 +319,7 @@ internal class AppDataRestoreManager( return } + Log.d(TAG, "onRestoreComplete()") // Restore finished, time to get the result. onRestoreComplete(getRestoreResult(), restorableBackup) closeSession() diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreService.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreService.kt index 017b154e..c639ec75 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreService.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreService.kt @@ -39,8 +39,8 @@ class RestoreService : Service() { override fun onDestroy() { Log.i(TAG, "onDestroy") - super.onDestroy() nm.cancelRestoreNotification() + super.onDestroy() } } diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt index f9112cb0..f214d49d 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt @@ -173,7 +173,6 @@ internal class RestoreViewModel( super.onCleared() @OptIn(DelicateCoroutinesApi::class) GlobalScope.launch(ioDispatcher) { iconManager.removeIcons() } - appDataRestoreManager.closeSession() } @UiThread diff --git a/app/src/main/java/com/stevesoltys/seedvault/transport/restore/RestoreCoordinator.kt b/app/src/main/java/com/stevesoltys/seedvault/transport/restore/RestoreCoordinator.kt index 4958aa32..d6873ac0 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/transport/restore/RestoreCoordinator.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/transport/restore/RestoreCoordinator.kt @@ -270,11 +270,11 @@ internal class RestoreCoordinator( * or null to indicate a transport-level error. */ suspend fun nextRestorePackage(): RestoreDescription? { - Log.i(TAG, "Next restore package!") val state = this.state ?: throw IllegalStateException("no state") if (!state.packages.hasNext()) return NO_MORE_PACKAGES val packageInfo = state.packages.next() + Log.i(TAG, "nextRestorePackage() => ${packageInfo.packageName}") val version = state.backup.version if (version == 0.toByte()) return nextRestorePackageV0(state, packageInfo) if (version == 1.toByte()) return nextRestorePackageV1(state, packageInfo) diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt index 1bd8a9b8..868995fd 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/notification/BackupNotificationManager.kt @@ -31,6 +31,7 @@ import com.stevesoltys.seedvault.R import com.stevesoltys.seedvault.restore.ACTION_RESTORE_ERROR_UNINSTALL import com.stevesoltys.seedvault.restore.EXTRA_PACKAGE_NAME import com.stevesoltys.seedvault.restore.REQUEST_CODE_UNINSTALL +import com.stevesoltys.seedvault.restore.RestoreActivity import com.stevesoltys.seedvault.settings.ACTION_APP_STATUS_LIST import com.stevesoltys.seedvault.settings.SettingsActivity import kotlin.math.min @@ -265,6 +266,9 @@ internal class BackupNotificationManager(private val context: Context) { } fun getRestoreNotification() = Notification.Builder(context, CHANNEL_ID_RESTORE).apply { + val intent = Intent(context, RestoreActivity::class.java) + val pendingIntent = PendingIntent.getActivity(context, 0, intent, FLAG_IMMUTABLE) + setContentIntent(pendingIntent) setSmallIcon(R.drawable.ic_cloud_restore) setContentTitle(context.getString(R.string.notification_restore_title)) setOngoing(true)