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 742eaffd..1947e3d0 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt @@ -66,7 +66,9 @@ import com.stevesoltys.seedvault.ui.systemData import com.stevesoltys.seedvault.worker.IconManager import com.stevesoltys.seedvault.worker.NUM_PACKAGES_PER_TRANSACTION import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import org.calyxos.backup.storage.api.SnapshotItem import org.calyxos.backup.storage.api.StorageBackup @@ -328,6 +330,8 @@ internal class RestoreViewModel( override fun onCleared() { super.onCleared() + @OptIn(DelicateCoroutinesApi::class) + GlobalScope.launch(ioDispatcher) { iconManager.removeIcons() } closeSession() } diff --git a/app/src/main/java/com/stevesoltys/seedvault/worker/IconManager.kt b/app/src/main/java/com/stevesoltys/seedvault/worker/IconManager.kt index 333c0741..629dd05e 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/worker/IconManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/worker/IconManager.kt @@ -10,6 +10,7 @@ import android.graphics.Bitmap.CompressFormat.WEBP_LOSSY import android.graphics.BitmapFactory import android.graphics.drawable.Drawable import android.util.Log +import androidx.annotation.WorkerThread import androidx.appcompat.content.res.AppCompatResources.getDrawable import androidx.core.graphics.drawable.toBitmap import androidx.core.graphics.drawable.toDrawable @@ -134,6 +135,13 @@ internal class IconManager( } } + @WorkerThread + fun removeIcons() { + val folder = File(context.cacheDir, CACHE_FOLDER) + val result = folder.deleteRecursively() + Log.e(TAG, "Could delete icons: $result") + } + private fun getAD(version: Byte, token: Long) = ByteBuffer.allocate(2 + 8) .put(version) .put(TYPE_ICONS)