Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow secondary user backup to USB #381

Merged
merged 4 commits into from
Apr 29, 2022
Merged

Allow secondary user backup to USB #381

merged 4 commits into from
Apr 29, 2022

Conversation

Uldiniad
Copy link
Contributor

@Uldiniad Uldiniad commented Feb 9, 2022

By default, Android exposes USB devices only to the main user.
In order to query, read and write to it, the signature permission INTERACT_ACROSS_USERS_FULL (optional) is granted to create Seedvault's context as the system user.

Change-Id: I0b1b4c8c5aeeb226419ff94e15f631ebe1db66df
Issue: calyxos#437
Issue: #77

Copy link
Collaborator

@grote grote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I found some minor stuff and will do one last pass before merging, checking all the context usage in the places you touched to make sure we are not accidentally using the wrong context somewhere.

@Uldiniad
Copy link
Contributor Author

02-16 16:35:59.761 12887 12990 E DocumentsStorage: Error finding file blocking
02-16 16:35:59.761 12887 12990 E DocumentsStorage: java.io.IOException
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at com.stevesoltys.seedvault.plugins.saf.DocumentsStorageKt$getLoadedCursor$2.invokeSuspend(DocumentsStorage.kt:281)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at com.stevesoltys.seedvault.plugins.saf.DocumentsStorageKt$getLoadedCursor$2.invoke(Unknown Source:8)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at com.stevesoltys.seedvault.plugins.saf.DocumentsStorageKt$getLoadedCursor$2.invoke(Unknown Source:4)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturnIgnoreTimeout(Undispatched.kt:102)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at kotlinx.coroutines.TimeoutKt.setupTimeout(Timeout.kt:78)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at kotlinx.coroutines.TimeoutKt.access$setupTimeout(Timeout.kt:1)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at kotlinx.coroutines.TimeoutKt.withTimeout(Timeout.kt:31)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at com.stevesoltys.seedvault.plugins.saf.DocumentsStorageKt.getLoadedCursor(DocumentsStorage.kt:279)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at com.stevesoltys.seedvault.plugins.saf.DocumentsStorageKt.getLoadedCursor$default(DocumentsStorage.kt:278)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at com.stevesoltys.seedvault.plugins.saf.DocumentsStorageKt.listFilesBlocking(DocumentsStorage.kt:204)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at com.stevesoltys.seedvault.plugins.saf.DocumentsStorageKt.findFileBlocking(DocumentsStorage.kt:248)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at com.stevesoltys.seedvault.plugins.saf.DocumentsProviderStoragePlugin.hasBackup(DocumentsProviderStoragePlugin.kt:82)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at com.stevesoltys.seedvault.ui.storage.RestoreStorageViewModel$onLocationSet$1.invokeSuspend(RestoreStorageViewModel.kt:28)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
02-16 16:35:59.761 12887 12990 E DocumentsStorage:      at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)

this is the error when save storage is not executed

By default, Android exposes USB devices only to the main user.
In order to query, read and write to it, the signature permission INTERACT_ACROSS_USERS_FULL (optional) is granted to create Seedvault's context as the system user.

Issue: calyxos#437
Issue: #77
Change-Id: I0b1b4c8c5aeeb226419ff94e15f631ebe1db66df
The storage plugin cannot find USB backups for secondary users if it is not saved before checking if backups exist
Incidentally this gets rid of the need to pass an implementation-specific Uri to the StoragePlugin.
@chirayudesai chirayudesai merged commit d598aac into seedvault-app:android12 Apr 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants