diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index fdded5ea..14914e4d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -19,6 +19,11 @@
android:name="android.permission.MANAGE_USB"
tools:ignore="ProtectedPermissions" />
+
+
+
) {
for (root in roots) {
- if (root.authority == AUTHORITY_STORAGE && root.supportsEject) return
+ if (root.authority == AUTHORITY_STORAGE && root.isUsb) return
}
val root = StorageRoot(
authority = AUTHORITY_STORAGE,
@@ -147,7 +146,7 @@ internal class StorageRootFetcher(private val context: Context) {
title = context.getString(R.string.storage_fake_drive_title),
summary = context.getString(R.string.storage_fake_drive_summary),
availableBytes = null,
- supportsEject = true,
+ isUsb = true,
enabled = false
)
roots.add(root)
diff --git a/app/src/main/java/com/stevesoltys/backup/ui/storage/StorageViewModel.kt b/app/src/main/java/com/stevesoltys/backup/ui/storage/StorageViewModel.kt
index 4f76607c..596c6ffa 100644
--- a/app/src/main/java/com/stevesoltys/backup/ui/storage/StorageViewModel.kt
+++ b/app/src/main/java/com/stevesoltys/backup/ui/storage/StorageViewModel.kt
@@ -15,6 +15,7 @@ import androidx.lifecycle.MutableLiveData
import com.stevesoltys.backup.Backup
import com.stevesoltys.backup.R
import com.stevesoltys.backup.isMassStorage
+import com.stevesoltys.backup.settings.BackupManagerSettings
import com.stevesoltys.backup.settings.FlashDrive
import com.stevesoltys.backup.settings.Storage
import com.stevesoltys.backup.transport.ConfigurableBackupTransportService
@@ -45,7 +46,7 @@ internal abstract class StorageViewModel(private val app: Application) : Android
internal fun validLocationIsSet(context: Context): Boolean {
val settingsManager = (context.applicationContext as Backup).settingsManager
val storage = settingsManager.getStorage() ?: return false
- if (storage.ejectable) return true
+ if (storage.isUsb) return true
return storage.getDocumentFile(context).isDirectory
}
}
@@ -88,16 +89,20 @@ internal abstract class StorageViewModel(private val app: Application) : Android
} else {
root.title
}
- val storage = Storage(uri, name, root.supportsEject)
+ val storage = Storage(uri, name, root.isUsb)
settingsManager.setStorage(storage)
// reset time of last backup to "Never"
settingsManager.resetBackupTime()
- if (storage.ejectable) {
+ if (storage.isUsb) {
val wasSaved = saveUsbDevice()
// reset stored flash drive, if we did not update it
if (!wasSaved) settingsManager.setFlashDrive(null)
+ BackupManagerSettings.disableAutomaticBackups(app.contentResolver)
+ } else {
+ settingsManager.setFlashDrive(null)
+ BackupManagerSettings.enableAutomaticBackups(app.contentResolver)
}
// stop backup service to be sure the old location will get updated
@@ -114,7 +119,7 @@ internal abstract class StorageViewModel(private val app: Application) : Android
return true
}
}
- Log.w(TAG, "No USB device found for ejectable storage.")
+ Log.e(TAG, "No USB device found even though we were expecting one.")
return false
}
diff --git a/permissions_com.stevesoltys.backup.xml b/permissions_com.stevesoltys.backup.xml
index 34ed8dc9..f0195387 100644
--- a/permissions_com.stevesoltys.backup.xml
+++ b/permissions_com.stevesoltys.backup.xml
@@ -3,5 +3,6 @@
+
\ No newline at end of file