mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
fix: Multiple launch instance
This commit is contained in:
@@ -365,10 +365,6 @@ class FileDatabaseSelectActivity : DatabaseModeActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
mDatabase?.let { database ->
|
||||
launchGroupActivityIfLoaded(database)
|
||||
}
|
||||
|
||||
// Show recent files if allowed
|
||||
if (PreferencesUtil.showRecentFiles(this@FileDatabaseSelectActivity)) {
|
||||
databaseFilesViewModel.loadListOfDatabases()
|
||||
|
||||
@@ -93,7 +93,7 @@ abstract class CredentialLauncherViewModel(application: Application): AndroidVie
|
||||
specialMode: SpecialMode,
|
||||
database: ContextualDatabase?
|
||||
) {
|
||||
database?.let {
|
||||
if (database != null && database.loaded) {
|
||||
onDatabaseRetrieved(database)
|
||||
}
|
||||
if (isResultLauncherRegistered.not()) {
|
||||
|
||||
@@ -155,7 +155,7 @@ class PasskeyLauncherViewModel(application: Application): CredentialLauncherView
|
||||
database: ContextualDatabase?
|
||||
) {
|
||||
// Launch with database when a nodeId is present
|
||||
if (database != null || intent.retrieveNodeId() == null) {
|
||||
if ((database != null && database.loaded) || intent.retrieveNodeId() == null) {
|
||||
super.launchActionIfNeeded(intent, specialMode, database)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat.RECEIVER_NOT_EXPORTED
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.dialogs.DatabaseChangedDialogFragment
|
||||
import com.kunzisoft.keepass.database.crypto.EncryptionAlgorithm
|
||||
import com.kunzisoft.keepass.database.crypto.kdf.KdfEngine
|
||||
import com.kunzisoft.keepass.database.element.Entry
|
||||
@@ -104,11 +103,6 @@ class DatabaseTaskProvider(
|
||||
|
||||
private var serviceConnection: ServiceConnection? = null
|
||||
|
||||
private var intentDatabaseTask: Intent = Intent(
|
||||
context.applicationContext,
|
||||
DatabaseTaskNotificationService::class.java
|
||||
)
|
||||
|
||||
fun destroy() {
|
||||
this.onDatabaseRetrieved = null
|
||||
this.databaseTaskBroadcastReceiver = null
|
||||
@@ -116,13 +110,6 @@ class DatabaseTaskProvider(
|
||||
this.serviceConnection = null
|
||||
}
|
||||
|
||||
private val mActionDatabaseListener =
|
||||
object : DatabaseChangedDialogFragment.ActionDatabaseChangedListener {
|
||||
override fun onDatabaseChangeValidated() {
|
||||
mBinder?.getService()?.saveDatabaseInfo()
|
||||
}
|
||||
}
|
||||
|
||||
fun onDatabaseChangeValidated() {
|
||||
mBinder?.getService()?.saveDatabaseInfo()
|
||||
}
|
||||
@@ -139,10 +126,12 @@ class DatabaseTaskProvider(
|
||||
serviceConnection = object : ServiceConnection {
|
||||
override fun onBindingDied(name: ComponentName?) {
|
||||
actionTaskListener?.onActionStopped()
|
||||
onDatabaseRetrieved?.invoke(null)
|
||||
}
|
||||
|
||||
override fun onNullBinding(name: ComponentName?) {
|
||||
actionTaskListener?.onActionStopped()
|
||||
onDatabaseRetrieved?.invoke(null)
|
||||
}
|
||||
|
||||
override fun onServiceConnected(name: ComponentName?, serviceBinder: IBinder?) {
|
||||
@@ -181,13 +170,17 @@ class DatabaseTaskProvider(
|
||||
service?.removeDatabaseFileInfoListener(infoListener)
|
||||
}
|
||||
service?.removeDatabaseListener(databaseListener)
|
||||
onDatabaseRetrieved?.invoke(null)
|
||||
}
|
||||
|
||||
private fun bindService() {
|
||||
initServiceConnection()
|
||||
serviceConnection?.let {
|
||||
context.bindService(
|
||||
intentDatabaseTask,
|
||||
Intent(
|
||||
context.applicationContext,
|
||||
DatabaseTaskNotificationService::class.java
|
||||
),
|
||||
it,
|
||||
BIND_AUTO_CREATE or BIND_IMPORTANT or BIND_ABOVE_CLIENT
|
||||
)
|
||||
|
||||
@@ -676,6 +676,12 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
|
||||
override fun actionOnLock() {
|
||||
if (!TimeoutHelper.temporarilyDisableLock) {
|
||||
closeDatabase(mDatabase)
|
||||
// Remove the database during the lock
|
||||
// And notify each subscriber
|
||||
mDatabase = null
|
||||
mDatabaseListeners.forEach { listener ->
|
||||
listener.onDatabaseRetrieved(null)
|
||||
}
|
||||
// Remove the lock timer (no more needed if it exists)
|
||||
TimeoutHelper.cancelLockTimer(this)
|
||||
// Service is stopped after receive the broadcast
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.kunzisoft.keepass.model.CipherEncryptDatabase
|
||||
import com.kunzisoft.keepass.model.SnapFileDatabaseInfo
|
||||
import com.kunzisoft.keepass.services.DatabaseTaskNotificationService
|
||||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||
import com.kunzisoft.keepass.utils.getBinaryDir
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import java.util.UUID
|
||||
@@ -154,12 +153,6 @@ class DatabaseViewModel(application: Application): AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
|
||||
fun closeDatabase() {
|
||||
database?.clearAndClose(
|
||||
filesDirectory = getApplication<Application>().getBinaryDir()
|
||||
)
|
||||
}
|
||||
|
||||
fun onDatabaseChangeValidated() {
|
||||
mDatabaseTaskProvider.onDatabaseChangeValidated()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user