Commit Graph

75 Commits

Author SHA1 Message Date
Jorge Martín de8de61b2e Remove dagger and anvil dependencies, try to simplify gradle build scripts a bit 2025-09-04 16:49:21 +02:00
Jorge Martín 4ab62a6a38 Redo DI gradle setup code 2025-09-04 16:49:20 +02:00
Jorge Martín 29a97fc0d9 Fix lint issues and restore commented out code 2025-09-04 16:49:18 +02:00
Jorge Martín b76a71ebf5 Start migrating Anvil KSP to Metro 2025-09-04 16:48:34 +02:00
Benoit Marty 58696780c8 Fix error. 2025-09-01 16:41:12 +02:00
Benoit Marty 025131841b Cleanup tests. 2025-09-01 15:03:41 +02:00
Benoit Marty 75a640b986 Refactor: Move InMemorySessionStore to test module
- Delete `libraries/session-storage/impl-memory` module
- Move `InMemorySessionStore.kt` to `libraries/session-storage/test`
2025-09-01 14:47:42 +02:00
Benoit Marty 5f191d9f9c Fix coroutine scope (#4820)
* Inject the session scope instead of the application scope where it's possible.

* Create AppCoroutineScope annotation to let developers explicitly choose the appropriate CoroutineScope when injecting one.
2025-06-04 15:33:51 +00:00
renovate[bot] f0c9f8294a fix(deps): update sqldelight to v2.1.0 (#4735)
* fix(deps): update sqldelight to v2.1.0

* Ignore new returned value from database query which know have type QueryResult<Long>.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
2025-05-26 14:58:57 +02:00
renovate[bot] 1dcd6088d3 fix(deps): update kotlin (#4552)
* fix(deps): update kotlin

* Fix deprecation warning

* Remove this workaround, it's not needed anymore, and was causing a compilation error:

* What went wrong:
A problem occurred configuring project ':libraries:session-storage:impl'.
> Failed to notify project evaluation listener.
   > Element 'kspDebugKotlin' of type 'com.google.devtools.ksp.gradle.KspAATask_Decorated' from container 'task set' cannot be cast to 'org.jetbrains.kotlin.gradle.tasks.KotlinCompile'.
   > Element 'kspReleaseKotlin' of type 'com.google.devtools.ksp.gradle.KspAATask_Decorated' from container 'task set' cannot be cast to 'org.jetbrains.kotlin.gradle.tasks.KotlinCompile'.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
2025-04-09 16:45:48 +02:00
Jorge Martin Espinosa 715d75c5c4 Add Google Tink dependency, replacing androidx.security.crypto (#4405)
* Add Google Tink dependency, replacing `androidx.security.crypto`

* Replace the `EncryptedFile` implementation too

* Extract constants, add some more docs
2025-03-17 10:04:21 +01:00
Benoit Marty 97f3be3dc5 Apply dual licenses: AGPL + Element Commercial to file headers.
2 replace all actions have been performed:
- "SPDX-License-Identifier: AGPL-3.0-only" to "SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial"
- "Please see LICENSE in the repository root for full details." to "Please see LICENSE files in the repository root for full details."
2025-01-07 10:05:04 +01:00
Jorge Martin Espinosa 79c17f714f Use Anvil KSP instead of the Square KAPT one (#3564)
* Use Anvil KSP instead of the Square KAPT one

* Fix several configuration cache, lint and test issues

* Allow incremental kotlin compilation in the CI

* Workaround Robolectric + Compose issue that caused `AppNotIdleException`

* Update the `enterprise` commit hash

* Update screenshots

---------

Co-authored-by: ElementBot <android@element.io>
2024-10-02 11:52:17 +00:00
Jorge Martin Espinosa eeec7cc785 Centralise the DI code generation logic (#3562)
* Create Anvil extension helper

* Use the helper everywhere
2024-09-30 12:20:28 +00:00
Benoit Marty 86844e0b27 Add test on RustClientSessionDelegate 2024-09-19 12:30:40 +02:00
Benoit Marty 5de84f6ad8 Use aSessionData() from the test module.
And fix typo.
2024-09-18 17:16:06 +02:00
Benoit Marty f61df38e55 Migrate license to AGPL.
Run script `uv run license-editor --repository ../element-x-android`
2024-09-06 17:19:19 +02:00
Benoit Marty 9d91cc6184 Add missing test for AppMigration06 2024-09-06 11:51:59 +02:00
Benoit Marty 56fd455d44 Add missing test for AppMigration05 2024-09-06 11:41:13 +02:00
Benoit Marty 951dff8951 Fix test compilation issue. 2024-09-03 10:01:45 +02:00
Benoit Marty c41cb33410 Provide distinct cache directory to the Rust SDK. 2024-08-30 18:36:20 +02:00
Benoit Marty 4227b42dfa Add unit test on DefaultImageLoaderHolder 2024-06-24 14:42:04 +02:00
ganfra 38329ab1ba Session : fix sessionPath missing 2024-06-12 15:42:30 +02:00
Jorge Martín 67f6bf0d2d Add session path migration to SessionData 2024-06-06 17:06:57 +02:00
Benoit Marty ec8cb2e32f Change Test class suffix. 2024-05-30 10:11:18 +02:00
Benoit Marty b38c144f46 Add test on DefaultFirebaseNewTokenHandler 2024-05-22 18:42:39 +02:00
Jorge Martin Espinosa 69d5b564da Fix crash when creating an EncryptedFile in Android 6 (#2853) 2024-05-15 16:10:16 +00:00
Jorge Martin Espinosa 5c59f6c20f Enforce mandatory session verification only for new logins (#2811)
* Enforce mandatory session verification only for new logins

- Creates `AppMigration` base interface as a way to isolate migration logic, app migrations must implement this interface.
- Creates `AppMigration01` with the existing logs removal migration and `AppMigration02` with the logic to allow existing sessions to skip verification.
- Add `DefaultSessionPreferencesStoreFactory.remove(sessionId)` to allow a ephemeral session store access to exist outside the `SessionScope` for this new migration.

* Fix tests

* Add more tests.

This also includes creating several abstractions.

* Review changes.

- Make `orderedMigrations` a class property, `migrations` just a constructor parameter to avoid incorrect usages.
- Create `lastMigration` property too, use it instead of `MIGRATION_VERSION`.
2024-05-07 14:06:34 +00:00
Jorge Martin Espinosa 1de6797673 Remove SessionData.needsVerification as the source of truth for session verification status (#2748)
* Remove `SessionData.needsVerification` as the source of truth for session verification status.

- Use the Rust SDK `EncryptionService.verificationState()` instead, but always waiting for the first 'known' result (either verified or not, discarding 'unknown').
- Add a workaround in the super rare case when reading this value gets stuck somehow. We'll assume the user is not verified in that case.
- Make `DefaultFtueService.getNextStep` and dependent checks `suspend`.
- Make the `skip` button use a value in the session preferences instead.

* Log exception when the verification status can't be loaded

Co-authored-by: Benoit Marty <benoit@matrix.org>

* Fix review comments

---------

Co-authored-by: Benoit Marty <benoit@matrix.org>
2024-04-24 13:55:25 +00:00
Jorge Martin Espinosa 1045f99d18 Add SessionData.needsVerification field (#2672)
* Add `SessionData.needsVerification`:
  - Allows us to add a skip button for debug builds.
  - We can have the verification state almost instantly.
  - It doesn't depend on network availability to know the verification state and display the UI.
* Add DB migration.
- Make the skip button in the verification flow skip the whole flow including the completed screen.
- Save the session as verified in `RustEncryptionService.recover(recoveryKey)`.
* Enforce session verification for existing users too.
* Fix verification confirmed screen subtitle (typo in id, was using the wrong string)
* Update screenshots

---------

Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2024-04-09 17:28:12 +02:00
Benoit Marty 0df33bf3e6 An interface is enough. 2024-02-27 14:42:43 +01:00
Benoit Marty b634fb43e2 Add test for DatabaseSessionStore.getAllSessions(), and update data when session is not found. 2024-02-27 12:04:59 +01:00
Benoit Marty eacb515e14 Add test on DefaultSessionObserver. 2024-02-27 11:39:17 +01:00
Benoit Marty 38bb166298 Remove useless log. 2024-02-27 10:41:14 +01:00
Benoit Marty b4773d541f Merge pull request #2244 from element-hq/feature/bma/encryptedDb2
Encrypted db
2024-01-19 17:40:23 +01:00
Jorge Martin Espinosa 6ecce81f45 Try mitigating unexpected logouts (#2251)
* Try mitigating unexpected logouts.

Try making getting/storing session data use a Mutex for synchronization.

Also added some more logs so we can understand exactly where it's failing.
2024-01-18 16:22:25 +01:00
Benoit Marty 877ed3c7ac Fix test. 2024-01-18 12:44:20 +01:00
Benoit Marty f9c1892f2f SessionData: add the passphrase. 2024-01-18 11:50:05 +01:00
Benoit Marty 5d086ad82d Fix moar ktlint issues 2024-01-11 10:02:10 +01:00
renovate[bot] c8bd362397 Update plugin ktlint to v12.1.0 (#2200)
* Update plugin ktlint to v12.1.0

* Run `./gradlew ktlintFormat` and fix some issues manually.

* Fix other issues reproted by Ktlint

* Limit false positives, KtLint removes unnecessary curly brace in String templates.

* Remove useless Unit

* Minor improvements over ktlint changes

* Restore `AlertDialogContent` behaviour

* Update screenshots

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Benoit Marty <benoit@matrix.org>
Co-authored-by: Jorge Martín <jorgem@element.io>
Co-authored-by: ElementBot <benoitm+elementbot@element.io>
2024-01-10 16:22:24 +01:00
Marco Romano 79d2941fe4 Include desugaring lib also in library modules (#1604)
## Type of change

- [ ] Feature
- [ ] Bugfix
- [x] Technical
- [ ] Other :

## Content

Includes the `coreLibraryDesugaring(libs.android.desugar)` dependency in all modules which use one of our gradle plugins.

## Motivation and context

Right now desugaring is enabled also in library modules but the desugar dependency is not included in those.
This causes some unwanted side effects such as being unable to run compose previews in an emu.

This change will also include the desugar dependency in those libraries.
2023-10-19 09:00:32 +00:00
Marco Romano 57ccafca42 Other fixes as per https://cashapp.github.io/sqldelight/2.0.0/upgrading-2.0/ 2023-10-13 15:17:12 +02:00
Marco Romano 2d3d007e60 Find and replace 2023-10-13 14:55:12 +02:00
Benoit Marty 12996e8253 Improve comment. 2023-10-12 15:48:13 +02:00
Benoit Marty 30b509456c Add some comment in the files manipulating the session DB 2023-10-12 14:59:06 +02:00
Benoit Marty 9bacf9df8e Add DB versions to test all migrations 2023-10-12 14:53:14 +02:00
Benoit Marty 1938525201 Fix DB migration test. Does not require a migration apparently. 2023-10-12 14:53:00 +02:00
Benoit Marty 8bbcb973c4 Fix test. 2023-10-10 10:20:49 +02:00
Benoit Marty 96867bccf2 Database version 4: add isTokenValid and loginType fields
Generate database with model version 4
2023-10-10 10:20:49 +02:00
Benoit Marty 6761a5e2fb Fix test compilation 2023-10-10 10:20:49 +02:00