Re-ask only on wrong password
This commit is contained in:
parent
393c458495
commit
cb3fc3c70e
1
TODO.md
1
TODO.md
@ -8,6 +8,7 @@ Here's a list of features that it would be nice to have in DroidFS. As this is a
|
||||
|
||||
## UX
|
||||
- File associations editor
|
||||
- Optional file discovery before file operations
|
||||
- Modifiable CryFS scrypt parameters
|
||||
- Alert dialog showing details of file operations
|
||||
- Internal file browser to select volumes
|
||||
|
@ -190,8 +190,10 @@ class VolumeOpener(
|
||||
.setTitle(R.string.open_volume_failed)
|
||||
.setMessage(getErrorMsg(result))
|
||||
.setPositiveButton(R.string.ok) { _, _ ->
|
||||
if (result.worthRetry) {
|
||||
askForPassword(volume, isVolumeSaved, callbacks, savePasswordHash)
|
||||
}
|
||||
}
|
||||
.show()
|
||||
} else {
|
||||
val fingerprintProtector = fingerprintProtector
|
||||
|
@ -20,6 +20,8 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.yield
|
||||
import sushi.hardcore.droidfs.Constants
|
||||
import sushi.hardcore.droidfs.R
|
||||
@ -124,7 +126,8 @@ class FileOperationService : Service() {
|
||||
|
||||
private suspend fun <T> waitForTask(notification: FileOperationNotification, task: Deferred<T>): TaskResult<out T> {
|
||||
tasks[notification.notificationId] = task
|
||||
return serviceScope.async {
|
||||
return coroutineScope {
|
||||
withContext(serviceScope.coroutineContext) {
|
||||
try {
|
||||
TaskResult.completed(task.await())
|
||||
} catch (e: CancellationException) {
|
||||
@ -135,7 +138,8 @@ class FileOperationService : Service() {
|
||||
} finally {
|
||||
cancelNotification(notification)
|
||||
}
|
||||
}.await()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun <T> volumeTask(
|
||||
|
@ -68,7 +68,10 @@ class CryfsVolume(private val fusePtr: Long): EncryptedVolume() {
|
||||
result.errorCode = errorCode.value ?: 0
|
||||
result.errorStringId = when (errorCode.value) {
|
||||
// Values from src/cryfs/impl/ErrorCodes.h
|
||||
11 -> R.string.wrong_password
|
||||
11 -> {
|
||||
result.worthRetry = true
|
||||
R.string.wrong_password
|
||||
}
|
||||
16 -> R.string.inaccessible_base_dir
|
||||
19 -> R.string.config_load_error
|
||||
20 -> R.string.filesystem_id_changed
|
||||
|
@ -8,7 +8,6 @@ import sushi.hardcore.droidfs.Constants
|
||||
import sushi.hardcore.droidfs.VolumeData
|
||||
import sushi.hardcore.droidfs.explorers.ExplorerElement
|
||||
import sushi.hardcore.droidfs.util.ObjRef
|
||||
import sushi.hardcore.droidfs.util.PathUtils
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.InputStream
|
||||
@ -16,13 +15,19 @@ import java.io.OutputStream
|
||||
|
||||
abstract class EncryptedVolume: Parcelable {
|
||||
|
||||
class InitResult(val errorCode: Int, val errorStringId: Int, val volume: EncryptedVolume?) {
|
||||
class InitResult(
|
||||
val errorCode: Int,
|
||||
val errorStringId: Int,
|
||||
val worthRetry: Boolean,
|
||||
val volume: EncryptedVolume?,
|
||||
) {
|
||||
class Builder {
|
||||
var errorCode = 0
|
||||
var errorStringId = 0
|
||||
var worthRetry = false
|
||||
var volume: EncryptedVolume? = null
|
||||
|
||||
fun build() = InitResult(errorCode, errorStringId, volume)
|
||||
fun build() = InitResult(errorCode, errorStringId, worthRetry, volume)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,10 @@ class GocryptfsVolume(private val sessionID: Int): EncryptedVolume() {
|
||||
result.errorCode = sessionId
|
||||
result.errorStringId = when (sessionId) {
|
||||
-1 -> R.string.config_load_error
|
||||
-2 -> R.string.wrong_password
|
||||
-2 -> {
|
||||
result.worthRetry = true
|
||||
R.string.wrong_password
|
||||
}
|
||||
else -> 0
|
||||
}
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user