Skip to content

Commit e3a8781

Browse files
committed
Merge branch 'release/1.6.16' into main
2 parents 310cecf + 10d89f2 commit e3a8781

File tree

66 files changed

+563
-2852
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+563
-2852
lines changed

.github/workflows/sync-from-external-sources.yml

-24
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,3 @@ jobs:
5858
- Update SAS Strings from matrix-doc.
5959
branch: sync-sas-strings
6060
base: develop
61-
62-
sync-analytics-plan:
63-
runs-on: ubuntu-latest
64-
# Skip in forks
65-
if: github.repository == 'element-hq/element-android'
66-
# No concurrency required, runs every time on a schedule.
67-
steps:
68-
- uses: actions/checkout@v3
69-
- name: Run analytics import script
70-
run: ./tools/import_analytic_plan.sh
71-
- name: Create Pull Request for analytics plan
72-
uses: peter-evans/create-pull-request@v5
73-
with:
74-
commit-message: Sync analytics plan
75-
title: Sync analytics plan
76-
body: |
77-
### Update analytics plan
78-
Reviewers:
79-
- [ ] Please remove usage of Event or Enum which may have been removed or updated
80-
- [ ] please ensure new Events or new Enums are used to send analytics by pushing new commit(s) to this PR.
81-
82-
*Note*: Change are coming from [this project](https://github.com/matrix-org/matrix-analytics-events)
83-
branch: sync-analytics-plan
84-
base: develop

CHANGES.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Changes in Element v1.6.16 (2024-05-29)
2+
=======================================
3+
4+
Bugfixes 🐛
5+
----------
6+
- Fix crash when accessing a local file and permission is revoked. ([#3616](https://github.com/element-hq/element-android/issues/3616))
7+
- Fixes Element on Android 12+ being ineligible for URL deeplinks ([#5748](https://github.com/element-hq/element-android/issues/5748))
8+
- Restore formatting when restoring a draft. Also keep formatting when switching composer mode. ([#7466](https://github.com/element-hq/element-android/issues/7466))
9+
10+
Other changes
11+
-------------
12+
- Update posthog sdk to 3.2.0 ([#8820](https://github.com/element-hq/element-android/issues/8820))
13+
- Update Rust crypto SDK to version 0.4.1 ([#8838](https://github.com/element-hq/element-android/issues/8838))
14+
15+
116
Changes in Element v1.6.14 (2024-04-02)
217
=======================================
318

dependencies_groups.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ext.groups = [
99
'com.github.hyuwah',
1010
'com.github.jetradarmobile',
1111
'com.github.MatrixFrog',
12+
'com.github.matrix-org',
1213
'com.github.tapadoo',
1314
'com.github.UnifiedPush',
1415
'com.github.yalantis',
@@ -120,7 +121,7 @@ ext.groups = [
120121
'com.parse.bolts',
121122
'com.pinterest',
122123
'com.pinterest.ktlint',
123-
'com.posthog.android',
124+
'com.posthog',
124125
'com.squareup',
125126
'com.squareup.curtains',
126127
'com.squareup.duktape',

docs/analytics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ We ask for the user to give consent before sending any analytics data.
1717

1818
The analytics plan is shared between all Element clients. To add an Event, please open a PR to this project: https://github.com/matrix-org/matrix-analytics-events
1919

20-
Then, once the PR has been merged, you can run the tool `import_analytic_plan.sh` to import the plan to Element, and then you can use the new Event. Note that this tool is run by Github action once a week.
20+
Then, once the PR has been merged, and the library is release, you can update the version of the library in the `build.gradle` file.
2121

2222
## Forks of Element
2323

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Main changes in this version: Bug fixes.
2+
Full changelog: https://github.com/element-hq/element-android/releases

library/multipicker/src/main/java/im/vector/lib/multipicker/AudioPicker.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AudioPicker : Picker<MultiPickerAudioType>() {
3131
* Returns selected audio files or empty list if user did not select any files.
3232
*/
3333
override fun getSelectedFiles(context: Context, data: Intent?): List<MultiPickerAudioType> {
34-
return getSelectedUriList(data).mapNotNull { selectedUri ->
34+
return getSelectedUriList(context, data).mapNotNull { selectedUri ->
3535
selectedUri.toMultiPickerAudioType(context)
3636
}
3737
}

library/multipicker/src/main/java/im/vector/lib/multipicker/FilePicker.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FilePicker : Picker<MultiPickerBaseType>() {
4141
* Returns selected files or empty list if user did not select any files.
4242
*/
4343
override fun getSelectedFiles(context: Context, data: Intent?): List<MultiPickerBaseType> {
44-
return getSelectedUriList(data).mapNotNull { selectedUri ->
44+
return getSelectedUriList(context, data).mapNotNull { selectedUri ->
4545
val type = context.contentResolver.getType(selectedUri)
4646

4747
when {

library/multipicker/src/main/java/im/vector/lib/multipicker/ImagePicker.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ImagePicker : Picker<MultiPickerImageType>() {
3131
* Returns selected image files or empty list if user did not select any files.
3232
*/
3333
override fun getSelectedFiles(context: Context, data: Intent?): List<MultiPickerImageType> {
34-
return getSelectedUriList(data).mapNotNull { selectedUri ->
34+
return getSelectedUriList(context, data).mapNotNull { selectedUri ->
3535
selectedUri.toMultiPickerImageType(context)
3636
}
3737
}

library/multipicker/src/main/java/im/vector/lib/multipicker/MediaPicker.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class MediaPicker : Picker<MultiPickerBaseMediaType>() {
3333
* Returns selected image/video files or empty list if user did not select any files.
3434
*/
3535
override fun getSelectedFiles(context: Context, data: Intent?): List<MultiPickerBaseMediaType> {
36-
return getSelectedUriList(data).mapNotNull { selectedUri ->
36+
return getSelectedUriList(context, data).mapNotNull { selectedUri ->
3737
val mimeType = context.contentResolver.getType(selectedUri)
3838

3939
if (mimeType.isMimeTypeVideo()) {

library/multipicker/src/main/java/im/vector/lib/multipicker/Picker.kt

+14-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package im.vector.lib.multipicker
1818

19+
import android.content.ComponentName
1920
import android.content.Context
2021
import android.content.Intent
2122
import android.content.pm.PackageManager
@@ -58,7 +59,17 @@ abstract class Picker<T> {
5859
uriList.forEach {
5960
for (resolveInfo in resInfoList) {
6061
val packageName: String = resolveInfo.activityInfo.packageName
61-
context.grantUriPermission(packageName, it, Intent.FLAG_GRANT_READ_URI_PERMISSION)
62+
63+
// Replace implicit intent by an explicit to fix crash on some devices like Xiaomi.
64+
// see https://juejin.cn/post/7031736325422186510
65+
try {
66+
context.grantUriPermission(packageName, it, Intent.FLAG_GRANT_READ_URI_PERMISSION)
67+
} catch (e: Exception) {
68+
continue
69+
}
70+
data.action = null
71+
data.component = ComponentName(packageName, resolveInfo.activityInfo.name)
72+
break
6273
}
6374
}
6475
return getSelectedFiles(context, data)
@@ -82,7 +93,7 @@ abstract class Picker<T> {
8293
activityResultLauncher.launch(createIntent().apply { addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) })
8394
}
8495

85-
protected fun getSelectedUriList(data: Intent?): List<Uri> {
96+
protected fun getSelectedUriList(context: Context, data: Intent?): List<Uri> {
8697
val selectedUriList = mutableListOf<Uri>()
8798
val dataUri = data?.data
8899
val clipData = data?.clipData
@@ -104,6 +115,6 @@ abstract class Picker<T> {
104115
}
105116
}
106117
}
107-
return selectedUriList
118+
return selectedUriList.onEach { context.grantUriPermission(context.applicationContext.packageName, it, Intent.FLAG_GRANT_READ_URI_PERMISSION) }
108119
}
109120
}

library/multipicker/src/main/java/im/vector/lib/multipicker/VideoPicker.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class VideoPicker : Picker<MultiPickerVideoType>() {
3131
* Returns selected video files or empty list if user did not select any files.
3232
*/
3333
override fun getSelectedFiles(context: Context, data: Intent?): List<MultiPickerVideoType> {
34-
return getSelectedUriList(data).mapNotNull { selectedUri ->
34+
return getSelectedUriList(context, data).mapNotNull { selectedUri ->
3535
selectedUri.toMultiPickerVideoType(context)
3636
}
3737
}

matrix-sdk-android/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ android {
6262
// that the app's state is completely cleared between tests.
6363
testInstrumentationRunnerArguments clearPackageData: 'true'
6464

65-
buildConfigField "String", "SDK_VERSION", "\"1.6.14\""
65+
buildConfigField "String", "SDK_VERSION", "\"1.6.16\""
6666

6767
buildConfigField "String", "GIT_SDK_REVISION", "\"${gitRevision()}\""
6868
buildConfigField "String", "GIT_SDK_REVISION_UNIX_DATE", "\"${gitRevisionUnixDate()}\""
@@ -215,7 +215,7 @@ dependencies {
215215

216216
implementation libs.google.phonenumber
217217

218-
implementation("org.matrix.rustcomponents:crypto-android:0.3.16")
218+
implementation("org.matrix.rustcomponents:crypto-android:0.4.1")
219219
// api project(":library:rustCrypto")
220220

221221
testImplementation libs.tests.junit

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/rendezvous/Rendezvous.kt

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ import org.matrix.android.sdk.api.session.crypto.crosssigning.DeviceTrustLevel
3737
import org.matrix.android.sdk.api.util.MatrixJsonParser
3838
import timber.log.Timber
3939

40+
// n.b MSC3886/MSC3903/MSC3906 that this is based on are now closed.
41+
// However, we want to keep this implementation around for some time.
42+
// TODO define an end-of-life date for this implementation.
43+
4044
/**
4145
* Implementation of MSC3906 to sign in + E2EE set up using a QR code.
4246
*/

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/Device.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import org.matrix.android.sdk.internal.crypto.verification.SasVerification
3131
import org.matrix.android.sdk.internal.crypto.verification.VerificationRequest
3232
import org.matrix.android.sdk.internal.crypto.verification.prepareMethods
3333
import org.matrix.rustcomponents.sdk.crypto.CryptoStoreException
34-
import org.matrix.rustcomponents.sdk.crypto.LocalTrust
3534
import org.matrix.rustcomponents.sdk.crypto.SignatureException
35+
import uniffi.matrix_sdk_crypto.LocalTrust
3636
import org.matrix.rustcomponents.sdk.crypto.Device as InnerDevice
3737

3838
/** Class representing a device that supports E2EE in the Matrix world

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OlmMachine.kt

+8-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ import org.matrix.rustcomponents.sdk.crypto.DeviceLists
7575
import org.matrix.rustcomponents.sdk.crypto.EncryptionSettings
7676
import org.matrix.rustcomponents.sdk.crypto.KeyRequestPair
7777
import org.matrix.rustcomponents.sdk.crypto.KeysImportResult
78-
import org.matrix.rustcomponents.sdk.crypto.LocalTrust
7978
import org.matrix.rustcomponents.sdk.crypto.Logger
8079
import org.matrix.rustcomponents.sdk.crypto.MegolmV1BackupKey
8180
import org.matrix.rustcomponents.sdk.crypto.Request
@@ -86,6 +85,7 @@ import org.matrix.rustcomponents.sdk.crypto.ShieldState
8685
import org.matrix.rustcomponents.sdk.crypto.SignatureVerification
8786
import org.matrix.rustcomponents.sdk.crypto.setLogger
8887
import timber.log.Timber
88+
import uniffi.matrix_sdk_crypto.LocalTrust
8989
import java.io.File
9090
import java.nio.charset.Charset
9191
import javax.inject.Inject
@@ -828,8 +828,14 @@ internal class OlmMachine @Inject constructor(
828828
val requests = withContext(coroutineDispatchers.io) {
829829
inner.bootstrapCrossSigning()
830830
}
831+
(requests.uploadKeysRequest)?.let {
832+
when (it) {
833+
is Request.KeysUpload -> requestSender.uploadKeys(it)
834+
else -> {}
835+
}
836+
}
831837
requestSender.uploadCrossSigningKeys(requests.uploadSigningKeysRequest, uiaInterceptor)
832-
requestSender.sendSignatureUpload(requests.signatureRequest)
838+
requestSender.sendSignatureUpload(requests.uploadSignatureRequest)
833839
}
834840

835841
/**

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/RustKeyBackupService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ import org.matrix.android.sdk.internal.util.JsonCanonicalizer
6868
import org.matrix.olm.OlmException
6969
import org.matrix.rustcomponents.sdk.crypto.Request
7070
import org.matrix.rustcomponents.sdk.crypto.RequestType
71-
import org.matrix.rustcomponents.sdk.crypto.SignatureState
7271
import org.matrix.rustcomponents.sdk.crypto.SignatureVerification
7372
import timber.log.Timber
73+
import uniffi.matrix_sdk_crypto.SignatureState
7474
import java.security.InvalidParameterException
7575
import javax.inject.Inject
7676
import kotlin.random.Random

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/migration/rust/RealmToMigrate.kt

+10-6
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fun RealmToMigrate.getPickledAccount(pickleKey: ByteArray): MigrationData {
100100
)
101101
MigrationData(
102102
account = pickledAccount,
103-
pickleKey = pickleKey.map { it.toUByte() },
103+
pickleKey = pickleKey,
104104
crossSigning = CrossSigningKeyExport(
105105
masterKey = masterKey,
106106
selfSigningKey = selfSignedKey,
@@ -153,7 +153,7 @@ fun RealmToMigrate.getPickledAccount(pickleKey: ByteArray): MigrationData {
153153

154154
migrationData = MigrationData(
155155
account = pickledAccount,
156-
pickleKey = pickleKey.map { it.toUByte() },
156+
pickleKey = pickleKey,
157157
crossSigning = CrossSigningKeyExport(
158158
masterKey = masterKey,
159159
selfSigningKey = selfSignedKey,
@@ -222,8 +222,10 @@ fun RealmToMigrate.pickledOlmSessions(pickleKey: ByteArray, chunkSize: Int, onCh
222222
pickle = pickle,
223223
senderKey = deviceKey,
224224
createdUsingFallbackKey = false,
225-
creationTime = lastReceivedMessageTs.toString(),
226-
lastUseTime = lastReceivedMessageTs.toString()
225+
// / Unix timestamp (in seconds) when the session was created.
226+
creationTime = (lastReceivedMessageTs / 1000).toULong(),
227+
// / Unix timestamp (in seconds) when the session was last used.
228+
lastUseTime = (lastReceivedMessageTs / 1000).toULong(),
227229
)
228230
// should we check the tracking status?
229231
pickledSessions.add(pickledSession)
@@ -323,8 +325,10 @@ private fun OlmSessionEntity.toPickledSession(pickleKey: ByteArray): PickledSess
323325
pickle = pickledOlmSession,
324326
senderKey = deviceKey,
325327
createdUsingFallbackKey = false,
326-
creationTime = lastReceivedMessageTs.toString(),
327-
lastUseTime = lastReceivedMessageTs.toString()
328+
// Rust expect in seconds
329+
creationTime = (lastReceivedMessageTs / 1000).toULong(),
330+
// Rust expect in seconds
331+
lastUseTime = (lastReceivedMessageTs / 1000).toULong(),
328332
)
329333
}
330334

matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt

+17-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
package org.matrix.android.sdk.internal.session.content
1818

1919
import android.content.Context
20+
import android.content.Intent
2021
import android.graphics.BitmapFactory
2122
import android.media.MediaMetadataRetriever
23+
import android.os.Build
2224
import androidx.core.net.toUri
2325
import androidx.work.WorkerParameters
2426
import com.squareup.moshi.JsonClass
@@ -115,7 +117,15 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
115117
if (allCancelled) {
116118
// there is no point in uploading the image!
117119
return Result.success(inputData)
118-
.also { Timber.e("## Send: Work cancelled by user") }
120+
.also {
121+
Timber.e("## Send: Work cancelled by user")
122+
123+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
124+
context.revokeUriPermission(context.packageName, params.attachment.queryUri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
125+
} else {
126+
context.revokeUriPermission(params.attachment.queryUri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
127+
}
128+
}
119129
}
120130

121131
val attachment = params.attachment
@@ -396,6 +406,12 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter
396406
)
397407
return Result.success(WorkerParamsFactory.toData(sendParams)).also {
398408
Timber.v("## handleSuccess $attachmentUrl, work is stopped $isStopped")
409+
410+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
411+
context.revokeUriPermission(context.packageName, params.attachment.queryUri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
412+
} else {
413+
context.revokeUriPermission(params.attachment.queryUri, Intent.FLAG_GRANT_READ_URI_PERMISSION)
414+
}
399415
}
400416
}
401417

0 commit comments

Comments
 (0)