mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
fix: runtime exception #1649
This commit is contained in:
@@ -3,7 +3,7 @@ KeePassDX(4.0.3)
|
||||
* Fix username autofill #1665 #530 #1572 #1426 #1523 #1556 #1653 #1658 #1508 #1667
|
||||
* Fix regex OTP recognition #1596
|
||||
* Change password color dynamically #1490
|
||||
* Small fixes #1641 #1656
|
||||
* Small fixes #1641 #1656 #1649
|
||||
|
||||
KeePassDX(4.0.2)
|
||||
* Fix Autofill with API 33
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.annotation.RequiresApi
|
||||
@@ -44,6 +45,7 @@ import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.getParcelableCompat
|
||||
import com.kunzisoft.keepass.utils.getParcelableExtraCompat
|
||||
import com.kunzisoft.keepass.utils.WebDomain
|
||||
import java.lang.RuntimeException
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
class AutofillLauncherActivity : DatabaseModeActivity() {
|
||||
@@ -216,6 +218,8 @@ class AutofillLauncherActivity : DatabaseModeActivity() {
|
||||
|
||||
companion object {
|
||||
|
||||
private val TAG = AutofillLauncherActivity::class.java.name
|
||||
|
||||
private const val KEY_SELECTION_BUNDLE = "KEY_SELECTION_BUNDLE"
|
||||
private const val KEY_SEARCH_INFO = "KEY_SEARCH_INFO"
|
||||
private const val KEY_INLINE_SUGGESTION = "KEY_INLINE_SUGGESTION"
|
||||
@@ -224,8 +228,10 @@ class AutofillLauncherActivity : DatabaseModeActivity() {
|
||||
|
||||
fun getPendingIntentForSelection(context: Context,
|
||||
searchInfo: SearchInfo? = null,
|
||||
compatInlineSuggestionsRequest: CompatInlineSuggestionsRequest? = null): PendingIntent {
|
||||
return PendingIntent.getActivity(context, 0,
|
||||
compatInlineSuggestionsRequest: CompatInlineSuggestionsRequest? = null): PendingIntent? {
|
||||
try {
|
||||
return PendingIntent.getActivity(
|
||||
context, 0,
|
||||
// Doesn't work with direct extra Parcelable (don't know why?)
|
||||
// Wrap into a bundle to bypass the problem
|
||||
Intent(context, AutofillLauncherActivity::class.java).apply {
|
||||
@@ -240,12 +246,19 @@ class AutofillLauncherActivity : DatabaseModeActivity() {
|
||||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_CANCEL_CURRENT
|
||||
} else {
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
})
|
||||
}
|
||||
)
|
||||
} catch (e: RuntimeException) {
|
||||
Log.e(TAG, "Unable to create pending intent for selection", e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun getPendingIntentForRegistration(context: Context,
|
||||
registerInfo: RegisterInfo): PendingIntent {
|
||||
return PendingIntent.getActivity(context, 0,
|
||||
registerInfo: RegisterInfo): PendingIntent? {
|
||||
try {
|
||||
return PendingIntent.getActivity(
|
||||
context, 0,
|
||||
Intent(context, AutofillLauncherActivity::class.java).apply {
|
||||
EntrySelectionHelper.addSpecialModeInIntent(this, SpecialMode.REGISTRATION)
|
||||
putExtra(KEY_REGISTER_INFO, registerInfo)
|
||||
@@ -254,7 +267,12 @@ class AutofillLauncherActivity : DatabaseModeActivity() {
|
||||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_CANCEL_CURRENT
|
||||
} else {
|
||||
PendingIntent.FLAG_CANCEL_CURRENT
|
||||
})
|
||||
}
|
||||
)
|
||||
} catch (e: RuntimeException) {
|
||||
Log.e(TAG, "Unable to create pending intent for registration", e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
fun launchForRegistration(context: Context,
|
||||
|
||||
@@ -452,14 +452,19 @@ object AutofillHelper {
|
||||
manualSelection = true
|
||||
}
|
||||
val manualSelectionView = RemoteViews(context.packageName, R.layout.item_autofill_select_entry)
|
||||
val pendingIntent = AutofillLauncherActivity.getPendingIntentForSelection(context,
|
||||
searchInfo, compatInlineSuggestionsRequest)
|
||||
AutofillLauncherActivity.getPendingIntentForSelection(context,
|
||||
searchInfo, compatInlineSuggestionsRequest)?.let { pendingIntent ->
|
||||
|
||||
var inlinePresentation: InlinePresentation? = null
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
compatInlineSuggestionsRequest?.inlineSuggestionsRequest?.let { inlineSuggestionsRequest ->
|
||||
val inlinePresentationSpec = inlineSuggestionsRequest.inlinePresentationSpecs[0]
|
||||
inlinePresentation = buildInlinePresentationForManualSelection(context, inlinePresentationSpec, pendingIntent)
|
||||
val inlinePresentationSpec =
|
||||
inlineSuggestionsRequest.inlinePresentationSpecs[0]
|
||||
inlinePresentation = buildInlinePresentationForManualSelection(
|
||||
context,
|
||||
inlinePresentationSpec,
|
||||
pendingIntent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,6 +499,7 @@ object AutofillHelper {
|
||||
responseBuilder.addDataset(dataset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return try {
|
||||
responseBuilder.build()
|
||||
|
||||
@@ -162,8 +162,8 @@ class KeeAutofillService : AutofillService() {
|
||||
if (autofillIds.isNotEmpty()) {
|
||||
// If the entire Autofill Response is authenticated, AuthActivity is used
|
||||
// to generate Response.
|
||||
val intentSender = AutofillLauncherActivity.getPendingIntentForSelection(this,
|
||||
searchInfo, inlineSuggestionsRequest).intentSender
|
||||
AutofillLauncherActivity.getPendingIntentForSelection(this,
|
||||
searchInfo, inlineSuggestionsRequest)?.intentSender?.let { intentSender ->
|
||||
val responseBuilder = FillResponse.Builder()
|
||||
val remoteViewsUnlock: RemoteViews = if (database == null) {
|
||||
if (!parseResult.webDomain.isNullOrEmpty()) {
|
||||
@@ -198,7 +198,10 @@ class KeeAutofillService : AutofillService() {
|
||||
)
|
||||
}
|
||||
} else if (!parseResult.applicationId.isNullOrEmpty()) {
|
||||
RemoteViews(packageName, R.layout.item_autofill_select_entry_app_id).apply {
|
||||
RemoteViews(
|
||||
packageName,
|
||||
R.layout.item_autofill_select_entry_app_id
|
||||
).apply {
|
||||
setTextViewText(
|
||||
R.id.autofill_app_id_text,
|
||||
parseResult.applicationId
|
||||
@@ -248,35 +251,47 @@ class KeeAutofillService : AutofillService() {
|
||||
|
||||
// Build inline presentation
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
||||
&& autofillInlineSuggestionsEnabled) {
|
||||
&& autofillInlineSuggestionsEnabled
|
||||
) {
|
||||
var inlinePresentation: InlinePresentation? = null
|
||||
inlineSuggestionsRequest?.inlineSuggestionsRequest?.let { inlineSuggestionsRequest ->
|
||||
val inlinePresentationSpecs = inlineSuggestionsRequest.inlinePresentationSpecs
|
||||
val inlinePresentationSpecs =
|
||||
inlineSuggestionsRequest.inlinePresentationSpecs
|
||||
if (inlineSuggestionsRequest.maxSuggestionCount > 0
|
||||
&& inlinePresentationSpecs.size > 0) {
|
||||
&& inlinePresentationSpecs.size > 0
|
||||
) {
|
||||
val inlinePresentationSpec = inlinePresentationSpecs[0]
|
||||
|
||||
// Make sure that the IME spec claims support for v1 UI template.
|
||||
val imeStyle = inlinePresentationSpec.style
|
||||
if (UiVersions.getVersions(imeStyle).contains(UiVersions.INLINE_UI_VERSION_1)) {
|
||||
if (UiVersions.getVersions(imeStyle)
|
||||
.contains(UiVersions.INLINE_UI_VERSION_1)
|
||||
) {
|
||||
// Build the content for IME UI
|
||||
inlinePresentation = InlinePresentation(
|
||||
InlineSuggestionUi.newContentBuilder(
|
||||
PendingIntent.getActivity(this,
|
||||
PendingIntent.getActivity(
|
||||
this,
|
||||
0,
|
||||
Intent(this, AutofillSettingsActivity::class.java),
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
PendingIntent.FLAG_IMMUTABLE
|
||||
} else {
|
||||
0
|
||||
})
|
||||
}
|
||||
)
|
||||
).apply {
|
||||
setContentDescription(getString(R.string.autofill_sign_in_prompt))
|
||||
setTitle(getString(R.string.autofill_sign_in_prompt))
|
||||
setStartIcon(Icon.createWithResource(this@KeeAutofillService, R.mipmap.ic_launcher_round).apply {
|
||||
setStartIcon(
|
||||
Icon.createWithResource(
|
||||
this@KeeAutofillService,
|
||||
R.mipmap.ic_launcher_round
|
||||
).apply {
|
||||
setTintBlendMode(BlendMode.DST)
|
||||
})
|
||||
}.build().slice, inlinePresentationSpec, false)
|
||||
}.build().slice, inlinePresentationSpec, false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,20 +313,35 @@ class KeeAutofillService : AutofillService() {
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Unable to use the new setAuthentication method.", e)
|
||||
@Suppress("DEPRECATION")
|
||||
responseBuilder.setAuthentication(autofillIds, intentSender, remoteViewsUnlock, inlinePresentation)
|
||||
responseBuilder.setAuthentication(
|
||||
autofillIds,
|
||||
intentSender,
|
||||
remoteViewsUnlock,
|
||||
inlinePresentation
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
responseBuilder.setAuthentication(autofillIds, intentSender, remoteViewsUnlock, inlinePresentation)
|
||||
responseBuilder.setAuthentication(
|
||||
autofillIds,
|
||||
intentSender,
|
||||
remoteViewsUnlock,
|
||||
inlinePresentation
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
responseBuilder.setAuthentication(autofillIds, intentSender, remoteViewsUnlock)
|
||||
responseBuilder.setAuthentication(
|
||||
autofillIds,
|
||||
intentSender,
|
||||
remoteViewsUnlock
|
||||
)
|
||||
}
|
||||
success = true
|
||||
callback.onSuccess(responseBuilder.build())
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!success)
|
||||
callback.onFailure("Unable to get Autofill ids for UI selection")
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
* Fix username autofill #1665 #530 #1572 #1426 #1523 #1556 #1653 #1658 #1508 #1667
|
||||
* Fix regex OTP recognition #1596
|
||||
* Change password color dynamically #1490
|
||||
* Small fixes #1641 #1656
|
||||
* Small fixes #1641 #1656 #1649
|
||||
@@ -2,4 +2,4 @@
|
||||
* Correction du nom d'utilisateur dans la reconnaissance automatique #1665 #530 #1572 #1426 #1523 #1556 #1653 #1658 #1508 #1667
|
||||
* Correction de la regex de reconnaissance OTP #1596
|
||||
* Changement de couleur de mot passe dynamique #1490
|
||||
* Petites corrections #1641 #1656
|
||||
* Petites corrections #1641 #1656 #1649
|
||||
|
||||
Reference in New Issue
Block a user