mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-12-04 15:52:34 -08:00
Revert "fix: Base64 encoder as external library"
This reverts commit 13f2003fed.
This commit is contained in:
1 parent
111a77d984
commit
09cf8aabf6
11 files changed
+44
-48
No files matched your search
@@ -25,9 +25,9 @@ import com.kunzisoft.keepass.app.database.CipherDatabaseAction
|
||||
import com.kunzisoft.keepass.app.database.FileDatabaseHistoryAction
|
||||
import com.kunzisoft.keepass.database.ContextualDatabase
|
||||
import com.kunzisoft.keepass.database.MainCredential
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryData
|
||||
import com.kunzisoft.keepass.database.exception.DatabaseInputException
|
||||
import com.kunzisoft.keepass.database.exception.UnknownDatabaseLocationException
|
||||
import com.kunzisoft.keepass.database.helper.MemoryHelper.canMemoryBeAllocatedInRAM
|
||||
import com.kunzisoft.keepass.hardware.HardwareKey
|
||||
import com.kunzisoft.keepass.model.CipherEncryptDatabase
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
@@ -69,7 +69,7 @@ class LoadDatabaseRunnable(
|
||||
mReadonly,
|
||||
binaryDir,
|
||||
{ memoryWanted ->
|
||||
canMemoryBeAllocatedInRAM(context, memoryWanted)
|
||||
BinaryData.canMemoryBeAllocatedInRAM(context, memoryWanted)
|
||||
},
|
||||
mFixDuplicateUUID,
|
||||
progressTaskUpdater
|
||||
|
||||
@@ -23,9 +23,9 @@ import android.content.Context
|
||||
import android.net.Uri
|
||||
import com.kunzisoft.keepass.database.ContextualDatabase
|
||||
import com.kunzisoft.keepass.database.MainCredential
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryData
|
||||
import com.kunzisoft.keepass.database.exception.DatabaseException
|
||||
import com.kunzisoft.keepass.database.exception.UnknownDatabaseLocationException
|
||||
import com.kunzisoft.keepass.database.helper.MemoryHelper.canMemoryBeAllocatedInRAM
|
||||
import com.kunzisoft.keepass.hardware.HardwareKey
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||
@@ -58,7 +58,7 @@ class MergeDatabaseRunnable(
|
||||
mDatabaseToMergeMainCredential?.toMasterCredential(contentResolver),
|
||||
mDatabaseToMergeChallengeResponseRetriever,
|
||||
{ memoryWanted ->
|
||||
canMemoryBeAllocatedInRAM(context, memoryWanted)
|
||||
BinaryData.canMemoryBeAllocatedInRAM(context, memoryWanted)
|
||||
},
|
||||
progressTaskUpdater
|
||||
)
|
||||
|
||||
@@ -21,9 +21,9 @@ package com.kunzisoft.keepass.database.action
|
||||
|
||||
import android.content.Context
|
||||
import com.kunzisoft.keepass.database.ContextualDatabase
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryData
|
||||
import com.kunzisoft.keepass.database.exception.DatabaseException
|
||||
import com.kunzisoft.keepass.database.exception.UnknownDatabaseLocationException
|
||||
import com.kunzisoft.keepass.database.helper.MemoryHelper.canMemoryBeAllocatedInRAM
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.tasks.ActionRunnable
|
||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||
@@ -51,7 +51,7 @@ class ReloadDatabaseRunnable(
|
||||
context.contentResolver.getUriInputStream(mDatabase.fileUri)
|
||||
?: throw UnknownDatabaseLocationException(),
|
||||
{ memoryWanted ->
|
||||
canMemoryBeAllocatedInRAM(context, memoryWanted)
|
||||
BinaryData.canMemoryBeAllocatedInRAM(context, memoryWanted)
|
||||
},
|
||||
progressTaskUpdater)
|
||||
} catch (e: DatabaseException) {
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.kunzisoft.keepass.database.helper
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
|
||||
object MemoryHelper {
|
||||
|
||||
private const val MAX_BINARY_BYTE = 10485760 // 10 MB
|
||||
|
||||
fun canMemoryBeAllocatedInRAM(context: Context, memoryWanted: Long): Boolean {
|
||||
if (memoryWanted > MAX_BINARY_BYTE)
|
||||
return false
|
||||
val memoryInfo = ActivityManager.MemoryInfo()
|
||||
(context.getSystemService(Context.ACTIVITY_SERVICE)
|
||||
as? ActivityManager?)?.getMemoryInfo(memoryInfo)
|
||||
val availableMemory = memoryInfo.availMem
|
||||
return availableMemory > (memoryWanted * 5)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user