Compare commits

..

5 Commits

Author SHA1 Message Date
J-Jamet
e6f082adfd Merge branch 'release/2.10.5' 2021-06-21 17:57:03 +02:00
J-Jamet
bb2f641073 Update to 2.10.5 2021-06-19 20:50:28 +02:00
J-Jamet
de6312d317 Fix binding service #1028 2021-06-19 19:42:26 +02:00
J-Jamet
887b0f3119 Revert #1018 and change runOnUIThread by lifecyclescope(main) 2021-06-19 12:12:26 +02:00
J-Jamet
3dad6daa2e Merge tag '2.10.4' into develop
2.10.4
2021-06-15 12:57:35 +02:00
8 changed files with 27 additions and 42 deletions

View File

@@ -1,3 +1,7 @@
KeePassDX(2.10.5)
* Increase the saving speed of database #1028
* Fix advanced unlocking by device credential #1029
KeePassDX(2.10.4) KeePassDX(2.10.4)
* Hot fix to increase the opening speed of database #1028 * Hot fix to increase the opening speed of database #1028

View File

@@ -11,8 +11,8 @@ android {
applicationId "com.kunzisoft.keepass" applicationId "com.kunzisoft.keepass"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 30 targetSdkVersion 30
versionCode = 82 versionCode = 83
versionName = "2.10.4" versionName = "2.10.5"
multiDexEnabled true multiDexEnabled true
testApplicationId = "com.kunzisoft.keepass.tests" testApplicationId = "com.kunzisoft.keepass.tests"

View File

@@ -462,11 +462,6 @@ open class PasswordActivity : SpecialModeActivity(), AdvancedUnlockFragment.Buil
override fun onPause() { override fun onPause() {
mProgressDatabaseTaskProvider?.unregisterProgressTask() mProgressDatabaseTaskProvider?.unregisterProgressTask()
// To prevent biometric prompt to appearing outside of the app
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
advancedUnlockFragment?.disconnect(hideViews = false, closePrompt = true)
}
// Reinit locking activity UI variable // Reinit locking activity UI variable
LockingActivity.LOCKING_ACTIVITY_UI_VISIBLE_DURING_LOCK = null LockingActivity.LOCKING_ACTIVITY_UI_VISIBLE_DURING_LOCK = null
mAllowAutoOpenBiometricPrompt = true mAllowAutoOpenBiometricPrompt = true

View File

@@ -30,6 +30,7 @@ import android.view.*
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import androidx.biometric.BiometricManager import androidx.biometric.BiometricManager
import androidx.biometric.BiometricPrompt import androidx.biometric.BiometricPrompt
import androidx.lifecycle.lifecycleScope
import com.getkeepsafe.taptargetview.TapTargetView import com.getkeepsafe.taptargetview.TapTargetView
import com.kunzisoft.keepass.R import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.activities.stylish.StylishFragment import com.kunzisoft.keepass.activities.stylish.StylishFragment
@@ -38,6 +39,8 @@ import com.kunzisoft.keepass.database.exception.IODatabaseException
import com.kunzisoft.keepass.education.PasswordActivityEducation import com.kunzisoft.keepass.education.PasswordActivityEducation
import com.kunzisoft.keepass.settings.PreferencesUtil import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.view.AdvancedUnlockInfoView import com.kunzisoft.keepass.view.AdvancedUnlockInfoView
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedUnlockCallback { class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedUnlockCallback {
@@ -309,7 +312,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
private fun openAdvancedUnlockPrompt(cryptoPrompt: AdvancedUnlockCryptoPrompt) { private fun openAdvancedUnlockPrompt(cryptoPrompt: AdvancedUnlockCryptoPrompt) {
activity?.runOnUiThread { lifecycleScope.launch(Dispatchers.Main) {
if (allowOpenBiometricPrompt) { if (allowOpenBiometricPrompt) {
if (cryptoPrompt.isDeviceCredentialOperation) if (cryptoPrompt.isDeviceCredentialOperation)
keepConnection = true keepConnection = true
@@ -450,7 +453,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
} }
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) { override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
activity?.runOnUiThread { lifecycleScope.launch(Dispatchers.Main) {
Log.e(TAG, "Biometric authentication error. Code : $errorCode Error : $errString") Log.e(TAG, "Biometric authentication error. Code : $errorCode Error : $errString")
setAdvancedUnlockedMessageView(errString.toString()) setAdvancedUnlockedMessageView(errString.toString())
} }
@@ -458,7 +461,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
override fun onAuthenticationFailed() { override fun onAuthenticationFailed() {
activity?.runOnUiThread { lifecycleScope.launch(Dispatchers.Main) {
Log.e(TAG, "Biometric authentication failed, biometric not recognized") Log.e(TAG, "Biometric authentication failed, biometric not recognized")
setAdvancedUnlockedMessageView(R.string.advanced_unlock_not_recognized) setAdvancedUnlockedMessageView(R.string.advanced_unlock_not_recognized)
} }
@@ -466,7 +469,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
override fun onAuthenticationSucceeded() { override fun onAuthenticationSucceeded() {
activity?.runOnUiThread { lifecycleScope.launch(Dispatchers.Main) {
when (biometricMode) { when (biometricMode) {
Mode.BIOMETRIC_UNAVAILABLE -> { Mode.BIOMETRIC_UNAVAILABLE -> {
} }
@@ -524,7 +527,7 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
} }
private fun showViews(show: Boolean) { private fun showViews(show: Boolean) {
activity?.runOnUiThread { lifecycleScope.launch(Dispatchers.Main) {
mAdvancedUnlockInfoView?.visibility = if (show) mAdvancedUnlockInfoView?.visibility = if (show)
View.VISIBLE View.VISIBLE
else { else {
@@ -535,20 +538,20 @@ class AdvancedUnlockFragment: StylishFragment(), AdvancedUnlockManager.AdvancedU
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
private fun setAdvancedUnlockedTitleView(textId: Int) { private fun setAdvancedUnlockedTitleView(textId: Int) {
activity?.runOnUiThread { lifecycleScope.launch(Dispatchers.Main) {
mAdvancedUnlockInfoView?.setTitle(textId) mAdvancedUnlockInfoView?.setTitle(textId)
} }
} }
@RequiresApi(Build.VERSION_CODES.M) @RequiresApi(Build.VERSION_CODES.M)
private fun setAdvancedUnlockedMessageView(textId: Int) { private fun setAdvancedUnlockedMessageView(textId: Int) {
activity?.runOnUiThread { lifecycleScope.launch(Dispatchers.Main) {
mAdvancedUnlockInfoView?.setMessage(textId) mAdvancedUnlockInfoView?.setMessage(textId)
} }
} }
private fun setAdvancedUnlockedMessageView(text: CharSequence) { private fun setAdvancedUnlockedMessageView(text: CharSequence) {
activity?.runOnUiThread { lifecycleScope.launch(Dispatchers.Main) {
mAdvancedUnlockInfoView?.message = text mAdvancedUnlockInfoView?.message = text
} }
} }

View File

@@ -23,7 +23,6 @@ import android.content.*
import android.content.Context.BIND_ABOVE_CLIENT import android.content.Context.BIND_ABOVE_CLIENT
import android.content.Context.BIND_NOT_FOREGROUND import android.content.Context.BIND_NOT_FOREGROUND
import android.net.Uri import android.net.Uri
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
@@ -286,11 +285,6 @@ class ProgressDatabaseTaskProvider(private val activity: FragmentActivity) {
readOnly: Boolean, readOnly: Boolean,
cipherEntity: CipherDatabaseEntity?, cipherEntity: CipherDatabaseEntity?,
fixDuplicateUuid: Boolean) { fixDuplicateUuid: Boolean) {
try {
activity.stopService(intentDatabaseTask)
} catch (e: Exception) {
Log.e(TAG, "Unable to stop the service", e)
}
start(Bundle().apply { start(Bundle().apply {
putParcelable(DatabaseTaskNotificationService.DATABASE_URI_KEY, databaseUri) putParcelable(DatabaseTaskNotificationService.DATABASE_URI_KEY, databaseUri)
putParcelable(DatabaseTaskNotificationService.MAIN_CREDENTIAL_KEY, mainCredential) putParcelable(DatabaseTaskNotificationService.MAIN_CREDENTIAL_KEY, mainCredential)

View File

@@ -19,9 +19,7 @@
*/ */
package com.kunzisoft.keepass.services package com.kunzisoft.keepass.services
import android.app.ActivityManager
import android.app.PendingIntent import android.app.PendingIntent
import android.content.Context
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
import android.os.* import android.os.*
@@ -50,7 +48,6 @@ import com.kunzisoft.keepass.utils.*
import com.kunzisoft.keepass.viewmodels.FileDatabaseInfo import com.kunzisoft.keepass.viewmodels.FileDatabaseInfo
import kotlinx.coroutines.* import kotlinx.coroutines.*
import java.util.* import java.util.*
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
open class DatabaseTaskNotificationService : LockNotificationService(), ProgressTaskUpdater { open class DatabaseTaskNotificationService : LockNotificationService(), ProgressTaskUpdater {
@@ -63,7 +60,6 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
private var mActionTaskBinder = ActionTaskBinder() private var mActionTaskBinder = ActionTaskBinder()
private var mActionTaskListeners = LinkedList<ActionTaskListener>() private var mActionTaskListeners = LinkedList<ActionTaskListener>()
private var mAllowFinishAction = AtomicBoolean()
private var mActionRunning = false private var mActionRunning = false
private var mDatabaseInfoListeners = LinkedList<DatabaseInfoListener>() private var mDatabaseInfoListeners = LinkedList<DatabaseInfoListener>()
@@ -86,19 +82,17 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
fun getService(): DatabaseTaskNotificationService = this@DatabaseTaskNotificationService fun getService(): DatabaseTaskNotificationService = this@DatabaseTaskNotificationService
fun addActionTaskListener(actionTaskListener: ActionTaskListener) { fun addActionTaskListener(actionTaskListener: ActionTaskListener) {
mAllowFinishAction.set(true) if (!mActionTaskListeners.contains(actionTaskListener))
mActionTaskListeners.add(actionTaskListener) mActionTaskListeners.add(actionTaskListener)
} }
fun removeActionTaskListener(actionTaskListener: ActionTaskListener) { fun removeActionTaskListener(actionTaskListener: ActionTaskListener) {
mActionTaskListeners.remove(actionTaskListener) mActionTaskListeners.remove(actionTaskListener)
if (mActionTaskListeners.size == 0) {
mAllowFinishAction.set(false)
}
} }
fun addDatabaseFileInfoListener(databaseInfoListener: DatabaseInfoListener) { fun addDatabaseFileInfoListener(databaseInfoListener: DatabaseInfoListener) {
mDatabaseInfoListeners.add(databaseInfoListener) if (!mDatabaseInfoListeners.contains(databaseInfoListener))
mDatabaseInfoListeners.add(databaseInfoListener)
} }
fun removeDatabaseFileInfoListener(databaseInfoListener: DatabaseInfoListener) { fun removeDatabaseFileInfoListener(databaseInfoListener: DatabaseInfoListener) {
@@ -236,6 +230,8 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
mainScope.launch { mainScope.launch {
executeAction(this@DatabaseTaskNotificationService, executeAction(this@DatabaseTaskNotificationService,
{ {
TimeoutHelper.temporarilyDisableTimeout()
mActionRunning = true mActionRunning = true
sendBroadcast(Intent(DATABASE_START_TASK_ACTION).apply { sendBroadcast(Intent(DATABASE_START_TASK_ACTION).apply {
@@ -427,23 +423,12 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
onPreExecute: () -> Unit, onPreExecute: () -> Unit,
onExecute: (ProgressTaskUpdater?) -> ActionRunnable?, onExecute: (ProgressTaskUpdater?) -> ActionRunnable?,
onPostExecute: (result: ActionRunnable.Result) -> Unit) { onPostExecute: (result: ActionRunnable.Result) -> Unit) {
mAllowFinishAction.set(false)
TimeoutHelper.temporarilyDisableTimeout()
onPreExecute.invoke() onPreExecute.invoke()
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
onExecute.invoke(progressTaskUpdater)?.apply { onExecute.invoke(progressTaskUpdater)?.apply {
val asyncResult: Deferred<ActionRunnable.Result> = async { val asyncResult: Deferred<ActionRunnable.Result> = async {
val startTime = System.currentTimeMillis()
var timeIsUp = false
// Run the actionRunnable // Run the actionRunnable
run() run()
// Wait onBind or 4 seconds max
while (!mAllowFinishAction.get() && !timeIsUp) {
delay(100)
if (startTime + 4000 < System.currentTimeMillis())
timeIsUp = true
}
result result
} }
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {

View File

@@ -0,0 +1,2 @@
* Increase the saving speed of database #1028
* Fix advanced unlocking by device credential #1029

View File

@@ -0,0 +1,2 @@
* Augmentation de la rapidité de sauvegarde de la base de données #1028
* Correction du déverouillage avancé #1029