From 61e748ac42f25ba6bdbf99ced3cc44a4c5fbae22 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 21 Aug 2024 14:47:54 -0300 Subject: [PATCH] Don't back up to USB, if backup disabled --- .../java/com/stevesoltys/seedvault/UsbIntentReceiver.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/UsbIntentReceiver.kt b/app/src/main/java/com/stevesoltys/seedvault/UsbIntentReceiver.kt index 39262764..c6f0c088 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/UsbIntentReceiver.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/UsbIntentReceiver.kt @@ -5,6 +5,7 @@ package com.stevesoltys.seedvault +import android.app.backup.IBackupManager import android.content.BroadcastReceiver import android.content.Context import android.content.Intent @@ -37,6 +38,7 @@ class UsbIntentReceiver : UsbMonitor() { // using KoinComponent would crash robolectric tests :( private val settingsManager: SettingsManager by lazy { get().get() } private val metadataManager: MetadataManager by lazy { get().get() } + private val backupManager: IBackupManager by lazy { get().get() } override fun shouldMonitorStatus(context: Context, action: String, device: UsbDevice): Boolean { if (action != ACTION_USB_DEVICE_ATTACHED) return false @@ -67,8 +69,10 @@ class UsbIntentReceiver : UsbMonitor() { // this starts an app backup afterwards i.putExtra(EXTRA_START_APP_BACKUP, true) startForegroundService(context, i) - } else { + } else if (backupManager.isBackupEnabled) { AppBackupWorker.scheduleNow(context, reschedule = false) + } else { + Log.d(TAG, "Neither files nor app backup enabled, do nothing.") } }