Cleaning, review

This commit is contained in:
Valere 2022-04-20 18:06:24 +02:00
parent effbc47bd3
commit 885f836adb
6 changed files with 3416 additions and 3420 deletions

View file

@ -472,7 +472,7 @@ internal class DefaultCryptoService @Inject constructor(
outgoingKeyRequestManager.requireProcessAllPendingKeyRequests()
} else {
Timber.tag(loggerTag.value)
.w("Don't process key requests yet as their might be more to_device to catchup")
.w("Don't process key requests yet as there might be more to_device to catchup")
}
} catch (failure: Throwable) {
// just for safety but should not throw
@ -1289,8 +1289,8 @@ internal class DefaultCryptoService @Inject constructor(
loadRoomMembersTask.execute(LoadRoomMembersTask.Params(roomId))
} catch (failure: Throwable) {
Timber.tag(loggerTag.value).e("prepareToEncrypt() : Failed to load room members")
// callback.onFailure(failure)
// return@launch
// we probably shouldn't block sending on that (but questionable)
// but some members won't be able to decrypt
}
val userIds = getRoomUserIds(roomId)

View file

@ -328,14 +328,6 @@ internal class MXOlmDevice @Inject constructor(
Timber.tag(loggerTag.value).e(e, "## createInboundSession() : removeOneTimeKeys failed")
}
// Timber.tag(loggerTag.value).v("## createInboundSession() : ciphertext: $ciphertext.")
// try {
// val sha256 = olmUtility!!.sha256(URLEncoder.encode(ciphertext, "utf-8"))
// Timber.tag(loggerTag.value).v("## createInboundSession() :ciphertext: SHA256: $sha256")
// } catch (e: Exception) {
// Timber.tag(loggerTag.value).e(e, "## createInboundSession() :ciphertext: cannot encode ciphertext")
// }
val olmMessage = OlmMessage()
olmMessage.mCipherText = ciphertext
olmMessage.mType = messageType.toLong()

View file

@ -113,7 +113,7 @@ internal class OutgoingKeyRequestManager @Inject constructor(
mapOf(
myUserId to listOf("*"),
// TODO we might not have deviceId in the future due to https://github.com/matrix-org/matrix-spec-proposals/pull/3700
// We might not have deviceId in the future due to https://github.com/matrix-org/matrix-spec-proposals/pull/3700
// so in this case query to all
sender to listOf(senderDevice ?: "*")
)
@ -137,7 +137,6 @@ internal class OutgoingKeyRequestManager @Inject constructor(
val megolmVersion = it.read()
if (megolmVersion != 3) return@tryOrNull null
/** Int tag */
/** Int tag */
if (it.read() != 8) return@tryOrNull null
it.read()
}

View file

@ -125,7 +125,8 @@ internal class SecretShareManager @Inject constructor(
if (userId != credentials.userId) {
// secrets are only shared between our own devices
Timber.e("Ignoring secret share request from other users $userId")
Timber.tag(loggerTag.value)
.e("Ignoring secret share request from other users $userId")
return
}
@ -137,7 +138,8 @@ internal class SecretShareManager @Inject constructor(
val device = cryptoStore.getUserDevice(credentials.userId, deviceId)
?: return Unit.also {
Timber.e("Received secret share request from unknown device $deviceId")
Timber.tag(loggerTag.value)
.e("Received secret share request from unknown device $deviceId")
}
val isRequestingDeviceTrusted = device.isVerified
@ -156,7 +158,8 @@ internal class SecretShareManager @Inject constructor(
else -> null
}
if (secretValue == null) {
Timber.i("The secret is unknown $secretName, passing to app layer")
Timber.tag(loggerTag.value)
.i("The secret is unknown $secretName, passing to app layer")
val toList = synchronized(gossipingRequestListeners) { gossipingRequestListeners.toList() }
toList.onEach { listener ->
listener.onSecretShareRequest(request)
@ -204,7 +207,8 @@ internal class SecretShareManager @Inject constructor(
.e(failure, "failed to send shared secret $secretName to ${device.shortDebugString()}")
}
} else {
Timber.d(" Received secret share request from un-authorised device ${device.deviceId}")
Timber.tag(loggerTag.value)
.d(" Received secret share request from un-authorised device ${device.deviceId}")
}
}

View file

@ -1,18 +1,18 @@
// /*
// * Copyright 2020 The Matrix.org Foundation C.I.C.
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// * http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
/*
* Copyright 2020 The Matrix.org Foundation C.I.C.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.matrix.android.sdk.internal.crypto.store.db.model

View file

@ -152,7 +152,7 @@ internal class VerificationTransportRoomMessage(
val params = SendVerificationMessageTask.Params(event)
sendVerificationMessageTask.executeRetry(params, 5)
} catch (failure: Throwable) {
Timber.w("")
Timber.w(failure, "Failed to cancel verification transaction")
}
}
}
@ -177,7 +177,8 @@ internal class VerificationTransportRoomMessage(
val params = SendVerificationMessageTask.Params(event)
sendVerificationMessageTask.executeRetry(params, 5)
} catch (failure: Throwable) {
Timber.w("")
Timber.w(failure, "Failed to complete (done) verification")
// should we call onDone?
} finally {
onDone?.invoke()
}