mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix crash in autofill save workflow
This commit is contained in:
@@ -23,6 +23,7 @@ import android.os.Build
|
|||||||
import android.os.CancellationSignal
|
import android.os.CancellationSignal
|
||||||
import android.service.autofill.*
|
import android.service.autofill.*
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.autofill.AutofillId
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import com.kunzisoft.keepass.R
|
import com.kunzisoft.keepass.R
|
||||||
@@ -111,12 +112,23 @@ class KeeAutofillService : AutofillService() {
|
|||||||
RemoteViews(packageName, R.layout.item_autofill_unlock)
|
RemoteViews(packageName, R.layout.item_autofill_unlock)
|
||||||
}
|
}
|
||||||
// Tell to service the interest to save credentials
|
// Tell to service the interest to save credentials
|
||||||
responseBuilder.setSaveInfo(
|
var types: Int = SaveInfo.SAVE_DATA_TYPE_GENERIC
|
||||||
SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_USERNAME
|
val info = ArrayList<AutofillId>()
|
||||||
or SaveInfo.SAVE_DATA_TYPE_PASSWORD,
|
// Only if at least a password
|
||||||
arrayOf(parseResult.usernameId, parseResult.passwordId)
|
parseResult.passwordId?.let { passwordInfo ->
|
||||||
).build()
|
parseResult.usernameId?.let { usernameInfo ->
|
||||||
)
|
types = types or SaveInfo.SAVE_DATA_TYPE_USERNAME
|
||||||
|
info.add(usernameInfo)
|
||||||
|
}
|
||||||
|
types = types or SaveInfo.SAVE_DATA_TYPE_PASSWORD
|
||||||
|
info.add(passwordInfo)
|
||||||
|
}
|
||||||
|
if (info.isNotEmpty()) {
|
||||||
|
responseBuilder.setSaveInfo(
|
||||||
|
SaveInfo.Builder(types, info.toTypedArray()).build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// Build response
|
||||||
responseBuilder.setAuthentication(autofillIds, sender, remoteViewsUnlock)
|
responseBuilder.setAuthentication(autofillIds, sender, remoteViewsUnlock)
|
||||||
callback.onSuccess(responseBuilder.build())
|
callback.onSuccess(responseBuilder.build())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user