forked from hardcoresushi/DroidFS
usf_keep_volume_open & Closing volume on fingerprint auth failed
This commit is contained in:
parent
9a8023fc33
commit
e5413653d0
@ -191,6 +191,15 @@ class CreateActivity : VolumeActionActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
//Closing volume if leaving activity while showing dialog
|
||||
if (sessionID != -1){
|
||||
GocryptfsVolume(sessionID).close()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
Wiper.wipeEditText(edit_password)
|
||||
|
@ -163,8 +163,12 @@ class OpenActivity : VolumeActionActivity() {
|
||||
}
|
||||
if (checkbox_save_password.isChecked && returnedHash != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
|
||||
stopTask {
|
||||
savePasswordHash(returnedHash) {
|
||||
startExplorer()
|
||||
savePasswordHash(returnedHash) { success ->
|
||||
if (success){
|
||||
startExplorer()
|
||||
} else {
|
||||
GocryptfsVolume(sessionID).close()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -3,7 +3,6 @@ package sushi.hardcore.droidfs
|
||||
import android.app.KeyguardManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.security.keystore.KeyGenParameterSpec
|
||||
import android.security.keystore.KeyPermanentlyInvalidatedException
|
||||
import android.security.keystore.KeyProperties
|
||||
@ -54,13 +53,20 @@ open class VolumeActionActivity : BaseActivity() {
|
||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
||||
super.onAuthenticationError(errorCode, errString)
|
||||
Toast.makeText(applicationContext, errString, Toast.LENGTH_SHORT).show()
|
||||
if (actionMode == Cipher.ENCRYPT_MODE){
|
||||
onAuthenticationResult(false)
|
||||
}
|
||||
}
|
||||
override fun onAuthenticationFailed() {
|
||||
super.onAuthenticationFailed()
|
||||
Toast.makeText(applicationContext, R.string.authentication_failed, Toast.LENGTH_SHORT).show()
|
||||
if (actionMode == Cipher.ENCRYPT_MODE){
|
||||
onAuthenticationResult(false)
|
||||
}
|
||||
}
|
||||
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
|
||||
super.onAuthenticationSucceeded(result)
|
||||
var success = false
|
||||
val cipherObject = result.cryptoObject?.cipher
|
||||
if (cipherObject != null){
|
||||
try {
|
||||
@ -72,7 +78,7 @@ open class VolumeActionActivity : BaseActivity() {
|
||||
val sharedPrefsEditor = sharedPrefs.edit()
|
||||
sharedPrefsEditor.putString(rootCipherDir, "$encodedIv:$encodedCipherText")
|
||||
sharedPrefsEditor.apply()
|
||||
onAuthenticationResult(true)
|
||||
success = true
|
||||
}
|
||||
Cipher.DECRYPT_MODE -> {
|
||||
try {
|
||||
@ -103,6 +109,9 @@ open class VolumeActionActivity : BaseActivity() {
|
||||
} else {
|
||||
Toast.makeText(applicationContext, R.string.error_cipher_null, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
if (actionMode == Cipher.ENCRYPT_MODE){
|
||||
onAuthenticationResult(success)
|
||||
}
|
||||
}
|
||||
}
|
||||
biometricPrompt = BiometricPrompt(this, executor, callback)
|
||||
|
@ -56,9 +56,11 @@ open class BaseExplorerActivity : BaseActivity() {
|
||||
private var isCreating = true
|
||||
protected var isStartingActivity = false
|
||||
private var usf_open = false
|
||||
protected var usf_keep_open = false
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
usf_open = sharedPrefs.getBoolean("usf_open", false)
|
||||
usf_keep_open = sharedPrefs.getBoolean("usf_keep_open", false)
|
||||
val intent = intent
|
||||
volumeName = intent.getStringExtra("volume_name") ?: ""
|
||||
val sessionID = intent.getIntExtra("sessionID", -1)
|
||||
@ -434,7 +436,7 @@ open class BaseExplorerActivity : BaseActivity() {
|
||||
if (!isChangingConfigurations){
|
||||
if (isStartingActivity){
|
||||
isStartingActivity = false
|
||||
} else {
|
||||
} else if (!usf_keep_open){
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class ExplorerActivityPick : BaseExplorerActivity() {
|
||||
}
|
||||
|
||||
override fun closeVolumeOnDestroy() {
|
||||
if (!isFinishingIntentionally){
|
||||
if (!isFinishingIntentionally && !usf_keep_open){
|
||||
val sessionID = intent.getIntExtra("originalSessionID", -1)
|
||||
if (sessionID != -1){
|
||||
val v = GocryptfsVolume(sessionID)
|
||||
|
@ -12,11 +12,13 @@ abstract class FileViewerActivity: BaseActivity() {
|
||||
lateinit var gocryptfsVolume: GocryptfsVolume
|
||||
lateinit var filePath: String
|
||||
private var isFinishingIntentionally = false
|
||||
protected var usf_keep_open = false
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
filePath = intent.getStringExtra("path")!!
|
||||
val sessionID = intent.getIntExtra("sessionID", -1)
|
||||
gocryptfsVolume = GocryptfsVolume(sessionID)
|
||||
usf_keep_open = sharedPrefs.getBoolean("usf_keep_open", false)
|
||||
hideSystemUi()
|
||||
viewFile()
|
||||
}
|
||||
@ -99,7 +101,9 @@ abstract class FileViewerActivity: BaseActivity() {
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
finish()
|
||||
if (!usf_keep_open) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
@ -97,6 +97,7 @@
|
||||
<string name="usf_screenshot">Allow screenshots</string>
|
||||
<string name="usf_fingerprint">Allow saving password hash using fingerprint</string>
|
||||
<string name="usf_volume_management">Volume Management</string>
|
||||
<string name="usf_keep_open">Keep volume open when the app goes in background</string>
|
||||
<string name="unsafe_features">Unsafe Features</string>
|
||||
<string name="manage_unsafe_features">Manage unsafe features</string>
|
||||
<string name="manage_unsafe_features_summary">Enable/Disable unsafe features</string>
|
||||
|
@ -31,6 +31,12 @@
|
||||
android:title="@string/usf_share"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:icon="@drawable/icon_decrypt"
|
||||
android:key="usf_keep_open"
|
||||
android:title="@string/usf_keep_open"
|
||||
android:defaultValue="false"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
Loading…
Reference in New Issue
Block a user