diff --git a/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt index 9bb36a4..0b48ebd 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/ChangePasswordActivity.kt @@ -110,7 +110,14 @@ class ChangePasswordActivity : BaseActivity() { if (rootCipherDir.isEmpty()) { Toast.makeText(this, R.string.enter_volume_path, Toast.LENGTH_SHORT).show() } else { - if (!File(rootCipherDir).canWrite()){ + val rootCipherDirFile = File(rootCipherDir) + if (!GocryptfsVolume.isGocryptfsVolume(rootCipherDirFile)){ + ColoredAlertDialogBuilder(this) + .setTitle(R.string.error) + .setMessage(R.string.error_not_a_volume) + .setPositiveButton(R.string.ok, null) + .show() + } else if (!rootCipherDirFile.canWrite()){ ColoredAlertDialogBuilder(this) .setTitle(R.string.warning) .setMessage(R.string.change_pwd_cant_write_error_msg) diff --git a/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt b/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt index c7d3577..c7cc0a6 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/ConstValues.kt @@ -6,6 +6,7 @@ import java.io.File class ConstValues { companion object { const val creator = "DroidFS" + const val gocryptfsConfFilename = "gocryptfs.conf" const val saved_volumes_key = "saved_volumes" const val sort_order_key = "sort_order" val fakeUri: Uri = Uri.parse("fakeuri://droidfs") diff --git a/app/src/main/java/sushi/hardcore/droidfs/OpenActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/OpenActivity.kt index cd820df..1f9d8b2 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/OpenActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/OpenActivity.kt @@ -115,7 +115,14 @@ class OpenActivity : BaseActivity() { if (rootCipherDir.isEmpty()) { Toast.makeText(this, R.string.enter_volume_path, Toast.LENGTH_SHORT).show() } else { - if (!File(rootCipherDir).canWrite()){ + val rootCipherDirFile = File(rootCipherDir) + if (!GocryptfsVolume.isGocryptfsVolume(rootCipherDirFile)){ + ColoredAlertDialogBuilder(this) + .setTitle(R.string.error) + .setMessage(R.string.error_not_a_volume) + .setPositiveButton(R.string.ok, null) + .show() + } else if (!rootCipherDirFile.canWrite()) { ColoredAlertDialogBuilder(this) .setTitle(R.string.warning) .setMessage(R.string.open_cant_write_warning) diff --git a/app/src/main/java/sushi/hardcore/droidfs/util/GocryptfsVolume.kt b/app/src/main/java/sushi/hardcore/droidfs/util/GocryptfsVolume.kt index 922ebb0..6215cde 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/util/GocryptfsVolume.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/util/GocryptfsVolume.kt @@ -2,7 +2,9 @@ package sushi.hardcore.droidfs.util import android.content.Context import android.net.Uri +import sushi.hardcore.droidfs.ConstValues import sushi.hardcore.droidfs.explorers.ExplorerElement +import java.io.File import java.io.FileOutputStream import java.io.InputStream import java.io.OutputStream @@ -32,6 +34,13 @@ class GocryptfsVolume(var sessionID: Int) { external fun init(root_cipher_dir: String, password: CharArray?, givenHash: ByteArray?, returnedHash: ByteArray?): Int external fun changePassword(root_cipher_dir: String, old_password: CharArray?, givenHash: ByteArray?, new_password: CharArray, returnedHash: ByteArray?): Boolean + fun isGocryptfsVolume(path: File): Boolean { + if (path.isDirectory){ + return File(path, ConstValues.gocryptfsConfFilename).isFile + } + return false + } + init { System.loadLibrary("gocryptfs_jni") } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3585899..5e5c726 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,7 +33,7 @@ The volume has been successfully created. The volume creation has failed. Open failed - Failed to open the volume. Check the selected volume path and the entered password. + Failed to open the volume. Please check your password. Share File Storage unavailable DroidFS can\'t work without storage access. @@ -68,7 +68,7 @@ New Password (confirmation): Password successfully changed ! The volume\'s password has been successfully changed. - Failed to change the volume\'s password. Check the selected volume path and the entered old password. + Operation failed. Please check your old password. Encrypt with DroidFS Failed to handle the share request. Unable to access this directory @@ -177,4 +177,5 @@ Image changes successfully saved. Failed to compress the bitmap. Failed to write the file. + Gocryptfs volume not recognized. Please check the selected path.