@@ -26,6 +26,7 @@ import eu.europa.ec.eudi.wallet.document.DocumentManager
2626import eu.europa.ec.eudi.wallet.document.IssuedDocument
2727import eu.europa.ec.eudi.wallet.document.format.MsoMdocData
2828import eu.europa.ec.eudi.wallet.document.format.MsoMdocFormat
29+ import eu.europa.ec.eudi.wallet.document.metadata.IssuerMetadata
2930import eu.europa.ec.eudi.wallet.internal.d
3031import eu.europa.ec.eudi.wallet.internal.e
3132import eu.europa.ec.eudi.wallet.logging.Logger
@@ -108,18 +109,14 @@ class DCAPIIsoMdocRegistration(
108109 )
109110
110111 // Try to get document logo provided by issuer else use an empty byte array
111- val bitmapBytes = document.issuerMetadata?.display?.find {
112- it.locale?.language == context.getLocale().language
113- }?.logo?.uri?.let { uri ->
114- getLogo(uri.toURL())?.let { logoBytes ->
115- BitmapFactory .decodeByteArray(logoBytes, 0 , logoBytes.size).getIconBytes()
116- }
112+ val bitmapBytes = document.issuerMetadata?.let {
113+ getBitmapBytes(it)
117114 } ? : byteArrayOf(0 )
118115
119116 docsBuilder.Add (CBORObject .NewMap ().apply {
120117 Add (TITLE , document.name)
121118 Add (SUBTITLE , context.getAppName())
122- Add (BITMAP , bitmapBytes)
119+ Add (BITMAP , bitmapBytes)
123120 Add (MDOC , CBORObject .NewMap ().apply {
124121 Add (ID , document.id)
125122 Add (DOC_TYPE , docType)
@@ -154,6 +151,20 @@ class DCAPIIsoMdocRegistration(
154151 return credentialBytes
155152 }
156153
154+ private suspend fun getBitmapBytes (issuerMetadata : IssuerMetadata ): ByteArray {
155+ return try {
156+ issuerMetadata.display.find {
157+ it.locale?.language == context.getLocale().language
158+ }?.logo?.uri?.let { uri ->
159+ getLogo(uri.toURL())?.let { logoBytes ->
160+ BitmapFactory .decodeByteArray(logoBytes, 0 , logoBytes.size).getIconBytes()
161+ }
162+ } ? : byteArrayOf(0 )
163+ } catch (_: Exception ) {
164+ byteArrayOf(0 )
165+ }
166+ }
167+
157168 private suspend fun getLogo (url : URL ): ByteArray? = withContext(ioDispatcher) {
158169 try {
159170 (url.openConnection() as ? HttpURLConnection )?.run {
0 commit comments