mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Merge pull request #2018 from vector-im/feature/moar_sonar_fixes
Feature/moar sonar fixes
This commit is contained in:
commit
dbd080ca6c
@ -19,9 +19,6 @@ package org.matrix.android.sdk.internal.crypto
|
||||
import android.os.MemoryFile
|
||||
import android.util.Base64
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.MXEncryptedAttachments
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileKey
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
@ -29,6 +26,9 @@ import org.junit.FixMethodOrder
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.MethodSorters
|
||||
import org.matrix.android.sdk.internal.crypto.attachments.MXEncryptedAttachments
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileInfo
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.EncryptedFileKey
|
||||
import java.io.InputStream
|
||||
|
||||
/**
|
||||
@ -40,15 +40,15 @@ import java.io.InputStream
|
||||
class AttachmentEncryptionTest {
|
||||
|
||||
private fun checkDecryption(input: String, encryptedFileInfo: EncryptedFileInfo): String {
|
||||
val `in` = Base64.decode(input, Base64.DEFAULT)
|
||||
val inputAsByteArray = Base64.decode(input, Base64.DEFAULT)
|
||||
|
||||
val inputStream: InputStream
|
||||
|
||||
inputStream = if (`in`.isEmpty()) {
|
||||
`in`.inputStream()
|
||||
inputStream = if (inputAsByteArray.isEmpty()) {
|
||||
inputAsByteArray.inputStream()
|
||||
} else {
|
||||
val memoryFile = MemoryFile("file" + System.currentTimeMillis(), `in`.size)
|
||||
memoryFile.outputStream.write(`in`)
|
||||
val memoryFile = MemoryFile("file" + System.currentTimeMillis(), inputAsByteArray.size)
|
||||
memoryFile.outputStream.write(inputAsByteArray)
|
||||
memoryFile.inputStream
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ class AttachmentEncryptionTest {
|
||||
key = EncryptedFileKey(
|
||||
alg = "A256CTR",
|
||||
k = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||
key_ops = listOf("encrypt", "decrypt"),
|
||||
keyOps = listOf("encrypt", "decrypt"),
|
||||
kty = "oct",
|
||||
ext = true
|
||||
),
|
||||
@ -92,7 +92,7 @@ class AttachmentEncryptionTest {
|
||||
key = EncryptedFileKey(
|
||||
alg = "A256CTR",
|
||||
k = "__________________________________________8",
|
||||
key_ops = listOf("encrypt", "decrypt"),
|
||||
keyOps = listOf("encrypt", "decrypt"),
|
||||
kty = "oct",
|
||||
ext = true
|
||||
),
|
||||
@ -111,7 +111,7 @@ class AttachmentEncryptionTest {
|
||||
key = EncryptedFileKey(
|
||||
alg = "A256CTR",
|
||||
k = "__________________________________________8",
|
||||
key_ops = listOf("encrypt", "decrypt"),
|
||||
keyOps = listOf("encrypt", "decrypt"),
|
||||
kty = "oct",
|
||||
ext = true
|
||||
),
|
||||
@ -132,7 +132,7 @@ class AttachmentEncryptionTest {
|
||||
key = EncryptedFileKey(
|
||||
alg = "A256CTR",
|
||||
k = "__________________________________________8",
|
||||
key_ops = listOf("encrypt", "decrypt"),
|
||||
keyOps = listOf("encrypt", "decrypt"),
|
||||
kty = "oct",
|
||||
ext = true
|
||||
),
|
||||
|
@ -54,7 +54,7 @@ internal data class AddThreePidRegistrationParams(
|
||||
* This parameter is ignored when the homeserver handles 3PID verification.
|
||||
*/
|
||||
@Json(name = "id_server")
|
||||
val id_server: String? = null,
|
||||
val idServer: String? = null,
|
||||
|
||||
/* ==========================================================================================
|
||||
* For emails
|
||||
|
@ -44,5 +44,6 @@ internal data class RegistrationParams(
|
||||
|
||||
// Temporary flag to notify the server that we support msisdn flow. Used to prevent old app
|
||||
// versions to end up in fallback because the HS returns the msisdn flow which they don't support
|
||||
val x_show_msisdn: Boolean? = null
|
||||
@Json(name = "x_show_msisdn")
|
||||
val xShowMsisdn: Boolean? = null
|
||||
)
|
||||
|
@ -145,7 +145,7 @@ object MXMegolmExportEncryption {
|
||||
*/
|
||||
@Throws(Exception::class)
|
||||
@JvmOverloads
|
||||
fun encryptMegolmKeyFile(data: String, password: String, kdf_rounds: Int = DEFAULT_ITERATION_COUNT): ByteArray {
|
||||
fun encryptMegolmKeyFile(data: String, password: String, kdfRounds: Int = DEFAULT_ITERATION_COUNT): ByteArray {
|
||||
if (password.isEmpty()) {
|
||||
throw Exception("Empty password is not supported")
|
||||
}
|
||||
@ -163,7 +163,7 @@ object MXMegolmExportEncryption {
|
||||
// of a single bit of salt is a price we have to pay.
|
||||
iv[9] = iv[9] and 0x7f
|
||||
|
||||
val deriveKey = deriveKeys(salt, kdf_rounds, password)
|
||||
val deriveKey = deriveKeys(salt, kdfRounds, password)
|
||||
|
||||
val decryptCipher = Cipher.getInstance("AES/CTR/NoPadding")
|
||||
|
||||
@ -188,10 +188,10 @@ object MXMegolmExportEncryption {
|
||||
System.arraycopy(iv, 0, resultBuffer, idx, iv.size)
|
||||
idx += iv.size
|
||||
|
||||
resultBuffer[idx++] = (kdf_rounds shr 24 and 0xff).toByte()
|
||||
resultBuffer[idx++] = (kdf_rounds shr 16 and 0xff).toByte()
|
||||
resultBuffer[idx++] = (kdf_rounds shr 8 and 0xff).toByte()
|
||||
resultBuffer[idx++] = (kdf_rounds and 0xff).toByte()
|
||||
resultBuffer[idx++] = (kdfRounds shr 24 and 0xff).toByte()
|
||||
resultBuffer[idx++] = (kdfRounds shr 16 and 0xff).toByte()
|
||||
resultBuffer[idx++] = (kdfRounds shr 8 and 0xff).toByte()
|
||||
resultBuffer[idx++] = (kdfRounds and 0xff).toByte()
|
||||
|
||||
System.arraycopy(cipherArray, 0, resultBuffer, idx, cipherArray.size)
|
||||
idx += cipherArray.size
|
||||
@ -320,26 +320,26 @@ object MXMegolmExportEncryption {
|
||||
|
||||
// 512 bits key length
|
||||
val key = ByteArray(64)
|
||||
val Uc = ByteArray(64)
|
||||
val uc = ByteArray(64)
|
||||
|
||||
// U1 = PRF(Password, Salt || INT_32_BE(i))
|
||||
prf.update(salt)
|
||||
val int32BE = ByteArray(4) { 0.toByte() }
|
||||
int32BE[3] = 1.toByte()
|
||||
prf.update(int32BE)
|
||||
prf.doFinal(Uc, 0)
|
||||
prf.doFinal(uc, 0)
|
||||
|
||||
// copy to the key
|
||||
System.arraycopy(Uc, 0, key, 0, Uc.size)
|
||||
System.arraycopy(uc, 0, key, 0, uc.size)
|
||||
|
||||
for (index in 2..iterations) {
|
||||
// Uc = PRF(Password, Uc-1)
|
||||
prf.update(Uc)
|
||||
prf.doFinal(Uc, 0)
|
||||
prf.update(uc)
|
||||
prf.doFinal(uc, 0)
|
||||
|
||||
// F(Password, Salt, c, i) = U1 ^ U2 ^ ... ^ Uc
|
||||
for (byteIndex in Uc.indices) {
|
||||
key[byteIndex] = key[byteIndex] xor Uc[byteIndex]
|
||||
for (byteIndex in uc.indices) {
|
||||
key[byteIndex] = key[byteIndex] xor uc[byteIndex]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ internal class MXOlmDecryption(
|
||||
String.format(MXCryptoError.BAD_RECIPIENT_REASON, olmPayloadContent.recipient))
|
||||
}
|
||||
|
||||
val recipientKeys = olmPayloadContent.recipient_keys ?: run {
|
||||
val recipientKeys = olmPayloadContent.recipientKeys ?: run {
|
||||
Timber.e("## decryptEvent() : Olm event (id=${event.eventId}) contains no 'recipient_keys'" +
|
||||
" property; cannot prevent unknown-key attack")
|
||||
throw MXCryptoError.Base(MXCryptoError.ErrorType.MISSING_PROPERTY,
|
||||
@ -129,10 +129,10 @@ internal class MXOlmDecryption(
|
||||
String.format(MXCryptoError.FORWARDED_MESSAGE_REASON, olmPayloadContent.sender))
|
||||
}
|
||||
|
||||
if (olmPayloadContent.room_id != event.roomId) {
|
||||
Timber.e("## decryptEvent() : Event ${event.eventId}: original room ${olmPayloadContent.room_id} does not match reported room ${event.roomId}")
|
||||
if (olmPayloadContent.roomId != event.roomId) {
|
||||
Timber.e("## decryptEvent() : Event ${event.eventId}: original room ${olmPayloadContent.roomId} does not match reported room ${event.roomId}")
|
||||
throw MXCryptoError.Base(MXCryptoError.ErrorType.BAD_ROOM,
|
||||
String.format(MXCryptoError.BAD_ROOM_REASON, olmPayloadContent.room_id))
|
||||
String.format(MXCryptoError.BAD_ROOM_REASON, olmPayloadContent.roomId))
|
||||
}
|
||||
|
||||
val keys = olmPayloadContent.keys ?: run {
|
||||
|
@ -93,7 +93,7 @@ internal object MXEncryptedAttachments {
|
||||
key = EncryptedFileKey(
|
||||
alg = "A256CTR",
|
||||
ext = true,
|
||||
key_ops = listOf("encrypt", "decrypt"),
|
||||
keyOps = listOf("encrypt", "decrypt"),
|
||||
kty = "oct",
|
||||
k = base64ToBase64Url(Base64.encodeToString(key, Base64.DEFAULT))
|
||||
),
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.matrix.android.sdk.internal.crypto.model.event
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||
|
||||
@ -27,27 +28,32 @@ data class OlmPayloadContent(
|
||||
/**
|
||||
* The room id
|
||||
*/
|
||||
var room_id: String? = null,
|
||||
@Json(name = "room_id")
|
||||
val roomId: String? = null,
|
||||
|
||||
/**
|
||||
* The sender
|
||||
*/
|
||||
var sender: String? = null,
|
||||
@Json(name = "sender")
|
||||
val sender: String? = null,
|
||||
|
||||
/**
|
||||
* The recipient
|
||||
*/
|
||||
var recipient: String? = null,
|
||||
@Json(name = "recipient")
|
||||
val recipient: String? = null,
|
||||
|
||||
/**
|
||||
* the recipient keys
|
||||
*/
|
||||
var recipient_keys: Map<String, String>? = null,
|
||||
@Json(name = "recipient_keys")
|
||||
val recipientKeys: Map<String, String>? = null,
|
||||
|
||||
/**
|
||||
* The keys
|
||||
*/
|
||||
var keys: Map<String, String>? = null
|
||||
@Json(name = "keys")
|
||||
val keys: Map<String, String>? = null
|
||||
) {
|
||||
fun toJsonString(): String {
|
||||
return MoshiProvider.providesMoshi().adapter(OlmPayloadContent::class.java).toJson(this)
|
||||
|
@ -31,7 +31,7 @@ data class DeviceInfo(
|
||||
* The owner user id (not documented and useless but the homeserver sent it. You should not need it)
|
||||
*/
|
||||
@Json(name = "user_id")
|
||||
val user_id: String? = null,
|
||||
val userId: String? = null,
|
||||
|
||||
/**
|
||||
* The device id
|
||||
|
@ -37,7 +37,7 @@ data class EncryptedFileKey(
|
||||
* Required. Key operations. Must at least contain "encrypt" and "decrypt".
|
||||
*/
|
||||
@Json(name = "key_ops")
|
||||
val key_ops: List<String>? = null,
|
||||
val keyOps: List<String>? = null,
|
||||
|
||||
/**
|
||||
* Required. Key type. Must be "oct".
|
||||
@ -63,7 +63,7 @@ data class EncryptedFileKey(
|
||||
return false
|
||||
}
|
||||
|
||||
if (key_ops?.contains("encrypt") != true || !key_ops.contains("decrypt")) {
|
||||
if (keyOps?.contains("encrypt") != true || !keyOps.contains("decrypt")) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ import java.io.ObjectStreamClass
|
||||
*
|
||||
* Ref: https://stackoverflow.com/questions/3884492/how-can-i-change-package-for-a-bunch-of-java-serializable-classes
|
||||
*/
|
||||
internal class SafeObjectInputStream(`in`: InputStream) : ObjectInputStream(`in`) {
|
||||
internal class SafeObjectInputStream(inputStream: InputStream) : ObjectInputStream(inputStream) {
|
||||
|
||||
init {
|
||||
enableResolveObject(true)
|
||||
|
@ -175,8 +175,8 @@ internal abstract class SASDefaultVerificationTransaction(
|
||||
?.unpaddedBase64PublicKey
|
||||
?.let { masterPublicKey ->
|
||||
val crossSigningKeyId = "ed25519:$masterPublicKey"
|
||||
macUsingAgreedMethod(masterPublicKey, baseInfo + crossSigningKeyId)?.let { MSKMacString ->
|
||||
keyMap[crossSigningKeyId] = MSKMacString
|
||||
macUsingAgreedMethod(masterPublicKey, baseInfo + crossSigningKeyId)?.let { mskMacString ->
|
||||
keyMap[crossSigningKeyId] = mskMacString
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,9 +220,9 @@ internal interface RoomAPI {
|
||||
*/
|
||||
@POST(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/send_relation/{parent_id}/{relation_type}/{event_type}")
|
||||
fun sendRelation(@Path("roomId") roomId: String,
|
||||
@Path("parentId") parent_id: String,
|
||||
@Path("parent_id") parentId: String,
|
||||
@Path("relation_type") relationType: String,
|
||||
@Path("eventType") eventType: String,
|
||||
@Path("event_type") eventType: String,
|
||||
@Body content: Content?
|
||||
): Call<SendResponse>
|
||||
|
||||
@ -296,16 +296,16 @@ internal interface RoomAPI {
|
||||
* This cannot be undone.
|
||||
* Users may redact their own events, and any user with a power level greater than or equal to the redact power level of the room may redact events there.
|
||||
*
|
||||
* @param txId the transaction Id
|
||||
* @param roomId the room id
|
||||
* @param eventId the event to delete
|
||||
* @param txId the transaction Id
|
||||
* @param roomId the room id
|
||||
* @param eventId the event to delete
|
||||
* @param reason json containing reason key {"reason": "Indecent material"}
|
||||
*/
|
||||
@PUT(NetworkConstants.URI_API_PREFIX_PATH_R0 + "rooms/{roomId}/redact/{eventId}/{txnId}")
|
||||
fun redactEvent(
|
||||
@Path("txnId") txId: String,
|
||||
@Path("roomId") roomId: String,
|
||||
@Path("eventId") parent_id: String,
|
||||
@Path("eventId") eventId: String,
|
||||
@Body reason: Map<String, String>
|
||||
): Call<SendResponse>
|
||||
|
||||
|
@ -57,8 +57,8 @@ internal class CreateRoomBodyBuilder @Inject constructor(
|
||||
|
||||
invites.map {
|
||||
ThreePidInviteBody(
|
||||
id_server = identityServerUrlWithoutProtocol,
|
||||
id_access_token = identityServerAccessToken,
|
||||
idServer = identityServerUrlWithoutProtocol,
|
||||
idAccessToken = identityServerAccessToken,
|
||||
medium = it.toMedium(),
|
||||
address = it.value
|
||||
)
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.matrix.android.sdk.internal.session.room.membership.threepid
|
||||
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
||||
import org.matrix.android.sdk.api.session.identity.ThreePid
|
||||
import org.matrix.android.sdk.api.session.identity.toMedium
|
||||
@ -28,7 +29,6 @@ import org.matrix.android.sdk.internal.session.identity.data.IdentityStore
|
||||
import org.matrix.android.sdk.internal.session.identity.data.getIdentityServerUrlWithoutProtocol
|
||||
import org.matrix.android.sdk.internal.session.room.RoomAPI
|
||||
import org.matrix.android.sdk.internal.task.Task
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface InviteThreePidTask : Task<InviteThreePidTask.Params, Unit> {
|
||||
@ -55,8 +55,8 @@ internal class DefaultInviteThreePidTask @Inject constructor(
|
||||
|
||||
return executeRequest(eventBus) {
|
||||
val body = ThreePidInviteBody(
|
||||
id_server = identityServerUrlWithoutProtocol,
|
||||
id_access_token = identityServerAccessToken,
|
||||
idServer = identityServerUrlWithoutProtocol,
|
||||
idAccessToken = identityServerAccessToken,
|
||||
medium = params.threePid.toMedium(),
|
||||
address = params.threePid.value
|
||||
)
|
||||
|
@ -25,18 +25,22 @@ internal data class ThreePidInviteBody(
|
||||
/**
|
||||
* Required. The hostname+port of the identity server which should be used for third party identifier lookups.
|
||||
*/
|
||||
@Json(name = "id_server") val id_server: String,
|
||||
@Json(name = "id_server")
|
||||
val idServer: String,
|
||||
/**
|
||||
* Required. An access token previously registered with the identity server. Servers can treat this as optional
|
||||
* to distinguish between r0.5-compatible clients and this specification version.
|
||||
*/
|
||||
@Json(name = "id_access_token") val id_access_token: String,
|
||||
@Json(name = "id_access_token")
|
||||
val idAccessToken: String,
|
||||
/**
|
||||
* Required. The kind of address being passed in the address field, for example email.
|
||||
*/
|
||||
@Json(name = "medium") val medium: String,
|
||||
@Json(name = "medium")
|
||||
val medium: String,
|
||||
/**
|
||||
* Required. The invitee's third party identifier.
|
||||
*/
|
||||
@Json(name = "address") val address: String
|
||||
@Json(name = "address")
|
||||
val address: String
|
||||
)
|
||||
|
@ -20,6 +20,7 @@ import android.content.Context
|
||||
import androidx.work.CoroutineWorker
|
||||
import androidx.work.WorkerParameters
|
||||
import com.squareup.moshi.JsonClass
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
@ -31,7 +32,6 @@ import org.matrix.android.sdk.internal.session.room.send.SendResponse
|
||||
import org.matrix.android.sdk.internal.worker.SessionWorkerParams
|
||||
import org.matrix.android.sdk.internal.worker.WorkerParamsFactory
|
||||
import org.matrix.android.sdk.internal.worker.getSessionComponent
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -92,7 +92,7 @@ internal class SendRelationWorker(context: Context, params: WorkerParameters) :
|
||||
executeRequest<SendResponse>(eventBus) {
|
||||
apiCall = roomAPI.sendRelation(
|
||||
roomId = roomId,
|
||||
parent_id = relatedEventId,
|
||||
parentId = relatedEventId,
|
||||
relationType = relationType,
|
||||
eventType = localEvent.type,
|
||||
content = localEvent.content
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.matrix.android.sdk.internal.session.sync.model
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
/**
|
||||
@ -26,26 +27,30 @@ internal data class DeviceInfo(
|
||||
/**
|
||||
* The owner user id
|
||||
*/
|
||||
val user_id: String? = null,
|
||||
@Json(name = "user_id")
|
||||
val userId: String? = null,
|
||||
|
||||
/**
|
||||
* The device id
|
||||
*/
|
||||
val device_id: String? = null,
|
||||
@Json(name = "device_id")
|
||||
val deviceId: String? = null,
|
||||
|
||||
/**
|
||||
* The device display name
|
||||
*/
|
||||
val display_name: String? = null,
|
||||
@Json(name = "display_name")
|
||||
val displayName: String? = null,
|
||||
|
||||
/**
|
||||
* The last time this device has been seen.
|
||||
*/
|
||||
val last_seen_ts: Long = 0,
|
||||
@Json(name = "last_seen_ts")
|
||||
val lastSeenTs: Long = 0,
|
||||
|
||||
/**
|
||||
* The last ip address
|
||||
*/
|
||||
val last_seen_ip: String? = null
|
||||
|
||||
@Json(name = "last_seen_ip")
|
||||
val lastSeenIp: String? = null
|
||||
)
|
||||
|
@ -257,12 +257,11 @@ object CompatUtil {
|
||||
|
||||
/**
|
||||
* Create a CipherInputStream instance.
|
||||
* Before Kitkat, this method will return `in` because local storage encryption is not implemented for devices before KitKat.
|
||||
* Warning, if `in` is not an encrypted stream, it's up to the caller to close and reopen `in`, because the stream has been read.
|
||||
* Warning, if inputStream is not an encrypted stream, it's up to the caller to close and reopen inputStream, because the stream has been read.
|
||||
*
|
||||
* @param in the input stream
|
||||
* @param context the context holding the application shared preferences
|
||||
* @return in, or the created InputStream, or null if the InputStream `in` does not contain encrypted data
|
||||
* @param inputStream the input stream
|
||||
* @param context the context holding the application shared preferences
|
||||
* @return inputStream, or the created InputStream, or null if the InputStream inputStream does not contain encrypted data
|
||||
*/
|
||||
@Throws(NoSuchPaddingException::class,
|
||||
NoSuchAlgorithmException::class,
|
||||
@ -274,15 +273,15 @@ object CompatUtil {
|
||||
NoSuchProviderException::class,
|
||||
InvalidAlgorithmParameterException::class,
|
||||
IOException::class)
|
||||
fun createCipherInputStream(`in`: InputStream, context: Context): InputStream? {
|
||||
val iv_len = `in`.read()
|
||||
if (iv_len != AES_GCM_IV_LENGTH) {
|
||||
Timber.e(TAG, "Invalid IV length $iv_len")
|
||||
fun createCipherInputStream(inputStream: InputStream, context: Context): InputStream? {
|
||||
val ivLen = inputStream.read()
|
||||
if (ivLen != AES_GCM_IV_LENGTH) {
|
||||
Timber.e(TAG, "Invalid IV length $ivLen")
|
||||
return null
|
||||
}
|
||||
|
||||
val iv = ByteArray(AES_GCM_IV_LENGTH)
|
||||
`in`.read(iv)
|
||||
inputStream.read(iv)
|
||||
|
||||
val cipher = Cipher.getInstance(AES_GCM_CIPHER_TYPE)
|
||||
|
||||
@ -296,6 +295,6 @@ object CompatUtil {
|
||||
|
||||
cipher.init(Cipher.DECRYPT_MODE, keyAndVersion.secretKey, spec)
|
||||
|
||||
return CipherInputStream(`in`, cipher)
|
||||
return CipherInputStream(inputStream, cipher)
|
||||
}
|
||||
}
|
||||
|
@ -272,29 +272,29 @@ private fun checkPermissions(permissionsToBeGrantedBitMap: Int,
|
||||
|
||||
/**
|
||||
* Helper method used in [.checkPermissions] to populate the list of the
|
||||
* permissions to be granted (permissionsListToBeGranted_out) and the list of the permissions already denied (permissionAlreadyDeniedList_out).
|
||||
* permissions to be granted (permissionsListToBeGrantedOut) and the list of the permissions already denied (permissionAlreadyDeniedListOut).
|
||||
*
|
||||
* @param activity calling activity
|
||||
* @param permissionAlreadyDeniedList_out list to be updated with the permissions already denied by the user
|
||||
* @param permissionsListToBeGranted_out list to be updated with the permissions to be granted
|
||||
* @param permissionType the permission to be checked
|
||||
* @param activity calling activity
|
||||
* @param permissionAlreadyDeniedListOut list to be updated with the permissions already denied by the user
|
||||
* @param permissionsListToBeGrantedOut list to be updated with the permissions to be granted
|
||||
* @param permissionType the permission to be checked
|
||||
* @return true if the permission requires to be granted, false otherwise
|
||||
*/
|
||||
private fun updatePermissionsToBeGranted(activity: Activity,
|
||||
permissionAlreadyDeniedList_out: MutableList<String>,
|
||||
permissionsListToBeGranted_out: MutableList<String>,
|
||||
permissionAlreadyDeniedListOut: MutableList<String>,
|
||||
permissionsListToBeGrantedOut: MutableList<String>,
|
||||
permissionType: String): Boolean {
|
||||
var isRequestPermissionRequested = false
|
||||
|
||||
// add permission to be granted
|
||||
permissionsListToBeGranted_out.add(permissionType)
|
||||
permissionsListToBeGrantedOut.add(permissionType)
|
||||
|
||||
if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activity.applicationContext, permissionType)) {
|
||||
isRequestPermissionRequested = true
|
||||
|
||||
// add permission to the ones that were already asked to the user
|
||||
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permissionType)) {
|
||||
permissionAlreadyDeniedList_out.add(permissionType)
|
||||
permissionAlreadyDeniedListOut.add(permissionType)
|
||||
}
|
||||
}
|
||||
return isRequestPermissionRequested
|
||||
|
@ -84,7 +84,7 @@ class VerificationChooseMethodController @Inject constructor(
|
||||
iconColor(colorProvider.getColorFromAttribute(R.attr.riotx_text_primary))
|
||||
listener { listener?.doVerifyBySas() }
|
||||
}
|
||||
} else if (state.SASModeAvailable) {
|
||||
} else if (state.sasModeAvailable) {
|
||||
bottomSheetVerificationActionItem {
|
||||
id("openEmoji")
|
||||
title(stringProvider.getString(R.string.verification_no_scan_emoji_title))
|
||||
|
@ -39,7 +39,7 @@ data class VerificationChooseMethodViewState(
|
||||
val otherCanShowQrCode: Boolean = false,
|
||||
val otherCanScanQrCode: Boolean = false,
|
||||
val qrCodeText: String? = null,
|
||||
val SASModeAvailable: Boolean = false,
|
||||
val sasModeAvailable: Boolean = false,
|
||||
val isMe: Boolean = false,
|
||||
val canCrossSign: Boolean = false
|
||||
) : MvRxState
|
||||
@ -74,7 +74,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||
copy(
|
||||
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
|
||||
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
|
||||
SASModeAvailable = pvr?.isSasSupported().orFalse()
|
||||
sasModeAvailable = pvr?.isSasSupported().orFalse()
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||
otherCanShowQrCode = pvr?.otherCanShowQrCode().orFalse(),
|
||||
otherCanScanQrCode = pvr?.otherCanScanQrCode().orFalse(),
|
||||
qrCodeText = (qrCodeVerificationTransaction as? QrCodeVerificationTransaction)?.qrCodeText,
|
||||
SASModeAvailable = pvr?.isSasSupported().orFalse()
|
||||
sasModeAvailable = pvr?.isSasSupported().orFalse()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ class FontTagHandler : SimpleTagHandler() {
|
||||
return ForegroundColorSpan(colorString)
|
||||
}
|
||||
|
||||
private fun parseColor(color_name: String): Int {
|
||||
private fun parseColor(colorName: String): Int {
|
||||
try {
|
||||
return Color.parseColor(color_name)
|
||||
return Color.parseColor(colorName)
|
||||
} catch (e: Exception) {
|
||||
// try other w3c colors?
|
||||
return when (color_name) {
|
||||
return when (colorName) {
|
||||
"white" -> Color.WHITE
|
||||
"yellow" -> Color.YELLOW
|
||||
"fuchsia" -> Color.parseColor("#FF00FF")
|
||||
|
@ -108,25 +108,25 @@ class CircleView @JvmOverloads constructor(context: Context, attrs: AttributeSet
|
||||
companion object {
|
||||
|
||||
val INNER_CIRCLE_RADIUS_PROGRESS: Property<CircleView, Float> = object : Property<CircleView, Float>(Float::class.java, "innerCircleRadiusProgress") {
|
||||
override operator fun get(`object`: CircleView): Float? {
|
||||
return `object`.innerCircleRadiusProgress
|
||||
override operator fun get(o: CircleView): Float? {
|
||||
return o.innerCircleRadiusProgress
|
||||
}
|
||||
|
||||
override operator fun set(`object`: CircleView, value: Float?) {
|
||||
override operator fun set(o: CircleView, value: Float?) {
|
||||
value?.let {
|
||||
`object`.innerCircleRadiusProgress = it
|
||||
o.innerCircleRadiusProgress = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val OUTER_CIRCLE_RADIUS_PROGRESS: Property<CircleView, Float> = object : Property<CircleView, Float>(Float::class.java, "outerCircleRadiusProgress") {
|
||||
override operator fun get(`object`: CircleView): Float? {
|
||||
return `object`.outerCircleRadiusProgress
|
||||
override operator fun get(o: CircleView): Float? {
|
||||
return o.outerCircleRadiusProgress
|
||||
}
|
||||
|
||||
override operator fun set(`object`: CircleView, value: Float?) {
|
||||
override operator fun set(o: CircleView, value: Float?) {
|
||||
value?.let {
|
||||
`object`.outerCircleRadiusProgress = it
|
||||
o.outerCircleRadiusProgress = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,12 +186,12 @@ class DotsView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
|
||||
private const val OUTER_DOTS_POSITION_ANGLE = 360 / DOTS_COUNT
|
||||
|
||||
val DOTS_PROGRESS: Property<DotsView, Float> = object : Property<DotsView, Float>(Float::class.java, "dotsProgress") {
|
||||
override operator fun get(`object`: DotsView): Float? {
|
||||
return `object`.currentProgress
|
||||
override operator fun get(o: DotsView): Float? {
|
||||
return o.currentProgress
|
||||
}
|
||||
|
||||
override operator fun set(`object`: DotsView, value: Float?) {
|
||||
`object`.currentProgress = value!!
|
||||
override operator fun set(o: DotsView, value: Float?) {
|
||||
o.currentProgress = value!!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||
private fun refreshMyDevice() {
|
||||
session.cryptoService().getUserDevices(session.myUserId).map {
|
||||
DeviceInfo(
|
||||
user_id = session.myUserId,
|
||||
userId = session.myUserId,
|
||||
deviceId = it.deviceId,
|
||||
displayName = it.displayName()
|
||||
)
|
||||
|
@ -25,7 +25,6 @@ import com.airbnb.mvrx.Async
|
||||
import com.airbnb.mvrx.Loading
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.dialogs.ManuallyVerifyDialog
|
||||
import im.vector.app.core.dialogs.PromptPasswordDialog
|
||||
@ -37,6 +36,7 @@ import im.vector.app.core.platform.VectorBaseFragment
|
||||
import im.vector.app.features.crypto.verification.VerificationBottomSheet
|
||||
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
|
||||
import kotlinx.android.synthetic.main.merge_overlay_waiting_view.*
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
@ -108,7 +108,7 @@ class VectorSettingsDevicesFragment @Inject constructor(
|
||||
}
|
||||
|
||||
override fun onDeviceClicked(deviceInfo: DeviceInfo) {
|
||||
DeviceVerificationInfoBottomSheet.newInstance(deviceInfo.user_id ?: "", deviceInfo.deviceId ?: "").show(
|
||||
DeviceVerificationInfoBottomSheet.newInstance(deviceInfo.userId ?: "", deviceInfo.deviceId ?: "").show(
|
||||
childFragmentManager,
|
||||
"VERIF_INFO"
|
||||
)
|
||||
|
@ -27,7 +27,7 @@
|
||||
tools:text="Riot X" />
|
||||
|
||||
<!---
|
||||
The following detailed informations are displayed in developper mode
|
||||
The following detailed data are displayed in developer mode
|
||||
-->
|
||||
<TextView
|
||||
android:id="@+id/itemDeviceDisplayNameLabel"
|
||||
|
Loading…
Reference in New Issue
Block a user