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